diff --git a/src/GodaddyWrapper.Tests/ClientJsonSerializationTests.cs b/src/GodaddyWrapper.Tests/ClientJsonSerializationTests.cs new file mode 100644 index 0000000..42df71a --- /dev/null +++ b/src/GodaddyWrapper.Tests/ClientJsonSerializationTests.cs @@ -0,0 +1,179 @@ +#if NETCORE +using GodaddyWrapper.Serialization; +using Microsoft.Extensions.Primitives; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Reflection; +using System.Text; +using System.Threading.Tasks; +using Xunit; +using Xunit.Abstractions; + +namespace GodaddyWrapper.Tests +{ + public class ClientJsonSerializationTests + { + private readonly ITestOutputHelper _output; + + public ClientJsonSerializationTests(ITestOutputHelper output) + { + _output = output; + } + + + [Fact] + public void ClientJsonRequestTest() + { + const string namespaceName = "GodaddyWrapper.Requests"; + HashSet missingTypes = new HashSet(); + Assembly assembly = typeof(GoDaddyClient).Assembly; + + //Check all the types in the client + typeof(GoDaddyClient).GetMethods() + .ToList() + .ForEach(method => + { + var parameters = method.GetParameters(); + if (parameters.Length > 0) + { + //_output.WriteLine($"Method: {nameof(GoDaddyClient)}.{method.Name}"); + + foreach (var p in parameters) + { + if (p.ParameterType.FullName.StartsWith(namespaceName)) + { + //_output.WriteLine($"Parm: {p.ParameterType.Name}:{p.Name}"); + bool found = JsonContext.Default.Options.TryGetTypeInfo(p.ParameterType, out _); + if (!found) + { + _ = missingTypes.Add($"[JsonSerializable(typeof({p.ParameterType.Name}))]"); + } + } + else if (p.ParameterType.IsGenericType && p.ParameterType.GenericTypeArguments.Any(a => a.FullName.StartsWith(namespaceName))) + { + StringBuilder sb = new StringBuilder(); + sb.Append(p.ParameterType.GetGenericTypeDefinition().Name.Split('`')[0]); + sb.Append('<'); + foreach (var a in p.ParameterType.GenericTypeArguments) + { + sb.Append(a.Name); + sb.Append(','); + } + sb.Remove(sb.Length - 1, 1); + sb.Append('>'); + + //_output.WriteLine($"GParm: {sb.ToString()}:{p.Name}"); + bool found = JsonContext.Default.Options.TryGetTypeInfo(p.ParameterType, out _); + if (!found) + { + _ = missingTypes.Add($"[JsonSerializable(typeof({sb.ToString()}))]"); + } + } + } + } + }); + + //Check the types in the namespace + var types = assembly.GetTypes().Where(x => x.Namespace == namespaceName).ToList(); + foreach (var t in types) + { + bool found = JsonContext.Default.Options.TryGetTypeInfo(t, out _); + if (!found) + { + _ = missingTypes.Add($"[JsonSerializable(typeof({t.Name}))]"); + } + } + + if (missingTypes.Count > 0) + { + _output.WriteLine($"Add the following attributes to the {nameof(JsonContext)} class:"); + foreach (var item in missingTypes) + { + _output.WriteLine(item); + } + } + Assert.Empty(missingTypes); + } + + [Fact] + public void ClientJsonResponseTest() + { + const string namespaceName = "GodaddyWrapper.Responses"; + HashSet missingTypes = new HashSet(); + Assembly assembly = typeof(GoDaddyClient).Assembly; + + //Check all the types in the client + typeof(GoDaddyClient).GetMethods() + .ToList() + .ForEach(method => + { + var p = method.ReturnParameter; + if (p is not null) + { + //_output.WriteLine($"Method: {nameof(GoDaddyClient)}.{method.Name}"); + Type parameterType = p.ParameterType; + if(parameterType.Name.StartsWith("Task")) + { + parameterType = parameterType.GenericTypeArguments.FirstOrDefault(); + } + if (parameterType is not null) + { + if (parameterType.FullName.StartsWith(namespaceName)) + { + //_output.WriteLine($"Parm: {parameterType.Name}:{p.Name}"); + bool found = JsonContext.Default.Options.TryGetTypeInfo(parameterType, out _); + if (!found) + { + _ = missingTypes.Add($"[JsonSerializable(typeof({parameterType.Name}))]"); + } + } + else if (parameterType.IsGenericType && parameterType.GenericTypeArguments.Any(a => a.FullName.StartsWith(namespaceName))) + { + StringBuilder sb = new StringBuilder(); + sb.Append(parameterType.GetGenericTypeDefinition().Name.Split('`')[0]); + sb.Append('<'); + foreach (var a in parameterType.GenericTypeArguments) + { + sb.Append(a.Name); + sb.Append(','); + } + sb.Remove(sb.Length - 1, 1); + sb.Append('>'); + + //_output.WriteLine($"GParm: {sb.ToString()}:{p.Name}"); + bool found = JsonContext.Default.Options.TryGetTypeInfo(parameterType, out _); + if (!found) + { + _ = missingTypes.Add($"[JsonSerializable(typeof({sb.ToString()}))]"); + } + } + } + } + }); + + //Check the types in the namespace + var types = assembly.GetTypes().Where(x => x.Namespace == namespaceName).ToList(); + foreach (var t in types) + { + bool found = JsonContext.Default.Options.TryGetTypeInfo(t, out _); + if (!found) + { + _ = missingTypes.Add($"[JsonSerializable(typeof({t.Name}))]"); + } + } + + if (missingTypes.Count > 0) + { + _output.WriteLine($"Add the following attributes to the {nameof(JsonContext)} class:"); + foreach (var item in missingTypes) + { + _output.WriteLine(item); + } + } + Assert.Empty(missingTypes); + } + + } +} +#endif \ No newline at end of file diff --git a/src/GodaddyWrapper.Tests/DomainTests.cs b/src/GodaddyWrapper.Tests/DomainTests.cs index a11959a..e58c9d6 100644 --- a/src/GodaddyWrapper.Tests/DomainTests.cs +++ b/src/GodaddyWrapper.Tests/DomainTests.cs @@ -29,36 +29,20 @@ public DomainTests() [Fact] public async Task DomainCheckTest() { - try + var response = await client.CheckDomainAvailable(new DomainAvailable { - var response = await client.CheckDomainAvailable(new DomainAvailable - { - Domain = "google.com" - }); + Domain = "google.com" + }); - response.Available.ShouldBe(false); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - Assert.Fail(); - } + response.Available.ShouldBe(false); } [Fact] public async Task DomainListTest() { - try - { - var response = await client.RetrieveDomainList(new DomainRetrieve { Limit = 100 }); + var response = await client.RetrieveDomainList(new DomainRetrieve { Limit = 100 }); - response.Count.ShouldBe(0); - } - catch (Exception ex) - { - Console.WriteLine(ex.ToString()); - Assert.Fail(); - } + response.Count.ShouldBe(0); } } } diff --git a/src/GodaddyWrapper.Tests/GodaddyWrapper.Tests.csproj b/src/GodaddyWrapper.Tests/GodaddyWrapper.Tests.csproj index 22ffd40..74b9958 100644 --- a/src/GodaddyWrapper.Tests/GodaddyWrapper.Tests.csproj +++ b/src/GodaddyWrapper.Tests/GodaddyWrapper.Tests.csproj @@ -24,6 +24,7 @@ + diff --git a/src/GodaddyWrapper/Client.AbuseTicket.cs b/src/GodaddyWrapper/Client.AbuseTicket.cs index c9e1abb..3929dea 100644 --- a/src/GodaddyWrapper/Client.AbuseTicket.cs +++ b/src/GodaddyWrapper/Client.AbuseTicket.cs @@ -1,7 +1,7 @@ using GodaddyWrapper.Helper; using GodaddyWrapper.Requests; using GodaddyWrapper.Responses; -using Newtonsoft.Json; +using System.Net.Http.Json; using System.Threading.Tasks; namespace GodaddyWrapper @@ -15,9 +15,9 @@ public partial class GoDaddyClient /// public async Task CreateAbuseTicket(AbuseTicketCreate request) { - var response = await httpClient.PostAsync($"abuse/tickets", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PostAsJsonAsync($"abuse/tickets", request, JsonSettings); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// List all abuse tickets ids that match user provided filters @@ -28,7 +28,7 @@ public async Task RetrieveAbuseTickets(AbuseTicketRetri { var response = await httpClient.GetAsync($"abuse/tickets{QueryStringBuilder.RequestObjectToQueryString(request)}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// @@ -40,7 +40,7 @@ public async Task RetrieveAbuseTicketDetail(AbuseTicketDeta { var response = await httpClient.GetAsync($"abuse/tickets/{request.TicketId}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } } } diff --git a/src/GodaddyWrapper/Client.Aftermarket.cs b/src/GodaddyWrapper/Client.Aftermarket.cs index f5d8182..65cab66 100644 --- a/src/GodaddyWrapper/Client.Aftermarket.cs +++ b/src/GodaddyWrapper/Client.Aftermarket.cs @@ -1,8 +1,8 @@ using GodaddyWrapper.Helper; using GodaddyWrapper.Requests; using GodaddyWrapper.Responses; -using Newtonsoft.Json; using System.Collections.Generic; +using System.Net.Http.Json; using System.Threading.Tasks; namespace GodaddyWrapper @@ -17,9 +17,9 @@ public partial class GoDaddyClient /// public async Task AddExpiryAuction(List request) { - var response = await httpClient.PostAsync($"aftermarket/listings/expiry", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PostAsJsonAsync($"aftermarket/listings/expiry", request, JsonSettings); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// @@ -31,7 +31,7 @@ public async Task RemoveAuctionListings(AgreementRetrieve { var response = await httpClient.DeleteAsync($"aftermarket/listings{QueryStringBuilder.RequestObjectToQueryString(request)}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } } diff --git a/src/GodaddyWrapper/Client.Agreements.cs b/src/GodaddyWrapper/Client.Agreements.cs index 279c032..c21f99a 100644 --- a/src/GodaddyWrapper/Client.Agreements.cs +++ b/src/GodaddyWrapper/Client.Agreements.cs @@ -24,7 +24,7 @@ public async Task> RetrieveAgreements(AgreementRetr httpClient.DefaultRequestHeaders.Add("X-Market-Id", XMarketId); var response = await httpClient.GetAsync($"aggreements{QueryStringBuilder.RequestObjectToQueryString(request)}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync>(); + return await response.Content.ReadAsAsync>(JsonSettings); } } diff --git a/src/GodaddyWrapper/Client.Certificate.cs b/src/GodaddyWrapper/Client.Certificate.cs index 6e2a506..0d7e6ae 100644 --- a/src/GodaddyWrapper/Client.Certificate.cs +++ b/src/GodaddyWrapper/Client.Certificate.cs @@ -1,9 +1,8 @@ using GodaddyWrapper.Helper; using GodaddyWrapper.Requests; using GodaddyWrapper.Responses; -using Newtonsoft.Json; -using System; using System.Collections.Generic; +using System.Net.Http.Json; using System.Threading.Tasks; namespace GodaddyWrapper @@ -18,7 +17,7 @@ public partial class GoDaddyClient public async Task CancelCertificate(CertificateCancel request) { CheckRequestValid(request); - var response = await httpClient.PostAsync($"certificates/{request.CertificateId}/cancel", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PostAsJsonAsync($"certificates/{request.CertificateId}/cancel", request, JsonSettings); await CheckResponseMessageIsValid(response); } /// @@ -43,9 +42,9 @@ public async Task CreateCertificate(CertificatesC CheckRequestValid(request); if (XMarketId != null) httpClient.DefaultRequestHeaders.Add("X-Market-Id", XMarketId); - var response = await httpClient.PostAsync($"certificates", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PostAsJsonAsync($"certificates", request, JsonSettings); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// Download certificate @@ -57,7 +56,7 @@ public async Task DownloadCertificate(CertificateDown CheckRequestValid(request); var response = await httpClient.GetAsync($"certificates/{request.CertificateId}/download"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// Reissue active certificate @@ -68,7 +67,7 @@ public async Task DownloadCertificate(CertificateDown public async Task ReissueActiveCertificate(CertificateReissue request, string certificateId) { CheckRequestValid(request); - var response = await httpClient.PostAsync($"certificates/{certificateId}/reissue", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PostAsJsonAsync($"certificates/{certificateId}/reissue", request, JsonSettings); await CheckResponseMessageIsValid(response); } /// @@ -80,7 +79,7 @@ public async Task ReissueActiveCertificate(CertificateReissue request, string ce public async Task RenewActiveCertificate(CertificateRenew request, string certificateId) { CheckRequestValid(request); - var response = await httpClient.PostAsync($"certificates/{certificateId}/renew", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PostAsJsonAsync($"certificates/{certificateId}/renew", request, JsonSettings); await CheckResponseMessageIsValid(response); } /// @@ -93,7 +92,7 @@ public async Task> RetrieveCertificateAction(Cer CheckRequestValid(request); var response = await httpClient.GetAsync($"certificates/{request.CertificateId}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync>(); + return await response.Content.ReadAsAsync>(JsonSettings); } /// /// Register of certificate action callback @@ -104,7 +103,7 @@ public async Task> RetrieveCertificateAction(Cer public async Task RegisterCertificateAction(CertificateCallbackActionRegister request, string certificateId) { CheckRequestValid(request); - var response = await httpClient.PutAsync($"certificates/{certificateId}/callback", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PutAsJsonAsync($"certificates/{certificateId}/callback", request, JsonSettings); await CheckResponseMessageIsValid(response); } /// @@ -117,7 +116,7 @@ public async Task RetrieveCertificateDetail(Certi CheckRequestValid(request); var response = await httpClient.GetAsync($"certificates/{request.CertificateId}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// Get Site seal @@ -130,7 +129,7 @@ public async Task RetrieveSiteSeal(CertificateSiteS CheckRequestValid(request); var response = await httpClient.GetAsync($"certificates/{certificateId}/siteseal"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// Revoke active certificate @@ -141,7 +140,7 @@ public async Task RetrieveSiteSeal(CertificateSiteS public async Task RevokeActiveCertificate(CertificateRevoke request, string certificateId) { CheckRequestValid(request); - var response = await httpClient.PostAsync($"certificates/{certificateId}/revoke", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PostAsJsonAsync($"certificates/{certificateId}/revoke", request, JsonSettings); await CheckResponseMessageIsValid(response); } /// diff --git a/src/GodaddyWrapper/Client.Countries.cs b/src/GodaddyWrapper/Client.Countries.cs index 99a03ba..17282da 100644 --- a/src/GodaddyWrapper/Client.Countries.cs +++ b/src/GodaddyWrapper/Client.Countries.cs @@ -1,13 +1,7 @@ -using GodaddyWrapper.Responses; +using GodaddyWrapper.Helper; using GodaddyWrapper.Requests; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Net.Http.Headers; +using GodaddyWrapper.Responses; using System.Threading.Tasks; -using System.ComponentModel.DataAnnotations; -using GodaddyWrapper.Helper; namespace GodaddyWrapper { @@ -23,7 +17,7 @@ public async Task RetrieveCountries(CountriesRetrieve re CheckRequestValid(request); var response = await httpClient.GetAsync($"countries{QueryStringBuilder.RequestObjectToQueryString(request)}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// Retrieves country and summary state information for provided countryKey @@ -36,7 +30,7 @@ public async Task RetrieveCountryDetail(CountryDetailRetrieve r CheckRequestValid(request); var response = await httpClient.GetAsync($"countries/{CountryKey}{QueryStringBuilder.RequestObjectToQueryString(request)}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } } } diff --git a/src/GodaddyWrapper/Client.Domain.cs b/src/GodaddyWrapper/Client.Domain.cs index b7c75f5..ee14d64 100644 --- a/src/GodaddyWrapper/Client.Domain.cs +++ b/src/GodaddyWrapper/Client.Domain.cs @@ -1,8 +1,8 @@ using GodaddyWrapper.Helper; using GodaddyWrapper.Requests; using GodaddyWrapper.Responses; -using Newtonsoft.Json; using System.Collections.Generic; +using System.Net.Http.Json; using System.Threading.Tasks; namespace GodaddyWrapper @@ -21,7 +21,7 @@ public async Task AddDNSRecordsToDomain(List request,string dom CheckRequestValid(request); if (XShopperId != null) httpClient.DefaultRequestHeaders.Add("X-Shopper-Id", XShopperId); - var response = await httpClient.PatchAsync($"domains/{domain}/records", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PatchAsJsonAsync($"domains/{domain}/records", request, JsonSettings); await CheckResponseMessageIsValid(response); return response.IsSuccessStatusCode; } @@ -33,19 +33,19 @@ public async Task AddDNSRecordsToDomain(List request,string dom public async Task BulkCheckDomainAvailable(Requests.DomainAvailableBulk request) { CheckRequestValid(request); - var response = await httpClient.PostAsync($"domains/available?checkType={request.CheckType}", JsonConvert.SerializeObject(request.Domains, JsonSettings)); + var response = await httpClient.PostAsJsonAsync($"domains/available?checkType={request.CheckType}", request.Domains, JsonSettings); await CheckResponseMessageIsValid(response); if (response.StatusCode.ToString() == "203") return new DomainAvailableBulkResultResponse { IsFullySuccessed = false, - BulkMixedDomain = await response.Content.ReadAsAsync() + BulkMixedDomain = await response.Content.ReadAsAsync(JsonSettings) }; else return new DomainAvailableBulkResultResponse { IsFullySuccessed = true, - BulkDomain = await response.Content.ReadAsAsync() + BulkDomain = await response.Content.ReadAsAsync(JsonSettings) }; } /// @@ -88,7 +88,7 @@ public async Task CheckDomainAvailable(DomainAvailable CheckRequestValid(request); var response = await httpClient.GetAsync($"domains/available{QueryStringBuilder.RequestObjectToQueryString(request)}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// Purchase and register the specified Domain @@ -101,9 +101,9 @@ public async Task PurchaseDomain(DomainPurchase request, CheckRequestValid(request); if (XShopperId != null) httpClient.DefaultRequestHeaders.Add("X-Shopper-Id", XShopperId); - var response = await httpClient.PostAsync("domains/purchase", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PostAsJsonAsync("domains/purchase", request, JsonSettings); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// Purchase and register the specified Domain without privacy (For the Tld which is not support privacy) @@ -116,9 +116,9 @@ public async Task PurchaseDomainWithoutPrivacy(DomainPur CheckRequestValid(request); if (XShopperId != null) httpClient.DefaultRequestHeaders.Add("X-Shopper-Id", XShopperId); - var response = await httpClient.PostAsync("domains/purchase", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PostAsJsonAsync("domains/purchase", request, JsonSettings); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// Purchase privacy for a specified domain @@ -132,9 +132,9 @@ public async Task PurchasePrivacy(PrivacyPurchase reques CheckRequestValid(request); if (XShopperId != null) httpClient.DefaultRequestHeaders.Add("X-Shopper-Id", XShopperId); - var response = await httpClient.PostAsync($"domains/{domain}/privacy/purchase", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PostAsJsonAsync($"domains/{domain}/privacy/purchase", request, JsonSettings); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// Retrieve the schema to be submitted when registering a Domain for the specified TLD @@ -146,7 +146,7 @@ public async Task RetrieveDomainPurhcaseSchema(DomainPurch CheckRequestValid(request); var response = await httpClient.GetAsync($"domains/purchase/schema/{request.Tld}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// Validate the request body using the Domain Purchase Schema for the specified TLD @@ -156,7 +156,7 @@ public async Task RetrieveDomainPurhcaseSchema(DomainPurch public async Task PurchaseDomainValidate(DomainPurchase request) { CheckRequestValid(request); - var response = await httpClient.PostAsync("domains/purchase/validate", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PostAsJsonAsync("domains/purchase/validate", request, JsonSettings); return response.IsSuccessStatusCode; } /// @@ -167,7 +167,7 @@ public async Task PurchaseDomainValidate(DomainPurchase request) public async Task PurchaseDomainValidateWithoutPrivacy(DomainPurchaseWithoutPrivacy request) { CheckRequestValid(request); - var response = await httpClient.PostAsync("domains/purchase/validate", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PostAsJsonAsync("domains/purchase/validate", request, JsonSettings); return response.IsSuccessStatusCode; } /// @@ -182,9 +182,9 @@ public async Task RenewDomain(DomainRenew request,string CheckRequestValid(request); if (XShopperId != null) httpClient.DefaultRequestHeaders.Add("X-Shopper-Id", XShopperId); - var response = await httpClient.PostAsync($"domains/{domain}/renew", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PostAsJsonAsync($"domains/{domain}/renew", request, JsonSettings); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// Replace all DNS Records for the specified Domain @@ -198,7 +198,7 @@ public async Task ReplaceDNSRecord(List request,string domain, CheckRequestValid(request); if (XShopperId != null) httpClient.DefaultRequestHeaders.Add("X-Shopper-Id", XShopperId); - var response = await httpClient.PutAsync($"domains/{domain}/records", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PutAsJsonAsync($"domains/{domain}/records", request, JsonSettings); await CheckResponseMessageIsValid(response); return response.IsSuccessStatusCode; } @@ -215,7 +215,7 @@ public async Task ReplaceDNSRecordsWithType(List requ CheckRequestValid(request); if (XShopperId != null) httpClient.DefaultRequestHeaders.Add("X-Shopper-Id", XShopperId); - var response = await httpClient.PutAsync($"domains/{domain}/records/{Type}", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PutAsJsonAsync($"domains/{domain}/records/{Type}", request, JsonSettings); await CheckResponseMessageIsValid(response); return response.IsSuccessStatusCode; } @@ -233,7 +233,7 @@ public async Task ReplaceDNSRecordsWithTypeAndName(List> RetrieveDomainAgreements(DomainA httpClient.DefaultRequestHeaders.Add("X-Market-Id", XMarketId); var response = await httpClient.GetAsync($"domains/agreements{QueryStringBuilder.RequestObjectToQueryString(request)}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync>(); + return await response.Content.ReadAsAsync>(JsonSettings); } /// /// Retrieve a list of Domains for the specified Shopper @@ -281,7 +281,7 @@ public async Task> RetrieveDomainList(DomainRetriev httpClient.DefaultRequestHeaders.Add("X-Shopper-Id", XShopperId); var response = await httpClient.GetAsync($"domains{QueryStringBuilder.RequestObjectToQueryString(request)}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync>(); + return await response.Content.ReadAsAsync>(JsonSettings); } /// /// Retrieve details for the specified Domain @@ -298,7 +298,7 @@ public async Task RetrieveDomainDetail(string domain, stri httpClient.DefaultRequestHeaders.Add("X-Shopper-Id", XShopperId); var response = await httpClient.GetAsync($"domains/{domain}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// Retrieve DNS Records for the specified Domain, optionally with the specified Type and/or Name @@ -317,7 +317,7 @@ public async Task> RetrieveDNSRecordsWithTypeAndName(DNS string urlPath = $"domains/{domain}/records/{Type}{(string.IsNullOrEmpty(Name) ? "" : $"/{Name}")}"; var response = await httpClient.GetAsync($"{urlPath}{QueryStringBuilder.RequestObjectToQueryString(request)}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync>(); + return await response.Content.ReadAsAsync>(JsonSettings); } /// /// Suggest alternate Domain names based on a seed Domain, a set of keywords, or the shopper's purchase history @@ -329,7 +329,7 @@ public async Task> RetrieveSuggestDomain(DomainSu CheckRequestValid(request); var response = await httpClient.GetAsync($"domains/suggest{QueryStringBuilder.RequestObjectToQueryString(request)}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync>(); + return await response.Content.ReadAsAsync>(JsonSettings); } /// /// Retrieves a list of TLDs supported and enabled for sale @@ -339,7 +339,7 @@ public async Task> RetrieveTldSummary() { var response = await httpClient.GetAsync("domains/tlds"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync>(); + return await response.Content.ReadAsAsync>(JsonSettings); } /// /// Purchase and start or restart transfer process @@ -353,9 +353,9 @@ public async Task TransferDomain(DomainTransferIn request,stri CheckRequestValid(request); if (XShopperId != null) httpClient.DefaultRequestHeaders.Add("X-Shopper-Id", XShopperId); - var response = await httpClient.PostAsync($"domains/{domain}/transfer", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PostAsJsonAsync($"domains/{domain}/transfer", request, JsonSettings); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// Update details for the specified Domain @@ -369,7 +369,7 @@ public async Task UpdateDomain(DomainUpdate request,string domain, string CheckRequestValid(request); if (XShopperId != null) httpClient.DefaultRequestHeaders.Add("X-Shopper-Id", XShopperId); - var response = await httpClient.PatchAsync($"domains/{domain}", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PatchAsJsonAsync($"domains/{domain}", request, JsonSettings); await CheckResponseMessageIsValid(response); return response.IsSuccessStatusCode; } @@ -385,7 +385,7 @@ public async Task UpdateDomainContacts(DomainContacts request,string domai CheckRequestValid(request); if (XShopperId != null) httpClient.DefaultRequestHeaders.Add("X-Shopper-Id", XShopperId); - var response = await httpClient.PatchAsync($"domains/{domain}/contacts", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PatchAsJsonAsync($"domains/{domain}/contacts", request, JsonSettings); await CheckResponseMessageIsValid(response); return response.IsSuccessStatusCode; } diff --git a/src/GodaddyWrapper/Client.Order.cs b/src/GodaddyWrapper/Client.Order.cs index 4333f09..bed4fec 100644 --- a/src/GodaddyWrapper/Client.Order.cs +++ b/src/GodaddyWrapper/Client.Order.cs @@ -23,7 +23,7 @@ public async Task RetrieveOrderList(OrderRetrieve request, st httpClient.DefaultRequestHeaders.Add("X-Market-Id", XMarketId); var response = await httpClient.GetAsync($"orders{QueryStringBuilder.RequestObjectToQueryString(request)}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// Retrieve details for specified order @@ -41,7 +41,7 @@ public async Task RetrieveSpecificOrder(OrderDetailRetrieve reque httpClient.DefaultRequestHeaders.Add("X-Market-Id", XMarketId); var response = await httpClient.GetAsync($"orders/{request.OrderId}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } } } diff --git a/src/GodaddyWrapper/Client.Shopper.cs b/src/GodaddyWrapper/Client.Shopper.cs index 9420a36..1c707ee 100644 --- a/src/GodaddyWrapper/Client.Shopper.cs +++ b/src/GodaddyWrapper/Client.Shopper.cs @@ -1,7 +1,7 @@ using GodaddyWrapper.Helper; using GodaddyWrapper.Requests; using GodaddyWrapper.Responses; -using Newtonsoft.Json; +using System.Net.Http.Json; using System.Threading.Tasks; namespace GodaddyWrapper @@ -16,9 +16,9 @@ public partial class GoDaddyClient public async Task CreateSubaccount(SubaccountCreate request) { CheckRequestValid(request); - var response = await httpClient.PostAsync($"shoppers/subaccount", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PostAsJsonAsync($"shoppers/subaccount", request, JsonSettings); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// Get details for the specified Shopper @@ -30,7 +30,7 @@ public async Task RetrieveShopper(ShopperRetrieve request) CheckRequestValid(request); var response = await httpClient.GetAsync($"shoppers/{request.ShopperId}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// Update details for the specified Shopper @@ -41,9 +41,9 @@ public async Task RetrieveShopper(ShopperRetrieve request) public async Task UpdateShopper(ShopperUpdate request, string shopperId) { CheckRequestValid(request); - var response = await httpClient.PostAsync($"shoppers/{shopperId}", JsonConvert.SerializeObject(request, JsonSettings)); + var response = await httpClient.PostAsJsonAsync($"shoppers/{shopperId}", request, JsonSettings); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } } } diff --git a/src/GodaddyWrapper/Client.Subscription.cs b/src/GodaddyWrapper/Client.Subscription.cs index 074cd8e..615d857 100644 --- a/src/GodaddyWrapper/Client.Subscription.cs +++ b/src/GodaddyWrapper/Client.Subscription.cs @@ -39,7 +39,7 @@ public async Task RetrieveSubscriptions(SubscriptionRe httpClient.DefaultRequestHeaders.Add("X-Market-Id", XMarketId); var response = await httpClient.GetAsync($"subscriptions{QueryStringBuilder.RequestObjectToQueryString(request)}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } /// /// Retrieve a list of ProductGroups for the specified Shopper @@ -55,7 +55,7 @@ public async Task> RetrieveSubscriptionProductGroups( httpClient.DefaultRequestHeaders.Add("X-Market-Id", XMarketId); var response = await httpClient.GetAsync($"subscriptions/productgroups"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync>(); + return await response.Content.ReadAsAsync>(JsonSettings); } /// /// Retrieve details for the specified Subscription @@ -73,7 +73,7 @@ public async Task RetrieveSubscriptionDetails(Subscription httpClient.DefaultRequestHeaders.Add("X-Market-Id", XMarketId); var response = await httpClient.GetAsync($"subscriptions/{request.SubscriptionId}"); await CheckResponseMessageIsValid(response); - return await response.Content.ReadAsAsync(); + return await response.Content.ReadAsAsync(JsonSettings); } } } diff --git a/src/GodaddyWrapper/Client.cs b/src/GodaddyWrapper/Client.cs index 551601e..f3d247e 100644 --- a/src/GodaddyWrapper/Client.cs +++ b/src/GodaddyWrapper/Client.cs @@ -9,8 +9,11 @@ using System.ComponentModel.DataAnnotations; using GodaddyWrapper.Helper; using GodaddyWrapper.Base; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; +using System.Text.Json; +using System.Text.Json.Serialization; +using GodaddyWrapper.Serialization; + + #if NETSTANDARD using Microsoft.Extensions.Options; #endif @@ -20,18 +23,7 @@ namespace GodaddyWrapper public partial class GoDaddyClient { private readonly HttpClient httpClient; - - readonly JsonSerializerSettings JsonSettings = new JsonSerializerSettings - { - ContractResolver = new DefaultContractResolver - { - NamingStrategy = new CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } - }, - NullValueHandling = NullValueHandling.Ignore - }; + private readonly static JsonSerializerOptions JsonSettings = JsonContext.Default.Options; #if !NETSTANDARD private string ProductionEndpoint { get; } = "https://api.godaddy.com/v1/"; @@ -62,7 +54,7 @@ private static async Task CheckResponseMessageIsValid(HttpResponseMessage respon { if (response.IsSuccessStatusCode) return; - throw new GodaddyException(response.StatusCode, await response.Content.ReadAsAsync(), ""); + throw new GodaddyException(response.StatusCode, await response.Content.ReadAsAsync(JsonSettings), ""); } private static void CheckRequestValid(object Model) diff --git a/src/GodaddyWrapper/GodaddyWrapper.csproj b/src/GodaddyWrapper/GodaddyWrapper.csproj index 6d5290a..d962fec 100644 --- a/src/GodaddyWrapper/GodaddyWrapper.csproj +++ b/src/GodaddyWrapper/GodaddyWrapper.csproj @@ -5,10 +5,11 @@ Copyright 2015 - 2017 Vip30, 2018 - 2024 ahwm23 GodaddyWrapper.Net vip30, ahwm23 - 3.0.0 - 3.0.0 + 3.1.0 + 3.1.0 + 13.0 MIT - netstandard2.0;net462 + net462;netstandard2.0 false GodaddyWrapper GodaddyWrapper @@ -29,17 +30,17 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - + NETSTANDARD;NETSTANDARD2_0 - - + + @@ -61,7 +62,13 @@ NET462;NETFULL - + + + <_Parameter1>GodaddyWrapper.Tests + + + + $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb diff --git a/src/GodaddyWrapper/Helper/HttpClientExtensions.cs b/src/GodaddyWrapper/Helper/HttpClientExtensions.cs deleted file mode 100644 index 247dba3..0000000 --- a/src/GodaddyWrapper/Helper/HttpClientExtensions.cs +++ /dev/null @@ -1,34 +0,0 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Net.Http; -using System.Text; -using System.Threading.Tasks; - -namespace GodaddyWrapper.Helper -{ - internal static class HttpClientExtensions - { - public static Task PostAsync(this HttpClient client, string requestUri, string jsonString) - { - return client.PostAsync(requestUri, new StringContent(jsonString, Encoding.UTF8, "application/json")); - } - - public static Task PutAsync(this HttpClient client, string requestUri, string jsonString) - { - return client.PutAsync(requestUri, new StringContent(jsonString, Encoding.UTF8, "application/json")); - } - - public static Task PatchAsync(this HttpClient client, string requestUri, string jsonString) - { - var method = new HttpMethod("PATCH"); - var request = new HttpRequestMessage(method, requestUri){ - Content = new StringContent(jsonString, Encoding.UTF8, "application/json") - }; - return client.SendAsync(request); - } - } -} - - diff --git a/src/GodaddyWrapper/Helper/HttpContentExtensions.cs b/src/GodaddyWrapper/Helper/HttpContentExtensions.cs index 7e91a3c..7608628 100644 --- a/src/GodaddyWrapper/Helper/HttpContentExtensions.cs +++ b/src/GodaddyWrapper/Helper/HttpContentExtensions.cs @@ -1,9 +1,9 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net.Http; using System.Text; +using System.Text.Json; using System.Threading.Tasks; namespace GodaddyWrapper.Helper @@ -13,12 +13,9 @@ namespace GodaddyWrapper.Helper /// internal static class HttpContentExtensions { - public static Task ReadAsAsync(this HttpContent client) + public static async Task ReadAsAsync(this HttpContent client, JsonSerializerOptions options) { - return client.ReadAsStringAsync().ContinueWith(data => - { - return JsonConvert.DeserializeObject(data.Result); - }); + return await JsonSerializer.DeserializeAsync(await client.ReadAsStreamAsync(), options); } } diff --git a/src/GodaddyWrapper/Helper/QueryStringBuilder.cs b/src/GodaddyWrapper/Helper/QueryStringBuilder.cs index d1117d8..21a9f97 100644 --- a/src/GodaddyWrapper/Helper/QueryStringBuilder.cs +++ b/src/GodaddyWrapper/Helper/QueryStringBuilder.cs @@ -1,30 +1,25 @@ using GodaddyWrapper.Attributes; -using Newtonsoft.Json; -using Newtonsoft.Json.Serialization; using System; using System.Collections.Generic; using System.Collections.Specialized; using System.Linq; using System.Reflection; using System.Text; +using System.Text.Json.Serialization; +using System.Text.Json; namespace GodaddyWrapper.Helper { internal static class QueryStringBuilder { + private readonly static JsonSerializerOptions JsonSettings = new JsonSerializerOptions(JsonSerializerDefaults.Web) + { + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + }; + public static string RequestObjectToQueryString(object RequestObject) { - var settings = new JsonSerializerSettings - { - ContractResolver = new DefaultContractResolver - { - NamingStrategy = new CamelCaseNamingStrategy - { - OverrideSpecifiedNames = false - } - }, - NullValueHandling = NullValueHandling.Ignore - }; var url = new StringBuilder("?"); foreach (var property in RequestObject.GetType().GetRuntimeProperties()) { @@ -40,7 +35,7 @@ public static string RequestObjectToQueryString(object RequestObject) else if (IsList(property.PropertyType.GetTypeInfo())) url.Append($"{ToFirstLetterLower(property.Name)}={ConvertFromList(property.GetValue(RequestObject))}&"); else - url.Append($"{ToFirstLetterLower(property.Name)}={JsonConvert.SerializeObject(property.GetValue(RequestObject), settings)}&"); + url.Append($"{ToFirstLetterLower(property.Name)}={JsonSerializer.Serialize(property.GetValue(RequestObject), JsonSettings)}&"); } } return url.ToString().Trim('&'); diff --git a/src/GodaddyWrapper/Requests/CertificatesCreate.cs b/src/GodaddyWrapper/Requests/CertificatesCreate.cs index 6568786..361ce39 100644 --- a/src/GodaddyWrapper/Requests/CertificatesCreate.cs +++ b/src/GodaddyWrapper/Requests/CertificatesCreate.cs @@ -1,7 +1,7 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace GodaddyWrapper.Requests @@ -18,7 +18,7 @@ public class CertificatesCreate public string CallbackUrl { get; set; } public string RootType { get; set; } - [JsonProperty(PropertyName = "intelVPro")] + [JsonPropertyName("intelVPro")] public bool IntelVPro { get; set; } public CertificateOrganizationCreate Organization { get; set; } } diff --git a/src/GodaddyWrapper/Responses/DNSRecordResponse.cs b/src/GodaddyWrapper/Responses/DNSRecordResponse.cs index 1c5caf8..5b0f083 100644 --- a/src/GodaddyWrapper/Responses/DNSRecordResponse.cs +++ b/src/GodaddyWrapper/Responses/DNSRecordResponse.cs @@ -1,10 +1,4 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace GodaddyWrapper.Responses +namespace GodaddyWrapper.Responses { public class DNSRecordResponse { diff --git a/src/GodaddyWrapper/Responses/DomainAvailableBulkMixedResponse.cs b/src/GodaddyWrapper/Responses/DomainAvailableBulkMixedResponse.cs index 9b02fb1..571532c 100644 --- a/src/GodaddyWrapper/Responses/DomainAvailableBulkMixedResponse.cs +++ b/src/GodaddyWrapper/Responses/DomainAvailableBulkMixedResponse.cs @@ -1,8 +1,4 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.Collections.Generic; namespace GodaddyWrapper.Responses { diff --git a/src/GodaddyWrapper/Responses/DomainAvailableBulkResponse.cs b/src/GodaddyWrapper/Responses/DomainAvailableBulkResponse.cs index 53298ff..3c1eefe 100644 --- a/src/GodaddyWrapper/Responses/DomainAvailableBulkResponse.cs +++ b/src/GodaddyWrapper/Responses/DomainAvailableBulkResponse.cs @@ -1,8 +1,4 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; +using System.Collections.Generic; namespace GodaddyWrapper.Responses { diff --git a/src/GodaddyWrapper/Responses/DomainAvailableBulkResultResponse.cs b/src/GodaddyWrapper/Responses/DomainAvailableBulkResultResponse.cs index 2ffe925..61044c0 100644 --- a/src/GodaddyWrapper/Responses/DomainAvailableBulkResultResponse.cs +++ b/src/GodaddyWrapper/Responses/DomainAvailableBulkResultResponse.cs @@ -1,10 +1,4 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace GodaddyWrapper.Responses +namespace GodaddyWrapper.Responses { public class DomainAvailableBulkResultResponse { diff --git a/src/GodaddyWrapper/Responses/JsonDataTypeResponse.cs b/src/GodaddyWrapper/Responses/JsonDataTypeResponse.cs index 15a09fc..323c272 100644 --- a/src/GodaddyWrapper/Responses/JsonDataTypeResponse.cs +++ b/src/GodaddyWrapper/Responses/JsonDataTypeResponse.cs @@ -1,7 +1,7 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace GodaddyWrapper.Responses @@ -9,7 +9,7 @@ namespace GodaddyWrapper.Responses public class JsonDataTypeResponse { public string Type { get; set; } - [JsonProperty("$ref")] + [JsonPropertyName("$ref")] public string RefVal { get; set; } public string Format { get; set; } public string Pattern { get; set; } diff --git a/src/GodaddyWrapper/Responses/JsonPropertyResponse.cs b/src/GodaddyWrapper/Responses/JsonPropertyResponse.cs index 46d6f46..80d8860 100644 --- a/src/GodaddyWrapper/Responses/JsonPropertyResponse.cs +++ b/src/GodaddyWrapper/Responses/JsonPropertyResponse.cs @@ -1,7 +1,7 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections.Generic; using System.Linq; +using System.Text.Json.Serialization; using System.Threading.Tasks; namespace GodaddyWrapper.Responses @@ -9,7 +9,7 @@ namespace GodaddyWrapper.Responses public class JsonPropertyResponse { public string Type { get; set; } - [JsonProperty("$ref")] + [JsonPropertyName("$ref")] public string RefVal { get; set; } public JsonDataTypeResponse Items { get; set; } public bool Required { get; set; } diff --git a/src/GodaddyWrapper/Responses/SubjectAlternativeNameDetailsResponse.cs b/src/GodaddyWrapper/Responses/SubjectAlternativeNameDetailsResponse.cs index f5bd318..57a2c48 100644 --- a/src/GodaddyWrapper/Responses/SubjectAlternativeNameDetailsResponse.cs +++ b/src/GodaddyWrapper/Responses/SubjectAlternativeNameDetailsResponse.cs @@ -1,10 +1,4 @@ -using Newtonsoft.Json; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; - -namespace GodaddyWrapper.Responses +namespace GodaddyWrapper.Responses { public class SubjectAlternativeNameDetailsResponse { diff --git a/src/GodaddyWrapper/Serialization/JsonContext.cs b/src/GodaddyWrapper/Serialization/JsonContext.cs new file mode 100644 index 0000000..86bae96 --- /dev/null +++ b/src/GodaddyWrapper/Serialization/JsonContext.cs @@ -0,0 +1,171 @@ +using GodaddyWrapper.Requests; +using GodaddyWrapper.Responses; +using System.Collections.Generic; +using System.Text.Json; +using System.Text.Json.Serialization; + +namespace GodaddyWrapper.Serialization +{ +#if NETSTANDARD + + [JsonSourceGenerationOptions(GenerationMode = JsonSourceGenerationMode.Metadata, + PropertyNameCaseInsensitive = true, + PropertyNamingPolicy = JsonKnownNamingPolicy.CamelCase, + NumberHandling = JsonNumberHandling.AllowReadingFromString, + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull)] + //Requests + [JsonSerializable(typeof(AbuseTicketCreate))] + [JsonSerializable(typeof(AbuseTicketRetrieve))] + [JsonSerializable(typeof(AbuseTicketDetailRetrieve))] + [JsonSerializable(typeof(List))] + [JsonSerializable(typeof(AgreementRetrieve))] + [JsonSerializable(typeof(CertificateCancel))] + [JsonSerializable(typeof(CertificateDomainControlCheck))] + [JsonSerializable(typeof(CertificatesCreate))] + [JsonSerializable(typeof(CertificateDownload))] + [JsonSerializable(typeof(CertificateReissue))] + [JsonSerializable(typeof(CertificateRenew))] + [JsonSerializable(typeof(CertificateActionRetrieve))] + [JsonSerializable(typeof(CertificateCallbackActionRegister))] + [JsonSerializable(typeof(CertificateDetailRetrieve))] + [JsonSerializable(typeof(CertificateSiteSealRetrieve))] + [JsonSerializable(typeof(CertificateRevoke))] + [JsonSerializable(typeof(CertificateCallbackUnregister))] + [JsonSerializable(typeof(CountriesRetrieve))] + [JsonSerializable(typeof(CountryDetailRetrieve))] + [JsonSerializable(typeof(List))] + [JsonSerializable(typeof(DomainAvailableBulk))] + [JsonSerializable(typeof(DomainDelete))] + [JsonSerializable(typeof(PrivacyDelete))] + [JsonSerializable(typeof(DomainAvailable))] + [JsonSerializable(typeof(DomainPurchase))] + [JsonSerializable(typeof(DomainPurchaseWithoutPrivacy))] + [JsonSerializable(typeof(PrivacyPurchase))] + [JsonSerializable(typeof(DomainPurchaseSchema))] + [JsonSerializable(typeof(DomainRenew))] + [JsonSerializable(typeof(List))] + [JsonSerializable(typeof(List))] + [JsonSerializable(typeof(DomainAgreements))] + [JsonSerializable(typeof(DomainRetrieve))] + [JsonSerializable(typeof(DNSRecordRetrieve))] + [JsonSerializable(typeof(DomainSuggest))] + [JsonSerializable(typeof(DomainTransferIn))] + [JsonSerializable(typeof(DomainUpdate))] + [JsonSerializable(typeof(DomainContacts))] + [JsonSerializable(typeof(VerifyRegistrantEmail))] + [JsonSerializable(typeof(OrderRetrieve))] + [JsonSerializable(typeof(OrderDetailRetrieve))] + [JsonSerializable(typeof(SubaccountCreate))] + [JsonSerializable(typeof(ShopperRetrieve))] + [JsonSerializable(typeof(ShopperUpdate))] + [JsonSerializable(typeof(SubscriptionDelete))] + [JsonSerializable(typeof(SubscriptionRetrieve))] + [JsonSerializable(typeof(SubscriptionDetailRetrieve))] + [JsonSerializable(typeof(Address))] + [JsonSerializable(typeof(AftermarketListingExpiryCreate))] + [JsonSerializable(typeof(AuctionListingRemove))] + [JsonSerializable(typeof(CertificateAddress))] + [JsonSerializable(typeof(CertificateCallbackRetrieve))] + [JsonSerializable(typeof(CertificateContact))] + [JsonSerializable(typeof(CertificateOrganizationCreate))] + [JsonSerializable(typeof(Consent))] + [JsonSerializable(typeof(Contact))] + [JsonSerializable(typeof(DNSRecord))] + [JsonSerializable(typeof(DNSRecordCreateType))] + [JsonSerializable(typeof(DNSRecordCreateTypeName))] + [JsonSerializable(typeof(DomainDetailRetrieve))] + [JsonSerializable(typeof(EmailPreferenceRetrieve))] + [JsonSerializable(typeof(TamperSignature))] + //Responses + [JsonSerializable(typeof(AbuseTicketIdResponse))] + [JsonSerializable(typeof(AbuseTicketListResponse))] + [JsonSerializable(typeof(AbuseTicketResponse))] + [JsonSerializable(typeof(AftermarketListingActionResponse))] + [JsonSerializable(typeof(ListingActionResponse))] + [JsonSerializable(typeof(List))] + [JsonSerializable(typeof(CertificateIdentifierResponse))] + [JsonSerializable(typeof(CertificateBundleResponse))] + [JsonSerializable(typeof(List))] + [JsonSerializable(typeof(CertificateSiteSealResponse))] + [JsonSerializable(typeof(CountrySummaryResponse))] + [JsonSerializable(typeof(CountryResponse))] + [JsonSerializable(typeof(DomainAvailableBulkResultResponse))] + [JsonSerializable(typeof(DomainAvailableResponse))] + [JsonSerializable(typeof(DomainPurchaseResponse))] + [JsonSerializable(typeof(JsonPropertyResponse))] + [JsonSerializable(typeof(List))] + [JsonSerializable(typeof(DomainDetailResponse))] + [JsonSerializable(typeof(List))] + [JsonSerializable(typeof(List))] + [JsonSerializable(typeof(List))] + [JsonSerializable(typeof(OrderListResponse))] + [JsonSerializable(typeof(OrderResponse))] + [JsonSerializable(typeof(ShopperIdResponse))] + [JsonSerializable(typeof(ShopperResponse))] + [JsonSerializable(typeof(SubscriptionListResponse))] + [JsonSerializable(typeof(List))] + [JsonSerializable(typeof(SubscriptionResponse))] + [JsonSerializable(typeof(AddressUsageDetailResponse))] + [JsonSerializable(typeof(BillToResponse))] + [JsonSerializable(typeof(CertificateActionResponse))] + [JsonSerializable(typeof(CertificateAddressResponse))] + [JsonSerializable(typeof(CertificateCallbackResponse))] + [JsonSerializable(typeof(CertificateContactResponse))] + [JsonSerializable(typeof(CertificateOrganizationResponse))] + [JsonSerializable(typeof(CertificateResponse))] + [JsonSerializable(typeof(ContactResponse))] + [JsonSerializable(typeof(DiscountDetailItemResponse))] + [JsonSerializable(typeof(DiscountDetailResponse))] + [JsonSerializable(typeof(DNSRecordResponse))] + [JsonSerializable(typeof(DomainAvailableBulkMixedResponse))] + [JsonSerializable(typeof(DomainAvailableBulkResponse))] + [JsonSerializable(typeof(DomainAvailableErrorResponse))] + [JsonSerializable(typeof(DomainRetrieveResponse))] + [JsonSerializable(typeof(DomainSuggestionResponse))] + [JsonSerializable(typeof(DomainSummaryResponse))] + [JsonSerializable(typeof(EmailPreferenceResponse))] + [JsonSerializable(typeof(ErrorFieldResponse))] + [JsonSerializable(typeof(ErrorResponse))] + [JsonSerializable(typeof(JsonDataTypeResponse))] + [JsonSerializable(typeof(JsonSchemaResponse))] + [JsonSerializable(typeof(JurisdictionOfIncorporationResponse))] + [JsonSerializable(typeof(LegalAgreementResponse))] + [JsonSerializable(typeof(LineItemPricingResponse))] + [JsonSerializable(typeof(LineItemResponse))] + [JsonSerializable(typeof(LineItemSummaryResponse))] + [JsonSerializable(typeof(OrderFeeResponse))] + [JsonSerializable(typeof(OrderPricingResponse))] + [JsonSerializable(typeof(OrderSummaryPricingResponse))] + [JsonSerializable(typeof(OrderSummaryResponse))] + [JsonSerializable(typeof(PaginationResponse))] + [JsonSerializable(typeof(PaymentResponse))] + [JsonSerializable(typeof(PEMCertificatesResponse))] + [JsonSerializable(typeof(ProductGroupResponse))] + [JsonSerializable(typeof(RealNameValidationResponse))] + [JsonSerializable(typeof(StateResponse))] + [JsonSerializable(typeof(SubjectAlternativeNameDetailsResponse))] + [JsonSerializable(typeof(SubscriptionAddonResponse))] + [JsonSerializable(typeof(SubscriptionBillingResponse))] + [JsonSerializable(typeof(SubscriptionProductResponse))] + [JsonSerializable(typeof(SubscriptionRelationsResponse))] + [JsonSerializable(typeof(TamperSignatureResponse))] + [JsonSerializable(typeof(TldSummaryResponse))] + [JsonSerializable(typeof(UsageDetailItemResponse))] + [JsonSerializable(typeof(UsageSummaryResponse))] + internal partial class JsonContext : JsonSerializerContext + { + } +#else + internal partial class JsonContext + { + public static class Default + { + public readonly static JsonSerializerOptions Options = new JsonSerializerOptions(JsonSerializerDefaults.Web) + { + DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull, + PropertyNamingPolicy = JsonNamingPolicy.CamelCase, + }; + } + } +#endif +} \ No newline at end of file diff --git a/src/GodaddyWrapper/Services.cs b/src/GodaddyWrapper/Services.cs index 2f3375c..f9a2fae 100644 --- a/src/GodaddyWrapper/Services.cs +++ b/src/GodaddyWrapper/Services.cs @@ -1,14 +1,12 @@ -#if NETSTANDARD +#if NETSTANDARD using Microsoft.Extensions.DependencyInjection; using System; using System.Linq; using System.Net.Http; using System.Net.Http.Headers; -#endif namespace GodaddyWrapper { -#if NETSTANDARD public static class ServicesExtension { /// @@ -32,5 +30,5 @@ public static IServiceCollection AddGoDaddy(this IServiceCollection services, st return services; } } -#endif } +#endif