diff --git a/ShopifySharp.Experimental/ShopifySharp.Experimental.fsproj b/ShopifySharp.Experimental/ShopifySharp.Experimental.fsproj index af535d2d..054802c5 100755 --- a/ShopifySharp.Experimental/ShopifySharp.Experimental.fsproj +++ b/ShopifySharp.Experimental/ShopifySharp.Experimental.fsproj @@ -34,4 +34,4 @@ - \ No newline at end of file + diff --git a/ShopifySharp.Extensions.DependencyInjection.Tests/TestExtensions.cs b/ShopifySharp.Extensions.DependencyInjection.Tests/TestExtensions.cs index 3c6acb41..817cc78a 100644 --- a/ShopifySharp.Extensions.DependencyInjection.Tests/TestExtensions.cs +++ b/ShopifySharp.Extensions.DependencyInjection.Tests/TestExtensions.cs @@ -1,28 +1,27 @@ -namespace ShopifySharp.Extensions.DependencyInjection.Tests +namespace ShopifySharp.Extensions.DependencyInjection.Tests; + +public static class ObjectExtensions { - public static class ObjectExtensions + private static readonly Dictionary ServiceLifetimeInstanceValidation = new() { - private static readonly Dictionary ServiceLifetimeInstanceValidation = new() - { - { ServiceLifetime.Scoped, true }, - { ServiceLifetime.Singleton, true }, - { ServiceLifetime.Transient, false } - }; + { ServiceLifetime.Scoped, true }, + { ServiceLifetime.Singleton, true }, + { ServiceLifetime.Transient, false } + }; - public static bool ValidLifetimeInstance(this object actual, object expceted, ServiceLifetime serviceLifetime) - { - return ServiceLifetimeInstanceValidation.TryGetValue(serviceLifetime, out bool value) && value ? ReferenceEquals(actual, expceted) : !ReferenceEquals(actual, expceted); - } + public static bool ValidLifetimeInstance(this object actual, object expceted, ServiceLifetime serviceLifetime) + { + return ServiceLifetimeInstanceValidation.TryGetValue(serviceLifetime, out bool value) && value ? ReferenceEquals(actual, expceted) : !ReferenceEquals(actual, expceted); } +} - public static class ServiceProviderExtensions +public static class ServiceProviderExtensions +{ + public static TestServiceLifetime GetServiceInstances(this ServiceProvider? serviceProvider) where T : class { - public static TestServiceLifetime GetServiceInstances(this ServiceProvider? serviceProvider) where T : class - { - var service1 = serviceProvider?.GetService(); - var service2 = serviceProvider?.GetService(); + var service1 = serviceProvider?.GetService(); + var service2 = serviceProvider?.GetService(); - return new TestServiceLifetime(service1, service2); - } + return new TestServiceLifetime(service1, service2); } -} +} \ No newline at end of file diff --git a/ShopifySharp.Extensions.DependencyInjection/ShopifySharp.Extensions.DependencyInjection.csproj b/ShopifySharp.Extensions.DependencyInjection/ShopifySharp.Extensions.DependencyInjection.csproj index 8f56689e..6d3b8bbb 100644 --- a/ShopifySharp.Extensions.DependencyInjection/ShopifySharp.Extensions.DependencyInjection.csproj +++ b/ShopifySharp.Extensions.DependencyInjection/ShopifySharp.Extensions.DependencyInjection.csproj @@ -27,4 +27,4 @@ - \ No newline at end of file + diff --git a/ShopifySharp.Tests/Checkout_Tests.cs b/ShopifySharp.Tests/Checkout_Tests.cs index 5e4b9eaf..11217cab 100644 --- a/ShopifySharp.Tests/Checkout_Tests.cs +++ b/ShopifySharp.Tests/Checkout_Tests.cs @@ -1,4 +1,4 @@ -using System.Threading.Tasks; +using System.Threading.Tasks; using Xunit; namespace ShopifySharp.Tests; diff --git a/ShopifySharp.Tests/CustomerAddress_Tests.cs b/ShopifySharp.Tests/CustomerAddress_Tests.cs index 3b0f1d7c..d3493fc7 100644 --- a/ShopifySharp.Tests/CustomerAddress_Tests.cs +++ b/ShopifySharp.Tests/CustomerAddress_Tests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net; diff --git a/ShopifySharp.Tests/DateTime_Tests.cs b/ShopifySharp.Tests/DateTime_Tests.cs index 712af61d..a0fc3195 100644 --- a/ShopifySharp.Tests/DateTime_Tests.cs +++ b/ShopifySharp.Tests/DateTime_Tests.cs @@ -1,4 +1,4 @@ -#nullable enable +#nullable enable using System.Globalization; using System.Linq; using System.Threading.Tasks; diff --git a/ShopifySharp.Tests/DiscountCode_Tests.cs b/ShopifySharp.Tests/DiscountCode_Tests.cs index e5892b36..f83c6d30 100644 --- a/ShopifySharp.Tests/DiscountCode_Tests.cs +++ b/ShopifySharp.Tests/DiscountCode_Tests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Net; using System.Threading.Tasks; diff --git a/ShopifySharp.Tests/FulfillmentRequest_Tests.cs b/ShopifySharp.Tests/FulfillmentRequest_Tests.cs index 9134c6e3..7f2b8451 100644 --- a/ShopifySharp.Tests/FulfillmentRequest_Tests.cs +++ b/ShopifySharp.Tests/FulfillmentRequest_Tests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading; diff --git a/ShopifySharp.Tests/GenerateGraphQLSchema_Test.cs b/ShopifySharp.Tests/GenerateGraphQLSchema_Test.cs index 1d6a27e4..ad8f1af4 100644 --- a/ShopifySharp.Tests/GenerateGraphQLSchema_Test.cs +++ b/ShopifySharp.Tests/GenerateGraphQLSchema_Test.cs @@ -7,44 +7,43 @@ using Wish.GraphQLSchemaGenerator; using Xunit; -namespace ShopifySharp.Tests +namespace ShopifySharp.Tests; + +[Trait("Category", "GraphQL")] +public class GenerateGraphQLSchema_Test { - [Trait("Category", "GraphQL")] - public class GenerateGraphQLSchema_Test + [Fact(Skip = "This test should be run manually to re-generate the GraphQL types whenever the API version is upgraded")] + public async Task GenerateGraphQLTypes() { - [Fact(Skip = "This test should be run manually to re-generate the GraphQL types whenever the API version is upgraded")] - public async Task GenerateGraphQLTypes() + var scalarNameToTypeName = new Dictionary + { + { "UnsignedInt64", "ulong" }, + { "Money", "decimal" }, + { "Decimal", "decimal" }, + { "DateTime", "DateTime" },//GraphQL datetimes are always UTC + { "Date", "DateOnly" }, + { "UtcOffset", "TimeSpan" }, + { "URL", "string" }, + { "HTML", "string" }, + { "JSON", "string" }, + { "FormattedString", "string" }, + { "ARN", "string" }, + { "StorefrontID", "string" }, + { "Color", "string" }, + }; + string csharpCode = await new GraphQLTypeGenerator().GenerateTypesAsync("ShopifySharp.GraphQL", scalarNameToTypeName, async query => { - var scalarNameToTypeName = new Dictionary - { - { "UnsignedInt64", "ulong" }, - { "Money", "decimal" }, - { "Decimal", "decimal" }, - { "DateTime", "DateTime" },//GraphQL datetimes are always UTC - { "Date", "DateOnly" }, - { "UtcOffset", "TimeSpan" }, - { "URL", "string" }, - { "HTML", "string" }, - { "JSON", "string" }, - { "FormattedString", "string" }, - { "ARN", "string" }, - { "StorefrontID", "string" }, - { "Color", "string" }, - }; - string csharpCode = await new GraphQLTypeGenerator().GenerateTypesAsync("ShopifySharp.GraphQL", scalarNameToTypeName, async query => - { - var res = await new GraphService(Utils.MyShopifyUrl, Utils.AccessToken).PostAsync(query); - var doc = JsonDocument.Parse(res.ToString()); - return doc; - }); + var res = await new GraphService(Utils.MyShopifyUrl, Utils.AccessToken).PostAsync(query); + var doc = JsonDocument.Parse(res.ToString()); + return doc; + }); - var strCode = new StringBuilder() - .AppendLine("#if NET6_0_OR_GREATER") - .AppendLine(csharpCode) - .AppendLine("#endif"); + var strCode = new StringBuilder() + .AppendLine("#if NET6_0_OR_GREATER") + .AppendLine(csharpCode) + .AppendLine("#endif"); - File.WriteAllText(@"../../../../ShopifySharp/Entities/GraphQL/GraphQLSchema.generated.cs", strCode.ToString()); - } + File.WriteAllText(@"../../../../ShopifySharp/Entities/GraphQL/GraphQLSchema.generated.cs", strCode.ToString()); } } #endif diff --git a/ShopifySharp.Tests/GiftCard_Tests.cs b/ShopifySharp.Tests/GiftCard_Tests.cs index 91993c8b..9d409d5e 100644 --- a/ShopifySharp.Tests/GiftCard_Tests.cs +++ b/ShopifySharp.Tests/GiftCard_Tests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; diff --git a/ShopifySharp.Tests/Graph_SendTests.cs b/ShopifySharp.Tests/Graph_SendTests.cs index 0bace957..e0850476 100644 --- a/ShopifySharp.Tests/Graph_SendTests.cs +++ b/ShopifySharp.Tests/Graph_SendTests.cs @@ -4,24 +4,24 @@ using ShopifySharp.GraphQL; using Xunit; -namespace ShopifySharp.Tests +namespace ShopifySharp.Tests; + +[Trait("Category", "Graph")] +public class Graph_SendTests { - [Trait("Category", "Graph")] - public class Graph_SendTests + [Fact] + public async Task GetOrders() { - [Fact] - public async Task GetOrders() + foreach (var policy in new IRequestExecutionPolicy[] + { + new DefaultRequestExecutionPolicy(), + new RetryExecutionPolicy(), + new LeakyBucketExecutionPolicy() + }) { - foreach (var policy in new IRequestExecutionPolicy[] - { - new DefaultRequestExecutionPolicy(), - new RetryExecutionPolicy(), - new LeakyBucketExecutionPolicy() - }) - { - var svc = new GraphService(Utils.MyShopifyUrl, Utils.AccessToken); - svc.SetExecutionPolicy(policy); - var res = await svc.SendAsync(@" + var svc = new GraphService(Utils.MyShopifyUrl, Utils.AccessToken); + svc.SetExecutionPolicy(policy); + var res = await svc.SendAsync(@" { orders(first:10) { @@ -43,33 +43,33 @@ public async Task GetOrders() } } "); - var orders = res.nodes; - Assert.True(orders.Count() > 0); - var o = orders.First(); - Assert.True(o.name != null); - Assert.True(o.lineItems.nodes.First().quantity != null); - var commentEventEmbed = o as ICommentEventEmbed; - Assert.NotNull(commentEventEmbed); - Assert.NotNull(commentEventEmbed.AsOrder()); - Assert.Null(commentEventEmbed.AsCustomer()); - } + var orders = res.nodes; + Assert.True(orders.Count() > 0); + var o = orders.First(); + Assert.True(o.name != null); + Assert.True(o.lineItems.nodes.First().quantity != null); + var commentEventEmbed = o as ICommentEventEmbed; + Assert.NotNull(commentEventEmbed); + Assert.NotNull(commentEventEmbed.AsOrder()); + Assert.Null(commentEventEmbed.AsCustomer()); } + } - [Fact] - public async Task GetOrdersWithVariables() + [Fact] + public async Task GetOrdersWithVariables() + { + foreach (var policy in new IRequestExecutionPolicy[] + { + new DefaultRequestExecutionPolicy(), + new RetryExecutionPolicy(), + new LeakyBucketExecutionPolicy() + }) { - foreach (var policy in new IRequestExecutionPolicy[] - { - new DefaultRequestExecutionPolicy(), - new RetryExecutionPolicy(), - new LeakyBucketExecutionPolicy() - }) + var svc = new GraphService(Utils.MyShopifyUrl, Utils.AccessToken); + svc.SetExecutionPolicy(policy); + var res = await svc.SendAsync(new GraphRequest { - var svc = new GraphService(Utils.MyShopifyUrl, Utils.AccessToken); - svc.SetExecutionPolicy(policy); - var res = await svc.SendAsync(new GraphRequest - { - query = + query = @" query ($firstOrders: Int!, $firstLineItems: Int!) { @@ -92,22 +92,21 @@ public async Task GetOrdersWithVariables() } } }", - variables = new - { - firstOrders = 10, - firstLineItems = 20 - } - }); - var orders = res.nodes; - Assert.True(orders.Count() > 0); - var o = orders.First(); - Assert.True(o.name != null); - Assert.True(o.lineItems.nodes.First().quantity != null); - var commentEventEmbed = o as ICommentEventEmbed; - Assert.NotNull(commentEventEmbed); - Assert.NotNull(commentEventEmbed.AsOrder()); - Assert.Null(commentEventEmbed.AsCustomer()); - } + variables = new + { + firstOrders = 10, + firstLineItems = 20 + } + }); + var orders = res.nodes; + Assert.True(orders.Count() > 0); + var o = orders.First(); + Assert.True(o.name != null); + Assert.True(o.lineItems.nodes.First().quantity != null); + var commentEventEmbed = o as ICommentEventEmbed; + Assert.NotNull(commentEventEmbed); + Assert.NotNull(commentEventEmbed.AsOrder()); + Assert.Null(commentEventEmbed.AsCustomer()); } } } diff --git a/ShopifySharp.Tests/LeakyBucket_Tests.cs b/ShopifySharp.Tests/LeakyBucket_Tests.cs index e92d0766..2b33ca9d 100644 --- a/ShopifySharp.Tests/LeakyBucket_Tests.cs +++ b/ShopifySharp.Tests/LeakyBucket_Tests.cs @@ -1,5 +1,7 @@ using System; +using System.Threading; using System.Threading.Tasks; +using FluentAssertions; using ShopifySharp.Infrastructure.Policies.LeakyBucketPolicy; using Xunit; @@ -124,7 +126,7 @@ public async Task BlockedMultipleCallsCompleteAfterEnoughTime() Assert.False(task3.IsCompleted); Assert.Equal(1, b.ComputedCurrentlyAvailable); - + await PassSeconds(1); Assert.True(task1.IsCompleted); Assert.False(task2.IsCompleted); @@ -163,4 +165,4 @@ private async Task PassSeconds(int seconds) now = now.AddSeconds(seconds); await Task.Delay(TimeSpan.FromSeconds(seconds * 1.2)); } -} \ No newline at end of file +} diff --git a/ShopifySharp.Tests/Policies/LeakyBucketExecutionPolicyTests.cs b/ShopifySharp.Tests/Policies/LeakyBucketExecutionPolicyTests.cs index e2ab2dc5..0670b0e8 100644 --- a/ShopifySharp.Tests/Policies/LeakyBucketExecutionPolicyTests.cs +++ b/ShopifySharp.Tests/Policies/LeakyBucketExecutionPolicyTests.cs @@ -1,6 +1,7 @@ using System; using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Threading.Tasks; using FluentAssertions; using JetBrains.Annotations; diff --git a/ShopifySharp.Tests/SalesChannel/CheckoutSalesChannel_Tests.cs b/ShopifySharp.Tests/SalesChannel/CheckoutSalesChannel_Tests.cs index 28aa7742..164a5b91 100644 --- a/ShopifySharp.Tests/SalesChannel/CheckoutSalesChannel_Tests.cs +++ b/ShopifySharp.Tests/SalesChannel/CheckoutSalesChannel_Tests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Threading.Tasks; diff --git a/ShopifySharp.Tests/SalesChannel/CollectionListing_Tests.cs b/ShopifySharp.Tests/SalesChannel/CollectionListing_Tests.cs index c40da9d0..05d3d54e 100644 --- a/ShopifySharp.Tests/SalesChannel/CollectionListing_Tests.cs +++ b/ShopifySharp.Tests/SalesChannel/CollectionListing_Tests.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using System.Threading.Tasks; using Xunit; diff --git a/ShopifySharp.Tests/SalesChannel/ProductListing_Tests.cs b/ShopifySharp.Tests/SalesChannel/ProductListing_Tests.cs index 18141540..892ea10a 100644 --- a/ShopifySharp.Tests/SalesChannel/ProductListing_Tests.cs +++ b/ShopifySharp.Tests/SalesChannel/ProductListing_Tests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Net; diff --git a/ShopifySharp.Tests/ShopifySharp.Tests.csproj b/ShopifySharp.Tests/ShopifySharp.Tests.csproj index 77ab7d11..01b0416e 100644 --- a/ShopifySharp.Tests/ShopifySharp.Tests.csproj +++ b/ShopifySharp.Tests/ShopifySharp.Tests.csproj @@ -1,4 +1,4 @@ - + latest net8.0;net472 diff --git a/ShopifySharp.Tests/TenderTransaction_Tests.cs b/ShopifySharp.Tests/TenderTransaction_Tests.cs index f38e4790..621a02c8 100644 --- a/ShopifySharp.Tests/TenderTransaction_Tests.cs +++ b/ShopifySharp.Tests/TenderTransaction_Tests.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Linq; using System.Threading.Tasks; using ShopifySharp.Filters; diff --git a/ShopifySharp.Tests/User_Tests.cs b/ShopifySharp.Tests/User_Tests.cs index 596ca6c3..05f01efa 100644 --- a/ShopifySharp.Tests/User_Tests.cs +++ b/ShopifySharp.Tests/User_Tests.cs @@ -1,4 +1,4 @@ -using System.Linq; +using System.Linq; using System.Threading.Tasks; using ShopifySharp.Filters; using Xunit; diff --git a/ShopifySharp/Converters/DateFormatConverter.cs b/ShopifySharp/Converters/DateFormatConverter.cs index dc38bdc9..91ce0a70 100644 --- a/ShopifySharp/Converters/DateFormatConverter.cs +++ b/ShopifySharp/Converters/DateFormatConverter.cs @@ -1,16 +1,15 @@ -using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Converters; -namespace ShopifySharp.Converters +namespace ShopifySharp.Converters; + +/// +/// Converts a Date to and from the provided date format string. +/// In Particular, GiftCard.ExpiresOn only accepts the format 'yyyy-MM-dd'. If the time is included the value is ignored +/// +public class DateFormatConverter : IsoDateTimeConverter { - /// - /// Converts a Date to and from the provided date format string. - /// In Particular, GiftCard.ExpiresOn only accepts the format 'yyyy-MM-dd'. If the time is included the value is ignored - /// - public class DateFormatConverter : IsoDateTimeConverter + public DateFormatConverter(string format) { - public DateFormatConverter(string format) - { - base.DateTimeFormat = format; - } + base.DateTimeFormat = format; } -} +} \ No newline at end of file diff --git a/ShopifySharp/Converters/FalseToNullConverter.cs b/ShopifySharp/Converters/FalseToNullConverter.cs index 0dc75341..1dd54d0f 100644 --- a/ShopifySharp/Converters/FalseToNullConverter.cs +++ b/ShopifySharp/Converters/FalseToNullConverter.cs @@ -1,73 +1,72 @@ -using System; +using System; using Newtonsoft.Json; -namespace ShopifySharp.Converters +namespace ShopifySharp.Converters; + +/// +/// A custom boolean converter that converts False to null and null to False. +/// +public class FalseToNullConverter : JsonConverter { - /// - /// A custom boolean converter that converts False to null and null to False. - /// - public class FalseToNullConverter : JsonConverter + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + if(reader.Value?.ToString() == null || reader.Value?.ToString() == "") + { + return false; + } + else { - if(reader.Value?.ToString() == null || reader.Value?.ToString() == "") + bool output = false; + + if (bool.TryParse(reader.Value.ToString(), out output)) { - return false; + return output; } else { - bool output = false; - - if (bool.TryParse(reader.Value.ToString(), out output)) - { - return output; - } - else - { - throw new JsonReaderException($"Cannot convert given JSON value with {nameof(FalseToNullConverter)}."); - } + throw new JsonReaderException($"Cannot convert given JSON value with {nameof(FalseToNullConverter)}."); } } + } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + if (value == null) { - if (value == null) + writer.WriteNull(); + } + else + { + bool boolean = bool.Parse(value.ToString()); + + if(boolean == false) { writer.WriteNull(); } else { - bool boolean = bool.Parse(value.ToString()); - - if(boolean == false) - { - writer.WriteNull(); - } - else - { - writer.WriteValue(true); - } + writer.WriteValue(true); } } + } - public override bool CanConvert(Type objectType) + public override bool CanConvert(Type objectType) + { + if(objectType == typeof(string)) { - if(objectType == typeof(string)) - { - return true; - } - else if(objectType == typeof(bool)) - { - return true; - } - else if(objectType == typeof(Nullable)) - { - return true; - } - else - { - return false; - } + return true; + } + else if(objectType == typeof(bool)) + { + return true; + } + else if(objectType == typeof(Nullable)) + { + return true; + } + else + { + return false; } } -} +} \ No newline at end of file diff --git a/ShopifySharp/Converters/InvalidDateConverter.cs b/ShopifySharp/Converters/InvalidDateConverter.cs index 122a91f3..5f8f756f 100644 --- a/ShopifySharp/Converters/InvalidDateConverter.cs +++ b/ShopifySharp/Converters/InvalidDateConverter.cs @@ -1,28 +1,27 @@ -using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Converters; using System; using Newtonsoft.Json; -namespace ShopifySharp.Converters +namespace ShopifySharp.Converters; + +/// +/// A custom converter that detects invalid dates and convert them to null instead of throwing an exception. +/// In particular, FulfillmentEvent.EstimatedDeliveryAt has been observed to sometimes contain an invalid date +/// e.g '0000-12-31T18:09:24-05:50', which is smaller than both DateTime.MinValue and DateTimeOffset.MinValue +/// UPDATE October 2022: +/// This API bug has been encountered in several additional API fields, such as transaction.processed_at, customer.accepts_marketing_updated_at and customer.email_marketing_consent.consent_updated_at +/// See https://github.com/nozzlegear/ShopifySharp/issues/803 +/// This converter is applied to all date properties because: +/// *It seems to can start occurring on multiple any date fields +/// *The impact of not handling is quite severe. ShopifySharp would fail to deserialize and return an error +/// +public class InvalidDateConverter : IsoDateTimeConverter { - /// - /// A custom converter that detects invalid dates and convert them to null instead of throwing an exception. - /// In particular, FulfillmentEvent.EstimatedDeliveryAt has been observed to sometimes contain an invalid date - /// e.g '0000-12-31T18:09:24-05:50', which is smaller than both DateTime.MinValue and DateTimeOffset.MinValue - /// UPDATE October 2022: - /// This API bug has been encountered in several additional API fields, such as transaction.processed_at, customer.accepts_marketing_updated_at and customer.email_marketing_consent.consent_updated_at - /// See https://github.com/nozzlegear/ShopifySharp/issues/803 - /// This converter is applied to all date properties because: - /// *It seems to can start occurring on multiple any date fields - /// *The impact of not handling is quite severe. ShopifySharp would fail to deserialize and return an error - /// - public class InvalidDateConverter : IsoDateTimeConverter + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) - { - if (reader.Value != null && reader.Value.ToString().StartsWith("0000-")) - return null; + if (reader.Value != null && reader.Value.ToString().StartsWith("0000-")) + return null; - return base.ReadJson(reader, objectType, existingValue, serializer); - } + return base.ReadJson(reader, objectType, existingValue, serializer); } -} +} \ No newline at end of file diff --git a/ShopifySharp/Converters/NullOnErrorConverter.cs b/ShopifySharp/Converters/NullOnErrorConverter.cs index b58f4e4b..23d0cdbf 100644 --- a/ShopifySharp/Converters/NullOnErrorConverter.cs +++ b/ShopifySharp/Converters/NullOnErrorConverter.cs @@ -1,35 +1,34 @@ -using System; +using System; using Newtonsoft.Json; -namespace ShopifySharp.Converters +namespace ShopifySharp.Converters; + +/// +/// A custom converter that returns null if an error occurs while deserializing +/// +public class NullOnErrorConverter : JsonConverter { - /// - /// A custom converter that returns null if an error occurs while deserializing - /// - public class NullOnErrorConverter : JsonConverter + public override bool CanWrite => false; + + public override bool CanConvert(Type objectType) { - public override bool CanWrite => false; + return true; + } - public override bool CanConvert(Type objectType) + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + { + try { - return true; + return serializer.Deserialize(reader, objectType); } - - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + catch { - try - { - return serializer.Deserialize(reader, objectType); - } - catch - { - return null; - } + return null; } + } - public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) - { - throw new NotImplementedException($"Unnecessary because {nameof(CanWrite)} is false."); - } + public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer) + { + throw new NotImplementedException($"Unnecessary because {nameof(CanWrite)} is false."); } -} +} \ No newline at end of file diff --git a/ShopifySharp/Converters/NullableEnumConverter.cs b/ShopifySharp/Converters/NullableEnumConverter.cs index e4d8dd03..cbd20daa 100644 --- a/ShopifySharp/Converters/NullableEnumConverter.cs +++ b/ShopifySharp/Converters/NullableEnumConverter.cs @@ -1,52 +1,51 @@ -using Newtonsoft.Json.Converters; +using Newtonsoft.Json.Converters; using System; using Newtonsoft.Json; using System.Runtime.Serialization; using System.Reflection; using System.Linq; -namespace ShopifySharp.Converters +namespace ShopifySharp.Converters; + +/// +/// A custom enum converter for all enums which returns the value +/// as null when the value is null or does not exist. +/// +public class NullableEnumConverter : StringEnumConverter where T : struct { - /// - /// A custom enum converter for all enums which returns the value - /// as null when the value is null or does not exist. - /// - public class NullableEnumConverter : StringEnumConverter where T : struct + public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { - public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) + T parsed; + + if (!Enum.TryParse(reader.Value?.ToString() ?? "", true, out parsed)) { - T parsed; + // Some EnumMember values have an '_', '-' or '/' in their value and will fail the TryParse or IsDefined checks. + // Use reflection to pull all of the enums values, get their EnumMember value and check if there's a match. - if (!Enum.TryParse(reader.Value?.ToString() ?? "", true, out parsed)) - { - // Some EnumMember values have an '_', '-' or '/' in their value and will fail the TryParse or IsDefined checks. - // Use reflection to pull all of the enums values, get their EnumMember value and check if there's a match. + var enumType = typeof(T); + var enumTypeInfo = enumType.GetTypeInfo(); + var enumVals = Enum.GetValues(enumType); - var enumType = typeof(T); - var enumTypeInfo = enumType.GetTypeInfo(); - var enumVals = Enum.GetValues(enumType); + foreach (var enumVal in enumVals) + { + var valInfo = enumTypeInfo.DeclaredMembers; + var enumMember = valInfo.First().GetCustomAttributes(typeof(EnumMemberAttribute), false); - foreach (var enumVal in enumVals) + if (enumMember.Count() == 0) { - var valInfo = enumTypeInfo.DeclaredMembers; - var enumMember = valInfo.First().GetCustomAttributes(typeof(EnumMemberAttribute), false); - - if (enumMember.Count() == 0) - { - continue; - } - - if (((EnumMemberAttribute)enumMember.First()).Value?.ToString() == reader.Value?.ToString()) - { - return (T)enumVal; - } + continue; } - //No match found. Return null. - return null; + if (((EnumMemberAttribute)enumMember.First()).Value?.ToString() == reader.Value?.ToString()) + { + return (T)enumVal; + } } - return parsed; + //No match found. Return null. + return null; } + + return parsed; } -} +} \ No newline at end of file diff --git a/ShopifySharp/Credentials/ShopifyApiCredentials.cs b/ShopifySharp/Credentials/ShopifyApiCredentials.cs index 4f1bc60a..4e3a0aa6 100644 --- a/ShopifySharp/Credentials/ShopifyApiCredentials.cs +++ b/ShopifySharp/Credentials/ShopifyApiCredentials.cs @@ -5,46 +5,45 @@ using System; -namespace ShopifySharp.Credentials +namespace ShopifySharp.Credentials; + +public readonly struct ShopifyApiCredentials(string shopDomain, string accessToken) { - public readonly struct ShopifyApiCredentials(string shopDomain, string accessToken) - { - public string ShopDomain { get; } = shopDomain; - public string AccessToken { get; } = accessToken; + public string ShopDomain { get; } = shopDomain; + public string AccessToken { get; } = accessToken; - #if NETSTANDARD2_0 +#if NETSTANDARD2_0 public override bool Equals(object obj) { return obj is ShopifyApiCredentials other && ShopDomain == other.ShopDomain && AccessToken == other.AccessToken; } - #else - public override bool Equals(object? obj) - { - return obj is ShopifyApiCredentials other - && ShopDomain == other.ShopDomain - && AccessToken == other.AccessToken; - } - #endif +#else + public override bool Equals(object? obj) + { + return obj is ShopifyApiCredentials other + && ShopDomain == other.ShopDomain + && AccessToken == other.AccessToken; + } +#endif - public override int GetHashCode() - { - #if NETSTANDARD2_0 + public override int GetHashCode() + { +#if NETSTANDARD2_0 return (ShopDomain, AccessToken).GetHashCode(); - #else - return HashCode.Combine(ShopDomain, AccessToken); - #endif - } +#else + return HashCode.Combine(ShopDomain, AccessToken); +#endif + } - public static bool operator ==(ShopifyApiCredentials left, ShopifyApiCredentials right) - { - return left.Equals(right); - } + public static bool operator ==(ShopifyApiCredentials left, ShopifyApiCredentials right) + { + return left.Equals(right); + } - public static bool operator !=(ShopifyApiCredentials left, ShopifyApiCredentials right) - { - return !(left == right); - } + public static bool operator !=(ShopifyApiCredentials left, ShopifyApiCredentials right) + { + return !(left == right); } -} +} \ No newline at end of file diff --git a/ShopifySharp/Credentials/ShopifyPartnerApiCredentials.cs b/ShopifySharp/Credentials/ShopifyPartnerApiCredentials.cs index 4e566f99..f5e44bee 100644 --- a/ShopifySharp/Credentials/ShopifyPartnerApiCredentials.cs +++ b/ShopifySharp/Credentials/ShopifyPartnerApiCredentials.cs @@ -5,46 +5,45 @@ using System; -namespace ShopifySharp.Credentials +namespace ShopifySharp.Credentials; + +public readonly struct ShopifyPartnerApiCredentials(long partnerOrganizationId, string accessToken) { - public readonly struct ShopifyPartnerApiCredentials(long partnerOrganizationId, string accessToken) - { - public long PartnerOrganizationId { get; } = partnerOrganizationId; - public string AccessToken { get; } = accessToken; + public long PartnerOrganizationId { get; } = partnerOrganizationId; + public string AccessToken { get; } = accessToken; - #if NETSTANDARD2_0 +#if NETSTANDARD2_0 public override bool Equals(object obj) { return obj is ShopifyPartnerApiCredentials other && PartnerOrganizationId == other.PartnerOrganizationId && AccessToken == other.AccessToken; } - #else - public override bool Equals(object? obj) - { - return obj is ShopifyPartnerApiCredentials other - && PartnerOrganizationId == other.PartnerOrganizationId - && AccessToken == other.AccessToken; - } - #endif +#else + public override bool Equals(object? obj) + { + return obj is ShopifyPartnerApiCredentials other + && PartnerOrganizationId == other.PartnerOrganizationId + && AccessToken == other.AccessToken; + } +#endif - public override int GetHashCode() - { - #if NETSTANDARD2_0 + public override int GetHashCode() + { +#if NETSTANDARD2_0 return (PartnerOrganizationId, AccessToken).GetHashCode(); - #else - return HashCode.Combine(PartnerOrganizationId, AccessToken); - #endif - } +#else + return HashCode.Combine(PartnerOrganizationId, AccessToken); +#endif + } - public static bool operator ==(ShopifyPartnerApiCredentials left, ShopifyPartnerApiCredentials right) - { - return left.Equals(right); - } + public static bool operator ==(ShopifyPartnerApiCredentials left, ShopifyPartnerApiCredentials right) + { + return left.Equals(right); + } - public static bool operator !=(ShopifyPartnerApiCredentials left, ShopifyPartnerApiCredentials right) - { - return !(left == right); - } + public static bool operator !=(ShopifyPartnerApiCredentials left, ShopifyPartnerApiCredentials right) + { + return !(left == right); } -} +} \ No newline at end of file diff --git a/ShopifySharp/Entities/AccessScope.cs b/ShopifySharp/Entities/AccessScope.cs index 5c037ae5..eac72b37 100644 --- a/ShopifySharp/Entities/AccessScope.cs +++ b/ShopifySharp/Entities/AccessScope.cs @@ -1,16 +1,15 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing an access scope +/// +public class AccessScope { /// - /// An object representing an access scope + /// The scope's handle, such as "read_orders", "write_products", etc... /// - public class AccessScope - { - /// - /// The scope's handle, such as "read_orders", "write_products", etc... - /// - [JsonProperty("handle")] - public string Handle { get; set; } - } -} + [JsonProperty("handle")] + public string Handle { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/Address.cs b/ShopifySharp/Entities/Address.cs index 1ad61300..e546764b 100644 --- a/ShopifySharp/Entities/Address.cs +++ b/ShopifySharp/Entities/Address.cs @@ -1,109 +1,108 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class Address: ShopifyObject { - public class Address: ShopifyObject - { - /// - /// The mailing address. - /// - [JsonProperty("address1")] - public string Address1 { get; set; } - - /// - /// An additional field for the mailing address. - /// - [JsonProperty("address2")] - public string Address2 { get; set; } - - /// - /// The city. - /// - [JsonProperty("city")] - public string City { get; set; } - - /// - /// The company. - /// - [JsonProperty("company")] - public string Company { get; set; } - - /// - /// The country. - /// - [JsonProperty("country")] - public string Country { get; set; } - - /// - /// The two-letter country code corresponding to the country. - /// - [JsonProperty("country_code")] - public string CountryCode { get; set; } - - /// - /// The normalized country name. - /// - [JsonProperty("country_name")] - public string CountryName { get; set; } - - /// - /// Indicates whether this address is the default address. - /// - [JsonProperty("default")] - public bool? Default { get; set; } - - /// - /// The first name. - /// - [JsonProperty("first_name")] - public string FirstName { get; set; } - - /// - /// The last name. - /// - [JsonProperty("last_name")] - public string LastName { get; set; } - - /// - /// The latitude. Auto-populated by Shopify on the order's Billing/Shipping address. - /// - [JsonProperty("latitude")] - public decimal? Latitude { get; set; } - - /// - /// The longitude. Auto-populated by Shopify on the order's Billing/Shipping address. - /// - [JsonProperty("longitude")] - public decimal? Longitude { get; set; } - - /// - /// The name. - /// - [JsonProperty("name")] - public string Name { get; set; } - - /// - /// The phone number. - /// - [JsonProperty("phone")] - public string Phone { get; set; } - - /// - /// The province or state name - /// - [JsonProperty("province")] - public string Province { get; set; } - - /// - /// The two-letter province or state code. - /// - [JsonProperty("province_code")] - public string ProvinceCode { get; set; } - - /// - /// The ZIP or postal code. - /// - [JsonProperty("zip")] - public string Zip { get; set; } - } -} + /// + /// The mailing address. + /// + [JsonProperty("address1")] + public string Address1 { get; set; } + + /// + /// An additional field for the mailing address. + /// + [JsonProperty("address2")] + public string Address2 { get; set; } + + /// + /// The city. + /// + [JsonProperty("city")] + public string City { get; set; } + + /// + /// The company. + /// + [JsonProperty("company")] + public string Company { get; set; } + + /// + /// The country. + /// + [JsonProperty("country")] + public string Country { get; set; } + + /// + /// The two-letter country code corresponding to the country. + /// + [JsonProperty("country_code")] + public string CountryCode { get; set; } + + /// + /// The normalized country name. + /// + [JsonProperty("country_name")] + public string CountryName { get; set; } + + /// + /// Indicates whether this address is the default address. + /// + [JsonProperty("default")] + public bool? Default { get; set; } + + /// + /// The first name. + /// + [JsonProperty("first_name")] + public string FirstName { get; set; } + + /// + /// The last name. + /// + [JsonProperty("last_name")] + public string LastName { get; set; } + + /// + /// The latitude. Auto-populated by Shopify on the order's Billing/Shipping address. + /// + [JsonProperty("latitude")] + public decimal? Latitude { get; set; } + + /// + /// The longitude. Auto-populated by Shopify on the order's Billing/Shipping address. + /// + [JsonProperty("longitude")] + public decimal? Longitude { get; set; } + + /// + /// The name. + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// The phone number. + /// + [JsonProperty("phone")] + public string Phone { get; set; } + + /// + /// The province or state name + /// + [JsonProperty("province")] + public string Province { get; set; } + + /// + /// The two-letter province or state code. + /// + [JsonProperty("province_code")] + public string ProvinceCode { get; set; } + + /// + /// The ZIP or postal code. + /// + [JsonProperty("zip")] + public string Zip { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ApplicationCredit.cs b/ShopifySharp/Entities/ApplicationCredit.cs index f104925d..ef914202 100644 --- a/ShopifySharp/Entities/ApplicationCredit.cs +++ b/ShopifySharp/Entities/ApplicationCredit.cs @@ -1,28 +1,27 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing Shopify's ApplicationCredit object, which can be used to offer credits for payments made via the Application Charge, Recurring Application Charge, and Usage Charge APIs. +/// +public class ApplicationCredit: ShopifyObject { /// - /// An object representing Shopify's ApplicationCredit object, which can be used to offer credits for payments made via the Application Charge, Recurring Application Charge, and Usage Charge APIs. + /// The description of the application credit. /// - public class ApplicationCredit: ShopifyObject - { - /// - /// The description of the application credit. - /// - [JsonProperty("description")] - public string Description { get; set; } + [JsonProperty("description")] + public string Description { get; set; } - /// - /// The amount refunded by the application credit. - /// - [JsonProperty("amount")] - public decimal? Amount { get; set; } + /// + /// The amount refunded by the application credit. + /// + [JsonProperty("amount")] + public decimal? Amount { get; set; } - /// - /// States whether or not the application credit is a test transaction. Valid values are true or null. - /// - [JsonProperty("test")] - public bool? Test { get; set; } - } -} + /// + /// States whether or not the application credit is a test transaction. Valid values are true or null. + /// + [JsonProperty("test")] + public bool? Test { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/AppliedDiscount.cs b/ShopifySharp/Entities/AppliedDiscount.cs index e9236bb3..f40ab408 100644 --- a/ShopifySharp/Entities/AppliedDiscount.cs +++ b/ShopifySharp/Entities/AppliedDiscount.cs @@ -1,39 +1,38 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class AppliedDiscount { - public class AppliedDiscount - { - /// - /// Title of the discount. - /// - [JsonProperty("title")] - public string Title { get; set; } + /// + /// Title of the discount. + /// + [JsonProperty("title")] + public string Title { get; set; } - /// - /// Reason for the discount. - /// - [JsonProperty("description")] - public string Description { get; set; } + /// + /// Reason for the discount. + /// + [JsonProperty("description")] + public string Description { get; set; } - /// - /// he value of the discount. If the type of the discount is fixed_amount, then this is a fixed dollar amount. If the type is percentage, then this is the percentage. - /// - [JsonProperty("value")] - public string Value { get; set; } + /// + /// he value of the discount. If the type of the discount is fixed_amount, then this is a fixed dollar amount. If the type is percentage, then this is the percentage. + /// + [JsonProperty("value")] + public string Value { get; set; } - /// - /// The type of discount. Known values are "percentage" and "fixed_amount". - /// - [JsonProperty("value_type")] - public string ValueType { get; set; } + /// + /// The type of discount. Known values are "percentage" and "fixed_amount". + /// + [JsonProperty("value_type")] + public string ValueType { get; set; } - /// - /// The applied amount of the discount, based on the setting of value_type. - /// When ValueType is set to fixed_amount discount amount = quantity * value - /// When ValueType is set to percentage discount amount = floor(price * quantity * value) / 100 - /// - [JsonProperty("amount")] - public decimal? Amount { get; set; } - } -} + /// + /// The applied amount of the discount, based on the setting of value_type. + /// When ValueType is set to fixed_amount discount amount = quantity * value + /// When ValueType is set to percentage discount amount = floor(price * quantity * value) / 100 + /// + [JsonProperty("amount")] + public decimal? Amount { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/Article.cs b/ShopifySharp/Entities/Article.cs index fad21b9c..b36bbef0 100644 --- a/ShopifySharp/Entities/Article.cs +++ b/ShopifySharp/Entities/Article.cs @@ -1,95 +1,94 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify blog article. +/// +public class Article : ShopifyObject { /// - /// An object representing a Shopify blog article. + /// The name of the author of this article /// - public class Article : ShopifyObject - { - /// - /// The name of the author of this article - /// - [JsonProperty("author")] - public string Author { get; set; } + [JsonProperty("author")] + public string Author { get; set; } - /// - /// A unique numeric identifier for the blog containing the article. - /// - [JsonProperty("blog_id")] - public long? BlogId { get; set; } + /// + /// A unique numeric identifier for the blog containing the article. + /// + [JsonProperty("blog_id")] + public long? BlogId { get; set; } - /// - /// The text of the body of the article, complete with HTML markup. - /// - [JsonProperty("body_html")] - public string BodyHtml { get; set; } + /// + /// The text of the body of the article, complete with HTML markup. + /// + [JsonProperty("body_html")] + public string BodyHtml { get; set; } - /// - /// The date and time when the article was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + /// + /// The date and time when the article was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - /// - /// A human-friendly unique string for an article automatically generated from its title. It is used in the article's URL. - /// - [JsonProperty("handle")] - public string Handle { get; set; } + /// + /// A human-friendly unique string for an article automatically generated from its title. It is used in the article's URL. + /// + [JsonProperty("handle")] + public string Handle { get; set; } - /// - /// The article image. - /// - [JsonProperty("image")] - public ArticleImage Image { get; set; } + /// + /// The article image. + /// + [JsonProperty("image")] + public ArticleImage Image { get; set; } - /// - /// States whether or not the article is visible. - /// - [JsonProperty("published")] - public bool? Published { get; set; } + /// + /// States whether or not the article is visible. + /// + [JsonProperty("published")] + public bool? Published { get; set; } - /// - /// The date and time when the article was published. - /// - [JsonProperty("published_at")] - public DateTimeOffset? PublishedAt { get; set; } + /// + /// The date and time when the article was published. + /// + [JsonProperty("published_at")] + public DateTimeOffset? PublishedAt { get; set; } - /// - /// The text of the summary of the article, complete with HTML markup. - /// - [JsonProperty("summary_html")] - public string SummaryHtml { get; set; } + /// + /// The text of the summary of the article, complete with HTML markup. + /// + [JsonProperty("summary_html")] + public string SummaryHtml { get; set; } - /// - /// Tags are additional short descriptors formatted as a string of comma-separated values. For example, if an article has three tags: tag1, tag2, tag3. - /// - [JsonProperty("tags")] - public string Tags { get; set; } + /// + /// Tags are additional short descriptors formatted as a string of comma-separated values. For example, if an article has three tags: tag1, tag2, tag3. + /// + [JsonProperty("tags")] + public string Tags { get; set; } - /// - /// States the name of the template an article is using if it is using an alternate template. If an article is using the default article.liquid template, the value returned is null. - /// - [JsonProperty("template_suffix")] - public string TemplateSuffix { get; set; } + /// + /// States the name of the template an article is using if it is using an alternate template. If an article is using the default article.liquid template, the value returned is null. + /// + [JsonProperty("template_suffix")] + public string TemplateSuffix { get; set; } - /// - /// The title of the article. - /// - [JsonProperty("title")] - public string Title { get; set; } + /// + /// The title of the article. + /// + [JsonProperty("title")] + public string Title { get; set; } - /// - /// The date and time when the article was last updated. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } + /// + /// The date and time when the article was last updated. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } - /// - /// A unique numeric identifier for the author of the article. - /// - [JsonProperty("user_id")] - public long? UserId { get; set; } - } -} + /// + /// A unique numeric identifier for the author of the article. + /// + [JsonProperty("user_id")] + public long? UserId { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ArticleImage.cs b/ShopifySharp/Entities/ArticleImage.cs index 37bc167c..3b6e18bc 100644 --- a/ShopifySharp/Entities/ArticleImage.cs +++ b/ShopifySharp/Entities/ArticleImage.cs @@ -1,29 +1,28 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// Represents a Shopify article's image. +/// +public class ArticleImage { /// - /// Represents a Shopify article's image. + /// A base64 image string only used when creating an image. It will be converted to the property. /// - public class ArticleImage - { - /// - /// A base64 image string only used when creating an image. It will be converted to the property. - /// - [JsonProperty("attachment")] - public string Attachment { get; set; } + [JsonProperty("attachment")] + public string Attachment { get; set; } - /// - /// The date and time the image was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + /// + /// The date and time the image was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - /// - /// The image's src URL. - /// - [JsonProperty("src")] - public string Src { get; set; } - } -} + /// + /// The image's src URL. + /// + [JsonProperty("src")] + public string Src { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/Asset.cs b/ShopifySharp/Entities/Asset.cs index 870eebb7..d7ce1da3 100644 --- a/ShopifySharp/Entities/Asset.cs +++ b/ShopifySharp/Entities/Asset.cs @@ -1,87 +1,86 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify asset. Assets do not have ids, but rather keys, and are associated with specific themes. +/// +public class Asset { /// - /// An object representing a Shopify asset. Assets do not have ids, but rather keys, and are associated with specific themes. + /// An asset attached to a store's theme. /// - public class Asset - { - /// - /// An asset attached to a store's theme. - /// - [JsonProperty("attachment")] - public string Attachment { get; set; } + [JsonProperty("attachment")] + public string Attachment { get; set; } - /// - /// The MD5 representation of the content, consisting of a string of 32 hexadecimal digits. - /// May be null if an asset has not been updated recently. - /// - [JsonProperty("checksum")] - public string Checksum { get; set; } + /// + /// The MD5 representation of the content, consisting of a string of 32 hexadecimal digits. + /// May be null if an asset has not been updated recently. + /// + [JsonProperty("checksum")] + public string Checksum { get; set; } - /// - /// MIME representation of the content, consisting of the type and subtype of the asset, - /// e.g. "image/gif" - /// - [JsonProperty("content_type")] - public string ContentType { get; set; } + /// + /// MIME representation of the content, consisting of the type and subtype of the asset, + /// e.g. "image/gif" + /// + [JsonProperty("content_type")] + public string ContentType { get; set; } - /// - /// The date and time when the asset was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + /// + /// The date and time when the asset was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - /// - /// The path to the asset within a shop, prefixed with the asset's 'bucket' type, - /// e.g. 'templates/index.liquid' or 'assets/bg-body.gif'. - /// - [JsonProperty("key")] - public string Key { get; set; } + /// + /// The path to the asset within a shop, prefixed with the asset's 'bucket' type, + /// e.g. 'templates/index.liquid' or 'assets/bg-body.gif'. + /// + [JsonProperty("key")] + public string Key { get; set; } - /// - /// The public facing URL of the asset. - /// - [JsonProperty("public_url")] - public string PublicUrl { get; set; } + /// + /// The public facing URL of the asset. + /// + [JsonProperty("public_url")] + public string PublicUrl { get; set; } - /// - /// The asset size in bytes. - /// - [JsonProperty("size")] - public long? Size { get; set; } + /// + /// The asset size in bytes. + /// + [JsonProperty("size")] + public long? Size { get; set; } - /// - /// When set in an asset and used in , - /// a new asset will be created and copied from an asset with the key matching this source key. - /// - [JsonProperty("source_key")] - public string SourceKey { get; set; } + /// + /// When set in an asset and used in , + /// a new asset will be created and copied from an asset with the key matching this source key. + /// + [JsonProperty("source_key")] + public string SourceKey { get; set; } - /// - /// Specifies the location of an asset. - /// - [JsonProperty("src")] - public string Src { get; set; } + /// + /// Specifies the location of an asset. + /// + [JsonProperty("src")] + public string Src { get; set; } - /// - /// A unique numeric identifier for the theme. - /// - [JsonProperty("theme_id")] - public long? ThemeId { get; set; } + /// + /// A unique numeric identifier for the theme. + /// + [JsonProperty("theme_id")] + public long? ThemeId { get; set; } - /// - /// The date and time when an asset was last updated. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } + /// + /// The date and time when an asset was last updated. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } - /// - /// The asset that you are adding. - /// - [JsonProperty("value")] - public string Value { get; set; } - } -} + /// + /// The asset that you are adding. + /// + [JsonProperty("value")] + public string Value { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/AssignedFulfillmentOrder.cs b/ShopifySharp/Entities/AssignedFulfillmentOrder.cs index 45aeda3f..ab23910c 100644 --- a/ShopifySharp/Entities/AssignedFulfillmentOrder.cs +++ b/ShopifySharp/Entities/AssignedFulfillmentOrder.cs @@ -1,66 +1,65 @@ using Newtonsoft.Json; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify assigned fulfillment order. +/// +public class AssignedFulfillmentOrder : ShopifyObject { /// - /// An object representing a Shopify assigned fulfillment order. + /// The ID of the fulfillment order's assigned location. This is the location from which the order is expected to be fulfilled. /// - public class AssignedFulfillmentOrder : ShopifyObject - { - /// - /// The ID of the fulfillment order's assigned location. This is the location from which the order is expected to be fulfilled. - /// - [JsonProperty("assigned_location_id")] - public long? AssignedLocationId { get; set; } + [JsonProperty("assigned_location_id")] + public long? AssignedLocationId { get; set; } - /// - /// The destination where the items should be sent upon fulfillment. - /// - [JsonProperty("destination")] - public FulfillmentOrderDestination Destination { get; set; } + /// + /// The destination where the items should be sent upon fulfillment. + /// + [JsonProperty("destination")] + public FulfillmentOrderDestination Destination { get; set; } - /// - /// Represents line items belonging to a fulfillment order: - /// - [JsonProperty("line_items")] - public IEnumerable LineItems { get; set; } + /// + /// Represents line items belonging to a fulfillment order: + /// + [JsonProperty("line_items")] + public IEnumerable LineItems { get; set; } - /// - /// The ID of the order that's associated with the fulfillment order. - /// - [JsonProperty("order_id")] - public long? OrderId { get; set; } + /// + /// The ID of the order that's associated with the fulfillment order. + /// + [JsonProperty("order_id")] + public long? OrderId { get; set; } - /// - /// The status of the fulfillment order. - /// unsubmitted: The initial request status for the newly-created fulfillment orders. This is the only valid request status for fulfillment orders that aren't assigned to a fulfillment service. - /// submitted: The merchant requested fulfillment for this fulfillment order. - /// accepted: The fulfillment service accepted the merchant's fulfillment request. - /// rejected: The fulfillment service rejected the merchant's fulfillment request. - /// cancellation_requested: The merchant requested a cancellation of the fulfillment request for this fulfillment order. - /// cancellation_accepted: The fulfillment service accepted the merchant's fulfillment cancellation request. - /// cancellation_rejected: The fulfillment service rejected the merchant's fulfillment cancellation request. - /// closed: The fulfillment service closed the fulfillment order without completing it. - /// - [JsonProperty("request_status")] - public string RequestStatus { get; set; } + /// + /// The status of the fulfillment order. + /// unsubmitted: The initial request status for the newly-created fulfillment orders. This is the only valid request status for fulfillment orders that aren't assigned to a fulfillment service. + /// submitted: The merchant requested fulfillment for this fulfillment order. + /// accepted: The fulfillment service accepted the merchant's fulfillment request. + /// rejected: The fulfillment service rejected the merchant's fulfillment request. + /// cancellation_requested: The merchant requested a cancellation of the fulfillment request for this fulfillment order. + /// cancellation_accepted: The fulfillment service accepted the merchant's fulfillment cancellation request. + /// cancellation_rejected: The fulfillment service rejected the merchant's fulfillment cancellation request. + /// closed: The fulfillment service closed the fulfillment order without completing it. + /// + [JsonProperty("request_status")] + public string RequestStatus { get; set; } - /// - /// The ID of the shop that's associated with the fulfillment order. - /// - [JsonProperty("shop_id")] - public long? ShopId { get; set; } + /// + /// The ID of the shop that's associated with the fulfillment order. + /// + [JsonProperty("shop_id")] + public long? ShopId { get; set; } - /// - /// The status of the fulfillment order. Valid values: - /// open: Default state for newly created fulfillment orders. - /// in_progress: The fulfillment order is being processed. - /// cancelled: The fulfillment order has been cancelled by the merchant. - /// incomplete: The fulfillment order cannot be completed as requested. - /// closed: The fulfillment order has been completed and closed. - /// - [JsonProperty("status")] - public string Status { get; set; } - } -} + /// + /// The status of the fulfillment order. Valid values: + /// open: Default state for newly created fulfillment orders. + /// in_progress: The fulfillment order is being processed. + /// cancelled: The fulfillment order has been cancelled by the merchant. + /// incomplete: The fulfillment order cannot be completed as requested. + /// closed: The fulfillment order has been completed and closed. + /// + [JsonProperty("status")] + public string Status { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/AssignedFulfillmentOrderLineItem.cs b/ShopifySharp/Entities/AssignedFulfillmentOrderLineItem.cs index c8bdbdea..0c0a62a3 100644 --- a/ShopifySharp/Entities/AssignedFulfillmentOrderLineItem.cs +++ b/ShopifySharp/Entities/AssignedFulfillmentOrderLineItem.cs @@ -1,43 +1,42 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class AssignedFulfillmentOrderLineItem : ShopifyObject { - public class AssignedFulfillmentOrderLineItem : ShopifyObject - { - /// - /// The ID of the shop associated with the fulfillment order line item. - /// - [JsonProperty("shop_id")] - public long? ShopId { get; set; } + /// + /// The ID of the shop associated with the fulfillment order line item. + /// + [JsonProperty("shop_id")] + public long? ShopId { get; set; } - /// - /// The ID of the fulfillment order associated with this line item. - /// - [JsonProperty("fulfillment_order_id")] - public long? FulfillmentOrderId { get; set; } + /// + /// The ID of the fulfillment order associated with this line item. + /// + [JsonProperty("fulfillment_order_id")] + public long? FulfillmentOrderId { get; set; } - /// - /// The ID of the line item associated with this fulfillment order line item. - /// - [JsonProperty("line_item_id")] - public long? LineItemId { get; set; } + /// + /// The ID of the line item associated with this fulfillment order line item. + /// + [JsonProperty("line_item_id")] + public long? LineItemId { get; set; } - /// - /// The ID of the inventory item associated with this fulfillment order line item. - /// - [JsonProperty("inventory_item_id")] - public long? InventoryItemId { get; set; } + /// + /// The ID of the inventory item associated with this fulfillment order line item. + /// + [JsonProperty("inventory_item_id")] + public long? InventoryItemId { get; set; } - /// - /// The total number of units to be fulfilled. - /// - [JsonProperty("quantity")] - public long? Quantity { get; set; } + /// + /// The total number of units to be fulfilled. + /// + [JsonProperty("quantity")] + public long? Quantity { get; set; } - /// - /// The number of units remaining to be fulfilled. - /// - [JsonProperty("fulfillable_quantity")] - public long? FulfillableQuantity { get; set; } - } -} + /// + /// The number of units remaining to be fulfilled. + /// + [JsonProperty("fulfillable_quantity")] + public long? FulfillableQuantity { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/AssignedLocation.cs b/ShopifySharp/Entities/AssignedLocation.cs index a0955105..82006f3d 100644 --- a/ShopifySharp/Entities/AssignedLocation.cs +++ b/ShopifySharp/Entities/AssignedLocation.cs @@ -1,61 +1,60 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class AssignedLocation { - public class AssignedLocation - { - /// - /// The street address of the assigned location. - /// - [JsonProperty("address1")] - public string Address1 { get; set; } - - /// - /// An optional additional field for the street address of the assigned location. - /// - [JsonProperty("address2")] - public string Address2 { get; set; } - - /// - /// The city of the assigned location. - /// - [JsonProperty("city")] - public string City { get; set; } - - /// - /// The two-letter code for the country of the assigned location. - /// - [JsonProperty("country_code")] - public string CountryCode { get; set; } - - /// - /// The ID of the assigned location. - /// - [JsonProperty("location_id")] - public string LocationId { get; set; } - - /// - /// The name of the assigned location. - /// - [JsonProperty("name")] - public string Name { get; set; } - - /// - /// The phone number of the assigned location. - /// - [JsonProperty("phone")] - public string Phone { get; set; } - - /// - /// The province of the assigned location. - /// - [JsonProperty("province")] - public string Province { get; set; } - - /// - /// The ZIP code of the assigned location. - /// - [JsonProperty("zip")] - public string Zip { get; set; } - } + /// + /// The street address of the assigned location. + /// + [JsonProperty("address1")] + public string Address1 { get; set; } + + /// + /// An optional additional field for the street address of the assigned location. + /// + [JsonProperty("address2")] + public string Address2 { get; set; } + + /// + /// The city of the assigned location. + /// + [JsonProperty("city")] + public string City { get; set; } + + /// + /// The two-letter code for the country of the assigned location. + /// + [JsonProperty("country_code")] + public string CountryCode { get; set; } + + /// + /// The ID of the assigned location. + /// + [JsonProperty("location_id")] + public string LocationId { get; set; } + + /// + /// The name of the assigned location. + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// The phone number of the assigned location. + /// + [JsonProperty("phone")] + public string Phone { get; set; } + + /// + /// The province of the assigned location. + /// + [JsonProperty("province")] + public string Province { get; set; } + + /// + /// The ZIP code of the assigned location. + /// + [JsonProperty("zip")] + public string Zip { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/Blog.cs b/ShopifySharp/Entities/Blog.cs index d1412c11..5f3f7fd9 100644 --- a/ShopifySharp/Entities/Blog.cs +++ b/ShopifySharp/Entities/Blog.cs @@ -1,74 +1,73 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// Represents a Blog � not a blog post � on a merchant's Shopify store. +/// +public class Blog: ShopifyObject { /// - /// Represents a Blog � not a blog post � on a merchant's Shopify store. + /// Indicates whether readers can post comments to the blog and if comments are moderated or not. Possible values are: + /// "no" (default): Readers cannot post comments to blog articles. + /// "moderate": Readers can post comments to blog articles, but comments must be moderated before they appear. + /// "yes": Readers can post comments to blog articles without moderation. /// - public class Blog: ShopifyObject - { - /// - /// Indicates whether readers can post comments to the blog and if comments are moderated or not. Possible values are: - /// "no" (default): Readers cannot post comments to blog articles. - /// "moderate": Readers can post comments to blog articles, but comments must be moderated before they appear. - /// "yes": Readers can post comments to blog articles without moderation. - /// - [JsonProperty("commentable")] - public string Commentable { get; set; } + [JsonProperty("commentable")] + public string Commentable { get; set; } - /// - /// The date and time when the blog was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + /// + /// The date and time when the blog was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - /// - /// Feedburner is a web feed management provider and can be enabled to provide custom RSS feeds for Shopify bloggers. This property will default to blank or "null" unless feedburner is enabled through the shop admin. - /// - /// - /// Shopify does not document the value type for this property. - /// - [JsonProperty("feedburner")] - public object Feedburner { get; set; } + /// + /// Feedburner is a web feed management provider and can be enabled to provide custom RSS feeds for Shopify bloggers. This property will default to blank or "null" unless feedburner is enabled through the shop admin. + /// + /// + /// Shopify does not document the value type for this property. + /// + [JsonProperty("feedburner")] + public object Feedburner { get; set; } - /// - /// URL to the feedburner location for blogs that have enabled feedburner through their store admin. - /// - [JsonProperty("feedburner_url")] - public string FeedburnerLocation { get; set; } + /// + /// URL to the feedburner location for blogs that have enabled feedburner through their store admin. + /// + [JsonProperty("feedburner_url")] + public string FeedburnerLocation { get; set; } - /// - /// A human-friendly unique string for a blog automatically generated from its title. This handle is used by the Liquid templating language to refer to the blog. - /// - [JsonProperty("handle")] - public string Handle { get; set; } + /// + /// A human-friendly unique string for a blog automatically generated from its title. This handle is used by the Liquid templating language to refer to the blog. + /// + [JsonProperty("handle")] + public string Handle { get; set; } - /// - /// Tags are additional short descriptors formatted as a string of comma-separated values. For example, if an article has three tags: tag1, tag2, tag3. - /// - /// - /// Shopify seems to ignore these tags when creating or updating a blog. - /// - [JsonProperty("tags")] - public string Tags { get; set; } + /// + /// Tags are additional short descriptors formatted as a string of comma-separated values. For example, if an article has three tags: tag1, tag2, tag3. + /// + /// + /// Shopify seems to ignore these tags when creating or updating a blog. + /// + [JsonProperty("tags")] + public string Tags { get; set; } - /// - /// States the name of the template a blog is using if it is using an alternate template. If a blog is using the default blog.liquid template, the value returned is "null". - /// - [JsonProperty("template_suffix")] - public string TemplateSuffix { get; set; } + /// + /// States the name of the template a blog is using if it is using an alternate template. If a blog is using the default blog.liquid template, the value returned is "null". + /// + [JsonProperty("template_suffix")] + public string TemplateSuffix { get; set; } - /// - /// The title of the blog. - /// - [JsonProperty("title")] - public string Title { get; set; } + /// + /// The title of the blog. + /// + [JsonProperty("title")] + public string Title { get; set; } - /// - /// The date and time when changes were last made to the blog's properties. Note that this is not updated when creating, modifying or deleting articles in the blog. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - } -} + /// + /// The date and time when changes were last made to the blog's properties. Note that this is not updated when creating, modifying or deleting articles in the blog. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/CancellationRequest.cs b/ShopifySharp/Entities/CancellationRequest.cs index 32f7f714..40344215 100644 --- a/ShopifySharp/Entities/CancellationRequest.cs +++ b/ShopifySharp/Entities/CancellationRequest.cs @@ -1,17 +1,16 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify fulfillment cancellation request. +/// +public class CancellationRequest { /// - /// An object representing a Shopify fulfillment cancellation request. + /// An optional reason for the cancellation request. /// - public class CancellationRequest - { - /// - /// An optional reason for the cancellation request. - /// - [JsonProperty("message")] - public string Message { get; set; } + [JsonProperty("message")] + public string Message { get; set; } - } } \ No newline at end of file diff --git a/ShopifySharp/Entities/Carrier.cs b/ShopifySharp/Entities/Carrier.cs index dd3f1b07..4a0c2363 100644 --- a/ShopifySharp/Entities/Carrier.cs +++ b/ShopifySharp/Entities/Carrier.cs @@ -1,49 +1,48 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify CarrierService. +/// +public class Carrier : ShopifyObject { /// - /// An object representing a Shopify CarrierService. + /// States whether or not this carrier service is active. Valid values are "true" and "false". /// - public class Carrier : ShopifyObject - { - /// - /// States whether or not this carrier service is active. Valid values are "true" and "false". - /// - [JsonProperty("active")] - public bool? Active { get; set; } - - /// - /// States the URL endpoint that shopify needs to retrieve shipping rates. This must be a public URL. - /// - [JsonProperty("callback_url")] - public string CallbackUrl { get; set; } - - /// - /// Distinguishes between api or legacy carrier services. - /// - [JsonProperty("carrier_service_type")] - public string CarrierServiceType { get; set; } - - /// - /// The name of the shipping service as seen by merchants and their customers. - /// - [JsonProperty("name")] - public string Name { get; set; } - - /// - /// States if merchants are able to send dummy data to your service through the Shopify admin - /// to see shipping rate examples. Valid values are "true" and "false". - /// - [JsonProperty("service_discovery")] - public bool? ServiceDiscovery { get; set; } - - /// - /// The format of the data returned by the URL endpoint. Valid values are "json" and "xml". - /// If a format is not specified, it will default to json. - /// - [JsonProperty("format")] - public string Format { get; set; } - - } + [JsonProperty("active")] + public bool? Active { get; set; } + + /// + /// States the URL endpoint that shopify needs to retrieve shipping rates. This must be a public URL. + /// + [JsonProperty("callback_url")] + public string CallbackUrl { get; set; } + + /// + /// Distinguishes between api or legacy carrier services. + /// + [JsonProperty("carrier_service_type")] + public string CarrierServiceType { get; set; } + + /// + /// The name of the shipping service as seen by merchants and their customers. + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// States if merchants are able to send dummy data to your service through the Shopify admin + /// to see shipping rate examples. Valid values are "true" and "false". + /// + [JsonProperty("service_discovery")] + public bool? ServiceDiscovery { get; set; } + + /// + /// The format of the data returned by the URL endpoint. Valid values are "json" and "xml". + /// If a format is not specified, it will default to json. + /// + [JsonProperty("format")] + public string Format { get; set; } + } \ No newline at end of file diff --git a/ShopifySharp/Entities/CarrierShippingRateProvider.cs b/ShopifySharp/Entities/CarrierShippingRateProvider.cs index 70d272d6..3f597552 100644 --- a/ShopifySharp/Entities/CarrierShippingRateProvider.cs +++ b/ShopifySharp/Entities/CarrierShippingRateProvider.cs @@ -1,32 +1,30 @@ using Newtonsoft.Json; -namespace ShopifySharp -{ - public class CarrierShippingRateProvider : ShopifyObject - { - /// - /// A Carrier Service (also known as a Carrier Calculated Service or Shipping Service) provides real-time shipping rates to Shopify. Some common carrier services include: Canada Post, FedEx, UPS, and USPS. Note that the term "carrier" is often used interchangeably with the terms "shipping company" and "rate provider." - /// - [JsonProperty("carrier_service_id")] - public long? CarrierServiceId { get; set; } +namespace ShopifySharp; - /// - /// Rate adjustments - Flat fee - /// - [JsonProperty("flat_modifier")] - public decimal? FlatModifier { get; set; } +public class CarrierShippingRateProvider : ShopifyObject +{ + /// + /// A Carrier Service (also known as a Carrier Calculated Service or Shipping Service) provides real-time shipping rates to Shopify. Some common carrier services include: Canada Post, FedEx, UPS, and USPS. Note that the term "carrier" is often used interchangeably with the terms "shipping company" and "rate provider." + /// + [JsonProperty("carrier_service_id")] + public long? CarrierServiceId { get; set; } - /// - /// Rate adjustments - percentage - /// - [JsonProperty("percent_modifier")] - public int? PercentModifier { get; set; } + /// + /// Rate adjustments - Flat fee + /// + [JsonProperty("flat_modifier")] + public decimal? FlatModifier { get; set; } - /// - /// Shipping zone id - /// - [JsonProperty("shipping_zone_id")] - public long? ShippingZoneId { get; set; } - } + /// + /// Rate adjustments - percentage + /// + [JsonProperty("percent_modifier")] + public int? PercentModifier { get; set; } + /// + /// Shipping zone id + /// + [JsonProperty("shipping_zone_id")] + public long? ShippingZoneId { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/Charge.cs b/ShopifySharp/Entities/Charge.cs index ba31a216..84859308 100644 --- a/ShopifySharp/Entities/Charge.cs +++ b/ShopifySharp/Entities/Charge.cs @@ -2,67 +2,66 @@ using Newtonsoft.Json; using ShopifySharp.Converters; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing an application charge. +/// +public class Charge : ShopifyObject { /// - /// An object representing an application charge. + /// The URL that the customer should be sent to, to accept or decline the application charge. /// - public class Charge : ShopifyObject - { - /// - /// The URL that the customer should be sent to, to accept or decline the application charge. - /// - [JsonProperty("confirmation_url")] - public string ConfirmationUrl { get; set; } + [JsonProperty("confirmation_url")] + public string ConfirmationUrl { get; set; } - /// - /// The date and time when the application charge was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + /// + /// The date and time when the application charge was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - /// - /// The name of the application charge. - /// - [JsonProperty("name")] - public string Name { get; set; } + /// + /// The name of the application charge. + /// + [JsonProperty("name")] + public string Name { get; set; } - /// - /// The price of the application charge. - /// - /// Shopify returns this as a string, but JSON.net should be able to convert it to a decimal. - [JsonProperty("price")] - public decimal? Price { get; set; } + /// + /// The price of the application charge. + /// + /// Shopify returns this as a string, but JSON.net should be able to convert it to a decimal. + [JsonProperty("price")] + public decimal? Price { get; set; } - /// - /// The URL the customer is sent to once they accept/decline a charge. - /// - [JsonProperty("return_url")] - public string ReturnUrl { get; set; } + /// + /// The URL the customer is sent to once they accept/decline a charge. + /// + [JsonProperty("return_url")] + public string ReturnUrl { get; set; } - /// - /// The status of the charged. Known values are 'pending', 'accepted', 'active', 'cancelled', 'declined' and 'expired'. - /// - [JsonProperty("status")] - public string Status { get; set; } + /// + /// The status of the charged. Known values are 'pending', 'accepted', 'active', 'cancelled', 'declined' and 'expired'. + /// + [JsonProperty("status")] + public string Status { get; set; } - /// - /// States whether or not the application charge is a test transaction. - /// - /// Valid values are 'true' or null. Needs a special converter to convert null to false and vice-versa. - [JsonProperty("test", NullValueHandling = NullValueHandling.Include), JsonConverter(typeof(FalseToNullConverter))] - public bool? Test { get; set; } + /// + /// States whether or not the application charge is a test transaction. + /// + /// Valid values are 'true' or null. Needs a special converter to convert null to false and vice-versa. + [JsonProperty("test", NullValueHandling = NullValueHandling.Include), JsonConverter(typeof(FalseToNullConverter))] + public bool? Test { get; set; } - /// - /// The date and time when the recurring application charge was last updated. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } + /// + /// The date and time when the recurring application charge was last updated. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } - /// - /// The currency of the price of the application charge. - /// - [JsonProperty("currency")] - public string Currency { get; set; } - } + /// + /// The currency of the price of the application charge. + /// + [JsonProperty("currency")] + public string Currency { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/Checkout.cs b/ShopifySharp/Entities/Checkout.cs index b8247f89..4430f53f 100644 --- a/ShopifySharp/Entities/Checkout.cs +++ b/ShopifySharp/Entities/Checkout.cs @@ -1,230 +1,229 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An entity representing a Shopify product. +/// +public class Checkout : ShopifyObject { /// - /// An entity representing a Shopify product. - /// - public class Checkout : ShopifyObject - { - /// - /// The full recovery URL to be sent to a customer to recover their abandoned checkout. - /// - [JsonProperty("abandoned_checkout_url")] - public string AbandonedCheckoutUrl { get; set; } - - /// - /// The mailing address associated with the payment method. - /// - [JsonProperty("billing_address")] - public Address BillingAddress { get; set; } - - /// - /// Indicates whether or not the person who placed the order would like to receive email - /// updates from the shop. This is set when checking the "I want to receive occasional - /// emails about new products, promotions and other news" checkbox during checkout. - /// - [JsonProperty("buyer_accepts_marketing")] - public bool? BuyerAcceptsMarketing { get; set; } - - /// - /// Unique identifier for a particular cart that is attached to a particular order. - /// - [JsonProperty("cart_token")] - public string CartToken { get; set; } - - /// - /// The date and time when the abandoned cart was completed. The API returns this value in ISO 8601 format. - /// - [JsonProperty("closed_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? ClosedAt { get; set; } - - /// - /// The date and time when the abandoned cart was last modified. The API returns this value in ISO 8601 format. - /// - [JsonProperty("completed_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? CompletedAt { get; set; } - - /// - /// The date and time when the abandoned cart was created. The API returns this value in ISO 8601 format. - /// - [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// The three letter code (ISO 4217) for the currency used for the payment. - /// - [JsonProperty("currency")] - public string Currency { get; set; } - - /// - /// Information about the customer. - /// - [JsonProperty("customer")] - public Customer Customer { get; set; } - - /// - /// The two or three-letter language code, optionally followed by a region modifier. Example values: en, en-CA. - /// - [JsonProperty("customer_locale")] - public string CustomerLocale { get; set; } - - /// - /// The ID of the Shopify POS device that created the checkout. - /// - [JsonProperty("device_id")] - public long? DeviceId { get; set; } - - /// - /// Applicable discount codes that can be applied to the order. If no codes exist the value will default to blank. - /// - [JsonProperty("discount_codes")] - public IEnumerable DiscountCodes { get; set; } - - /// - /// The customer's email address. - /// - [JsonProperty("email")] - public string Email { get; set; } - - /// - /// The payment gateway used. - /// - [JsonProperty("gateway")] - public string Gateway { get; set; } - - /// - /// The URL for the page where the buyer landed when entering the shop. - /// - [JsonProperty("landing_site")] - public string LandingSite { get; set; } - - /// - /// A list of line item objects, each one containing information about an item in the order. - /// - [JsonProperty("line_items")] - public IEnumerable LineItems { get; set; } - - /// - /// The ID of the physical location where the checkout was processed. - /// - [JsonProperty("location_id")] - public long? LocationId { get; set; } - - /// - /// The text of an optional note that a shop owner can attach to the order. - /// - [JsonProperty("note")] - public string Note { get; set; } - - /// - /// The customer's phone number for receiving SMS notifications. - /// - [JsonProperty("phone")] - public string Phone { get; set; } - - /// - /// The three-letter code (ISO 4217 format) of the currency that the customer used at checkout. - /// - [JsonProperty("presentment_currency")] - public string PresentmentCurrency { get; set; } - - /// - /// The website that the customer clicked on to come to the shop. - /// - [JsonProperty("referring_site")] - public string ReferringSite { get; set; } - - /// - /// The mailing address to where the order will be shipped. This address is optional and will not be available on orders that do not require one. - /// - [JsonProperty("shipping_address")] - public Address ShippingAddress { get; set; } - - /// - /// An array of shipping line objects, each of which details the shipping methods used. - /// - [JsonProperty("shipping_lines")] - public IEnumerable ShippingLines { get; set; } - - /// - /// Where the checkout originated. Known values are: "web", "pos", "iphone", and "android" - /// - [JsonProperty("source_name")] - public string SourceName { get; set; } - - /// - /// Price of the order before shipping and taxes - /// - [JsonProperty("subtotal_price")] - public decimal? SubtotalPrice { get; set; } - - /// - /// An array of tax line objects, each of which details the taxes applicable to the order. - /// - [JsonProperty("tax_lines")] - public IEnumerable TaxLines { get; set; } - - /// - /// Whether taxes are included in the price. - /// - [JsonProperty("taxes_included")] - public bool? TaxesIncluded { get; set; } - - /// - /// Unique identifier for a particular order. - /// - [JsonProperty("token")] - public string Token { get; set; } - - /// - /// The total amount of the discounts to be applied to the price of the order. - /// - [JsonProperty("total_discounts")] - public decimal? TotalDiscounts { get; set; } + /// The full recovery URL to be sent to a customer to recover their abandoned checkout. + /// + [JsonProperty("abandoned_checkout_url")] + public string AbandonedCheckoutUrl { get; set; } + + /// + /// The mailing address associated with the payment method. + /// + [JsonProperty("billing_address")] + public Address BillingAddress { get; set; } + + /// + /// Indicates whether or not the person who placed the order would like to receive email + /// updates from the shop. This is set when checking the "I want to receive occasional + /// emails about new products, promotions and other news" checkbox during checkout. + /// + [JsonProperty("buyer_accepts_marketing")] + public bool? BuyerAcceptsMarketing { get; set; } + + /// + /// Unique identifier for a particular cart that is attached to a particular order. + /// + [JsonProperty("cart_token")] + public string CartToken { get; set; } + + /// + /// The date and time when the abandoned cart was completed. The API returns this value in ISO 8601 format. + /// + [JsonProperty("closed_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? ClosedAt { get; set; } + + /// + /// The date and time when the abandoned cart was last modified. The API returns this value in ISO 8601 format. + /// + [JsonProperty("completed_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? CompletedAt { get; set; } + + /// + /// The date and time when the abandoned cart was created. The API returns this value in ISO 8601 format. + /// + [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// The three letter code (ISO 4217) for the currency used for the payment. + /// + [JsonProperty("currency")] + public string Currency { get; set; } + + /// + /// Information about the customer. + /// + [JsonProperty("customer")] + public Customer Customer { get; set; } + + /// + /// The two or three-letter language code, optionally followed by a region modifier. Example values: en, en-CA. + /// + [JsonProperty("customer_locale")] + public string CustomerLocale { get; set; } + + /// + /// The ID of the Shopify POS device that created the checkout. + /// + [JsonProperty("device_id")] + public long? DeviceId { get; set; } + + /// + /// Applicable discount codes that can be applied to the order. If no codes exist the value will default to blank. + /// + [JsonProperty("discount_codes")] + public IEnumerable DiscountCodes { get; set; } + + /// + /// The customer's email address. + /// + [JsonProperty("email")] + public string Email { get; set; } + + /// + /// The payment gateway used. + /// + [JsonProperty("gateway")] + public string Gateway { get; set; } + + /// + /// The URL for the page where the buyer landed when entering the shop. + /// + [JsonProperty("landing_site")] + public string LandingSite { get; set; } + + /// + /// A list of line item objects, each one containing information about an item in the order. + /// + [JsonProperty("line_items")] + public IEnumerable LineItems { get; set; } + + /// + /// The ID of the physical location where the checkout was processed. + /// + [JsonProperty("location_id")] + public long? LocationId { get; set; } + + /// + /// The text of an optional note that a shop owner can attach to the order. + /// + [JsonProperty("note")] + public string Note { get; set; } + + /// + /// The customer's phone number for receiving SMS notifications. + /// + [JsonProperty("phone")] + public string Phone { get; set; } + + /// + /// The three-letter code (ISO 4217 format) of the currency that the customer used at checkout. + /// + [JsonProperty("presentment_currency")] + public string PresentmentCurrency { get; set; } + + /// + /// The website that the customer clicked on to come to the shop. + /// + [JsonProperty("referring_site")] + public string ReferringSite { get; set; } + + /// + /// The mailing address to where the order will be shipped. This address is optional and will not be available on orders that do not require one. + /// + [JsonProperty("shipping_address")] + public Address ShippingAddress { get; set; } + + /// + /// An array of shipping line objects, each of which details the shipping methods used. + /// + [JsonProperty("shipping_lines")] + public IEnumerable ShippingLines { get; set; } + + /// + /// Where the checkout originated. Known values are: "web", "pos", "iphone", and "android" + /// + [JsonProperty("source_name")] + public string SourceName { get; set; } + + /// + /// Price of the order before shipping and taxes + /// + [JsonProperty("subtotal_price")] + public decimal? SubtotalPrice { get; set; } + + /// + /// An array of tax line objects, each of which details the taxes applicable to the order. + /// + [JsonProperty("tax_lines")] + public IEnumerable TaxLines { get; set; } + + /// + /// Whether taxes are included in the price. + /// + [JsonProperty("taxes_included")] + public bool? TaxesIncluded { get; set; } + + /// + /// Unique identifier for a particular order. + /// + [JsonProperty("token")] + public string Token { get; set; } + + /// + /// The total amount of the discounts to be applied to the price of the order. + /// + [JsonProperty("total_discounts")] + public decimal? TotalDiscounts { get; set; } - /// - /// The total duties of the checkout in presentment currency. - /// - [JsonProperty("total_duties")] - public decimal? TotalDuties { get; set; } + /// + /// The total duties of the checkout in presentment currency. + /// + [JsonProperty("total_duties")] + public decimal? TotalDuties { get; set; } - /// - /// The sum of all the prices of all the items in the order. - /// - [JsonProperty("total_line_items_price")] - public decimal? TotalLineItemsPrice { get; set; } - - /// - /// The sum of all the prices of all the items in the order, taxes and discounts included. - /// - [JsonProperty("total_price")] - public decimal? TotalPrice { get; set; } - - /// - /// The sum of all the taxes applied to the line items in the order. - /// - [JsonProperty("total_tax")] - public decimal? TotalTax { get; set; } - - /// - /// The sum of all the weights of the line items in the order, in grams. - /// - [JsonProperty("total_weight")] - public decimal? TotalWeight { get; set; } - - /// - /// The date and time when the abandoned cart was last modified. The API returns this value in ISO 8601 format. - /// - [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? UpdatedAt { get; set; } - - /// - /// The ID of the user who created the checkout. - /// - [JsonProperty("user_id")] - public long? UserId { get; set; } - } -} + /// + /// The sum of all the prices of all the items in the order. + /// + [JsonProperty("total_line_items_price")] + public decimal? TotalLineItemsPrice { get; set; } + + /// + /// The sum of all the prices of all the items in the order, taxes and discounts included. + /// + [JsonProperty("total_price")] + public decimal? TotalPrice { get; set; } + + /// + /// The sum of all the taxes applied to the line items in the order. + /// + [JsonProperty("total_tax")] + public decimal? TotalTax { get; set; } + + /// + /// The sum of all the weights of the line items in the order, in grams. + /// + [JsonProperty("total_weight")] + public decimal? TotalWeight { get; set; } + + /// + /// The date and time when the abandoned cart was last modified. The API returns this value in ISO 8601 format. + /// + [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? UpdatedAt { get; set; } + + /// + /// The ID of the user who created the checkout. + /// + [JsonProperty("user_id")] + public long? UserId { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/CheckoutLineItem.cs b/ShopifySharp/Entities/CheckoutLineItem.cs index e384d454..bf5d176a 100644 --- a/ShopifySharp/Entities/CheckoutLineItem.cs +++ b/ShopifySharp/Entities/CheckoutLineItem.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System.Collections.Generic; using ShopifySharp.Converters; diff --git a/ShopifySharp/Entities/CheckoutShippingRate.cs b/ShopifySharp/Entities/CheckoutShippingRate.cs index 780519d3..c4429004 100755 --- a/ShopifySharp/Entities/CheckoutShippingRate.cs +++ b/ShopifySharp/Entities/CheckoutShippingRate.cs @@ -1,36 +1,35 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class CheckoutShippingRate { - public class CheckoutShippingRate + public CheckoutShippingRate() { - public CheckoutShippingRate() - { - } + } - [JsonProperty("id")] - public string Id { get; set; } + [JsonProperty("id")] + public string Id { get; set; } - [JsonProperty("handle")] - public string Handle { get; set; } + [JsonProperty("handle")] + public string Handle { get; set; } - [JsonProperty("price")] - public string Price { get; set; } + [JsonProperty("price")] + public string Price { get; set; } - [JsonProperty("title")] - public string Title { get; set; } + [JsonProperty("title")] + public string Title { get; set; } - [JsonProperty("phoneRequired")] - public bool PhoneRequired { get; set; } + [JsonProperty("phoneRequired")] + public bool PhoneRequired { get; set; } - /// - /// As of 2019-01-21, the type of this property is unknown. In Shopify's documentation, it only appears as a null value. - /// - [JsonProperty("deliveryRange")] - public object DeliveryRange { get; set; } + /// + /// As of 2019-01-21, the type of this property is unknown. In Shopify's documentation, it only appears as a null value. + /// + [JsonProperty("deliveryRange")] + public object DeliveryRange { get; set; } - [JsonProperty("checkout")] - public CheckoutShippingRatePrices Checkout { get; set; } - } + [JsonProperty("checkout")] + public CheckoutShippingRatePrices Checkout { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/CheckoutShippingRatePrices.cs b/ShopifySharp/Entities/CheckoutShippingRatePrices.cs index e9eb0a20..25cf7f0d 100755 --- a/ShopifySharp/Entities/CheckoutShippingRatePrices.cs +++ b/ShopifySharp/Entities/CheckoutShippingRatePrices.cs @@ -1,16 +1,15 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class CheckoutShippingRatePrices { - public class CheckoutShippingRatePrices - { - [JsonProperty("totalTax")] - public string TotalTax { get; set; } + [JsonProperty("totalTax")] + public string TotalTax { get; set; } - [JsonProperty("totalPrice")] - public string TotalPrice { get; set; } + [JsonProperty("totalPrice")] + public string TotalPrice { get; set; } - [JsonProperty("subtotalPrice")] - public string SubtotalPrice { get; set; } - } + [JsonProperty("subtotalPrice")] + public string SubtotalPrice { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/ClientDetails.cs b/ShopifySharp/Entities/ClientDetails.cs index fe774e4a..bec4a13e 100644 --- a/ShopifySharp/Entities/ClientDetails.cs +++ b/ShopifySharp/Entities/ClientDetails.cs @@ -1,43 +1,42 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class ClientDetails { - public class ClientDetails - { - /// - /// Shopify does not offer documentation for this field. - /// - [JsonProperty("accept_language")] - public string AcceptLanguage { get; set; } + /// + /// Shopify does not offer documentation for this field. + /// + [JsonProperty("accept_language")] + public string AcceptLanguage { get; set; } - /// - /// The browser screen height in pixels, if available. - /// - [JsonProperty("browser_height")] - public int? BrowserHeight { get; set; } + /// + /// The browser screen height in pixels, if available. + /// + [JsonProperty("browser_height")] + public int? BrowserHeight { get; set; } - /// - /// The browser IP address. - /// - [JsonProperty("browser_ip")] - public string BrowserIp { get; set; } + /// + /// The browser IP address. + /// + [JsonProperty("browser_ip")] + public string BrowserIp { get; set; } - /// - /// The browser screen width in pixels, if available. - /// - [JsonProperty("browser_width")] - public int? BrowserWidth { get; set; } + /// + /// The browser screen width in pixels, if available. + /// + [JsonProperty("browser_width")] + public int? BrowserWidth { get; set; } - /// - /// A hash of the session. - /// - [JsonProperty("session_hash")] - public string SessionHash { get; set; } + /// + /// A hash of the session. + /// + [JsonProperty("session_hash")] + public string SessionHash { get; set; } - /// - /// The browser's user agent string. - /// - [JsonProperty("user_agent")] - public string UserAgent { get; set; } - } -} + /// + /// The browser's user agent string. + /// + [JsonProperty("user_agent")] + public string UserAgent { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/Collect.cs b/ShopifySharp/Entities/Collect.cs index 5efd3a77..6a7f31fa 100644 --- a/ShopifySharp/Entities/Collect.cs +++ b/ShopifySharp/Entities/Collect.cs @@ -1,47 +1,46 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify collect. +/// +public class Collect : ShopifyObject { /// - /// An object representing a Shopify collect. + /// The id of the custom collection containing the product. /// - public class Collect : ShopifyObject - { - /// - /// The id of the custom collection containing the product. - /// - [JsonProperty("collection_id")] - public long? CollectionId { get; set; } + [JsonProperty("collection_id")] + public long? CollectionId { get; set; } - /// - /// The unique numeric identifier for the product in the custom collection. - /// - [JsonProperty("product_id")] - public long? ProductId { get; set; } + /// + /// The unique numeric identifier for the product in the custom collection. + /// + [JsonProperty("product_id")] + public long? ProductId { get; set; } - /// - /// The date and time when the collect was created. The API returns this value in ISO 8601 format. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + /// + /// The date and time when the collect was created. The API returns this value in ISO 8601 format. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - /// - /// The date and time when the collect was last updated. The API returns this value in ISO 8601 format. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } + /// + /// The date and time when the collect was last updated. The API returns this value in ISO 8601 format. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } - /// - /// A number specifying the manually sorted position of this product in a custom collection. The first position is 1. This value only applies when the custom collection is viewed using the Manual sort order. - /// - [JsonProperty("position")] - public int? Position { get; set; } + /// + /// A number specifying the manually sorted position of this product in a custom collection. The first position is 1. This value only applies when the custom collection is viewed using the Manual sort order. + /// + [JsonProperty("position")] + public int? Position { get; set; } - /// - /// This is the same value as position but padded with leading zeroes to make it alphanumeric-sortable. - /// - [JsonProperty("sort_value")] - public string SortValue { get; set; } - } -} + /// + /// This is the same value as position but padded with leading zeroes to make it alphanumeric-sortable. + /// + [JsonProperty("sort_value")] + public string SortValue { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/Collection.cs b/ShopifySharp/Entities/Collection.cs index b254f303..bc00797c 100644 --- a/ShopifySharp/Entities/Collection.cs +++ b/ShopifySharp/Entities/Collection.cs @@ -1,64 +1,63 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class Collection : ShopifyObject { - public class Collection : ShopifyObject - { - /// - /// A description of the collection, complete with HTML markup. Many templates display this on their collection pages. - /// - [JsonProperty("body_html")] - public string BodyHtml { get; set; } - - /// - /// A unique, human-readable string for the collection automatically generated from its title. This is used in themes by the Liquid templating language to refer to the collection. (limit: 255 characters) - /// - [JsonProperty("handle")] - public string Handle { get; set; } - - /// - /// Image associated with the collection. - /// - [JsonProperty("image")] - public CollectionImage Image { get; set; } - - /// - /// The time and date (ISO 8601 format) when the collection was made visible. Returns null for a hidden collection. - /// - [JsonProperty("published_at")] - public DateTimeOffset? PublishedAt { get; set; } - - /// - /// Whether the collection is published to the Point of Sale channel. Valid values: `web`, `global` - /// - [JsonProperty("published_scope")] - public string PublishedScope { get; set; } - - /// - /// The order in which products in the collection appear. Valid values: `alpha-asc`, `alpha-desc`, `best-selling`, - /// `created`, `created-desc`, `manual`, `price-asc`, `price-desc` - /// - [JsonProperty("sort_order")] - public string SortOrder { get; set; } - - /// - /// The suffix of the liquid template being used. For example, if the value is custom, then the collection is - /// using the collection.custom.liquid template. If the value is null, then the collection is using the default collection.liquid. - /// - [JsonProperty("template_suffix")] - public string TemplateSuffix { get; set; } - - /// - /// The name of the collection. (limit: 255 characters) - /// - [JsonProperty("title")] - public string Title { get; set; } - - /// - /// The date and time (ISO 8601 format) when the collection was last modified. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - } + /// + /// A description of the collection, complete with HTML markup. Many templates display this on their collection pages. + /// + [JsonProperty("body_html")] + public string BodyHtml { get; set; } + + /// + /// A unique, human-readable string for the collection automatically generated from its title. This is used in themes by the Liquid templating language to refer to the collection. (limit: 255 characters) + /// + [JsonProperty("handle")] + public string Handle { get; set; } + + /// + /// Image associated with the collection. + /// + [JsonProperty("image")] + public CollectionImage Image { get; set; } + + /// + /// The time and date (ISO 8601 format) when the collection was made visible. Returns null for a hidden collection. + /// + [JsonProperty("published_at")] + public DateTimeOffset? PublishedAt { get; set; } + + /// + /// Whether the collection is published to the Point of Sale channel. Valid values: `web`, `global` + /// + [JsonProperty("published_scope")] + public string PublishedScope { get; set; } + + /// + /// The order in which products in the collection appear. Valid values: `alpha-asc`, `alpha-desc`, `best-selling`, + /// `created`, `created-desc`, `manual`, `price-asc`, `price-desc` + /// + [JsonProperty("sort_order")] + public string SortOrder { get; set; } + + /// + /// The suffix of the liquid template being used. For example, if the value is custom, then the collection is + /// using the collection.custom.liquid template. If the value is null, then the collection is using the default collection.liquid. + /// + [JsonProperty("template_suffix")] + public string TemplateSuffix { get; set; } + + /// + /// The name of the collection. (limit: 255 characters) + /// + [JsonProperty("title")] + public string Title { get; set; } + + /// + /// The date and time (ISO 8601 format) when the collection was last modified. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/CollectionImage.cs b/ShopifySharp/Entities/CollectionImage.cs index a6b3dbd2..8fb619da 100644 --- a/ShopifySharp/Entities/CollectionImage.cs +++ b/ShopifySharp/Entities/CollectionImage.cs @@ -1,44 +1,43 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class CollectionImage { - public class CollectionImage - { - /// - /// An image attached to a collection returned as Base64-encoded binary data. - /// - [JsonProperty("attachment")] - public string Attachment { get; set; } + /// + /// An image attached to a collection returned as Base64-encoded binary data. + /// + [JsonProperty("attachment")] + public string Attachment { get; set; } - /// - /// The source URL that specifies the location of the image. - /// - [JsonProperty("src")] - public string Src { get; set; } + /// + /// The source URL that specifies the location of the image. + /// + [JsonProperty("src")] + public string Src { get; set; } - /// - /// The alternative text that describes the collection image. - /// - [JsonProperty("alt")] - public string Alt { get; set; } + /// + /// The alternative text that describes the collection image. + /// + [JsonProperty("alt")] + public string Alt { get; set; } - /// - /// The time and date (ISO 8601 format) when the image was added to the collection. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + /// + /// The time and date (ISO 8601 format) when the image was added to the collection. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - /// - /// The width of the image in pixels. - /// - [JsonProperty("width")] - public int Width { get; set; } + /// + /// The width of the image in pixels. + /// + [JsonProperty("width")] + public int Width { get; set; } - /// - /// The height of the image in pixels. - /// - [JsonProperty("height")] - public int Height { get; set; } - } + /// + /// The height of the image in pixels. + /// + [JsonProperty("height")] + public int Height { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/CollectionListing.cs b/ShopifySharp/Entities/CollectionListing.cs index f2f93394..085a85aa 100644 --- a/ShopifySharp/Entities/CollectionListing.cs +++ b/ShopifySharp/Entities/CollectionListing.cs @@ -1,42 +1,41 @@ -using System; +using System; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A CollectionListing resource represents a product collection +/// that a merchant has made available to your sales channel. +/// Merchants can make collections available to your sales channel directly from their Shopify admin. +/// You can use this resource to retrieve collections that a merchant has published and display them in your marketplace. +/// You can also retrieve a list of published product IDs that belong to a published collection. +/// +public class CollectionListing { - /// - /// A CollectionListing resource represents a product collection - /// that a merchant has made available to your sales channel. - /// Merchants can make collections available to your sales channel directly from their Shopify admin. - /// You can use this resource to retrieve collections that a merchant has published and display them in your marketplace. - /// You can also retrieve a list of published product IDs that belong to a published collection. - /// - public class CollectionListing - { - [JsonProperty("collection_id")] - public long? CollectionId { get; set; } - - [JsonProperty("body_html")] - public string BodyHtml { get; set; } - - [JsonProperty("default_product_image")] - public ProductImage DefaultProductImage { get; set; } - - [JsonProperty("image")] - public CollectionImage[] Image { get; set; } - - [JsonProperty("handle")] - public string Handle { get; set; } - - [JsonProperty("published_at")] - public DateTimeOffset? PublishedAt { get; set; } - - [JsonProperty("title")] - public string Title { get; set; } - - [JsonProperty("sort_order")] - public string SortOrder { get; set; } - - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - } -} + [JsonProperty("collection_id")] + public long? CollectionId { get; set; } + + [JsonProperty("body_html")] + public string BodyHtml { get; set; } + + [JsonProperty("default_product_image")] + public ProductImage DefaultProductImage { get; set; } + + [JsonProperty("image")] + public CollectionImage[] Image { get; set; } + + [JsonProperty("handle")] + public string Handle { get; set; } + + [JsonProperty("published_at")] + public DateTimeOffset? PublishedAt { get; set; } + + [JsonProperty("title")] + public string Title { get; set; } + + [JsonProperty("sort_order")] + public string SortOrder { get; set; } + + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/Country.cs b/ShopifySharp/Entities/Country.cs index 063bebe0..ab96251b 100644 --- a/ShopifySharp/Entities/Country.cs +++ b/ShopifySharp/Entities/Country.cs @@ -1,39 +1,38 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class Country : ShopifyObject { - public class Country : ShopifyObject - { - /// - /// The full name of the country, in English. - /// - [JsonProperty("name")] - public string Name { get; set; } + /// + /// The full name of the country, in English. + /// + [JsonProperty("name")] + public string Name { get; set; } - /// - /// The tax value in decimal format. - /// - /// - [JsonProperty("tax")] - public decimal? Tax { get; set; } + /// + /// The tax value in decimal format. + /// + /// + [JsonProperty("tax")] + public decimal? Tax { get; set; } - /// - /// The ISO 3166-1 alpha-2 two-letter country code for the country. The code for a given country will be the same as the code for the same country in another shop. - /// - [JsonProperty("code")] - public string Code { get; set; } + /// + /// The ISO 3166-1 alpha-2 two-letter country code for the country. The code for a given country will be the same as the code for the same country in another shop. + /// + [JsonProperty("code")] + public string Code { get; set; } - /// - /// The name of the tax as it is referred to in the applicable province/state. For example, in Ontario, Canada the tax is referred to as HST. - /// - [JsonProperty("tax_name")] - public string TaxName { get; set; } + /// + /// The name of the tax as it is referred to in the applicable province/state. For example, in Ontario, Canada the tax is referred to as HST. + /// + [JsonProperty("tax_name")] + public string TaxName { get; set; } - /// - /// The sub-regions of a country. The term provinces also encompasses states. - /// - [JsonProperty("provinces")] - public IEnumerable Provinces { get; set; } - } + /// + /// The sub-regions of a country. The term provinces also encompasses states. + /// + [JsonProperty("provinces")] + public IEnumerable Provinces { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/CurrencyExchangeAdjustment.cs b/ShopifySharp/Entities/CurrencyExchangeAdjustment.cs index 74872040..949ec711 100644 --- a/ShopifySharp/Entities/CurrencyExchangeAdjustment.cs +++ b/ShopifySharp/Entities/CurrencyExchangeAdjustment.cs @@ -1,31 +1,30 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class CurrencyExchangeAdjustment : ShopifyObject { - public class CurrencyExchangeAdjustment : ShopifyObject - { - /// - /// The difference between the amounts on the associated transaction and the parent transaction. - /// - [JsonProperty("adjustment")] - public decimal? Adjustment { get; set; } + /// + /// The difference between the amounts on the associated transaction and the parent transaction. + /// + [JsonProperty("adjustment")] + public decimal? Adjustment { get; set; } - /// - /// The amount of the parent transaction in the shop currency. - /// - [JsonProperty("original_amount")] - public decimal? OriginalAmount { get; set; } + /// + /// The amount of the parent transaction in the shop currency. + /// + [JsonProperty("original_amount")] + public decimal? OriginalAmount { get; set; } - /// - /// The amount of the associated transaction in the shop currency. - /// - [JsonProperty("final_amount")] - public decimal? FinalAmount { get; set; } + /// + /// The amount of the associated transaction in the shop currency. + /// + [JsonProperty("final_amount")] + public decimal? FinalAmount { get; set; } - /// - /// The shop currency. - /// - [JsonProperty("currency")] - public string Currency { get; set; } - } + /// + /// The shop currency. + /// + [JsonProperty("currency")] + public string Currency { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/CustomCollection.cs b/ShopifySharp/Entities/CustomCollection.cs index 3558cd3d..30d29539 100644 --- a/ShopifySharp/Entities/CustomCollection.cs +++ b/ShopifySharp/Entities/CustomCollection.cs @@ -2,89 +2,88 @@ using System; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An entity representing a Shopify Custom Collection Object. +/// +public class CustomCollection : ShopifyObject { /// - /// An entity representing a Shopify Custom Collection Object. + /// The description of the Custom collection, complete with HTML markup. Many templates display this on their Custom collection page. /// - public class CustomCollection : ShopifyObject - { - /// - /// The description of the Custom collection, complete with HTML markup. Many templates display this on their Custom collection page. - /// - [JsonProperty("body_html")] - public string BodyHtml { get; set; } + [JsonProperty("body_html")] + public string BodyHtml { get; set; } - /// - /// A human-friendly unique string for the Custom collection automatically generated from its title. This is used in shop themes by the Liquid templating language to refer to the Custom collection. Limit of 255 characters. - /// - [JsonProperty("handle")] - public string Handle { get; set; } + /// + /// A human-friendly unique string for the Custom collection automatically generated from its title. This is used in shop themes by the Liquid templating language to refer to the Custom collection. Limit of 255 characters. + /// + [JsonProperty("handle")] + public string Handle { get; set; } - /// - /// The collection image. - /// - [JsonProperty("image")] - public CustomCollectionImage Image { get; set; } + /// + /// The collection image. + /// + [JsonProperty("image")] + public CustomCollectionImage Image { get; set; } - /// - /// Whether the collection is published or not. - /// - [JsonProperty("published")] - public bool? Published { get; set; } + /// + /// Whether the collection is published or not. + /// + [JsonProperty("published")] + public bool? Published { get; set; } - /// - /// This can have two different types of values, depending on whether the Custom collection has been published (i.e., made visible to customers): - /// If the Custom collection is published, this value is the date and time when it was published.The API returns this value in ISO 8601 format. - /// If the Custom collection is hidden (i.e., not published), this value is null. Changing a Custom collection's status from published to hidden changes its published_at property to null. - /// - [JsonProperty("published_at")] - public DateTimeOffset? PublishedAt { get; set; } + /// + /// This can have two different types of values, depending on whether the Custom collection has been published (i.e., made visible to customers): + /// If the Custom collection is published, this value is the date and time when it was published.The API returns this value in ISO 8601 format. + /// If the Custom collection is hidden (i.e., not published), this value is null. Changing a Custom collection's status from published to hidden changes its published_at property to null. + /// + [JsonProperty("published_at")] + public DateTimeOffset? PublishedAt { get; set; } - /// - /// The sales channels in which the Custom collection is visible. - /// - [JsonProperty("published_scope")] - public string PublishedScope { get; set; } + /// + /// The sales channels in which the Custom collection is visible. + /// + [JsonProperty("published_scope")] + public string PublishedScope { get; set; } - /// - /// The order in which products in the Custom collection appear - /// - [JsonProperty("sort_order")] - public string SortOrder { get; set; } + /// + /// The order in which products in the Custom collection appear + /// + [JsonProperty("sort_order")] + public string SortOrder { get; set; } - /// - /// The suffix of the template you are using. By default, the original template is called product.liquid, without any suffix. Any additional templates will be: product.suffix.liquid. - /// - [JsonProperty("template_suffix")] - public string TemplateSuffix { get; set; } + /// + /// The suffix of the template you are using. By default, the original template is called product.liquid, without any suffix. Any additional templates will be: product.suffix.liquid. + /// + [JsonProperty("template_suffix")] + public string TemplateSuffix { get; set; } - /// - /// The name of the Custom collection. Limit of 255 characters. - /// - [JsonProperty("title")] - public string Title { get; set; } + /// + /// The name of the Custom collection. Limit of 255 characters. + /// + [JsonProperty("title")] + public string Title { get; set; } - /// - /// The date and time when the Custom collection was last modified. The API returns this value in ISO 8601 format. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } + /// + /// The date and time when the Custom collection was last modified. The API returns this value in ISO 8601 format. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } - /// - /// The collection of collects associated to this custom collection - /// - [JsonProperty("collects")] - public IEnumerable Collects { get; set; } + /// + /// The collection of collects associated to this custom collection + /// + [JsonProperty("collects")] + public IEnumerable Collects { get; set; } - /// - /// Additional metadata about the . Note: This is not naturally returned with a response, as - /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . - /// Uses include: Creating, updating, & deserializing webhook bodies that include them. - /// - [JsonProperty("metafields")] - public IEnumerable Metafields { get; set; } - } -} + /// + /// Additional metadata about the . Note: This is not naturally returned with a response, as + /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . + /// Uses include: Creating, updating, & deserializing webhook bodies that include them. + /// + [JsonProperty("metafields")] + public IEnumerable Metafields { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/CustomCollectionImage.cs b/ShopifySharp/Entities/CustomCollectionImage.cs index 84a1214d..23c41482 100644 --- a/ShopifySharp/Entities/CustomCollectionImage.cs +++ b/ShopifySharp/Entities/CustomCollectionImage.cs @@ -1,47 +1,46 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// Represents the image for a +/// +public class CustomCollectionImage { /// - /// Represents the image for a + /// An image attached to a shop's theme returned as Base64-encoded binary data. /// - public class CustomCollectionImage - { - /// - /// An image attached to a shop's theme returned as Base64-encoded binary data. - /// - [JsonProperty("attachment")] - public string Attachment { get; set; } + [JsonProperty("attachment")] + public string Attachment { get; set; } - /// - /// Source URL that specifies the location of the image. - /// - [JsonProperty("src")] - public string Src { get; set; } + /// + /// Source URL that specifies the location of the image. + /// + [JsonProperty("src")] + public string Src { get; set; } - /// - /// Alternative text that describes the collection image. - /// - [JsonProperty("alt")] - public string Alt { get; set; } + /// + /// Alternative text that describes the collection image. + /// + [JsonProperty("alt")] + public string Alt { get; set; } - /// - /// The date the image was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? Created_At { get; set; } + /// + /// The date the image was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? Created_At { get; set; } - /// - /// Width of the image in pixels. - /// - [JsonProperty("width")] - public int? Width { get; set; } + /// + /// Width of the image in pixels. + /// + [JsonProperty("width")] + public int? Width { get; set; } - /// - /// Height of the image in pixels. - /// - [JsonProperty("height")] - public int? Height { get; set; } - } -} + /// + /// Height of the image in pixels. + /// + [JsonProperty("height")] + public int? Height { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/Customer.cs b/ShopifySharp/Entities/Customer.cs index ed30bbe1..4f3f87fe 100644 --- a/ShopifySharp/Entities/Customer.cs +++ b/ShopifySharp/Entities/Customer.cs @@ -2,164 +2,163 @@ using System; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +public class Customer : ShopifyObject { - public class Customer : ShopifyObject - { - /// - /// A list of addresses for the customer. - /// - [JsonProperty("addresses")] - public IEnumerable
Addresses { get; set; } - - /// - /// The date and time when the customer was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// Currency used for customer's last order - /// - [JsonProperty("currency")] - public string Currency { get; set; } - - /// - /// The default address for the customer. - /// - [JsonProperty("default_address")] - public Address DefaultAddress { get; set; } - - /// - /// The email address of the customer. - /// - [JsonProperty("email")] - public string Email { get; set; } - - /// - /// The customer's first name. - /// - [JsonProperty("first_name")] - public string FirstName { get; set; } - - /// - /// The customer's identifier used with Multipass login - /// - [JsonProperty("multipass_identifier")] - public string MultipassIdentifier { get; set; } - - /// - /// The customer's last name. - /// - [JsonProperty("last_name")] - public string LastName { get; set; } - - /// - /// The id of the customer's last order. - /// **Note**: this value is deprecated specifically when the customer is returned using the Orders API. In that case, the value will always be null. The property is still available via the Customers API. - /// - /// Property can be null or longer than max int32 value. Set to nullable long instead. - [JsonProperty("last_order_id")] - public long? LastOrderId { get; set; } - - /// - /// The name of the customer's last order. This is directly related to the Order's name field. - /// **Note**: this value is deprecated specifically when the customer is returned using the Orders API. In that case, the value will always be null. The property is still available via the Customers API. - /// - [JsonProperty("last_order_name")] - public string LastOrderName { get; set; } - - /// - /// A note about the customer. - /// - [JsonProperty("note")] - public string Note { get; set; } - - /// - /// The number of orders associated with this customer. - /// **Note**: this value is deprecated specifically when the customer is returned using the Orders API. In that case, the value will always be null. The property is still available via the Customers API. - /// - [JsonProperty("orders_count")] - public int? OrdersCount { get; set; } - - /// - /// The phone number for the customer. Valid formats can be of different types, for example: - /// - /// 6135551212 - /// - /// +16135551212 - /// - /// 555-1212 - /// - /// (613)555-1212 - /// - /// +1 613-555-1212 - /// - [JsonProperty("phone")] - public string Phone { get; set; } - - /// - /// The state of the customer in a shop. Valid values are 'disabled', 'decline', 'invited' and 'enabled'. - /// - [JsonProperty("state")] - public string State { get; set; } - - /// - /// Tags are additional short descriptors formatted as a string of comma-separated values. - /// - [JsonProperty("tags")] - public string Tags { get; set; } - - /// - /// Indicates whether the customer should be charged taxes when placing orders. - /// - [JsonProperty("tax_exempt")] - public bool? TaxExempt { get; set; } - - /// - /// Whether the customer is exempt from paying specific taxes on their order. Canadian taxes only - /// - [JsonProperty("tax_exemptions")] - public string[] TaxExemptions { get; set; } - - /// - /// The total amount of money that the customer has spent at the shop. - /// **Note**: this value is deprecated specifically when the customer is returned using the Orders API. In that case, the value will always be null. The property is still available via the Customers API. - /// - /// The Shopify API actually returns this value as a string, but Json.Net can automatically convert to decimal. - [JsonProperty("total_spent")] - public decimal? TotalSpent { get; set; } - - /// - /// The date and time when the customer information was updated. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - - /// - /// States whether or not the email address has been verified. - /// - [JsonProperty("verified_email")] - public bool? VerifiedEmail { get; set; } - - /// - /// The marketing consent information when the customer consented to receiving marketing material by SMS. The phone property is required to create a customer with SMS consent information and to perform an SMS update on a customer that doesn't have a phone number recorded. - /// - [JsonProperty("sms_marketing_consent")] - public CustomerSmsMarketingConsent SmsMarketingConsent { get; set; } - - /// - /// Additional metadata about the . Note: This is not naturally returned with a response, as - /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . - /// Uses include: Creating, updating, & deserializing webhook bodies that include them. - /// - [JsonProperty("metafields")] - public IEnumerable Metafields { get; set; } - - /// - /// The marketing consent information when the customer consented to receiving marketing material by email. The email property is required to create a customer with email consent information and to update a customer for email consent that doesn't have an email recorded. - /// - [JsonProperty("email_marketing_consent")] - public CustomerEmailMarketingConsent EmailMarketingConsent { get; set; } - } -} + /// + /// A list of addresses for the customer. + /// + [JsonProperty("addresses")] + public IEnumerable
Addresses { get; set; } + + /// + /// The date and time when the customer was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// Currency used for customer's last order + /// + [JsonProperty("currency")] + public string Currency { get; set; } + + /// + /// The default address for the customer. + /// + [JsonProperty("default_address")] + public Address DefaultAddress { get; set; } + + /// + /// The email address of the customer. + /// + [JsonProperty("email")] + public string Email { get; set; } + + /// + /// The customer's first name. + /// + [JsonProperty("first_name")] + public string FirstName { get; set; } + + /// + /// The customer's identifier used with Multipass login + /// + [JsonProperty("multipass_identifier")] + public string MultipassIdentifier { get; set; } + + /// + /// The customer's last name. + /// + [JsonProperty("last_name")] + public string LastName { get; set; } + + /// + /// The id of the customer's last order. + /// **Note**: this value is deprecated specifically when the customer is returned using the Orders API. In that case, the value will always be null. The property is still available via the Customers API. + /// + /// Property can be null or longer than max int32 value. Set to nullable long instead. + [JsonProperty("last_order_id")] + public long? LastOrderId { get; set; } + + /// + /// The name of the customer's last order. This is directly related to the Order's name field. + /// **Note**: this value is deprecated specifically when the customer is returned using the Orders API. In that case, the value will always be null. The property is still available via the Customers API. + /// + [JsonProperty("last_order_name")] + public string LastOrderName { get; set; } + + /// + /// A note about the customer. + /// + [JsonProperty("note")] + public string Note { get; set; } + + /// + /// The number of orders associated with this customer. + /// **Note**: this value is deprecated specifically when the customer is returned using the Orders API. In that case, the value will always be null. The property is still available via the Customers API. + /// + [JsonProperty("orders_count")] + public int? OrdersCount { get; set; } + + /// + /// The phone number for the customer. Valid formats can be of different types, for example: + /// + /// 6135551212 + /// + /// +16135551212 + /// + /// 555-1212 + /// + /// (613)555-1212 + /// + /// +1 613-555-1212 + /// + [JsonProperty("phone")] + public string Phone { get; set; } + + /// + /// The state of the customer in a shop. Valid values are 'disabled', 'decline', 'invited' and 'enabled'. + /// + [JsonProperty("state")] + public string State { get; set; } + + /// + /// Tags are additional short descriptors formatted as a string of comma-separated values. + /// + [JsonProperty("tags")] + public string Tags { get; set; } + + /// + /// Indicates whether the customer should be charged taxes when placing orders. + /// + [JsonProperty("tax_exempt")] + public bool? TaxExempt { get; set; } + + /// + /// Whether the customer is exempt from paying specific taxes on their order. Canadian taxes only + /// + [JsonProperty("tax_exemptions")] + public string[] TaxExemptions { get; set; } + + /// + /// The total amount of money that the customer has spent at the shop. + /// **Note**: this value is deprecated specifically when the customer is returned using the Orders API. In that case, the value will always be null. The property is still available via the Customers API. + /// + /// The Shopify API actually returns this value as a string, but Json.Net can automatically convert to decimal. + [JsonProperty("total_spent")] + public decimal? TotalSpent { get; set; } + + /// + /// The date and time when the customer information was updated. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } + + /// + /// States whether or not the email address has been verified. + /// + [JsonProperty("verified_email")] + public bool? VerifiedEmail { get; set; } + + /// + /// The marketing consent information when the customer consented to receiving marketing material by SMS. The phone property is required to create a customer with SMS consent information and to perform an SMS update on a customer that doesn't have a phone number recorded. + /// + [JsonProperty("sms_marketing_consent")] + public CustomerSmsMarketingConsent SmsMarketingConsent { get; set; } + + /// + /// Additional metadata about the . Note: This is not naturally returned with a response, as + /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . + /// Uses include: Creating, updating, & deserializing webhook bodies that include them. + /// + [JsonProperty("metafields")] + public IEnumerable Metafields { get; set; } + + /// + /// The marketing consent information when the customer consented to receiving marketing material by email. The email property is required to create a customer with email consent information and to update a customer for email consent that doesn't have an email recorded. + /// + [JsonProperty("email_marketing_consent")] + public CustomerEmailMarketingConsent EmailMarketingConsent { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/CustomerDataRequestWebhook.cs b/ShopifySharp/Entities/CustomerDataRequestWebhook.cs index 5f3be6a4..31929a12 100644 --- a/ShopifySharp/Entities/CustomerDataRequestWebhook.cs +++ b/ShopifySharp/Entities/CustomerDataRequestWebhook.cs @@ -1,23 +1,22 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// Sent via the GDPR customers/data_request webhook, indicating that a customer has requested all data that you may have stored related to them. It's your responsibility to provide this data to the store owner directly. +/// +public class CustomerDataRequestWebhook : ShopRedactedWebhook { /// - /// Sent via the GDPR customers/data_request webhook, indicating that a customer has requested all data that you may have stored related to them. It's your responsibility to provide this data to the store owner directly. + /// The customer who has been redacted. /// - public class CustomerDataRequestWebhook : ShopRedactedWebhook - { - /// - /// The customer who has been redacted. - /// - [JsonProperty("customer")] - public RedactedCustomer Customer { get; set; } + [JsonProperty("customer")] + public RedactedCustomer Customer { get; set; } - /// - /// A list of order ids placed by the customer that they are requesting information on. - /// - [JsonProperty("orders_requested")] - public IEnumerable OrdersRequested { get; set; } - } + /// + /// A list of order ids placed by the customer that they are requesting information on. + /// + [JsonProperty("orders_requested")] + public IEnumerable OrdersRequested { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/CustomerEmailMarketingConsent.cs b/ShopifySharp/Entities/CustomerEmailMarketingConsent.cs index 87506f28..c884c931 100644 --- a/ShopifySharp/Entities/CustomerEmailMarketingConsent.cs +++ b/ShopifySharp/Entities/CustomerEmailMarketingConsent.cs @@ -1,26 +1,25 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +public class CustomerEmailMarketingConsent { - public class CustomerEmailMarketingConsent - { - /// - /// The current email marketing state for the customer. - /// - [JsonProperty("state")] - public string State { get; set; } + /// + /// The current email marketing state for the customer. + /// + [JsonProperty("state")] + public string State { get; set; } - /// - /// The marketing subscription opt-in level, as described in the M3AAWG Sender Best Common Practices, that the customer gave when they consented to receive marketing material by email. - /// - [JsonProperty("opt_in_level")] - public string OptInLevel { get; set; } + /// + /// The marketing subscription opt-in level, as described in the M3AAWG Sender Best Common Practices, that the customer gave when they consented to receive marketing material by email. + /// + [JsonProperty("opt_in_level")] + public string OptInLevel { get; set; } - /// - /// The date and time when the customer consented to receive marketing material by email. If no date is provided, then the date and time when the consent information was sent is used. - /// - [JsonProperty("consent_updated_at")] - public DateTimeOffset? ConsentUpdatedAt { get; set; } - } -} + /// + /// The date and time when the customer consented to receive marketing material by email. If no date is provided, then the date and time when the consent information was sent is used. + /// + [JsonProperty("consent_updated_at")] + public DateTimeOffset? ConsentUpdatedAt { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/CustomerEmailMarketingConsentWebhook.cs b/ShopifySharp/Entities/CustomerEmailMarketingConsentWebhook.cs index 5d969b4f..c9f8758a 100644 --- a/ShopifySharp/Entities/CustomerEmailMarketingConsentWebhook.cs +++ b/ShopifySharp/Entities/CustomerEmailMarketingConsentWebhook.cs @@ -1,20 +1,19 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// Payload for webhook customers_email_marketing_consent/update +/// https://shopify.dev/docs/api/admin-rest/2023-07/resources/webhook#event-topics-customers-marketing-consent-update +/// +public class CustomerEmailMarketingConsentWebhook : ShopifyObject { - /// - /// Payload for webhook customers_email_marketing_consent/update - /// https://shopify.dev/docs/api/admin-rest/2023-07/resources/webhook#event-topics-customers-marketing-consent-update - /// - public class CustomerEmailMarketingConsentWebhook : ShopifyObject - { - [JsonProperty("customer_id")] - public long? CustomerId { get; set; } + [JsonProperty("customer_id")] + public long? CustomerId { get; set; } - [JsonProperty("email_address")] - public string EmailAddress { get; set; } + [JsonProperty("email_address")] + public string EmailAddress { get; set; } - [JsonProperty("email_marketing_consent")] - public CustomerEmailMarketingConsent EmailMarketingConsent { get; set; } - } -} + [JsonProperty("email_marketing_consent")] + public CustomerEmailMarketingConsent EmailMarketingConsent { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/CustomerInvite.cs b/ShopifySharp/Entities/CustomerInvite.cs index ab2bf8e3..4c8bbb69 100644 --- a/ShopifySharp/Entities/CustomerInvite.cs +++ b/ShopifySharp/Entities/CustomerInvite.cs @@ -1,39 +1,38 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +public class CustomerInvite : ShopifyObject { - public class CustomerInvite : ShopifyObject - { - /// - /// The email address of the customer to be invited - /// - [JsonProperty("to")] - public string To { get; set; } + /// + /// The email address of the customer to be invited + /// + [JsonProperty("to")] + public string To { get; set; } - /// - /// The sender of the email - /// - [JsonProperty("from")] - public string From { get; set; } + /// + /// The sender of the email + /// + [JsonProperty("from")] + public string From { get; set; } - /// - /// the subject - /// - [JsonProperty("subject")] - public string Subject { get; set; } + /// + /// the subject + /// + [JsonProperty("subject")] + public string Subject { get; set; } - /// - /// a custom message to include - /// - [JsonProperty("custom_message")] - public string CustomMessage { get; set; } + /// + /// a custom message to include + /// + [JsonProperty("custom_message")] + public string CustomMessage { get; set; } - /// - /// blind copy addresses - /// - [JsonProperty("bcc")] - public IEnumerable Bcc { get; set; } + /// + /// blind copy addresses + /// + [JsonProperty("bcc")] + public IEnumerable Bcc { get; set; } - } -} +} \ No newline at end of file diff --git a/ShopifySharp/Entities/CustomerMarketingConsentWebhook.cs b/ShopifySharp/Entities/CustomerMarketingConsentWebhook.cs index e4885cba..706043a3 100644 --- a/ShopifySharp/Entities/CustomerMarketingConsentWebhook.cs +++ b/ShopifySharp/Entities/CustomerMarketingConsentWebhook.cs @@ -1,17 +1,16 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// Payload for webhook customers_marketing_consent/update +/// https://shopify.dev/docs/api/admin-rest/2023-07/resources/webhook#event-topics-customers-marketing-consent-update +/// +public class CustomerMarketingConsentWebhook : ShopifyObject { - /// - /// Payload for webhook customers_marketing_consent/update - /// https://shopify.dev/docs/api/admin-rest/2023-07/resources/webhook#event-topics-customers-marketing-consent-update - /// - public class CustomerMarketingConsentWebhook : ShopifyObject - { - [JsonProperty("phone")] - public string Phone { get; set; } + [JsonProperty("phone")] + public string Phone { get; set; } - [JsonProperty("sms_marketing_consent")] - public CustomerSmsMarketingConsent SmsMarketingConsent { get; set; } - } -} + [JsonProperty("sms_marketing_consent")] + public CustomerSmsMarketingConsent SmsMarketingConsent { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/CustomerRedactedWebhook.cs b/ShopifySharp/Entities/CustomerRedactedWebhook.cs index 001e6f61..7fcc641e 100644 --- a/ShopifySharp/Entities/CustomerRedactedWebhook.cs +++ b/ShopifySharp/Entities/CustomerRedactedWebhook.cs @@ -1,23 +1,22 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// Sent via the GDPR customers/redact webhook, indicating that you should purge the customer's data from your systems. +/// +public class CustomerRedactedWebhook : ShopRedactedWebhook { /// - /// Sent via the GDPR customers/redact webhook, indicating that you should purge the customer's data from your systems. + /// The customer who has been redacted. /// - public class CustomerRedactedWebhook : ShopRedactedWebhook - { - /// - /// The customer who has been redacted. - /// - [JsonProperty("customer")] - public RedactedCustomer Customer { get; set; } + [JsonProperty("customer")] + public RedactedCustomer Customer { get; set; } - /// - /// A list of order ids placed by the customer that must also be purged from your systems. - /// - [JsonProperty("orders_to_redact")] - public IEnumerable OrdersToRedact { get; set; } - } + /// + /// A list of order ids placed by the customer that must also be purged from your systems. + /// + [JsonProperty("orders_to_redact")] + public IEnumerable OrdersToRedact { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/CustomerSmsMarketingConsent.cs b/ShopifySharp/Entities/CustomerSmsMarketingConsent.cs index 54ef3527..5cb42c97 100644 --- a/ShopifySharp/Entities/CustomerSmsMarketingConsent.cs +++ b/ShopifySharp/Entities/CustomerSmsMarketingConsent.cs @@ -1,32 +1,31 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class CustomerSmsMarketingConsent { - public class CustomerSmsMarketingConsent - { - /// - /// The current SMS marketing state for the customer. - /// - [JsonProperty("state")] - public string State { get; set; } + /// + /// The current SMS marketing state for the customer. + /// + [JsonProperty("state")] + public string State { get; set; } - /// - /// The marketing subscription opt-in level, as described by the M3AAWG best practices guidelines, that the customer gave when they consented to receive marketing material by SMS. - /// - [JsonProperty("opt_in_level")] - public string OptInLevel { get; set; } + /// + /// The marketing subscription opt-in level, as described by the M3AAWG best practices guidelines, that the customer gave when they consented to receive marketing material by SMS. + /// + [JsonProperty("opt_in_level")] + public string OptInLevel { get; set; } - /// - /// The date and time at which the customer consented to receive marketing material by SMS. - /// - [JsonProperty("consent_updated_at")] - public DateTimeOffset? ConsentUpdatedAt { get; set; } + /// + /// The date and time at which the customer consented to receive marketing material by SMS. + /// + [JsonProperty("consent_updated_at")] + public DateTimeOffset? ConsentUpdatedAt { get; set; } - /// - /// The source for whether the customer has consented to receive marketing material by SMS. - /// - [JsonProperty("consent_collected_from")] - public string ConsentCollectedFrom { get; set; } - } -} + /// + /// The source for whether the customer has consented to receive marketing material by SMS. + /// + [JsonProperty("consent_collected_from")] + public string ConsentCollectedFrom { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/DeliveryMethod.cs b/ShopifySharp/Entities/DeliveryMethod.cs index 6ff478bf..35628b4b 100644 --- a/ShopifySharp/Entities/DeliveryMethod.cs +++ b/ShopifySharp/Entities/DeliveryMethod.cs @@ -1,24 +1,23 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class DeliveryMethod { - public class DeliveryMethod - { - /// - /// The ID of the delivery method. - /// - [JsonProperty("id")] - public long? Id { get; set; } + /// + /// The ID of the delivery method. + /// + [JsonProperty("id")] + public long? Id { get; set; } - /// - /// The type of delivery method. Valid values. - ///
local: A delivery to a customer's doorstep
- ///
none: No delivery method
- ///
pick_up: A delivery that a customer picks up at your retail store, curbside, or any location that you choose
- ///
retail: A delivery to a retail store
- ///
shipping: A delivery to a customer using a shipping carrier
- ///
- [JsonProperty("method_type")] - public string MethodType { get; set; } - } -} + /// + /// The type of delivery method. Valid values. + ///
local: A delivery to a customer's doorstep
+ ///
none: No delivery method
+ ///
pick_up: A delivery that a customer picks up at your retail store, curbside, or any location that you choose
+ ///
retail: A delivery to a retail store
+ ///
shipping: A delivery to a customer using a shipping carrier
+ ///
+ [JsonProperty("method_type")] + public string MethodType { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/DiscountAllocation.cs b/ShopifySharp/Entities/DiscountAllocation.cs index 64c57482..bd926a8b 100644 --- a/ShopifySharp/Entities/DiscountAllocation.cs +++ b/ShopifySharp/Entities/DiscountAllocation.cs @@ -1,25 +1,24 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class DiscountAllocation { - public class DiscountAllocation - { - /// - /// The discount amount allocated to the line (not sure why it is a string) - /// - [JsonProperty("amount")] - public string Amount { get; set; } + /// + /// The discount amount allocated to the line (not sure why it is a string) + /// + [JsonProperty("amount")] + public string Amount { get; set; } - /// - /// The index of the associated discount application in the order's discount_applications list. - /// - [JsonProperty("discount_application_index")] - public long DiscountApplicationIndex { get; set; } + /// + /// The index of the associated discount application in the order's discount_applications list. + /// + [JsonProperty("discount_application_index")] + public long DiscountApplicationIndex { get; set; } - /// - /// The discount amount allocated to the line item in shop and presentment currencies. - /// - [JsonProperty("amount_set")] - public PriceSet AmountSet { get; set; } - } -} + /// + /// The discount amount allocated to the line item in shop and presentment currencies. + /// + [JsonProperty("amount_set")] + public PriceSet AmountSet { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/DiscountApplication.cs b/ShopifySharp/Entities/DiscountApplication.cs index 94b46798..857137fc 100644 --- a/ShopifySharp/Entities/DiscountApplication.cs +++ b/ShopifySharp/Entities/DiscountApplication.cs @@ -1,76 +1,75 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class DiscountApplication { - public class DiscountApplication - { - /// - /// The discount application type. Valid values: - /// manual: The discount was manually applied by the merchant(for example, by using an app or creating a draft order). - /// script: The discount was applied by a Shopify Script. - /// discount_code: The discount was applied by a discount code. - /// - [JsonProperty("type")] - public string Type { get; set; } + /// + /// The discount application type. Valid values: + /// manual: The discount was manually applied by the merchant(for example, by using an app or creating a draft order). + /// script: The discount was applied by a Shopify Script. + /// discount_code: The discount was applied by a discount code. + /// + [JsonProperty("type")] + public string Type { get; set; } - /// - /// The discount code that was used to apply the discount. Available only for discount code applications. - /// - [JsonProperty("code")] - public string Code { get; set; } + /// + /// The discount code that was used to apply the discount. Available only for discount code applications. + /// + [JsonProperty("code")] + public string Code { get; set; } - /// - /// The title of the discount application, as defined by the merchant. Available only for manual discount applications. - /// - [JsonProperty("title")] - public string Title { get; set; } + /// + /// The title of the discount application, as defined by the merchant. Available only for manual discount applications. + /// + [JsonProperty("title")] + public string Title { get; set; } - /// - /// The description of the discount application, as defined by the merchant or the Shopify Script. Available only for manual and script discount applications. - /// - [JsonProperty("description")] - public string Description { get; set; } + /// + /// The description of the discount application, as defined by the merchant or the Shopify Script. Available only for manual and script discount applications. + /// + [JsonProperty("description")] + public string Description { get; set; } - /// - /// The value of the discount application as a decimal. This represents the intention of the discount application. - /// For example, if the intent was to apply a 20% discount, then the value will be 20.0. - /// If the intent was to apply a $15 discount, then the value will be 15.0. - /// - [JsonProperty("value")] - public string Value { get; set; } + /// + /// The value of the discount application as a decimal. This represents the intention of the discount application. + /// For example, if the intent was to apply a 20% discount, then the value will be 20.0. + /// If the intent was to apply a $15 discount, then the value will be 15.0. + /// + [JsonProperty("value")] + public string Value { get; set; } - /// - /// The type of the value. Valid values: - /// fixed_amount: A fixed amount discount value in the currency of the order. - /// percentage: A percentage discount value. - /// - [JsonProperty("value_type")] - public string ValueType { get; set; } + /// + /// The type of the value. Valid values: + /// fixed_amount: A fixed amount discount value in the currency of the order. + /// percentage: A percentage discount value. + /// + [JsonProperty("value_type")] + public string ValueType { get; set; } - /// - /// The method by which the discount application value has been allocated to entitled lines. Valid values: - /// across: The value is spread across all entitled lines. - /// each: The value is applied onto every entitled line. - /// one: The value is applied onto a single line. - /// - [JsonProperty("allocation_method")] - public string AllocationMethod { get; set; } + /// + /// The method by which the discount application value has been allocated to entitled lines. Valid values: + /// across: The value is spread across all entitled lines. + /// each: The value is applied onto every entitled line. + /// one: The value is applied onto a single line. + /// + [JsonProperty("allocation_method")] + public string AllocationMethod { get; set; } - /// - /// The lines on the order, of the type defined by target_type, that the discount is allocated over. Valid values: - /// all: The discount is allocated onto all lines, - /// entitled: The discount is allocated only onto lines it is entitled for. - /// explicit: The discount is allocated onto explicitly selected lines. - /// - [JsonProperty("target_selection")] - public string TargetSelection { get; set; } + /// + /// The lines on the order, of the type defined by target_type, that the discount is allocated over. Valid values: + /// all: The discount is allocated onto all lines, + /// entitled: The discount is allocated only onto lines it is entitled for. + /// explicit: The discount is allocated onto explicitly selected lines. + /// + [JsonProperty("target_selection")] + public string TargetSelection { get; set; } - /// - /// The type of line on the order that the discount is applicable on. Valid values: - /// line_item: The discount applies to line items. - /// shipping_line: The discount applies to shipping lines. - /// - [JsonProperty("target_type")] - public string TargetType { get; set; } - } -} + /// + /// The type of line on the order that the discount is applicable on. Valid values: + /// line_item: The discount applies to line items. + /// shipping_line: The discount applies to shipping lines. + /// + [JsonProperty("target_type")] + public string TargetType { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/DiscountCode.cs b/ShopifySharp/Entities/DiscountCode.cs index 43bd23d8..6f976715 100644 --- a/ShopifySharp/Entities/DiscountCode.cs +++ b/ShopifySharp/Entities/DiscountCode.cs @@ -1,25 +1,24 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class DiscountCode : ShopifyObject { - public class DiscountCode : ShopifyObject - { - /// - /// The amount of the discount. - /// - [JsonProperty("amount")] - public string Amount { get; set; } + /// + /// The amount of the discount. + /// + [JsonProperty("amount")] + public string Amount { get; set; } - /// - /// The discount code. - /// - [JsonProperty("code")] - public string Code { get; set; } + /// + /// The discount code. + /// + [JsonProperty("code")] + public string Code { get; set; } - /// - /// The type of discount. Known values are 'percentage', 'shipping', 'fixed_amount' and 'none'. - /// - [JsonProperty("type")] - public string Type { get; set; } - } -} + /// + /// The type of discount. Known values are 'percentage', 'shipping', 'fixed_amount' and 'none'. + /// + [JsonProperty("type")] + public string Type { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/DraftLineItem.cs b/ShopifySharp/Entities/DraftLineItem.cs index 9f2e4501..8b9e96fc 100644 --- a/ShopifySharp/Entities/DraftLineItem.cs +++ b/ShopifySharp/Entities/DraftLineItem.cs @@ -1,19 +1,18 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class DraftLineItem : LineItem { - public class DraftLineItem : LineItem - { - /// - /// Indicates if this is a product variant line item, or a custom line item. If set to true indicates a custom line item. If set to false indicates a product variant line item. This is a read only field. - /// - [JsonProperty("custom")] - public bool? Custom { get; set; } + /// + /// Indicates if this is a product variant line item, or a custom line item. If set to true indicates a custom line item. If set to false indicates a product variant line item. This is a read only field. + /// + [JsonProperty("custom")] + public bool? Custom { get; set; } - /// - /// Discount which will be applied to the line item or the overall order. - /// - [JsonProperty("applied_discount")] - public AppliedDiscount AppliedDiscount { get; set; } - } + /// + /// Discount which will be applied to the line item or the overall order. + /// + [JsonProperty("applied_discount")] + public AppliedDiscount AppliedDiscount { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/DraftOrder.cs b/ShopifySharp/Entities/DraftOrder.cs index 7895dca4..ec837362 100644 --- a/ShopifySharp/Entities/DraftOrder.cs +++ b/ShopifySharp/Entities/DraftOrder.cs @@ -2,185 +2,184 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class DraftOrder : ShopifyObject { - public class DraftOrder : ShopifyObject - { - /// - /// The unique numeric identifier for the order associated to the draft order, once created. - /// - [JsonProperty("order_id")] - public long? OrderId { get; set; } - - /// - /// Name of the draft order. - /// - [JsonProperty("name")] - public string Name { get; set; } - - /// - /// Customer associated with the draft order. Customer associated with the draft order. Used to load/remove the associated customer with customer id. When a customer is loaded, the customer’s email address is also assocaited. - /// - [JsonProperty("customer")] - public Customer Customer { get; set; } - - /// - /// The mailing address to where the order will be shipped. This address is optional and will not be available on orders that do not require one. - /// - [JsonProperty("shipping_address")] - public Address ShippingAddress { get; set; } - - /// - /// The mailing address associated with the payment method. This address is an optional field that will not be available on orders that do not require one. - /// - [JsonProperty("billing_address")] - public Address BillingAddress { get; set; } - - /// - /// The text of an optional note that a shop owner can attach to the draft order. - /// - [JsonProperty("note")] - public string Note { get; set; } - - /// - /// Extra information that is added to the order. - /// - [JsonProperty("note_attributes")] - public IEnumerable NoteAttributes { get; set; } - - /// - /// The customer's email address. - /// - [JsonProperty("email")] - public string Email { get; set; } - - /// - /// The three letter code (ISO 4217) for the currency used for the payment. - /// - [JsonProperty("currency")] - public string Currency { get; set; } - - /// - /// This auto-generated property is the date and time when the invoice was emailed to the customer, in ISO 8601 format. - /// - [JsonProperty("invoice_sent_at")] - public DateTimeOffset? InvoiceSentAt { get; set; } - - /// - /// The URL for the invoice. - /// - [JsonProperty("invoice_url")] - public string InvoiceUrl { get; set; } - - /// - /// Product variant line item or custom line item associated to the draft order. Each draft order must include at least one line_item. - /// - [JsonProperty("line_items")] - public IEnumerable LineItems { get; set; } - - /// - /// Details the shipping method used. - /// - [JsonProperty("shipping_line")] - public DraftShippingLine ShippingLine { get; set; } - - /// - /// Tags are additional short descriptors, commonly used for filtering and searching, formatted as a string of comma-separated values. - /// - [JsonProperty("tags")] - public string Tags { get; set; } - - /// - /// Sets whether or not taxes are exempt for the draft order. If this field is set to false, then Shopify will refer to the taxable field for each line_item. If a customer is applied to the draft order, then Shopify will use the customer's tax_exempt field instead. - /// - [JsonProperty("tax_exempt")] - public bool? TaxExempt { get; set; } - - /// - /// Whether the customer is exempt from paying specific taxes on their order - /// - [JsonProperty("tax_exemptions")] - public IEnumerable TaxExemptions { get; set; } - - /// - /// An array of tax_line objects, each of which details the total taxes applicable to the order. When creating an order through the API, tax lines may be specified on the order or the line items but not both. Tax lines specified on the order are split on the taxable line items in the created order. - /// - [JsonProperty("tax_lines")] - public IEnumerable TaxLines { get; set; } - - /// - /// Discount which will be applied to the line item or the overall order. A draft order line_item can have one discount. A draft order can have one order-level discount. - /// - [JsonProperty("applied_discount")] - public AppliedDiscount AppliedDiscount { get; set; } - - /// - /// States whether or not taxes are included in the order subtotal. - /// - [JsonProperty("taxes_included")] - public bool? TaxesIncluded { get; set; } - - /// - /// The sum of all the taxes applied to the order (must be positive). - /// - [JsonProperty("total_tax")] - public decimal? TotalTax { get; set; } - - /// - /// Price of the order before shipping and taxes - /// - [JsonProperty("subtotal_price")] - public decimal? SubtotalPrice { get; set; } - - /// - /// The sum of all the prices of all the items in the order, taxes and discounts included (must be positive). - /// - [JsonProperty("total_price")] - public decimal? TotalPrice { get; set; } - - /// - /// Date at which order is created and the draft order changes to completed status. The API returns this value in ISO 8601 format. - /// - [JsonProperty("completed_at")] - public DateTimeOffset? CompletedAt { get; set; } - - /// - /// This auto-generated property is the date and time when the draft order was created in Shopify, in ISO 8601 format. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// The date and time when the order was last modified. The API returns this value in ISO 8601 format. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - - /// - /// Once a draft order is set to status completed the only further draft order modifications that can be made are adding tags or metafields. No other draft order actions are permitted. - /// Known values are "open", "invoice_sent", and "completed". - /// - [JsonProperty("status")] - public string Status { get; set; } - - /// - /// Additional metadata about the . Note: This is not naturally returned with a response, as - /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . - /// Uses include: Creating, updating, & deserializing webhook bodies that include them. - /// - [JsonProperty("metafields")] - public IEnumerable Metafields { get; set; } - - /// - /// An optional boolean that you can send as part of a draft order object to load customer shipping information. - /// - [JsonProperty("use_customer_default_address")] - public bool? UseCustomerDefaultAddress { get; set; } - - /// - /// The terms and conditions under which a payment should be processed. - /// - [JsonProperty("payment_terms")] - public PaymentTerms PaymentTerms { get; set; } - } -} + /// + /// The unique numeric identifier for the order associated to the draft order, once created. + /// + [JsonProperty("order_id")] + public long? OrderId { get; set; } + + /// + /// Name of the draft order. + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// Customer associated with the draft order. Customer associated with the draft order. Used to load/remove the associated customer with customer id. When a customer is loaded, the customer’s email address is also assocaited. + /// + [JsonProperty("customer")] + public Customer Customer { get; set; } + + /// + /// The mailing address to where the order will be shipped. This address is optional and will not be available on orders that do not require one. + /// + [JsonProperty("shipping_address")] + public Address ShippingAddress { get; set; } + + /// + /// The mailing address associated with the payment method. This address is an optional field that will not be available on orders that do not require one. + /// + [JsonProperty("billing_address")] + public Address BillingAddress { get; set; } + + /// + /// The text of an optional note that a shop owner can attach to the draft order. + /// + [JsonProperty("note")] + public string Note { get; set; } + + /// + /// Extra information that is added to the order. + /// + [JsonProperty("note_attributes")] + public IEnumerable NoteAttributes { get; set; } + + /// + /// The customer's email address. + /// + [JsonProperty("email")] + public string Email { get; set; } + + /// + /// The three letter code (ISO 4217) for the currency used for the payment. + /// + [JsonProperty("currency")] + public string Currency { get; set; } + + /// + /// This auto-generated property is the date and time when the invoice was emailed to the customer, in ISO 8601 format. + /// + [JsonProperty("invoice_sent_at")] + public DateTimeOffset? InvoiceSentAt { get; set; } + + /// + /// The URL for the invoice. + /// + [JsonProperty("invoice_url")] + public string InvoiceUrl { get; set; } + + /// + /// Product variant line item or custom line item associated to the draft order. Each draft order must include at least one line_item. + /// + [JsonProperty("line_items")] + public IEnumerable LineItems { get; set; } + + /// + /// Details the shipping method used. + /// + [JsonProperty("shipping_line")] + public DraftShippingLine ShippingLine { get; set; } + + /// + /// Tags are additional short descriptors, commonly used for filtering and searching, formatted as a string of comma-separated values. + /// + [JsonProperty("tags")] + public string Tags { get; set; } + + /// + /// Sets whether or not taxes are exempt for the draft order. If this field is set to false, then Shopify will refer to the taxable field for each line_item. If a customer is applied to the draft order, then Shopify will use the customer's tax_exempt field instead. + /// + [JsonProperty("tax_exempt")] + public bool? TaxExempt { get; set; } + + /// + /// Whether the customer is exempt from paying specific taxes on their order + /// + [JsonProperty("tax_exemptions")] + public IEnumerable TaxExemptions { get; set; } + + /// + /// An array of tax_line objects, each of which details the total taxes applicable to the order. When creating an order through the API, tax lines may be specified on the order or the line items but not both. Tax lines specified on the order are split on the taxable line items in the created order. + /// + [JsonProperty("tax_lines")] + public IEnumerable TaxLines { get; set; } + + /// + /// Discount which will be applied to the line item or the overall order. A draft order line_item can have one discount. A draft order can have one order-level discount. + /// + [JsonProperty("applied_discount")] + public AppliedDiscount AppliedDiscount { get; set; } + + /// + /// States whether or not taxes are included in the order subtotal. + /// + [JsonProperty("taxes_included")] + public bool? TaxesIncluded { get; set; } + + /// + /// The sum of all the taxes applied to the order (must be positive). + /// + [JsonProperty("total_tax")] + public decimal? TotalTax { get; set; } + + /// + /// Price of the order before shipping and taxes + /// + [JsonProperty("subtotal_price")] + public decimal? SubtotalPrice { get; set; } + + /// + /// The sum of all the prices of all the items in the order, taxes and discounts included (must be positive). + /// + [JsonProperty("total_price")] + public decimal? TotalPrice { get; set; } + + /// + /// Date at which order is created and the draft order changes to completed status. The API returns this value in ISO 8601 format. + /// + [JsonProperty("completed_at")] + public DateTimeOffset? CompletedAt { get; set; } + + /// + /// This auto-generated property is the date and time when the draft order was created in Shopify, in ISO 8601 format. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// The date and time when the order was last modified. The API returns this value in ISO 8601 format. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } + + /// + /// Once a draft order is set to status completed the only further draft order modifications that can be made are adding tags or metafields. No other draft order actions are permitted. + /// Known values are "open", "invoice_sent", and "completed". + /// + [JsonProperty("status")] + public string Status { get; set; } + + /// + /// Additional metadata about the . Note: This is not naturally returned with a response, as + /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . + /// Uses include: Creating, updating, & deserializing webhook bodies that include them. + /// + [JsonProperty("metafields")] + public IEnumerable Metafields { get; set; } + + /// + /// An optional boolean that you can send as part of a draft order object to load customer shipping information. + /// + [JsonProperty("use_customer_default_address")] + public bool? UseCustomerDefaultAddress { get; set; } + + /// + /// The terms and conditions under which a payment should be processed. + /// + [JsonProperty("payment_terms")] + public PaymentTerms PaymentTerms { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/DraftOrderInvoice.cs b/ShopifySharp/Entities/DraftOrderInvoice.cs index 199fea26..9b23a70e 100644 --- a/ShopifySharp/Entities/DraftOrderInvoice.cs +++ b/ShopifySharp/Entities/DraftOrderInvoice.cs @@ -1,23 +1,22 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class DraftOrderInvoice : Parameterizable { - public class DraftOrderInvoice : Parameterizable - { - [JsonProperty("to")] - public string To { get; set; } + [JsonProperty("to")] + public string To { get; set; } - [JsonProperty("from")] - public string From { get; set; } + [JsonProperty("from")] + public string From { get; set; } - [JsonProperty("bcc")] - public IEnumerable BCC { get; set; } + [JsonProperty("bcc")] + public IEnumerable BCC { get; set; } - [JsonProperty("subject")] - public string Subject { get; set; } + [JsonProperty("subject")] + public string Subject { get; set; } - [JsonProperty("custom_message")] - public string CustomMessage { get; set; } - } + [JsonProperty("custom_message")] + public string CustomMessage { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/DraftShippingLine.cs b/ShopifySharp/Entities/DraftShippingLine.cs index c5d4386a..bc57fdb7 100644 --- a/ShopifySharp/Entities/DraftShippingLine.cs +++ b/ShopifySharp/Entities/DraftShippingLine.cs @@ -1,31 +1,30 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class DraftShippingLine { - public class DraftShippingLine - { - /// - /// Whether this is a regular shipping line or custom shipping line. - /// - [JsonProperty("custom")] - public bool? Custom { get; set; } + /// + /// Whether this is a regular shipping line or custom shipping line. + /// + [JsonProperty("custom")] + public bool? Custom { get; set; } - /// - /// The handle of the shipping rate which was selected and applied. Required for regular shipping lines. - /// - [JsonProperty("handle")] - public string Handle { get; set; } + /// + /// The handle of the shipping rate which was selected and applied. Required for regular shipping lines. + /// + [JsonProperty("handle")] + public string Handle { get; set; } - /// - /// The title of the shipping method. Required for custom shipping lines. (maximum: 255 characters) - /// - [JsonProperty("title")] - public string Title { get; set; } + /// + /// The title of the shipping method. Required for custom shipping lines. (maximum: 255 characters) + /// + [JsonProperty("title")] + public string Title { get; set; } - /// - /// The price of the shipping method. Required for custom shipping lines. - /// - [JsonProperty("price")] - public decimal? Price { get; set; } - } + /// + /// The price of the shipping method. Required for custom shipping lines. + /// + [JsonProperty("price")] + public decimal? Price { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/Event.cs b/ShopifySharp/Entities/Event.cs index 5116da4f..b9032432 100644 --- a/ShopifySharp/Entities/Event.cs +++ b/ShopifySharp/Entities/Event.cs @@ -2,65 +2,64 @@ using System; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify event. +/// +public class Event : ShopifyObject { /// - /// An object representing a Shopify event. + /// Refers to a certain event and its resources. /// - public class Event : ShopifyObject - { - /// - /// Refers to a certain event and its resources. - /// - [JsonProperty("arguments")] - public IEnumerable Arguments { get; set; } + [JsonProperty("arguments")] + public IEnumerable Arguments { get; set; } - /// - /// A text field containing information about the event. - /// - [JsonProperty("body")] - public string Body { get; set; } + /// + /// A text field containing information about the event. + /// + [JsonProperty("body")] + public string Body { get; set; } - /// - /// The date and time when the event was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + /// + /// The date and time when the event was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - /// - /// A relative URL to the resource the event is for (may be null) - /// - [JsonProperty("path")] - public string Path { get; set; } + /// + /// A relative URL to the resource the event is for (may be null) + /// + [JsonProperty("path")] + public string Path { get; set; } - /// - /// Human readable text that describes the event (may contain limited HTML formatting). - /// - [JsonProperty("message")] - public string Message { get; set; } + /// + /// Human readable text that describes the event (may contain limited HTML formatting). + /// + [JsonProperty("message")] + public string Message { get; set; } - /// - /// The id of the resource that generated the event. - /// - [JsonProperty("subject_id")] - public long? SubjectId { get; set; } + /// + /// The id of the resource that generated the event. + /// + [JsonProperty("subject_id")] + public long? SubjectId { get; set; } - /// - /// The type of the resource that generated the event. - /// - [JsonProperty("subject_type")] - public string SubjectType { get; set; } + /// + /// The type of the resource that generated the event. + /// + [JsonProperty("subject_type")] + public string SubjectType { get; set; } - /// - /// The type of event that took place. - /// - [JsonProperty("verb")] - public string Verb { get; set; } + /// + /// The type of event that took place. + /// + [JsonProperty("verb")] + public string Verb { get; set; } - /// - /// Undocumented by Shopify - /// - [JsonProperty("author")] - public string Author { get; set; } - } -} + /// + /// Undocumented by Shopify + /// + [JsonProperty("author")] + public string Author { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/Fulfillment.cs b/ShopifySharp/Entities/Fulfillment.cs index 0750c398..6fea22f9 100644 --- a/ShopifySharp/Entities/Fulfillment.cs +++ b/ShopifySharp/Entities/Fulfillment.cs @@ -2,135 +2,134 @@ using System; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify fulfillment. +/// +public class Fulfillment : ShopifyObject { /// - /// An object representing a Shopify fulfillment. - /// - public class Fulfillment : ShopifyObject - { - /// - /// The date and time when the fulfillment was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// A historical record of each item in the fulfillment. - /// - [JsonProperty("line_items")] - public IEnumerable LineItems { get; set; } - - /// - /// The unique numeric identifier for the order. - /// - [JsonProperty("order_id")] - public long? OrderId { get; set; } - - /// - /// A textfield with information about the receipt. - /// - [JsonProperty("receipt")] - public object Receipt { get; set; } - - /// - /// The status of the fulfillment. Valid values are 'pending', 'open', 'success', 'cancelled', - /// 'error' and 'failure'. - /// - [JsonProperty("status")] - public string Status { get; set; } - - /// - /// The unique identifier of the location that the fulfillment should be processed for. - /// - [JsonProperty("location_id")] - public long? LocationId { get; set; } - - - /// - /// This property is undocumented by Shopify. It appears to be the customer's email address - /// - [JsonProperty("email")] - public string Email { get; set; } - - /// - /// A flag indicating whether the customer should be notified. If set to true, an email will be - /// sent when the fulfillment is created or updated. The default value is false for fulfillments - /// on any orders created initially through the API. For all other orders, the default value is true. - /// - [JsonProperty("notify_customer")] - public bool? NotifyCustomer { get; set; } - - - /// - /// This property is undocumented by Shopify. It appears to be the shipping address of the order - /// - [JsonProperty("destination")] - public Address Destination { get; set; } - - /// - /// The name of the shipping company. - /// - [JsonProperty("tracking_company")] - public string TrackingCompany { get; set; } - - /// - /// The shipping number, provided by the shipping company. If multiple tracking numbers - /// exist (), returns the first number. - /// - [JsonProperty("tracking_number")] - public string TrackingNumber { get; set; } - - /// - /// A list of shipping numbers, provided by the shipping company. May be null. - /// - [JsonProperty("tracking_numbers")] - public IEnumerable TrackingNumbers { get; set; } - - /// - /// The tracking url, provided by the shipping company. May be null. If multiple tracking URLs - /// exist (), returns the first URL. - /// - [JsonProperty("tracking_url")] - public string TrackingUrl { get; set; } - - /// - /// An array of one or more tracking urls, provided by the shipping company. May be null. - /// - [JsonProperty("tracking_urls")] - public IEnumerable TrackingUrls { get; set; } - - /// - /// The date and time when the fulfillment was last modified. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - - /// - /// States the name of the inventory management service. - /// - [JsonProperty("variant_inventory_management")] - public string VariantInventoryManagement { get; set; } - - /// - /// This property is undocumented by Shopify. - /// - [JsonProperty("service")] - public string Service { get; set; } - - /// - /// This property is undocumented by Shopify. - /// - [JsonProperty("shipment_status")] - public string ShipmentStatus { get; set; } - - [JsonProperty("name")] - public string Name { get; set; } - - /// - /// The address of the fulfillment location. - /// - [JsonProperty("origin_address")] - public FulfillmentOriginAddress OriginAddress { get; set; } - } -} + /// The date and time when the fulfillment was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// A historical record of each item in the fulfillment. + /// + [JsonProperty("line_items")] + public IEnumerable LineItems { get; set; } + + /// + /// The unique numeric identifier for the order. + /// + [JsonProperty("order_id")] + public long? OrderId { get; set; } + + /// + /// A textfield with information about the receipt. + /// + [JsonProperty("receipt")] + public object Receipt { get; set; } + + /// + /// The status of the fulfillment. Valid values are 'pending', 'open', 'success', 'cancelled', + /// 'error' and 'failure'. + /// + [JsonProperty("status")] + public string Status { get; set; } + + /// + /// The unique identifier of the location that the fulfillment should be processed for. + /// + [JsonProperty("location_id")] + public long? LocationId { get; set; } + + + /// + /// This property is undocumented by Shopify. It appears to be the customer's email address + /// + [JsonProperty("email")] + public string Email { get; set; } + + /// + /// A flag indicating whether the customer should be notified. If set to true, an email will be + /// sent when the fulfillment is created or updated. The default value is false for fulfillments + /// on any orders created initially through the API. For all other orders, the default value is true. + /// + [JsonProperty("notify_customer")] + public bool? NotifyCustomer { get; set; } + + + /// + /// This property is undocumented by Shopify. It appears to be the shipping address of the order + /// + [JsonProperty("destination")] + public Address Destination { get; set; } + + /// + /// The name of the shipping company. + /// + [JsonProperty("tracking_company")] + public string TrackingCompany { get; set; } + + /// + /// The shipping number, provided by the shipping company. If multiple tracking numbers + /// exist (), returns the first number. + /// + [JsonProperty("tracking_number")] + public string TrackingNumber { get; set; } + + /// + /// A list of shipping numbers, provided by the shipping company. May be null. + /// + [JsonProperty("tracking_numbers")] + public IEnumerable TrackingNumbers { get; set; } + + /// + /// The tracking url, provided by the shipping company. May be null. If multiple tracking URLs + /// exist (), returns the first URL. + /// + [JsonProperty("tracking_url")] + public string TrackingUrl { get; set; } + + /// + /// An array of one or more tracking urls, provided by the shipping company. May be null. + /// + [JsonProperty("tracking_urls")] + public IEnumerable TrackingUrls { get; set; } + + /// + /// The date and time when the fulfillment was last modified. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } + + /// + /// States the name of the inventory management service. + /// + [JsonProperty("variant_inventory_management")] + public string VariantInventoryManagement { get; set; } + + /// + /// This property is undocumented by Shopify. + /// + [JsonProperty("service")] + public string Service { get; set; } + + /// + /// This property is undocumented by Shopify. + /// + [JsonProperty("shipment_status")] + public string ShipmentStatus { get; set; } + + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// The address of the fulfillment location. + /// + [JsonProperty("origin_address")] + public FulfillmentOriginAddress OriginAddress { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/FulfillmentEvent.cs b/ShopifySharp/Entities/FulfillmentEvent.cs index de57665c..7f1e4656 100644 --- a/ShopifySharp/Entities/FulfillmentEvent.cs +++ b/ShopifySharp/Entities/FulfillmentEvent.cs @@ -1,108 +1,107 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify fulfillment event. +/// +public class FulfillmentEvent : ShopifyObject { /// - /// An object representing a Shopify fulfillment event. - /// - public class FulfillmentEvent : ShopifyObject - { - /// - /// The date and time when the fulfillment event was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// The unique numeric identifier for the order. - /// - [JsonProperty("order_id")] - public long? OrderId { get; set; } - - /// - /// The unique numeric identifier for the shop. - /// - [JsonProperty("shop_id")] - public long? ShopId { get; set; } - - /// - /// The unique numeric identifier for the fulfillment. - /// - [JsonProperty("fulfillment_id")] - public long? FulfillmentId { get; set; } - - /// - /// The status of the fulfillment event. Valid values are 'confirmed', 'in_transit', - /// 'out_for_delivery', 'delivered' and 'failure' - /// - [JsonProperty("status")] - public string Status { get; set; } - - /// - /// The date and time when the fulfillment event occurred - /// - [JsonProperty("happened_at")] - public DateTimeOffset? HappenedAt { get; set; } - - /// - /// An arbitrary message describing the status. - /// - [JsonProperty("message")] - public string Message { get; set; } - - /// - /// The city in which the fulfillment event occurred. - /// - [JsonProperty("city")] - public string City { get; set; } - - /// - /// The province in which the fulfillment event occurred. - /// - [JsonProperty("province")] - public string Province { get; set; } - - /// - /// The zip code in the location in which the fulfillment event occurred. - /// - [JsonProperty("zip")] - public string Zip { get; set; } - - /// - /// The country in which the fulfillment event occurred. - /// - [JsonProperty("country")] - public string Country { get; set; } - - /// - /// The fulfillment event's street address. - /// - [JsonProperty("address1")] - public string Address1 { get; set; } - - /// - /// Geographic coordinate specifying the north/south location of a fulfillment event. - /// - [JsonProperty("latitude")] - public decimal? Latitude { get; set; } - - /// - /// Geographic coordinate specifying the east/west location of a fulfillment event. - /// - [JsonProperty("longitude")] - public decimal? Longitude { get; set; } - - /// - /// The estimated date of delivery. - /// - [JsonProperty("estimated_delivery_at")] - public DateTimeOffset? EstimatedDeliveryAt { get; set; } - - /// - /// The date and time when the fulfillment event was last modified. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - } -} + /// The date and time when the fulfillment event was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// The unique numeric identifier for the order. + /// + [JsonProperty("order_id")] + public long? OrderId { get; set; } + + /// + /// The unique numeric identifier for the shop. + /// + [JsonProperty("shop_id")] + public long? ShopId { get; set; } + + /// + /// The unique numeric identifier for the fulfillment. + /// + [JsonProperty("fulfillment_id")] + public long? FulfillmentId { get; set; } + + /// + /// The status of the fulfillment event. Valid values are 'confirmed', 'in_transit', + /// 'out_for_delivery', 'delivered' and 'failure' + /// + [JsonProperty("status")] + public string Status { get; set; } + + /// + /// The date and time when the fulfillment event occurred + /// + [JsonProperty("happened_at")] + public DateTimeOffset? HappenedAt { get; set; } + + /// + /// An arbitrary message describing the status. + /// + [JsonProperty("message")] + public string Message { get; set; } + + /// + /// The city in which the fulfillment event occurred. + /// + [JsonProperty("city")] + public string City { get; set; } + + /// + /// The province in which the fulfillment event occurred. + /// + [JsonProperty("province")] + public string Province { get; set; } + + /// + /// The zip code in the location in which the fulfillment event occurred. + /// + [JsonProperty("zip")] + public string Zip { get; set; } + + /// + /// The country in which the fulfillment event occurred. + /// + [JsonProperty("country")] + public string Country { get; set; } + + /// + /// The fulfillment event's street address. + /// + [JsonProperty("address1")] + public string Address1 { get; set; } + + /// + /// Geographic coordinate specifying the north/south location of a fulfillment event. + /// + [JsonProperty("latitude")] + public decimal? Latitude { get; set; } + + /// + /// Geographic coordinate specifying the east/west location of a fulfillment event. + /// + [JsonProperty("longitude")] + public decimal? Longitude { get; set; } + + /// + /// The estimated date of delivery. + /// + [JsonProperty("estimated_delivery_at")] + public DateTimeOffset? EstimatedDeliveryAt { get; set; } + + /// + /// The date and time when the fulfillment event was last modified. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/FulfillmentHold.cs b/ShopifySharp/Entities/FulfillmentHold.cs index 7c366843..94e29ee6 100644 --- a/ShopifySharp/Entities/FulfillmentHold.cs +++ b/ShopifySharp/Entities/FulfillmentHold.cs @@ -1,21 +1,20 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class FulfillmentHold { - public class FulfillmentHold - { - /// - /// A mandatory reason for the fulfillment hold. - /// awaiting_payment: The fulfillment hold is applied because payment is pending. - /// high_risk_of_fraud: The fulfillment hold is applied because of a high risk of fraud. - /// incorrect_address: The fulfillment hold is applied because of an incorrect address. - /// inventory_out_of_stock: The fulfillment hold is applied because inventory is out of stock. - /// other: The fulfillment hold is applied for any other reason. - /// - [JsonProperty("reason")] - public string Reason { get; set; } + /// + /// A mandatory reason for the fulfillment hold. + /// awaiting_payment: The fulfillment hold is applied because payment is pending. + /// high_risk_of_fraud: The fulfillment hold is applied because of a high risk of fraud. + /// incorrect_address: The fulfillment hold is applied because of an incorrect address. + /// inventory_out_of_stock: The fulfillment hold is applied because inventory is out of stock. + /// other: The fulfillment hold is applied for any other reason. + /// + [JsonProperty("reason")] + public string Reason { get; set; } - [JsonProperty("reason_notes")] - public string ReasonNotes { get; set; } - } + [JsonProperty("reason_notes")] + public string ReasonNotes { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/FulfillmentInternationalDuties.cs b/ShopifySharp/Entities/FulfillmentInternationalDuties.cs index 50521c68..f06e393b 100644 --- a/ShopifySharp/Entities/FulfillmentInternationalDuties.cs +++ b/ShopifySharp/Entities/FulfillmentInternationalDuties.cs @@ -1,16 +1,15 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class FulfillmentInternationalDuties { - public class FulfillmentInternationalDuties - { - /// - /// The method of duties payment. Valid values: - /// DAP: Delivered at place. - /// DDP: Delivered duty paid. - /// - [JsonProperty("incoterm")] - public string Incoterm { get; set; } + /// + /// The method of duties payment. Valid values: + /// DAP: Delivered at place. + /// DDP: Delivered duty paid. + /// + [JsonProperty("incoterm")] + public string Incoterm { get; set; } - } } \ No newline at end of file diff --git a/ShopifySharp/Entities/FulfillmentOrder.cs b/ShopifySharp/Entities/FulfillmentOrder.cs index 83f92a59..088e9528 100644 --- a/ShopifySharp/Entities/FulfillmentOrder.cs +++ b/ShopifySharp/Entities/FulfillmentOrder.cs @@ -2,126 +2,125 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify fulfillment order. +/// +public class FulfillmentOrder : ShopifyObject { /// - /// An object representing a Shopify fulfillment order. - /// - public class FulfillmentOrder : ShopifyObject - { - /// - /// The ID of the shop that's associated with the fulfillment order. - /// - [JsonProperty("shop_id")] - public long? ShopId { get; set; } - - /// - /// The ID of the order that's associated with the fulfillment order. - /// - [JsonProperty("order_id")] - public long? OrderId { get; set; } - - /// - /// The ID of the location that has been assigned to do the work. - /// - [JsonProperty("assigned_location_id")] - public long? AssignedLocationId { get; set; } - - /// - /// The status of the fulfillment order. - /// - [JsonProperty("request_status")] - public string RequestStatus { get; set; } - - /// - /// "open". - /// - [JsonProperty("status")] - public string Status { get; set; } - - /// - /// Destination for the fulfillment. - /// - [JsonProperty("destination")] - public FulfillmentOrderDestination FulfillmentOrderDestination { get; set; } - - /// - /// Represents line items belonging to a fulfillment order: - /// - [JsonProperty("line_items")] - public IEnumerable FulfillmentOrderLineItems { get; set; } - - /// - /// Followings actions can be performed on this fulfillment order. - ///
create_fulfillment
- ///
request_fulfillment
- ///
cancel_fulfillment_order
- ///
request_cancellation
- ///
- [JsonProperty("supported_actions")] - public IEnumerable SupportedActions { get; set; } - - /// - /// Followings actions can be performed on this fulfillment order. - /// - [JsonProperty("outgoing_requests")] - public IEnumerable OutgoingRequests { get; set; } - - /// - /// A list of requests sent by the merchant to the fulfillment service for this fulfillment order. - /// - [JsonProperty("merchant_requests")] - public IEnumerable MerchantRequests { get; set; } - - /// - /// The fulfillment order's assigned location - /// - [JsonProperty("assigned_location")] - public AssignedLocation AssignedLocation { get; set; } - - /// - /// The type of method used to transfer a product or service to a customer - /// - [JsonProperty("delivery_method")] - public DeliveryMethod DeliveryMethod { get; set; } - - /// - /// The datetime (in UTC) when the fulfillment order is ready for fulfillment. When this datetime is reached, a scheduled fulfillment - /// order is automatically transitioned to open. For more information about fulfillment statuses, refer to the status property. - /// - [JsonProperty("fulfill_at")] - public DateTimeOffset? FulfillAt { get; set; } - - /// - /// The latest date and time by which all items in the fulfillment order need to be fulfilled. - /// - [JsonProperty("fulfill_by")] - public DateTimeOffset? FulfilledBy { get; set; } - - /// - /// A list of requests sent by the merchant to the fulfillment service for this fulfillment order. - /// - [JsonProperty("fulfillment_holds")] - public IEnumerable FulfillmentHolds { get; set; } - - /// - /// The international duties relevant to the fulfillment order. The method of duties payment.Valid values: - ///
DAP: Delivered at place.
- ///
DDP: Delivered duty paid.
- ///
- [JsonProperty("international_duties")] - public FulfillmentInternationalDuties InternationalDuties { get; set; } + /// The ID of the shop that's associated with the fulfillment order. + /// + [JsonProperty("shop_id")] + public long? ShopId { get; set; } + + /// + /// The ID of the order that's associated with the fulfillment order. + /// + [JsonProperty("order_id")] + public long? OrderId { get; set; } + + /// + /// The ID of the location that has been assigned to do the work. + /// + [JsonProperty("assigned_location_id")] + public long? AssignedLocationId { get; set; } + + /// + /// The status of the fulfillment order. + /// + [JsonProperty("request_status")] + public string RequestStatus { get; set; } + + /// + /// "open". + /// + [JsonProperty("status")] + public string Status { get; set; } + + /// + /// Destination for the fulfillment. + /// + [JsonProperty("destination")] + public FulfillmentOrderDestination FulfillmentOrderDestination { get; set; } + + /// + /// Represents line items belonging to a fulfillment order: + /// + [JsonProperty("line_items")] + public IEnumerable FulfillmentOrderLineItems { get; set; } + + /// + /// Followings actions can be performed on this fulfillment order. + ///
create_fulfillment
+ ///
request_fulfillment
+ ///
cancel_fulfillment_order
+ ///
request_cancellation
+ ///
+ [JsonProperty("supported_actions")] + public IEnumerable SupportedActions { get; set; } + + /// + /// Followings actions can be performed on this fulfillment order. + /// + [JsonProperty("outgoing_requests")] + public IEnumerable OutgoingRequests { get; set; } + + /// + /// A list of requests sent by the merchant to the fulfillment service for this fulfillment order. + /// + [JsonProperty("merchant_requests")] + public IEnumerable MerchantRequests { get; set; } + + /// + /// The fulfillment order's assigned location + /// + [JsonProperty("assigned_location")] + public AssignedLocation AssignedLocation { get; set; } + + /// + /// The type of method used to transfer a product or service to a customer + /// + [JsonProperty("delivery_method")] + public DeliveryMethod DeliveryMethod { get; set; } + + /// + /// The datetime (in UTC) when the fulfillment order is ready for fulfillment. When this datetime is reached, a scheduled fulfillment + /// order is automatically transitioned to open. For more information about fulfillment statuses, refer to the status property. + /// + [JsonProperty("fulfill_at")] + public DateTimeOffset? FulfillAt { get; set; } + + /// + /// The latest date and time by which all items in the fulfillment order need to be fulfilled. + /// + [JsonProperty("fulfill_by")] + public DateTimeOffset? FulfilledBy { get; set; } + + /// + /// A list of requests sent by the merchant to the fulfillment service for this fulfillment order. + /// + [JsonProperty("fulfillment_holds")] + public IEnumerable FulfillmentHolds { get; set; } + + /// + /// The international duties relevant to the fulfillment order. The method of duties payment.Valid values: + ///
DAP: Delivered at place.
+ ///
DDP: Delivered duty paid.
+ ///
+ [JsonProperty("international_duties")] + public FulfillmentInternationalDuties InternationalDuties { get; set; } - /// - /// The date and time when the fulfillment order was created in Shopify. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// The date and time when the fulfillment order was last modified. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - } -} + /// + /// The date and time when the fulfillment order was created in Shopify. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// The date and time when the fulfillment order was last modified. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/FulfillmentOrderDestination.cs b/ShopifySharp/Entities/FulfillmentOrderDestination.cs index 5cdb10d9..3f941971 100644 --- a/ShopifySharp/Entities/FulfillmentOrderDestination.cs +++ b/ShopifySharp/Entities/FulfillmentOrderDestination.cs @@ -1,73 +1,72 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class FulfillmentOrderDestination : ShopifyObject { - public class FulfillmentOrderDestination : ShopifyObject - { - /// - /// The street address of the assigned location. - /// - [JsonProperty("address1")] - public string Address1 { get; set; } + /// + /// The street address of the assigned location. + /// + [JsonProperty("address1")] + public string Address1 { get; set; } - /// - /// An optional additional field for the street address of the assigned location. - /// - [JsonProperty("address2")] - public string Address2 { get; set; } + /// + /// An optional additional field for the street address of the assigned location. + /// + [JsonProperty("address2")] + public string Address2 { get; set; } - /// - /// The city of the destination. - /// - [JsonProperty("city")] - public string City { get; set; } + /// + /// The city of the destination. + /// + [JsonProperty("city")] + public string City { get; set; } - /// - /// The company of the destination. - /// - [JsonProperty("company")] - public string Company { get; set; } + /// + /// The company of the destination. + /// + [JsonProperty("company")] + public string Company { get; set; } - /// - /// The country of the destination. - /// - [JsonProperty("country")] - public string Country { get; set; } + /// + /// The country of the destination. + /// + [JsonProperty("country")] + public string Country { get; set; } - /// - /// The email of the customer at the destination. - /// - [JsonProperty("email")] - public string Email { get; set; } + /// + /// The email of the customer at the destination. + /// + [JsonProperty("email")] + public string Email { get; set; } - /// - /// The first name of the customer at the destination. - /// - [JsonProperty("first_name")] - public string FirstName { get; set; } + /// + /// The first name of the customer at the destination. + /// + [JsonProperty("first_name")] + public string FirstName { get; set; } - /// - /// The last name of the customer at the destination. - /// - [JsonProperty("last_name")] - public string LastName { get; set; } + /// + /// The last name of the customer at the destination. + /// + [JsonProperty("last_name")] + public string LastName { get; set; } - /// - /// The phone number of the customer at the destination. - /// - [JsonProperty("phone")] - public string Phone { get; set; } + /// + /// The phone number of the customer at the destination. + /// + [JsonProperty("phone")] + public string Phone { get; set; } - /// - /// The province of the destination. - /// - [JsonProperty("province")] - public string Province { get; set; } + /// + /// The province of the destination. + /// + [JsonProperty("province")] + public string Province { get; set; } - /// - /// The ZIP code of the destination. - /// - [JsonProperty("zip")] - public string Zip { get; set; } - } -} + /// + /// The ZIP code of the destination. + /// + [JsonProperty("zip")] + public string Zip { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/FulfillmentOrderLineItem.cs b/ShopifySharp/Entities/FulfillmentOrderLineItem.cs index 4e7b8faa..214ba699 100644 --- a/ShopifySharp/Entities/FulfillmentOrderLineItem.cs +++ b/ShopifySharp/Entities/FulfillmentOrderLineItem.cs @@ -1,51 +1,50 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class FulfillmentOrderLineItem : ShopifyObject { - public class FulfillmentOrderLineItem : ShopifyObject - { - /// - /// The ID of the shop associated with the fulfillment order line item. - /// - [JsonProperty("shop_id")] - public long? ShopId { get; set; } - - /// - /// The ID of the fulfillment order associated with this line item. - /// - [JsonProperty("fulfillment_order_id")] - public long? FulfillmentOrderId { get; set; } - - /// - /// The ID of the line item associated with this fulfillment order line item. - /// Note: this is **not** what should be used as the value for ; - /// for that, you'll want to use . - /// - [JsonProperty("line_item_id")] - public long? LineItemId { get; set; } - - /// - /// The ID of the inventory item associated with this fulfillment order line item. - /// - [JsonProperty("inventory_item_id")] - public long? InventoryItemId { get; set; } - - /// - /// The total number of units to be fulfilled. - /// - [JsonProperty("quantity")] - public long? Quantity { get; set; } - - /// - /// The number of units remaining to be fulfilled. - /// - [JsonProperty("fulfillable_quantity")] - public long? FulfillableQuantity { get; set; } - - /// - /// The ID of the variant associated with this fulfillment order line item. - /// - [JsonProperty("variant_id")] - public long? VariantId { get; set; } - } -} + /// + /// The ID of the shop associated with the fulfillment order line item. + /// + [JsonProperty("shop_id")] + public long? ShopId { get; set; } + + /// + /// The ID of the fulfillment order associated with this line item. + /// + [JsonProperty("fulfillment_order_id")] + public long? FulfillmentOrderId { get; set; } + + /// + /// The ID of the line item associated with this fulfillment order line item. + /// Note: this is **not** what should be used as the value for ; + /// for that, you'll want to use . + /// + [JsonProperty("line_item_id")] + public long? LineItemId { get; set; } + + /// + /// The ID of the inventory item associated with this fulfillment order line item. + /// + [JsonProperty("inventory_item_id")] + public long? InventoryItemId { get; set; } + + /// + /// The total number of units to be fulfilled. + /// + [JsonProperty("quantity")] + public long? Quantity { get; set; } + + /// + /// The number of units remaining to be fulfilled. + /// + [JsonProperty("fulfillable_quantity")] + public long? FulfillableQuantity { get; set; } + + /// + /// The ID of the variant associated with this fulfillment order line item. + /// + [JsonProperty("variant_id")] + public long? VariantId { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/FulfillmentOrderMove.cs b/ShopifySharp/Entities/FulfillmentOrderMove.cs index 35bbc695..189789da 100644 --- a/ShopifySharp/Entities/FulfillmentOrderMove.cs +++ b/ShopifySharp/Entities/FulfillmentOrderMove.cs @@ -1,29 +1,28 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// Fulfillment Order Move object +/// +public class FulfillmentOrderMove { /// - /// Fulfillment Order Move object + /// Original fulfillment order /// - public class FulfillmentOrderMove - { - /// - /// Original fulfillment order - /// - [JsonProperty("original_fulfillment_order")] - public FulfillmentOrder OriginalFulfillmentOrder { get; set; } + [JsonProperty("original_fulfillment_order")] + public FulfillmentOrder OriginalFulfillmentOrder { get; set; } - /// - /// Moved fulfillment order - /// - [JsonProperty("moved_fulfillment_order")] - public FulfillmentOrder MovedFulfillmentOrder { get; set; } + /// + /// Moved fulfillment order + /// + [JsonProperty("moved_fulfillment_order")] + public FulfillmentOrder MovedFulfillmentOrder { get; set; } - /// - /// Remaining fulfillment order if anything remains. - /// - [JsonProperty("remaining_fulfillment_order")] - public FulfillmentOrder RemainingFulfillmentOrder { get; set; } + /// + /// Remaining fulfillment order if anything remains. + /// + [JsonProperty("remaining_fulfillment_order")] + public FulfillmentOrder RemainingFulfillmentOrder { get; set; } - } -} +} \ No newline at end of file diff --git a/ShopifySharp/Entities/FulfillmentOriginAddress.cs b/ShopifySharp/Entities/FulfillmentOriginAddress.cs index 5c835f2d..0a0cda1c 100644 --- a/ShopifySharp/Entities/FulfillmentOriginAddress.cs +++ b/ShopifySharp/Entities/FulfillmentOriginAddress.cs @@ -1,43 +1,42 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class FulfillmentOriginAddress { - public class FulfillmentOriginAddress - { - /// - /// The street address of the fulfillment location. - /// - [JsonProperty("address1")] - public string Address1 { get; set; } + /// + /// The street address of the fulfillment location. + /// + [JsonProperty("address1")] + public string Address1 { get; set; } - /// - /// The second line of the address. Typically the number of the apartment, suite, or unit. - /// - [JsonProperty("address2")] - public string Address2 { get; set; } + /// + /// The second line of the address. Typically the number of the apartment, suite, or unit. + /// + [JsonProperty("address2")] + public string Address2 { get; set; } - /// - /// The city of the fulfillment location. - /// - [JsonProperty("city")] - public string City { get; set; } + /// + /// The city of the fulfillment location. + /// + [JsonProperty("city")] + public string City { get; set; } - /// - /// (Required) The two-letter country code (ISO 3166-1 alpha-2 format) of the fulfillment location. - /// - [JsonProperty("country_code")] - public string CountryCode { get; set; } + /// + /// (Required) The two-letter country code (ISO 3166-1 alpha-2 format) of the fulfillment location. + /// + [JsonProperty("country_code")] + public string CountryCode { get; set; } - /// - /// The province of the fulfillment location. - /// - [JsonProperty("province_code")] - public string ProvinceCode { get; set; } + /// + /// The province of the fulfillment location. + /// + [JsonProperty("province_code")] + public string ProvinceCode { get; set; } - /// - /// The zip code of the fulfillment location. - /// - [JsonProperty("zip")] - public string Zip { get; set; } - } + /// + /// The zip code of the fulfillment location. + /// + [JsonProperty("zip")] + public string Zip { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/FulfillmentRequest.cs b/ShopifySharp/Entities/FulfillmentRequest.cs index 6bc5745f..d1f6f0ec 100644 --- a/ShopifySharp/Entities/FulfillmentRequest.cs +++ b/ShopifySharp/Entities/FulfillmentRequest.cs @@ -1,23 +1,22 @@ using Newtonsoft.Json; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify fulfillment request. +/// +public class FulfillmentRequest { /// - /// An object representing a Shopify fulfillment request. + /// An optional message for the fulfillment request. /// - public class FulfillmentRequest - { - /// - /// An optional message for the fulfillment request. - /// - [JsonProperty("message")] - public string Message { get; set; } + [JsonProperty("message")] + public string Message { get; set; } - /// - /// The fulfillment order line items to be requested for fulfillment. If left blank, all line items of the fulfillment order are requested for fulfillment. - /// - [JsonProperty("fulfillment_order_line_items")] - public IEnumerable FulfillmentRequestOrderLineItems { get; set; } - } + /// + /// The fulfillment order line items to be requested for fulfillment. If left blank, all line items of the fulfillment order are requested for fulfillment. + /// + [JsonProperty("fulfillment_order_line_items")] + public IEnumerable FulfillmentRequestOrderLineItems { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/FulfillmentRequestOrderLineItem.cs b/ShopifySharp/Entities/FulfillmentRequestOrderLineItem.cs index e06a861f..34792589 100644 --- a/ShopifySharp/Entities/FulfillmentRequestOrderLineItem.cs +++ b/ShopifySharp/Entities/FulfillmentRequestOrderLineItem.cs @@ -1,24 +1,23 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify fulfillment request order line items. +/// +public class FulfillmentRequestOrderLineItem : ShopifyObject { /// - /// An object representing a Shopify fulfillment request order line items. + /// The id of the fulfillment order line item being fulfilled. This is **not** the same as ; + /// instead, Shopify expects the value of . /// - public class FulfillmentRequestOrderLineItem : ShopifyObject - { - /// - /// The id of the fulfillment order line item being fulfilled. This is **not** the same as ; - /// instead, Shopify expects the value of . - /// - [JsonProperty("id")] - public new long? Id { get; set; } + [JsonProperty("id")] + public new long? Id { get; set; } - /// - /// The total number of units to be fulfilled. - /// - [JsonProperty("quantity")] - public long? Quantity { get; set; } + /// + /// The total number of units to be fulfilled. + /// + [JsonProperty("quantity")] + public long? Quantity { get; set; } - } -} +} \ No newline at end of file diff --git a/ShopifySharp/Entities/FulfillmentServiceEntity.cs b/ShopifySharp/Entities/FulfillmentServiceEntity.cs index 167218d9..fa3da97a 100644 --- a/ShopifySharp/Entities/FulfillmentServiceEntity.cs +++ b/ShopifySharp/Entities/FulfillmentServiceEntity.cs @@ -1,98 +1,97 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify fulfillment service. +/// +public class FulfillmentServiceEntity : ShopifyObject { /// - /// An object representing a Shopify fulfillment service. + /// The name of the fulfillment service as seen by merchants and their customers. /// - public class FulfillmentServiceEntity : ShopifyObject - { - /// - /// The name of the fulfillment service as seen by merchants and their customers. - /// - [JsonProperty("name")] - public string Name { get; set; } + [JsonProperty("name")] + public string Name { get; set; } - /// - /// States the URL endpoint that Shopify needs to retrieve inventory and tracking updates. - /// This field is necessary if either inventory_management or tracking_support is set to "true". - /// - [JsonProperty("callback_url")] - public string CallbackUrl { get; set; } + /// + /// States the URL endpoint that Shopify needs to retrieve inventory and tracking updates. + /// This field is necessary if either inventory_management or tracking_support is set to "true". + /// + [JsonProperty("callback_url")] + public string CallbackUrl { get; set; } - /// - /// Specifies the format of the API output. Valid values are "json" and "xml". - /// - [JsonProperty("format")] - public string Format { get; set; } + /// + /// Specifies the format of the API output. Valid values are "json" and "xml". + /// + [JsonProperty("format")] + public string Format { get; set; } - /// - /// A human-friendly unique string for the fulfillment service generated from its title. - /// - [JsonProperty("handle")] - public string Handle { get; set; } + /// + /// A human-friendly unique string for the fulfillment service generated from its title. + /// + [JsonProperty("handle")] + public string Handle { get; set; } - /// - /// States if the fulfillment service tracks product inventory and provides updates to Shopify. - /// - [JsonProperty("inventory_management")] - public bool? InventoryManagement { get; set; } + /// + /// States if the fulfillment service tracks product inventory and provides updates to Shopify. + /// + [JsonProperty("inventory_management")] + public bool? InventoryManagement { get; set; } - /// - /// The unique identifier of the location tied to the fulfillment service - /// - [JsonProperty("location_id")] - public long? LocationId { get; set; } + /// + /// The unique identifier of the location tied to the fulfillment service + /// + [JsonProperty("location_id")] + public long? LocationId { get; set; } - /// - /// A unique identifier for the fulfillment service provider. - /// - [JsonProperty("provider_id")] - public string ProviderId { get; set; } + /// + /// A unique identifier for the fulfillment service provider. + /// + [JsonProperty("provider_id")] + public string ProviderId { get; set; } - /// - /// States if the fulfillment service requires products to be physically shipped. - /// - [JsonProperty("requires_shipping_method")] - public bool? RequiresShippingMethod { get; set; } + /// + /// States if the fulfillment service requires products to be physically shipped. + /// + [JsonProperty("requires_shipping_method")] + public bool? RequiresShippingMethod { get; set; } - /// - /// States if the fulfillment service allows products to have more than 1 shipping location - /// - [JsonProperty("permits_sku_sharing")] - public bool? PermitsSkuSharing { get; set; } + /// + /// States if the fulfillment service allows products to have more than 1 shipping location + /// + [JsonProperty("permits_sku_sharing")] + public bool? PermitsSkuSharing { get; set; } - /// - /// States if the fulfillment service provides tracking numbers for packages. - /// - [JsonProperty("tracking_support")] - public bool? TrackingSupport { get; set; } + /// + /// States if the fulfillment service provides tracking numbers for packages. + /// + [JsonProperty("tracking_support")] + public bool? TrackingSupport { get; set; } - /// - /// This property is undocumented by Shopify. - /// - [JsonProperty("email")] - public string Email { get; set; } + /// + /// This property is undocumented by Shopify. + /// + [JsonProperty("email")] + public string Email { get; set; } - /// - /// This property is undocumented by Shopify. - /// - [JsonProperty("include_pending_stock")] - public bool? IncludePendingStock { get; set; } + /// + /// This property is undocumented by Shopify. + /// + [JsonProperty("include_pending_stock")] + public bool? IncludePendingStock { get; set; } - /// - /// This property is undocumented by Shopify. - /// - [JsonProperty("service_name")] - public string ServiceName { get; set; } + /// + /// This property is undocumented by Shopify. + /// + [JsonProperty("service_name")] + public string ServiceName { get; set; } - /// - /// Whether the fulfillment service wants to register for APIs related to fulfillment orders. - /// - [JsonProperty("fulfillment_orders_opt_in")] - [Obsolete("https://shopify.dev/changelog/deprecation-of-the-fulfillmentservice-fulfillmentordersoptin-field")] - public bool? FulfillmentOrdersOptIn { get; set; } - } + /// + /// Whether the fulfillment service wants to register for APIs related to fulfillment orders. + /// + [JsonProperty("fulfillment_orders_opt_in")] + [Obsolete("https://shopify.dev/changelog/deprecation-of-the-fulfillmentservice-fulfillmentordersoptin-field")] + public bool? FulfillmentOrdersOptIn { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/FulfillmentShipping.cs b/ShopifySharp/Entities/FulfillmentShipping.cs index de334cf3..6e96b5e8 100644 --- a/ShopifySharp/Entities/FulfillmentShipping.cs +++ b/ShopifySharp/Entities/FulfillmentShipping.cs @@ -1,43 +1,42 @@ using Newtonsoft.Json; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing Shopify fulfillment shipping options. +/// +public class FulfillmentShipping { /// - /// An object representing Shopify fulfillment shipping options. + /// An optional message for the fulfillment request. /// - public class FulfillmentShipping - { - /// - /// An optional message for the fulfillment request. - /// - [JsonProperty("message")] - public string Message { get; set; } + [JsonProperty("message")] + public string Message { get; set; } - /// - /// A flag indicating whether the customer should be notified. If set to true, an email will be - /// sent when the fulfillment is created or updated. The default value is false for fulfillments - /// on any orders created initially through the API. For all other orders, the default value is true. - /// - [JsonProperty("notify_customer")] - public bool? NotifyCustomer { get; set; } + /// + /// A flag indicating whether the customer should be notified. If set to true, an email will be + /// sent when the fulfillment is created or updated. The default value is false for fulfillments + /// on any orders created initially through the API. For all other orders, the default value is true. + /// + [JsonProperty("notify_customer")] + public bool? NotifyCustomer { get; set; } - /// - /// If applicable tracking details for the package. - /// - [JsonProperty("tracking_info")] - public TrackingInfo TrackingInfo { get; set; } + /// + /// If applicable tracking details for the package. + /// + [JsonProperty("tracking_info")] + public TrackingInfo TrackingInfo { get; set; } - /// - /// The address of the fulfillment location. - /// - [JsonProperty("origin_address")] - public FulfillmentOriginAddress OriginAddress { get; set; } + /// + /// The address of the fulfillment location. + /// + [JsonProperty("origin_address")] + public FulfillmentOriginAddress OriginAddress { get; set; } - /// - /// The fulfillment order line items that have to be fulfilled. - /// - [JsonProperty("line_items_by_fulfillment_order")] - public IEnumerable FulfillmentRequestOrderLineItems { get; set; } - } -} + /// + /// The fulfillment order line items that have to be fulfilled. + /// + [JsonProperty("line_items_by_fulfillment_order")] + public IEnumerable FulfillmentRequestOrderLineItems { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/GiftCard.cs b/ShopifySharp/Entities/GiftCard.cs index 8d5e7850..36fe5ee0 100644 --- a/ShopifySharp/Entities/GiftCard.cs +++ b/ShopifySharp/Entities/GiftCard.cs @@ -1,110 +1,109 @@ -using System; +using System; using Newtonsoft.Json; using ShopifySharp.Converters; -namespace ShopifySharp +namespace ShopifySharp; + +public class GiftCard : ShopifyObject { - public class GiftCard : ShopifyObject - { - /// - /// Returns the amount of money remaining on the gift card. - /// - [JsonProperty("balance")] - public decimal? Balance { get; set; } - - /// - /// The date and time when the gift card was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// The date and time when the gift card was updated. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - - /// - /// The three letter code (ISO 4217) for the currency used for the gift card. - /// - [JsonProperty("currency")] - public string Currency { get; set; } - - /// - /// Returns the initial amount of money on the gift card. - /// - [JsonProperty("initial_value")] - public decimal? InitialValue { get; set; } - - /// - /// The date and time when the gift card was disabled. - /// - [JsonProperty("disabled_at")] - public DateTimeOffset? DisabledAt { get; set; } - - /// - /// The date and time when the gift card will expire. - /// - [JsonProperty("expires_on")] - [JsonConverter(typeof(DateFormatConverter),"yyyy-MM-dd")] - public DateTimeOffset? ExpiresOn { get; set; } - - /// - /// A unique numeric identifier of the line_item that caused the creation of this gift card (if it was created by an order). - /// - [JsonProperty("line_item_id")] - public long? LineItemId { get; set; } - - - /// - /// A unique numeric identifier of the application that issued the gift card (if it was issued by an application). - /// - [JsonProperty("api_client_id")] - public long? ApiClientId { get; set; } - - - /// - /// A unique numeric identifier of the user that issued the gift card (if it was issued by a user). - /// - [JsonProperty("user_id")] - public long? UserId { get; set; } - - - /// - /// The id of a customer who is associated with this gift card. - /// - [JsonProperty("customer_id")] - public long? CustomerId { get; set; } - - - /// - /// The text of an optional note that a shop owner can attach to the gift card. Not visible to merchants. - /// - [JsonProperty("note")] - public string Note { get; set; } - - /// - /// When specified, the gift card will be rendered using gift_card.SUFFIX.liquid instead of gift_card.liquid. - /// - [JsonProperty("template_suffix")] - public string TemplateSuffix { get; set; } - - /// - /// The last four characters of the gift card code. Because gift cards are alternate payment methods, the full code cannot be retrieved. - /// - [JsonProperty("last_characters")] - public string LastCharacters { get; set; } - - /// - /// A unique numeric identifier of the order that caused the creation of this gift card (if it was created by an order). - /// - [JsonProperty("order_id")] - public long? OrderId { get; set; } - - /// - /// Thethe gift card code. Only for Creation - /// - [JsonProperty("code")] - public string Code { get; set; } - } -} + /// + /// Returns the amount of money remaining on the gift card. + /// + [JsonProperty("balance")] + public decimal? Balance { get; set; } + + /// + /// The date and time when the gift card was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// The date and time when the gift card was updated. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } + + /// + /// The three letter code (ISO 4217) for the currency used for the gift card. + /// + [JsonProperty("currency")] + public string Currency { get; set; } + + /// + /// Returns the initial amount of money on the gift card. + /// + [JsonProperty("initial_value")] + public decimal? InitialValue { get; set; } + + /// + /// The date and time when the gift card was disabled. + /// + [JsonProperty("disabled_at")] + public DateTimeOffset? DisabledAt { get; set; } + + /// + /// The date and time when the gift card will expire. + /// + [JsonProperty("expires_on")] + [JsonConverter(typeof(DateFormatConverter),"yyyy-MM-dd")] + public DateTimeOffset? ExpiresOn { get; set; } + + /// + /// A unique numeric identifier of the line_item that caused the creation of this gift card (if it was created by an order). + /// + [JsonProperty("line_item_id")] + public long? LineItemId { get; set; } + + + /// + /// A unique numeric identifier of the application that issued the gift card (if it was issued by an application). + /// + [JsonProperty("api_client_id")] + public long? ApiClientId { get; set; } + + + /// + /// A unique numeric identifier of the user that issued the gift card (if it was issued by a user). + /// + [JsonProperty("user_id")] + public long? UserId { get; set; } + + + /// + /// The id of a customer who is associated with this gift card. + /// + [JsonProperty("customer_id")] + public long? CustomerId { get; set; } + + + /// + /// The text of an optional note that a shop owner can attach to the gift card. Not visible to merchants. + /// + [JsonProperty("note")] + public string Note { get; set; } + + /// + /// When specified, the gift card will be rendered using gift_card.SUFFIX.liquid instead of gift_card.liquid. + /// + [JsonProperty("template_suffix")] + public string TemplateSuffix { get; set; } + + /// + /// The last four characters of the gift card code. Because gift cards are alternate payment methods, the full code cannot be retrieved. + /// + [JsonProperty("last_characters")] + public string LastCharacters { get; set; } + + /// + /// A unique numeric identifier of the order that caused the creation of this gift card (if it was created by an order). + /// + [JsonProperty("order_id")] + public long? OrderId { get; set; } + + /// + /// Thethe gift card code. Only for Creation + /// + [JsonProperty("code")] + public string Code { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/GiftCardAdjustment.cs b/ShopifySharp/Entities/GiftCardAdjustment.cs index 63366091..02cc910e 100644 --- a/ShopifySharp/Entities/GiftCardAdjustment.cs +++ b/ShopifySharp/Entities/GiftCardAdjustment.cs @@ -1,87 +1,86 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +public class GiftCardAdjustment : ShopifyObject { - public class GiftCardAdjustment : ShopifyObject - { - /// - /// A unique numeric identifier for gift card the adjustment is applied onto. - /// - [JsonProperty("gift_card_id")] - public long? GiftCardId { get; set; } + /// + /// A unique numeric identifier for gift card the adjustment is applied onto. + /// + [JsonProperty("gift_card_id")] + public long? GiftCardId { get; set; } - /// - /// A numeric sequence number for this adjustment with respect to the gift card. - /// - [JsonProperty("number")] - public int? Number { get; set; } + /// + /// A numeric sequence number for this adjustment with respect to the gift card. + /// + [JsonProperty("number")] + public int? Number { get; set; } - /// - /// A number (signed) representing the value of the adjustment. - /// - [JsonProperty("amount")] - public decimal Amount { get; set; } + /// + /// A number (signed) representing the value of the adjustment. + /// + [JsonProperty("amount")] + public decimal Amount { get; set; } - /// - /// The text of an optional note that can be attached to the adjustment. - /// This value is not visible to customers. - /// - [JsonProperty("note")] - public string Note { get; set; } + /// + /// The text of an optional note that can be attached to the adjustment. + /// This value is not visible to customers. + /// + [JsonProperty("note")] + public string Note { get; set; } - /// - /// The text of an optional reference note that can be attached to the adjustment. - /// This value is not visible to customers. - /// - [JsonProperty("remote_transaction_ref")] - public string RemoteTransactionRef { get; set; } + /// + /// The text of an optional reference note that can be attached to the adjustment. + /// This value is not visible to customers. + /// + [JsonProperty("remote_transaction_ref")] + public string RemoteTransactionRef { get; set; } - /// - /// An optional reference URL that can be attached to the adjustment. - /// This value is not visible to customers. - /// - [JsonProperty("remote_transaction_url")] - public string RemoteTransactionUrl { get; set; } + /// + /// An optional reference URL that can be attached to the adjustment. + /// This value is not visible to customers. + /// + [JsonProperty("remote_transaction_url")] + public string RemoteTransactionUrl { get; set; } - /// - /// A unique numeric identifier of the application that issued the adjustment (if it was issued by an application). - /// - [JsonProperty("api_client_id")] - public long? ApiClientId { get; set; } + /// + /// A unique numeric identifier of the application that issued the adjustment (if it was issued by an application). + /// + [JsonProperty("api_client_id")] + public long? ApiClientId { get; set; } - /// - /// A unique numeric identifier of the user that issued the adjustment (if it was issued by a user). - /// - [JsonProperty("user_id")] - public long? UserId { get; set; } + /// + /// A unique numeric identifier of the user that issued the adjustment (if it was issued by a user). + /// + [JsonProperty("user_id")] + public long? UserId { get; set; } - /// - /// A unique numeric identifier of the order transaction that issued the adjustment - /// (if it was caused by an application of a gift card to an order). - /// - [JsonProperty("order_transaction_id")] - public long? OrderTransactionId { get; set; } + /// + /// A unique numeric identifier of the order transaction that issued the adjustment + /// (if it was caused by an application of a gift card to an order). + /// + [JsonProperty("order_transaction_id")] + public long? OrderTransactionId { get; set; } - /// - /// The date and time when the adjustment was created. The API returns this value in ISO 8601 format. - /// - [JsonProperty("created_at")] - public DateTime? CreatedAt { get; set; } + /// + /// The date and time when the adjustment was created. The API returns this value in ISO 8601 format. + /// + [JsonProperty("created_at")] + public DateTime? CreatedAt { get; set; } - /// - /// The date and time when the gift card adjustment was updated in ISO 8601 format. - /// - [JsonProperty("updated_at")] - public DateTime? UpdatedAt { get; set; } + /// + /// The date and time when the gift card adjustment was updated in ISO 8601 format. + /// + [JsonProperty("updated_at")] + public DateTime? UpdatedAt { get; set; } - /// - /// The date and time when the adjustment was imported, in ISO 8601 format. - /// This value can be set to dates in the past when importing from other systems. - /// If no value is provided, it will be auto-generated. - /// - [JsonProperty("processed_at")] - public DateTime? ProcessedAt { get; set; } + /// + /// The date and time when the adjustment was imported, in ISO 8601 format. + /// This value can be set to dates in the past when importing from other systems. + /// If no value is provided, it will be auto-generated. + /// + [JsonProperty("processed_at")] + public DateTime? ProcessedAt { get; set; } - } -} +} \ No newline at end of file diff --git a/ShopifySharp/Entities/HSCode.cs b/ShopifySharp/Entities/HSCode.cs index 74e0de42..bbc428a3 100644 --- a/ShopifySharp/Entities/HSCode.cs +++ b/ShopifySharp/Entities/HSCode.cs @@ -1,19 +1,18 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class HSCode : ShopifyObject { - public class HSCode : ShopifyObject - { - /// - /// The two-digit code for the country where the inventory item was made. - /// - [JsonProperty("country_code")] - public string CountryCode { get; set; } + /// + /// The two-digit code for the country where the inventory item was made. + /// + [JsonProperty("country_code")] + public string CountryCode { get; set; } - /// - /// The general Harmonized System (HS) code for the inventory item. Used if a country-specific HS code is not available. - /// - [JsonProperty("harmonized_system_code")] - public string HarmonizedSystemCode { get; set; } - } -} + /// + /// The general Harmonized System (HS) code for the inventory item. Used if a country-specific HS code is not available. + /// + [JsonProperty("harmonized_system_code")] + public string HarmonizedSystemCode { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/InventoryItem.cs b/ShopifySharp/Entities/InventoryItem.cs index 30e9d9cd..0e5db483 100644 --- a/ShopifySharp/Entities/InventoryItem.cs +++ b/ShopifySharp/Entities/InventoryItem.cs @@ -2,68 +2,67 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class InventoryItem : ShopifyObject { - public class InventoryItem : ShopifyObject - { - /// - /// The unique SKU (Stock Keeping Unit) of the inventory item. - /// - [JsonProperty("sku")] - public string SKU { get; set; } + /// + /// The unique SKU (Stock Keeping Unit) of the inventory item. + /// + [JsonProperty("sku")] + public string SKU { get; set; } - /// - /// Whether the inventory item is tracked. If true, then inventory quantity changes are tracked by Shopify. - /// - [JsonProperty("tracked")] - public bool? Tracked { get; set; } + /// + /// Whether the inventory item is tracked. If true, then inventory quantity changes are tracked by Shopify. + /// + [JsonProperty("tracked")] + public bool? Tracked { get; set; } - /// - /// The unit cost of the inventory item. - /// - [JsonProperty("cost")] - public decimal? Cost { get; set; } + /// + /// The unit cost of the inventory item. + /// + [JsonProperty("cost")] + public decimal? Cost { get; set; } - /// - /// The two-digit code for the country where the inventory item was made. - /// - [JsonProperty("country_code_of_origin")] - public string CountryCodeOfOrigin { get; set; } + /// + /// The two-digit code for the country where the inventory item was made. + /// + [JsonProperty("country_code_of_origin")] + public string CountryCodeOfOrigin { get; set; } - /// - /// The two-digit code for the province where the inventory item was made. Used only if the shipping provider for the inventory item is Canada Post. - /// - [JsonProperty("province_code_of_origin")] - public string ProvinceCodeOfOrigin { get; set; } + /// + /// The two-digit code for the province where the inventory item was made. Used only if the shipping provider for the inventory item is Canada Post. + /// + [JsonProperty("province_code_of_origin")] + public string ProvinceCodeOfOrigin { get; set; } - /// - /// The general Harmonized System (HS) code for the inventory item. Used if a country-specific HS code is not available. - /// - [JsonProperty("harmonized_system_code")] - public string HarmonizedSystemCode { get; set; } + /// + /// The general Harmonized System (HS) code for the inventory item. Used if a country-specific HS code is not available. + /// + [JsonProperty("harmonized_system_code")] + public string HarmonizedSystemCode { get; set; } - /// - /// An array of country-specific Harmonized System (HS) codes for the item. Used to determine duties when shipping the inventory item to certain countries. - /// - [JsonProperty("country_harmonized_system_codes")] - public IEnumerable CountryHarmonizedSystemCodes { get; set; } + /// + /// An array of country-specific Harmonized System (HS) codes for the item. Used to determine duties when shipping the inventory item to certain countries. + /// + [JsonProperty("country_harmonized_system_codes")] + public IEnumerable CountryHarmonizedSystemCodes { get; set; } - /// - /// Whether a customer needs to provide a shipping address when placing an order containing the inventory item. - /// - [JsonProperty("requires_shipping")] - public bool? RequiresShipping { get; set; } + /// + /// Whether a customer needs to provide a shipping address when placing an order containing the inventory item. + /// + [JsonProperty("requires_shipping")] + public bool? RequiresShipping { get; set; } - /// - /// The date and time when the product variant was created. The API returns this value in ISO 8601 format. - /// - [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? CreatedAt { get; set; } + /// + /// The date and time when the product variant was created. The API returns this value in ISO 8601 format. + /// + [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? CreatedAt { get; set; } - /// - /// The date and time when the product variant was last modified. The API returns this value in ISO 8601 format. - /// - [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? UpdatedAt { get; set; } - } -} + /// + /// The date and time when the product variant was last modified. The API returns this value in ISO 8601 format. + /// + [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? UpdatedAt { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/InventoryLevel.cs b/ShopifySharp/Entities/InventoryLevel.cs index 3ea712b0..f9968f7f 100644 --- a/ShopifySharp/Entities/InventoryLevel.cs +++ b/ShopifySharp/Entities/InventoryLevel.cs @@ -1,38 +1,37 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class InventoryLevel { - public class InventoryLevel - { - /// - /// The GraphQL Admin API Id - /// - [JsonProperty("admin_graphql_api_id")] - public string AdminGraphQLAPIId { get; set; } + /// + /// The GraphQL Admin API Id + /// + [JsonProperty("admin_graphql_api_id")] + public string AdminGraphQLAPIId { get; set; } - /// - /// The unique identifier of the inventory item that the inventory level belongs to. - /// - [JsonProperty("inventory_item_id")] - public long? InventoryItemId { get; set; } + /// + /// The unique identifier of the inventory item that the inventory level belongs to. + /// + [JsonProperty("inventory_item_id")] + public long? InventoryItemId { get; set; } - /// - /// The unique identifier of the location that the inventory level belongs to. - /// - [JsonProperty("location_id")] - public long? LocationId { get; set; } + /// + /// The unique identifier of the location that the inventory level belongs to. + /// + [JsonProperty("location_id")] + public long? LocationId { get; set; } - /// - /// The quantity of inventory items available for sale. Returns null if the inventory item is not tracked. - /// - [JsonProperty("available")] - public long? Available { get; set; } + /// + /// The quantity of inventory items available for sale. Returns null if the inventory item is not tracked. + /// + [JsonProperty("available")] + public long? Available { get; set; } - /// - /// The date and time when the inventory level was last modified. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - } -} + /// + /// The date and time when the inventory level was last modified. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/InventoryLevelAdjust.cs b/ShopifySharp/Entities/InventoryLevelAdjust.cs index 3580d4c8..d294094f 100644 --- a/ShopifySharp/Entities/InventoryLevelAdjust.cs +++ b/ShopifySharp/Entities/InventoryLevelAdjust.cs @@ -1,25 +1,24 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class InventoryLevelAdjust { - public class InventoryLevelAdjust - { - /// - /// The unique identifier of the inventory item that the inventory level belongs to. - /// - [JsonProperty("inventory_item_id")] - public long? InventoryItemId { get; set; } + /// + /// The unique identifier of the inventory item that the inventory level belongs to. + /// + [JsonProperty("inventory_item_id")] + public long? InventoryItemId { get; set; } - /// - /// The unique identifier of the location that the inventory level belongs to. - /// - [JsonProperty("location_id")] - public long? LocationId { get; set; } + /// + /// The unique identifier of the location that the inventory level belongs to. + /// + [JsonProperty("location_id")] + public long? LocationId { get; set; } - /// - /// The quantity adjust of inventory items. - /// - [JsonProperty("available_adjustment")] - public int? AvailableAdjustment { get; set; } - } + /// + /// The quantity adjust of inventory items. + /// + [JsonProperty("available_adjustment")] + public int? AvailableAdjustment { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/LineItem.cs b/ShopifySharp/Entities/LineItem.cs index 9680ed13..f6c374fc 100644 --- a/ShopifySharp/Entities/LineItem.cs +++ b/ShopifySharp/Entities/LineItem.cs @@ -3,212 +3,211 @@ using ShopifySharp.Converters; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +public class LineItem : ShopifyObject { - public class LineItem : ShopifyObject - { - /// - /// The amount available to fulfill. This is the quantity - max(refunded_quantity, fulfilled_quantity) - pending_fulfilled_quantity. - /// - [JsonProperty("fulfillable_quantity")] - public int? FulfillableQuantity { get; set; } - - /// - /// Service provider who is doing the fulfillment. Valid values are either "manual" or the name of the provider. eg: "amazon", "shipwire", etc. - /// - [JsonProperty("fulfillment_service")] - public string FulfillmentService { get; set; } - - /// - /// The fulfillment status of this line item. Known values are 'fulfilled', 'null' and 'partial'. - /// - [JsonProperty("fulfillment_status")] - public string FulfillmentStatus { get; set; } - - /// - /// The weight of the item in grams. - /// - [JsonProperty("grams")] - public long? Grams { get; set; } - - /// - /// The price of the item before discounts have been applied. - /// - /// Shopify returns this value as a string. - [JsonProperty("price")] - public decimal? Price { get; set; } - - /// - /// The unique numeric identifier for the product in the fulfillment. Can be null if the original product associated with the order is deleted at a later date - /// - [JsonProperty("product_id")] - public long? ProductId { get; set; } - - /// - /// The number of products that were purchased. - /// - [JsonProperty("quantity")] - public int? Quantity { get; set; } - - /// - /// States whether or not the fulfillment requires shipping. - /// - [JsonProperty("requires_shipping")] - public bool? RequiresShipping { get; set; } - - /// - /// A unique identifier of the item in the fulfillment. - /// - [JsonProperty("sku")] - public string SKU { get; set; } - - /// - /// The title of the product. - /// - [JsonProperty("title")] - public string Title { get; set; } - - /// - /// The id of the product variant. Can be null if the product purchased is not a variant. - /// - [JsonProperty("variant_id")] - public long? VariantId { get; set; } - - /// - /// The title of the product variant. Can be null if the product purchased is not a variant. - /// - [JsonProperty("variant_title")] - public string VariantTitle { get; set; } - - /// - /// The name of the product variant. - /// - [JsonProperty("name")] - public string Name { get; set; } - - /// - /// The name of the supplier of the item. - /// - [JsonProperty("vendor")] - public string Vendor { get; set; } - - /// - /// States whether the order used a gift card. - /// - [JsonProperty("gift_card")] - public bool? GiftCard { get; set; } - - /// - /// States whether or not the product was taxable. - /// - [JsonProperty("taxable")] - public bool? Taxable { get; set; } - - /// - /// An array of objects, each of which details the taxes applicable to this . - /// - [JsonProperty("tax_lines")] - public IEnumerable TaxLines { get; set; } - - /// - /// The payment gateway used to tender the tip, such as shopify_payments. Present only on tips. - /// - [JsonProperty("tip_payment_gateway", NullValueHandling = NullValueHandling.Include)] - public string TipPaymentGateway { get; set; } - - /// - /// The payment method used to tender the tip, such as Visa. Present only on tips. - /// - [JsonProperty("tip_payment_method")] - public string TipPaymentMethod { get; set; } - - /// - /// Whether the tip_payment_gateway field is present or not. If true, the line is a tip line. - /// For a tip line, tip_payment_gateway is always specified (though it can be null). - /// For a non tip line, tip_payment_gateway is never specified. - /// - /// - /// This is a Json.Net feature and not a Shopify API property. Refer to #706 for more details. - /// - [JsonIgnore] - public bool TipPaymentGatewaySpecified { get; set; } - - /// - /// The total discount amount applied to this line item. This value is not subtracted in the line item price. - /// - [JsonProperty("total_discount")] - public decimal? TotalDiscount { get; set; } - - /// - /// The total discount applied to the line item in shop and presentment currencies. - /// - [JsonProperty("total_discount_set")] - public PriceSet TotalDiscountSet { get; set; } - - /// - /// An ordered list of amounts allocated by discount applications. Each discount allocation is associated to a particular discount application. - /// - [JsonProperty("discount_allocations")] - public IEnumerable DiscountAllocations { get; set; } - - /// - /// An array of custom information for an item that has been added to the cart. - /// Often used to provide product customization options. - /// An array of objects, each of which details the taxes applicable to this . - /// - /// - /// See https://github.com/nozzlegear/ShopifySharp/pull/461 for why the custom converter is required - /// - [JsonProperty("properties")] - [JsonConverter(typeof(NullOnErrorConverter))] - public IEnumerable Properties { get; set; } - - /// - /// This property is undocumented by Shopify. - /// - [JsonProperty("variant_inventory_management")] - public string VariantInventoryManagement { get; set; } - - /// - /// This property is undocumented by Shopify. - /// - [JsonProperty("product_exists")] - public bool? ProductExists { get; set; } - - /// - /// The price of the line item in shop and presentment currencies - /// - [JsonProperty("price_set")] - public PriceSet PriceSet { get; set; } - - /// - /// The price per item, excluding taxes and excluding discounts. - /// - [JsonProperty("pre_tax_price")] - public decimal? PreTaxPrice { get; set; } - - /// - /// The price per item, excluding taxes and excluding discounts in shop and presentment currencies. - /// - [JsonProperty("pre_tax_price_set")] - public PriceSet PreTaxPriceSet { get; set; } + /// + /// The amount available to fulfill. This is the quantity - max(refunded_quantity, fulfilled_quantity) - pending_fulfilled_quantity. + /// + [JsonProperty("fulfillable_quantity")] + public int? FulfillableQuantity { get; set; } + + /// + /// Service provider who is doing the fulfillment. Valid values are either "manual" or the name of the provider. eg: "amazon", "shipwire", etc. + /// + [JsonProperty("fulfillment_service")] + public string FulfillmentService { get; set; } + + /// + /// The fulfillment status of this line item. Known values are 'fulfilled', 'null' and 'partial'. + /// + [JsonProperty("fulfillment_status")] + public string FulfillmentStatus { get; set; } + + /// + /// The weight of the item in grams. + /// + [JsonProperty("grams")] + public long? Grams { get; set; } + + /// + /// The price of the item before discounts have been applied. + /// + /// Shopify returns this value as a string. + [JsonProperty("price")] + public decimal? Price { get; set; } + + /// + /// The unique numeric identifier for the product in the fulfillment. Can be null if the original product associated with the order is deleted at a later date + /// + [JsonProperty("product_id")] + public long? ProductId { get; set; } + + /// + /// The number of products that were purchased. + /// + [JsonProperty("quantity")] + public int? Quantity { get; set; } + + /// + /// States whether or not the fulfillment requires shipping. + /// + [JsonProperty("requires_shipping")] + public bool? RequiresShipping { get; set; } + + /// + /// A unique identifier of the item in the fulfillment. + /// + [JsonProperty("sku")] + public string SKU { get; set; } + + /// + /// The title of the product. + /// + [JsonProperty("title")] + public string Title { get; set; } + + /// + /// The id of the product variant. Can be null if the product purchased is not a variant. + /// + [JsonProperty("variant_id")] + public long? VariantId { get; set; } + + /// + /// The title of the product variant. Can be null if the product purchased is not a variant. + /// + [JsonProperty("variant_title")] + public string VariantTitle { get; set; } + + /// + /// The name of the product variant. + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// The name of the supplier of the item. + /// + [JsonProperty("vendor")] + public string Vendor { get; set; } + + /// + /// States whether the order used a gift card. + /// + [JsonProperty("gift_card")] + public bool? GiftCard { get; set; } + + /// + /// States whether or not the product was taxable. + /// + [JsonProperty("taxable")] + public bool? Taxable { get; set; } + + /// + /// An array of objects, each of which details the taxes applicable to this . + /// + [JsonProperty("tax_lines")] + public IEnumerable TaxLines { get; set; } + + /// + /// The payment gateway used to tender the tip, such as shopify_payments. Present only on tips. + /// + [JsonProperty("tip_payment_gateway", NullValueHandling = NullValueHandling.Include)] + public string TipPaymentGateway { get; set; } + + /// + /// The payment method used to tender the tip, such as Visa. Present only on tips. + /// + [JsonProperty("tip_payment_method")] + public string TipPaymentMethod { get; set; } + + /// + /// Whether the tip_payment_gateway field is present or not. If true, the line is a tip line. + /// For a tip line, tip_payment_gateway is always specified (though it can be null). + /// For a non tip line, tip_payment_gateway is never specified. + /// + /// + /// This is a Json.Net feature and not a Shopify API property. Refer to #706 for more details. + /// + [JsonIgnore] + public bool TipPaymentGatewaySpecified { get; set; } + + /// + /// The total discount amount applied to this line item. This value is not subtracted in the line item price. + /// + [JsonProperty("total_discount")] + public decimal? TotalDiscount { get; set; } + + /// + /// The total discount applied to the line item in shop and presentment currencies. + /// + [JsonProperty("total_discount_set")] + public PriceSet TotalDiscountSet { get; set; } + + /// + /// An ordered list of amounts allocated by discount applications. Each discount allocation is associated to a particular discount application. + /// + [JsonProperty("discount_allocations")] + public IEnumerable DiscountAllocations { get; set; } + + /// + /// An array of custom information for an item that has been added to the cart. + /// Often used to provide product customization options. + /// An array of objects, each of which details the taxes applicable to this . + /// + /// + /// See https://github.com/nozzlegear/ShopifySharp/pull/461 for why the custom converter is required + /// + [JsonProperty("properties")] + [JsonConverter(typeof(NullOnErrorConverter))] + public IEnumerable Properties { get; set; } + + /// + /// This property is undocumented by Shopify. + /// + [JsonProperty("variant_inventory_management")] + public string VariantInventoryManagement { get; set; } + + /// + /// This property is undocumented by Shopify. + /// + [JsonProperty("product_exists")] + public bool? ProductExists { get; set; } + + /// + /// The price of the line item in shop and presentment currencies + /// + [JsonProperty("price_set")] + public PriceSet PriceSet { get; set; } + + /// + /// The price per item, excluding taxes and excluding discounts. + /// + [JsonProperty("pre_tax_price")] + public decimal? PreTaxPrice { get; set; } + + /// + /// The price per item, excluding taxes and excluding discounts in shop and presentment currencies. + /// + [JsonProperty("pre_tax_price_set")] + public PriceSet PreTaxPriceSet { get; set; } - /// - /// A list of duty objects, each containing information about a duty on the line item - /// - [JsonProperty("duties")] - public IEnumerable Duties { get; set; } - - /// - /// A unique identifier for a quantity of items within a single fulfillment. An order can have multiple fulfillment line items. - /// - [JsonProperty("fulfillment_line_item_id")] - public long? FulfillmentLineItemId { get; set; } - - /// - /// A list of attributed staffs for this line item - /// - [JsonProperty("attributed_staffs")] - public IEnumerable AttributedStaffs { get; set; } - } -} + /// + /// A list of duty objects, each containing information about a duty on the line item + /// + [JsonProperty("duties")] + public IEnumerable Duties { get; set; } + + /// + /// A unique identifier for a quantity of items within a single fulfillment. An order can have multiple fulfillment line items. + /// + [JsonProperty("fulfillment_line_item_id")] + public long? FulfillmentLineItemId { get; set; } + + /// + /// A list of attributed staffs for this line item + /// + [JsonProperty("attributed_staffs")] + public IEnumerable AttributedStaffs { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/LineItemAttributedStaff.cs b/ShopifySharp/Entities/LineItemAttributedStaff.cs index e7ffa32e..76b7581e 100644 --- a/ShopifySharp/Entities/LineItemAttributedStaff.cs +++ b/ShopifySharp/Entities/LineItemAttributedStaff.cs @@ -1,22 +1,21 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing the staff member attributed to the line item +/// +public class LineItemAttributedStaff { /// - /// An object representing the staff member attributed to the line item + /// The GraphQL id of the staff member /// - public class LineItemAttributedStaff - { - /// - /// The GraphQL id of the staff member - /// - [JsonProperty("id")] - public string Id { get; set; } + [JsonProperty("id")] + public string Id { get; set; } - /// - /// The quantity of the line item attributed to the staff member. - /// - [JsonProperty("quantity")] - public long? Quantity { get; set; } - } -} + /// + /// The quantity of the line item attributed to the staff member. + /// + [JsonProperty("quantity")] + public long? Quantity { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/LineItemDuty.cs b/ShopifySharp/Entities/LineItemDuty.cs index 449eb06f..08dcca02 100644 --- a/ShopifySharp/Entities/LineItemDuty.cs +++ b/ShopifySharp/Entities/LineItemDuty.cs @@ -1,20 +1,19 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +public class LineItemDuty : ShopifyObject { - public class LineItemDuty : ShopifyObject - { - [JsonProperty("harmonized_system_code")] - public string HarmonizedSystemCode { get; set; } + [JsonProperty("harmonized_system_code")] + public string HarmonizedSystemCode { get; set; } - [JsonProperty("country_code_of_origin")] - public string CountryCodeOfOrigin { get; set; } + [JsonProperty("country_code_of_origin")] + public string CountryCodeOfOrigin { get; set; } - [JsonProperty("price_set")] - public PriceSet PriceSet { get; set; } + [JsonProperty("price_set")] + public PriceSet PriceSet { get; set; } - [JsonProperty("tax_lines")] - public IEnumerable TaxLines { get; set; } - } -} + [JsonProperty("tax_lines")] + public IEnumerable TaxLines { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/LineItemProperty.cs b/ShopifySharp/Entities/LineItemProperty.cs index c0e038b2..806be1c3 100644 --- a/ShopifySharp/Entities/LineItemProperty.cs +++ b/ShopifySharp/Entities/LineItemProperty.cs @@ -1,22 +1,21 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a properties for +/// +public class LineItemProperty { /// - /// An object representing a properties for + /// The name of the note attribute. /// - public class LineItemProperty - { - /// - /// The name of the note attribute. - /// - [JsonProperty("name")] - public object Name { get; set; } + [JsonProperty("name")] + public object Name { get; set; } - /// - /// The value of the note attribute. - /// - [JsonProperty("value")] - public object Value { get; set; } - } -} + /// + /// The value of the note attribute. + /// + [JsonProperty("value")] + public object Value { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/LineItemsByFulfillmentOrder.cs b/ShopifySharp/Entities/LineItemsByFulfillmentOrder.cs index f3c7f867..7d9b3f5b 100644 --- a/ShopifySharp/Entities/LineItemsByFulfillmentOrder.cs +++ b/ShopifySharp/Entities/LineItemsByFulfillmentOrder.cs @@ -1,20 +1,19 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +public class LineItemsByFulfillmentOrder { - public class LineItemsByFulfillmentOrder - { - /// - /// The ID of the fulfillment order associated with this line item. - /// - [JsonProperty("fulfillment_order_id")] - public long? FulfillmentOrderId { get; set; } + /// + /// The ID of the fulfillment order associated with this line item. + /// + [JsonProperty("fulfillment_order_id")] + public long? FulfillmentOrderId { get; set; } - /// - /// The fulfillment order line items to be requested for fulfillment. If left blank, all line items of the fulfillment order are requested for fulfillment. - /// - [JsonProperty("fulfillment_order_line_items")] - public IEnumerable FulfillmentRequestOrderLineItems { get; set; } - } -} + /// + /// The fulfillment order line items to be requested for fulfillment. If left blank, all line items of the fulfillment order are requested for fulfillment. + /// + [JsonProperty("fulfillment_order_line_items")] + public IEnumerable FulfillmentRequestOrderLineItems { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/Location.cs b/ShopifySharp/Entities/Location.cs index 6543204a..3f29364d 100644 --- a/ShopifySharp/Entities/Location.cs +++ b/ShopifySharp/Entities/Location.cs @@ -1,113 +1,112 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a physical store location. +/// +public class Location : ShopifyObject { /// - /// An object representing a physical store location. - /// - public class Location : ShopifyObject - { - /// - /// Whether the location is active. - /// - [JsonProperty("active")] - public bool? Active { get; set; } - - /// - /// The name of the location. - /// - [JsonProperty("name")] - public string Name { get; set; } - - /// - /// The first line of the address. - /// - [JsonProperty("address1")] - public string Address1 { get; set; } - - /// - /// The second line of the address. - /// - [JsonProperty("address2")] - public string Address2 { get; set; } - - /// - /// The zip or postal code. - /// - [JsonProperty("zip")] - public string Zip { get; set; } - - /// - /// The city the location is in. - /// - [JsonProperty("city")] - public string City { get; set; } - - /// - /// The province the location is in. - /// - [JsonProperty("province")] - public string Province { get; set; } - - /// - /// The code of the province the location is in. - /// - [JsonProperty("province_code")] - public string ProvinceCode { get; set; } - - /// - /// The country the location is in. - /// - [JsonProperty("country")] - public string Country { get; set; } - - /// - /// The name of the country the location is in. - /// - [JsonProperty("country_name")] - public string CountryName { get; set; } - - /// - /// The code of the country the location is in. - /// - [JsonProperty("country_code")] - public string CountryCode { get; set; } - - /// - /// The phone number of the location. Can contain special chars like - and +. - /// - [JsonProperty("phone")] - public string Phone { get; set; } - - /// - /// The date and time when the location was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// The date and time when the location was last updated. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - - /// - /// Whether this is a fulfillment service location. If true, then the location is a fulfillment service location. If false, then the location was created by the merchant and isn't tied to a fulfillment service. - /// - [JsonProperty("legacy")] - public bool? Legacy { get; set; } - - /// - /// The localized name of the location's country. - /// - [JsonProperty("localized_country_name")] - public string LocalizedCountryName { get; set; } - - /// - /// The localized name of the location's region. Typically a province, state, or prefecture. - /// - [JsonProperty("localized_province_name")] - public string LocalizedProvinceName { get; set; } - } -} + /// Whether the location is active. + /// + [JsonProperty("active")] + public bool? Active { get; set; } + + /// + /// The name of the location. + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// The first line of the address. + /// + [JsonProperty("address1")] + public string Address1 { get; set; } + + /// + /// The second line of the address. + /// + [JsonProperty("address2")] + public string Address2 { get; set; } + + /// + /// The zip or postal code. + /// + [JsonProperty("zip")] + public string Zip { get; set; } + + /// + /// The city the location is in. + /// + [JsonProperty("city")] + public string City { get; set; } + + /// + /// The province the location is in. + /// + [JsonProperty("province")] + public string Province { get; set; } + + /// + /// The code of the province the location is in. + /// + [JsonProperty("province_code")] + public string ProvinceCode { get; set; } + + /// + /// The country the location is in. + /// + [JsonProperty("country")] + public string Country { get; set; } + + /// + /// The name of the country the location is in. + /// + [JsonProperty("country_name")] + public string CountryName { get; set; } + + /// + /// The code of the country the location is in. + /// + [JsonProperty("country_code")] + public string CountryCode { get; set; } + + /// + /// The phone number of the location. Can contain special chars like - and +. + /// + [JsonProperty("phone")] + public string Phone { get; set; } + + /// + /// The date and time when the location was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// The date and time when the location was last updated. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } + + /// + /// Whether this is a fulfillment service location. If true, then the location is a fulfillment service location. If false, then the location was created by the merchant and isn't tied to a fulfillment service. + /// + [JsonProperty("legacy")] + public bool? Legacy { get; set; } + + /// + /// The localized name of the location's country. + /// + [JsonProperty("localized_country_name")] + public string LocalizedCountryName { get; set; } + + /// + /// The localized name of the location's region. Typically a province, state, or prefecture. + /// + [JsonProperty("localized_province_name")] + public string LocalizedProvinceName { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/MerchantRequest.cs b/ShopifySharp/Entities/MerchantRequest.cs index b4f086ce..dbdcaebd 100644 --- a/ShopifySharp/Entities/MerchantRequest.cs +++ b/ShopifySharp/Entities/MerchantRequest.cs @@ -1,25 +1,24 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class MerchantRequest { - public class MerchantRequest - { - /// - /// The message returned by the merchant, if any. - /// - [JsonProperty("message")] - public string Message { get; set; } + /// + /// The message returned by the merchant, if any. + /// + [JsonProperty("message")] + public string Message { get; set; } - /// - /// The request options returned by the merchant, if any. - /// - [JsonProperty("request_options")] - public MerchantRequestOptions RequestOptions { get; set; } + /// + /// The request options returned by the merchant, if any. + /// + [JsonProperty("request_options")] + public MerchantRequestOptions RequestOptions { get; set; } - /// - /// The kind of request. Known valid values: "fulfillment_request", "cancellation_request", or "legacy_fulfill_request". - /// - [JsonProperty("kind")] - public string Kind { get; set; } - } + /// + /// The kind of request. Known valid values: "fulfillment_request", "cancellation_request", or "legacy_fulfill_request". + /// + [JsonProperty("kind")] + public string Kind { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/MerchantRequestOptions.cs b/ShopifySharp/Entities/MerchantRequestOptions.cs index 178fca60..85bda3f9 100644 --- a/ShopifySharp/Entities/MerchantRequestOptions.cs +++ b/ShopifySharp/Entities/MerchantRequestOptions.cs @@ -1,17 +1,16 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class MerchantRequestOptions { - public class MerchantRequestOptions - { - [JsonProperty("shipping_method")] - public string ShippingMethod { get; set; } + [JsonProperty("shipping_method")] + public string ShippingMethod { get; set; } - [JsonProperty("note")] - public string Note { get; set; } + [JsonProperty("note")] + public string Note { get; set; } - [JsonProperty("date")] - public DateTimeOffset? Date { get; set; } - } + [JsonProperty("date")] + public DateTimeOffset? Date { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/MetaField.cs b/ShopifySharp/Entities/MetaField.cs index 2eba2a9f..6d1b01bb 100644 --- a/ShopifySharp/Entities/MetaField.cs +++ b/ShopifySharp/Entities/MetaField.cs @@ -1,62 +1,61 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +public class MetaField : ShopifyObject { - public class MetaField : ShopifyObject - { - /// - /// The date and time when the metafield was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// The date and time when the metafield was last updated. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - - /// - /// Identifier for the metafield (maximum of 30 characters). - /// - [JsonProperty("key")] - public string Key { get; set; } - - /// - /// Information to be stored as metadata. Must be either a string or an int. - /// - [JsonProperty("value")] - public object Value { get; set; } - - /// - /// The metafield's information type. See https://shopify.dev/apps/metafields/definitions/types for a full list of types. - /// - [JsonProperty("type")] - public string Type { get; set; } - - /// - /// Container for a set of metadata. Namespaces help distinguish between metadata you created and metadata created by another individual with a similar namespace (maximum of 20 characters). - /// - [JsonProperty("namespace")] - public string Namespace { get; set; } - - /// - /// Additional information about the metafield. - /// - [JsonProperty("description")] - public string Description { get; set; } + /// + /// The date and time when the metafield was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// The date and time when the metafield was last updated. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } + + /// + /// Identifier for the metafield (maximum of 30 characters). + /// + [JsonProperty("key")] + public string Key { get; set; } + + /// + /// Information to be stored as metadata. Must be either a string or an int. + /// + [JsonProperty("value")] + public object Value { get; set; } + + /// + /// The metafield's information type. See https://shopify.dev/apps/metafields/definitions/types for a full list of types. + /// + [JsonProperty("type")] + public string Type { get; set; } + + /// + /// Container for a set of metadata. Namespaces help distinguish between metadata you created and metadata created by another individual with a similar namespace (maximum of 20 characters). + /// + [JsonProperty("namespace")] + public string Namespace { get; set; } + + /// + /// Additional information about the metafield. + /// + [JsonProperty("description")] + public string Description { get; set; } - /// - /// The Id of the Shopify Resource that the metafield is associated with. This value could be the id of things like product, order, variant, collection. - /// - [JsonProperty("owner_id")] - public long? OwnerId { get; set; } - - /// - /// The name of the Shopify Resource that the metafield is associated with. This could be things like product, order, variant, collection. - /// - [JsonProperty("owner_resource")] - public string OwnerResource { get; set; } - } -} + /// + /// The Id of the Shopify Resource that the metafield is associated with. This value could be the id of things like product, order, variant, collection. + /// + [JsonProperty("owner_id")] + public long? OwnerId { get; set; } + + /// + /// The name of the Shopify Resource that the metafield is associated with. This could be things like product, order, variant, collection. + /// + [JsonProperty("owner_resource")] + public string OwnerResource { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/NoteAttribute.cs b/ShopifySharp/Entities/NoteAttribute.cs index be501206..4d14b19a 100644 --- a/ShopifySharp/Entities/NoteAttribute.cs +++ b/ShopifySharp/Entities/NoteAttribute.cs @@ -1,22 +1,21 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a note attribute for +/// +public class NoteAttribute { /// - /// An object representing a note attribute for + /// The name of the note attribute. /// - public class NoteAttribute - { - /// - /// The name of the note attribute. - /// - [JsonProperty("name")] - public string Name { get; set; } + [JsonProperty("name")] + public string Name { get; set; } - /// - /// The value of the note attribute. - /// - [JsonProperty("value")] - public object Value { get; set; } - } -} + /// + /// The value of the note attribute. + /// + [JsonProperty("value")] + public object Value { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/OptionValue.cs b/ShopifySharp/Entities/OptionValue.cs index 92c60f4c..01be8678 100644 --- a/ShopifySharp/Entities/OptionValue.cs +++ b/ShopifySharp/Entities/OptionValue.cs @@ -1,25 +1,24 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class OptionValue { - public class OptionValue - { - /// - /// Custom property option id - /// - [JsonProperty("option_id")] - public long OptionId { get; set; } + /// + /// Custom property option id + /// + [JsonProperty("option_id")] + public long OptionId { get; set; } - /// - /// Custom property option name - /// - [JsonProperty("name")] - public string Name { get; set; } + /// + /// Custom property option name + /// + [JsonProperty("name")] + public string Name { get; set; } - /// - /// Custom property option value - /// - [JsonProperty("value")] - public string Value { get; set; } - } + /// + /// Custom property option value + /// + [JsonProperty("value")] + public string Value { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/Order.cs b/ShopifySharp/Entities/Order.cs index e832acc2..e61b4fb4 100644 --- a/ShopifySharp/Entities/Order.cs +++ b/ShopifySharp/Entities/Order.cs @@ -2,518 +2,517 @@ using System; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify order. +/// +public class Order : ShopifyObject { /// - /// An object representing a Shopify order. - /// - public class Order : ShopifyObject - { - /// - /// Unique identifier of the app who created the order. - /// - [JsonProperty("app_id")] - public long? AppId { get; set; } - - /// - /// The mailing address associated with the payment method. This address is an optional field that will not be available on orders that do not require one. - /// - [JsonProperty("billing_address")] - public Address BillingAddress { get; set; } - - /// - /// The IP address of the browser used by the customer when placing the order. - /// - [JsonProperty("browser_ip")] - public string BrowserIp { get; set; } - - /// - /// Indicates whether or not the person who placed the order would like to receive email updates from the shop. - /// This is set when checking the "I want to receive occasional emails about new products, promotions and other news" checkbox during checkout. - /// - [JsonProperty("buyer_accepts_marketing")] - public bool? BuyerAcceptsMarketing { get; set; } - - /// - /// The reason why the order was cancelled. If the order was not cancelled, this value is null. Known values are "customer", "fraud", "inventory" and "other". - /// - [JsonProperty("cancel_reason")] - public string CancelReason { get; set; } - - /// - /// The date and time when the order was cancelled. If the order was not cancelled, this value is null. - /// - [JsonProperty("cancelled_at")] - public DateTimeOffset? CancelledAt { get; set; } - - /// - /// Unique identifier for a particular cart that is attached to a particular order. - /// - [JsonProperty("cart_token")] - public string CartToken { get; set; } + /// Unique identifier of the app who created the order. + /// + [JsonProperty("app_id")] + public long? AppId { get; set; } + + /// + /// The mailing address associated with the payment method. This address is an optional field that will not be available on orders that do not require one. + /// + [JsonProperty("billing_address")] + public Address BillingAddress { get; set; } + + /// + /// The IP address of the browser used by the customer when placing the order. + /// + [JsonProperty("browser_ip")] + public string BrowserIp { get; set; } + + /// + /// Indicates whether or not the person who placed the order would like to receive email updates from the shop. + /// This is set when checking the "I want to receive occasional emails about new products, promotions and other news" checkbox during checkout. + /// + [JsonProperty("buyer_accepts_marketing")] + public bool? BuyerAcceptsMarketing { get; set; } + + /// + /// The reason why the order was cancelled. If the order was not cancelled, this value is null. Known values are "customer", "fraud", "inventory" and "other". + /// + [JsonProperty("cancel_reason")] + public string CancelReason { get; set; } + + /// + /// The date and time when the order was cancelled. If the order was not cancelled, this value is null. + /// + [JsonProperty("cancelled_at")] + public DateTimeOffset? CancelledAt { get; set; } + + /// + /// Unique identifier for a particular cart that is attached to a particular order. + /// + [JsonProperty("cart_token")] + public string CartToken { get; set; } - /// - /// A unique value when referencing the that's associated with the order. - /// - [JsonProperty("checkout_token")] - public string CheckoutToken { get; set; } - - /// - /// ID of the checkout that's associated with the order. - /// - [JsonProperty("checkout_id")] - public long? CheckoutId { get; set; } - - /// - /// A object containing information about the client. - /// - [JsonProperty("client_details")] - public ClientDetails ClientDetails { get; set; } - - /// - /// The date and time when the order was closed. If the order was not clsoed, this value is null. - /// - [JsonProperty("closed_at")] - public DateTimeOffset? ClosedAt { get; set; } + /// + /// A unique value when referencing the that's associated with the order. + /// + [JsonProperty("checkout_token")] + public string CheckoutToken { get; set; } + + /// + /// ID of the checkout that's associated with the order. + /// + [JsonProperty("checkout_id")] + public long? CheckoutId { get; set; } + + /// + /// A object containing information about the client. + /// + [JsonProperty("client_details")] + public ClientDetails ClientDetails { get; set; } + + /// + /// The date and time when the order was closed. If the order was not clsoed, this value is null. + /// + [JsonProperty("closed_at")] + public DateTimeOffset? ClosedAt { get; set; } - /// - /// Whether inventory has been reserved for the order. - /// - [JsonProperty("confirmed")] - public bool? Confirmed { get; set; } + /// + /// Whether inventory has been reserved for the order. + /// + [JsonProperty("confirmed")] + public bool? Confirmed { get; set; } - /// - /// The date and time when the order was created in Shopify. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// The three letter code (ISO 4217) for the currency used for the payment. - /// - [JsonProperty("currency")] - public string Currency { get; set; } - - /// - /// A object containing information about the customer. This value may be null if the order was created through Shopify POS. - /// - [JsonProperty("customer")] - public Customer Customer { get; set; } - - /// - /// The two or three letter language code, optionally followed by a region modifier. Example values could be 'en', 'en-CA', 'en-PIRATE'. - /// - [JsonProperty("customer_locale")] - public string CustomerLocale { get; set; } - - /// - /// The unique numeric identifier of the POS device used. - /// - [JsonProperty("device_id")] - public long? DeviceId { get; set; } - - /// - /// Applicable discount codes that can be applied to the order. - /// - [JsonProperty("discount_codes")] - public IEnumerable DiscountCodes { get; set; } - - /// - /// An ordered list of amounts allocated by discount applications. Each discount allocation is associated to a particular discount application. - /// - [JsonProperty("discount_applications")] - public IEnumerable DiscountApplications { get; set; } - - /// - /// The order's email address. Note: On and after 2015-11-03, you should be using to refer to the customer's email address. - /// Between 2015-11-03 and 2015-12-03, updates to an order's email will also update the customer's email. This is temporary so apps can be migrated over to - /// doing customer updates rather than order updates to change the contact email. After 2015-12-03, updating updating an order's email will no longer update - /// the customer's email and apps will have to use the customer update endpoint to do so. - /// - [JsonProperty("email")] - public string Email { get; set; } - - /// - /// The financial status of an order. Known values are "authorized", "paid", "pending", "partially_paid", "partially_refunded", "refunded" and "voided". - /// - [JsonProperty("financial_status")] - public string FinancialStatus { get; set; } - - /// - /// An array of objects for this order. - /// - [JsonProperty("fulfillments")] - public IEnumerable Fulfillments { get; set; } - - /// - /// The fulfillment status for this order. Known values are 'fulfilled', 'null' and 'partial'. - /// - [JsonProperty("fulfillment_status")] - public string FulfillmentStatus { get; set; } - - /// - /// The customer's phone number. - /// - [JsonProperty("phone")] - public string Phone { get; set; } - - /// - /// Tags are additional short descriptors, commonly used for filtering and searching, formatted as a string of comma-separated values. - /// - [JsonProperty("tags")] - public string Tags { get; set; } - - /// - /// The URL for the page where the buyer landed when entering the shop. - /// - [JsonProperty("landing_site")] - public string LandingSite { get; set; } - - /// - /// An array of objects, each one containing information about an item in the order. - /// - [JsonProperty("line_items")] - public IEnumerable LineItems { get; set; } - - /// - /// The unique numeric identifier for the physical location at which the order was processed. Only present on orders processed at point of sale. - /// - [JsonProperty("location_id")] - public long? LocationId { get; set; } - - /// - /// The customer's order name as represented by a number, e.g. '#1001'. - /// - [JsonProperty("name")] - public string Name { get; set; } - - /// - /// The text of an optional note that a shop owner can attach to the order. - /// - [JsonProperty("note")] - public string Note { get; set; } - - /// - /// Extra information that is added to the order. - /// - [JsonProperty("note_attributes")] - public IEnumerable NoteAttributes { get; set; } - - /// - /// Numerical identifier unique to the shop. A number is sequential and starts at 1000. - /// - [JsonProperty("number")] - public int? Number { get; set; } - - /// - /// A unique numeric identifier for the order. This one is used by the shop owner and customer. - /// This is different from the id property, which is also a unique numeric identifier for the order, but used for API purposes. - /// - [JsonProperty("order_number")] - public int? OrderNumber { get; set; } - - /// - /// The URL pointing to the order status web page. The URL will be null unless the order was created from a checkout. - /// - [JsonProperty("order_status_url")] - public string OrderStatusUrl { get; set; } - - /// - /// The list of all payment gateways used for the order. - /// - [JsonProperty("payment_gateway_names")] - public IEnumerable PaymentGatewayNames { get; set; } - - /// - /// The date that the order was processed at. - /// - [JsonProperty("processed_at")] - public DateTimeOffset? ProcessedAt { get; set; } - - /// - /// The type of payment processing method. Known values are 'checkout', 'direct', 'manual', 'offsite', 'express', 'free' and 'none'. - /// - [JsonProperty("processing_method")] - [Obsolete("Deprecated in version 2023-04. https://shopify.dev/docs/api/release-notes/2023-04#payment-properties-on-the-order-resource-have-been-removed")] - public string ProcessingMethod { get; set; } - - /// - /// The website that the customer clicked on to come to the shop. - /// - [JsonProperty("referring_site")] - public string ReferringSite { get; set; } - - /// - /// The list of objects applied to the order - /// - [JsonProperty("refunds")] - public IEnumerable Refunds { get; set; } - - /// - /// The mailing address to where the order will be shipped. This address is optional and will not be available on orders that do not require one. - /// - [JsonProperty("shipping_address")] - public Address ShippingAddress { get; set; } - - /// - /// An array of objects, each of which details the shipping methods used. - /// - [JsonProperty("shipping_lines")] - public IEnumerable ShippingLines { get; set; } - - /// - /// The ID of the order placed on the originating platform. This value doesn't correspond to the Shopify ID that's generated from a completed draft - /// - [JsonProperty("source_identifier")] - public string SourceIdentifier { get; set; } - - /// - /// Where the order originated. May only be set during creation, and is not writeable thereafter. - /// Orders created via the API may be assigned any string of your choice except for "web", "pos", "iphone", and "android". - /// Default is "api". - /// - [JsonProperty("source_name")] - public string SourceName { get; set; } - - /// - /// Price of the order before shipping and taxes - /// - [JsonProperty("subtotal_price")] - public decimal? SubtotalPrice { get; set; } - - /// - /// An array of objects, each of which details the total taxes applicable to the order. - /// - [JsonProperty("tax_lines")] - public IEnumerable TaxLines { get; set; } - - /// - /// States whether or not taxes are included in the order subtotal. - /// - [JsonProperty("taxes_included")] - public bool? TaxesIncluded { get; set; } - - /// - /// States whether this is a test order. - /// - [JsonProperty("test")] - public bool? Test { get; set; } - - /// - /// Unique identifier for a particular order. - /// - [JsonProperty("token")] - public string Token { get; set; } - - /// - /// The total amount of the discounts applied to the price of the order. - /// - [JsonProperty("total_discounts")] - public decimal? TotalDiscounts { get; set; } - - /// - /// The sum of all the prices of all the items in the order. - /// - [JsonProperty("total_line_items_price")] - public decimal? TotalLineItemsPrice { get; set; } - - /// - /// The sum of all the tips in the order. - /// - [JsonProperty("total_tip_received")] - public decimal? TotalTipReceived { get; set; } - - /// - /// The sum of all the prices of all the items in the order, with taxes and discounts included (must be positive). - /// - [JsonProperty("total_price")] - public decimal? TotalPrice { get; set; } - - /// - /// The sum of all the taxes applied to the order (must be positive). - /// - [JsonProperty("total_tax")] - public decimal? TotalTax { get; set; } - - /// - /// The sum of all the weights of the line items in the order, in grams. - /// - [JsonProperty("total_weight")] - public long? TotalWeight { get; set; } - - /// - /// The date and time when the order was last modified. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - - /// - /// The unique numerical identifier for the user logged into the terminal at the time the order was processed at. Only present on orders processed at point of sale. - /// - [JsonProperty("user_id")] - public long? UserId { get; set; } - - /// - /// An array of objects that detail all of the transactions in - /// this order. - /// - [JsonProperty("transactions")] - public IEnumerable Transactions { get; set; } - - /// - /// Additional metadata about the . Note: This is not naturally returned with a response, as - /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . - /// Uses include: Creating, updating, & deserializing webhook bodies that include them. - /// - [JsonProperty("metafields")] - public IEnumerable Metafields { get; set; } - - /// - /// The current total duties charged on the order in shop and presentment currencies. - /// - [JsonProperty("current_total_duties_set")] - public PriceSet CurrentTotalDutiesSet { get; set; } - - /// - /// The original total duties charged on the order in shop and presentment currencies. - /// - [JsonProperty("original_total_duties_set")] - public PriceSet OriginalTotalDutiesSet { get; set; } - - /// - /// The three letter code (ISO 4217) for the currency used used to display prices to the customer. - /// - [JsonProperty("presentment_currency")] - public string PresentmentCurrency { get; set; } + /// + /// The date and time when the order was created in Shopify. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// The three letter code (ISO 4217) for the currency used for the payment. + /// + [JsonProperty("currency")] + public string Currency { get; set; } + + /// + /// A object containing information about the customer. This value may be null if the order was created through Shopify POS. + /// + [JsonProperty("customer")] + public Customer Customer { get; set; } + + /// + /// The two or three letter language code, optionally followed by a region modifier. Example values could be 'en', 'en-CA', 'en-PIRATE'. + /// + [JsonProperty("customer_locale")] + public string CustomerLocale { get; set; } + + /// + /// The unique numeric identifier of the POS device used. + /// + [JsonProperty("device_id")] + public long? DeviceId { get; set; } + + /// + /// Applicable discount codes that can be applied to the order. + /// + [JsonProperty("discount_codes")] + public IEnumerable DiscountCodes { get; set; } + + /// + /// An ordered list of amounts allocated by discount applications. Each discount allocation is associated to a particular discount application. + /// + [JsonProperty("discount_applications")] + public IEnumerable DiscountApplications { get; set; } + + /// + /// The order's email address. Note: On and after 2015-11-03, you should be using to refer to the customer's email address. + /// Between 2015-11-03 and 2015-12-03, updates to an order's email will also update the customer's email. This is temporary so apps can be migrated over to + /// doing customer updates rather than order updates to change the contact email. After 2015-12-03, updating updating an order's email will no longer update + /// the customer's email and apps will have to use the customer update endpoint to do so. + /// + [JsonProperty("email")] + public string Email { get; set; } + + /// + /// The financial status of an order. Known values are "authorized", "paid", "pending", "partially_paid", "partially_refunded", "refunded" and "voided". + /// + [JsonProperty("financial_status")] + public string FinancialStatus { get; set; } + + /// + /// An array of objects for this order. + /// + [JsonProperty("fulfillments")] + public IEnumerable Fulfillments { get; set; } + + /// + /// The fulfillment status for this order. Known values are 'fulfilled', 'null' and 'partial'. + /// + [JsonProperty("fulfillment_status")] + public string FulfillmentStatus { get; set; } + + /// + /// The customer's phone number. + /// + [JsonProperty("phone")] + public string Phone { get; set; } + + /// + /// Tags are additional short descriptors, commonly used for filtering and searching, formatted as a string of comma-separated values. + /// + [JsonProperty("tags")] + public string Tags { get; set; } + + /// + /// The URL for the page where the buyer landed when entering the shop. + /// + [JsonProperty("landing_site")] + public string LandingSite { get; set; } + + /// + /// An array of objects, each one containing information about an item in the order. + /// + [JsonProperty("line_items")] + public IEnumerable LineItems { get; set; } + + /// + /// The unique numeric identifier for the physical location at which the order was processed. Only present on orders processed at point of sale. + /// + [JsonProperty("location_id")] + public long? LocationId { get; set; } + + /// + /// The customer's order name as represented by a number, e.g. '#1001'. + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// The text of an optional note that a shop owner can attach to the order. + /// + [JsonProperty("note")] + public string Note { get; set; } + + /// + /// Extra information that is added to the order. + /// + [JsonProperty("note_attributes")] + public IEnumerable NoteAttributes { get; set; } + + /// + /// Numerical identifier unique to the shop. A number is sequential and starts at 1000. + /// + [JsonProperty("number")] + public int? Number { get; set; } + + /// + /// A unique numeric identifier for the order. This one is used by the shop owner and customer. + /// This is different from the id property, which is also a unique numeric identifier for the order, but used for API purposes. + /// + [JsonProperty("order_number")] + public int? OrderNumber { get; set; } + + /// + /// The URL pointing to the order status web page. The URL will be null unless the order was created from a checkout. + /// + [JsonProperty("order_status_url")] + public string OrderStatusUrl { get; set; } + + /// + /// The list of all payment gateways used for the order. + /// + [JsonProperty("payment_gateway_names")] + public IEnumerable PaymentGatewayNames { get; set; } + + /// + /// The date that the order was processed at. + /// + [JsonProperty("processed_at")] + public DateTimeOffset? ProcessedAt { get; set; } + + /// + /// The type of payment processing method. Known values are 'checkout', 'direct', 'manual', 'offsite', 'express', 'free' and 'none'. + /// + [JsonProperty("processing_method")] + [Obsolete("Deprecated in version 2023-04. https://shopify.dev/docs/api/release-notes/2023-04#payment-properties-on-the-order-resource-have-been-removed")] + public string ProcessingMethod { get; set; } + + /// + /// The website that the customer clicked on to come to the shop. + /// + [JsonProperty("referring_site")] + public string ReferringSite { get; set; } + + /// + /// The list of objects applied to the order + /// + [JsonProperty("refunds")] + public IEnumerable Refunds { get; set; } + + /// + /// The mailing address to where the order will be shipped. This address is optional and will not be available on orders that do not require one. + /// + [JsonProperty("shipping_address")] + public Address ShippingAddress { get; set; } + + /// + /// An array of objects, each of which details the shipping methods used. + /// + [JsonProperty("shipping_lines")] + public IEnumerable ShippingLines { get; set; } + + /// + /// The ID of the order placed on the originating platform. This value doesn't correspond to the Shopify ID that's generated from a completed draft + /// + [JsonProperty("source_identifier")] + public string SourceIdentifier { get; set; } + + /// + /// Where the order originated. May only be set during creation, and is not writeable thereafter. + /// Orders created via the API may be assigned any string of your choice except for "web", "pos", "iphone", and "android". + /// Default is "api". + /// + [JsonProperty("source_name")] + public string SourceName { get; set; } + + /// + /// Price of the order before shipping and taxes + /// + [JsonProperty("subtotal_price")] + public decimal? SubtotalPrice { get; set; } + + /// + /// An array of objects, each of which details the total taxes applicable to the order. + /// + [JsonProperty("tax_lines")] + public IEnumerable TaxLines { get; set; } + + /// + /// States whether or not taxes are included in the order subtotal. + /// + [JsonProperty("taxes_included")] + public bool? TaxesIncluded { get; set; } + + /// + /// States whether this is a test order. + /// + [JsonProperty("test")] + public bool? Test { get; set; } + + /// + /// Unique identifier for a particular order. + /// + [JsonProperty("token")] + public string Token { get; set; } + + /// + /// The total amount of the discounts applied to the price of the order. + /// + [JsonProperty("total_discounts")] + public decimal? TotalDiscounts { get; set; } + + /// + /// The sum of all the prices of all the items in the order. + /// + [JsonProperty("total_line_items_price")] + public decimal? TotalLineItemsPrice { get; set; } + + /// + /// The sum of all the tips in the order. + /// + [JsonProperty("total_tip_received")] + public decimal? TotalTipReceived { get; set; } + + /// + /// The sum of all the prices of all the items in the order, with taxes and discounts included (must be positive). + /// + [JsonProperty("total_price")] + public decimal? TotalPrice { get; set; } + + /// + /// The sum of all the taxes applied to the order (must be positive). + /// + [JsonProperty("total_tax")] + public decimal? TotalTax { get; set; } + + /// + /// The sum of all the weights of the line items in the order, in grams. + /// + [JsonProperty("total_weight")] + public long? TotalWeight { get; set; } + + /// + /// The date and time when the order was last modified. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } + + /// + /// The unique numerical identifier for the user logged into the terminal at the time the order was processed at. Only present on orders processed at point of sale. + /// + [JsonProperty("user_id")] + public long? UserId { get; set; } + + /// + /// An array of objects that detail all of the transactions in + /// this order. + /// + [JsonProperty("transactions")] + public IEnumerable Transactions { get; set; } + + /// + /// Additional metadata about the . Note: This is not naturally returned with a response, as + /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . + /// Uses include: Creating, updating, & deserializing webhook bodies that include them. + /// + [JsonProperty("metafields")] + public IEnumerable Metafields { get; set; } + + /// + /// The current total duties charged on the order in shop and presentment currencies. + /// + [JsonProperty("current_total_duties_set")] + public PriceSet CurrentTotalDutiesSet { get; set; } + + /// + /// The original total duties charged on the order in shop and presentment currencies. + /// + [JsonProperty("original_total_duties_set")] + public PriceSet OriginalTotalDutiesSet { get; set; } + + /// + /// The three letter code (ISO 4217) for the currency used used to display prices to the customer. + /// + [JsonProperty("presentment_currency")] + public string PresentmentCurrency { get; set; } - /// - /// The total of all line item prices in shop and presentment currencies. - /// - [JsonProperty("total_line_items_price_set")] - public PriceSet TotalLineItemsPriceSet { get; set; } + /// + /// The total of all line item prices in shop and presentment currencies. + /// + [JsonProperty("total_line_items_price_set")] + public PriceSet TotalLineItemsPriceSet { get; set; } - /// - /// The total discounts applied to the price of the order in shop and presentment currencies. - /// - [JsonProperty("total_discounts_set")] - public PriceSet TotalDiscountsSet { get; set; } + /// + /// The total discounts applied to the price of the order in shop and presentment currencies. + /// + [JsonProperty("total_discounts_set")] + public PriceSet TotalDiscountsSet { get; set; } - /// - /// The total shipping price of the order, excluding discounts and returns, in shop and presentment currencies. - /// If taxes_included is set to true, then total_shipping_price_set includes taxes. - /// - [JsonProperty("total_shipping_price_set")] - public PriceSet TotalShippingPriceSet { get; set; } + /// + /// The total shipping price of the order, excluding discounts and returns, in shop and presentment currencies. + /// If taxes_included is set to true, then total_shipping_price_set includes taxes. + /// + [JsonProperty("total_shipping_price_set")] + public PriceSet TotalShippingPriceSet { get; set; } - /// - /// The subtotal of the order in shop and presentment currencies. - /// - [JsonProperty("subtotal_price_set")] - public PriceSet SubtotalPriceSet { get; set; } - - /// - /// The total price of the order in shop and presentment currencies. - /// - [JsonProperty("total_price_set")] - public PriceSet TotalPriceSet { get; set; } + /// + /// The subtotal of the order in shop and presentment currencies. + /// + [JsonProperty("subtotal_price_set")] + public PriceSet SubtotalPriceSet { get; set; } + + /// + /// The total price of the order in shop and presentment currencies. + /// + [JsonProperty("total_price_set")] + public PriceSet TotalPriceSet { get; set; } - /// - /// The total outstanding amount of the order in the shop currency. - /// - [JsonProperty("total_outstanding")] - public string TotalOutstanding { get; set; } - - /// - /// The total tax applied to the order in shop and presentment currencies. - /// - [JsonProperty("total_tax_set")] - public PriceSet TotalTaxSet { get; set; } - - /// - /// Indicates whether taxes on an order are estimated. Will be set to false when taxes on an order are finalized and aren't subject to any change. - /// - [JsonProperty("estimated_taxes")] - public bool? EstimatedTaxes { get; set; } + /// + /// The total outstanding amount of the order in the shop currency. + /// + [JsonProperty("total_outstanding")] + public string TotalOutstanding { get; set; } + + /// + /// The total tax applied to the order in shop and presentment currencies. + /// + [JsonProperty("total_tax_set")] + public PriceSet TotalTaxSet { get; set; } + + /// + /// Indicates whether taxes on an order are estimated. Will be set to false when taxes on an order are finalized and aren't subject to any change. + /// + [JsonProperty("estimated_taxes")] + public bool? EstimatedTaxes { get; set; } - /// - /// The current subtotal price of the order in the shop currency. The value of this field reflects order edits, returns, and refunds. - /// - [JsonProperty("current_subtotal_price")] - public decimal? CurrentSubtotalPrice { get; set; } - - /// - /// The current subtotal price of the order in shop and presentment currencies. The amount values associated with this field reflect order edits, returns, and refunds. - /// - [JsonProperty("current_subtotal_price_set")] - public PriceSet CurrentSubtotalPriceSet { get; set; } + /// + /// The current subtotal price of the order in the shop currency. The value of this field reflects order edits, returns, and refunds. + /// + [JsonProperty("current_subtotal_price")] + public decimal? CurrentSubtotalPrice { get; set; } + + /// + /// The current subtotal price of the order in shop and presentment currencies. The amount values associated with this field reflect order edits, returns, and refunds. + /// + [JsonProperty("current_subtotal_price_set")] + public PriceSet CurrentSubtotalPriceSet { get; set; } - /// - /// The current total discounts on the order in the shop currency. The value of this field reflects order edits, returns, and refunds. - /// - [JsonProperty("current_total_discounts")] - public decimal? CurrentTotalDiscounts { get; set; } - - /// - /// The current total discounts on the order in shop and presentment currencies. The amount values associated with this field reflect order edits, returns, and refunds. - /// - [JsonProperty("current_total_discounts_set")] - public PriceSet CurrentTotalDiscountsSet { get; set; } + /// + /// The current total discounts on the order in the shop currency. The value of this field reflects order edits, returns, and refunds. + /// + [JsonProperty("current_total_discounts")] + public decimal? CurrentTotalDiscounts { get; set; } + + /// + /// The current total discounts on the order in shop and presentment currencies. The amount values associated with this field reflect order edits, returns, and refunds. + /// + [JsonProperty("current_total_discounts_set")] + public PriceSet CurrentTotalDiscountsSet { get; set; } - /// - /// The current total price of the order in the shop currency. The value of this field reflects order edits, returns, and refunds. - /// - [JsonProperty("current_total_price")] - public decimal? CurrentTotalPrice { get; set; } - - /// - /// The current total price of the order in shop and presentment currencies. The amount values associated with this field reflect order edits, returns, and refunds. - /// - [JsonProperty("current_total_price_set")] - public PriceSet CurrentTotalPriceSet { get; set; } + /// + /// The current total price of the order in the shop currency. The value of this field reflects order edits, returns, and refunds. + /// + [JsonProperty("current_total_price")] + public decimal? CurrentTotalPrice { get; set; } + + /// + /// The current total price of the order in shop and presentment currencies. The amount values associated with this field reflect order edits, returns, and refunds. + /// + [JsonProperty("current_total_price_set")] + public PriceSet CurrentTotalPriceSet { get; set; } - /// - /// The current total taxes charged on the order in the shop currency. The value of this field reflects order edits, returns, or refunds. - /// - [JsonProperty("current_total_tax")] - public decimal? CurrentTotalTax { get; set; } - - /// - /// The current total taxes charged on the order in shop and presentment currencies. The amount values associated with this field reflect order edits, returns, and refunds. - /// - [JsonProperty("current_total_tax_set")] - public PriceSet CurrentTotalTaxSet { get; set; } + /// + /// The current total taxes charged on the order in the shop currency. The value of this field reflects order edits, returns, or refunds. + /// + [JsonProperty("current_total_tax")] + public decimal? CurrentTotalTax { get; set; } + + /// + /// The current total taxes charged on the order in shop and presentment currencies. The amount values associated with this field reflect order edits, returns, and refunds. + /// + [JsonProperty("current_total_tax_set")] + public PriceSet CurrentTotalTaxSet { get; set; } - /// - /// The terms and conditions under which a payment should be processed. - /// - [JsonProperty("payment_terms")] - public PaymentTerms PaymentTerms { get; set; } - - /// - /// The current total additional fees on the order in shop and presentment currencies. The amount values associated with this field reflect order edits, returns, and refunds. - /// - [JsonProperty("current_total_additional_fees_set")] - public PriceSet CurrentTotalAdditionalFeesSet { get; set; } - - /// - /// The original total additional fees on the order in shop and presentment currencies. - /// - [JsonProperty("original_total_additional_fees_set")] - public PriceSet OriginalTotalAdditionalFeesSet { get; set; } - - /// - /// The purchase order number associated to this order - /// - [JsonProperty("po_number")] - public string PoNumber { get; set; } - - /// - /// Whether this order was exempt from taxes. - /// - [JsonProperty("tax_exempt")] - public bool? TaxExempt { get; set; } - - [JsonProperty("company")] - public OrderCompany Company { get; set; } - } -} + /// + /// The terms and conditions under which a payment should be processed. + /// + [JsonProperty("payment_terms")] + public PaymentTerms PaymentTerms { get; set; } + + /// + /// The current total additional fees on the order in shop and presentment currencies. The amount values associated with this field reflect order edits, returns, and refunds. + /// + [JsonProperty("current_total_additional_fees_set")] + public PriceSet CurrentTotalAdditionalFeesSet { get; set; } + + /// + /// The original total additional fees on the order in shop and presentment currencies. + /// + [JsonProperty("original_total_additional_fees_set")] + public PriceSet OriginalTotalAdditionalFeesSet { get; set; } + + /// + /// The purchase order number associated to this order + /// + [JsonProperty("po_number")] + public string PoNumber { get; set; } + + /// + /// Whether this order was exempt from taxes. + /// + [JsonProperty("tax_exempt")] + public bool? TaxExempt { get; set; } + + [JsonProperty("company")] + public OrderCompany Company { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/OrderCompany.cs b/ShopifySharp/Entities/OrderCompany.cs index 93e67c01..848484a4 100644 --- a/ShopifySharp/Entities/OrderCompany.cs +++ b/ShopifySharp/Entities/OrderCompany.cs @@ -1,16 +1,15 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a company and its location +/// +public class OrderCompany { - /// - /// An object representing a company and its location - /// - public class OrderCompany - { - [JsonProperty("id")] - public long? Id { get; set; } + [JsonProperty("id")] + public long? Id { get; set; } - [JsonProperty("location_id")] - public long? LocationId { get; set; } - } -} + [JsonProperty("location_id")] + public long? LocationId { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/OrderEdit.cs b/ShopifySharp/Entities/OrderEdit.cs index 494482ba..1b4ad0ea 100644 --- a/ShopifySharp/Entities/OrderEdit.cs +++ b/ShopifySharp/Entities/OrderEdit.cs @@ -1,53 +1,52 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify order edit. +/// +public class OrderEdit : ShopifyObject { /// - /// An object representing a Shopify order edit. + /// Unique identifier of the app who created the order edit. + /// + [JsonProperty("app_id")] + public long? AppId { get; set; } + + /// + /// The date and time when the order was edited in Shopify. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// A flag indicating whether the customer should be notified. + /// + [JsonProperty("notify_customer")] + public bool? NotifyCustomer { get; set; } + + /// + /// The unique numeric identifier for the order associated to this edit + /// + [JsonProperty("order_id")] + public long? OrderId { get; set; } + + /// + /// The text of an optional note that a shop owner can attach to the order. + /// + [JsonProperty("staff_note")] + public string StaffNote { get; set; } + + /// + /// The unique numerical identifier of the user that made this edit + /// + [JsonProperty("user_id")] + public long? UserId { get; set; } + + /// + /// Changes to line items /// - public class OrderEdit : ShopifyObject - { - /// - /// Unique identifier of the app who created the order edit. - /// - [JsonProperty("app_id")] - public long? AppId { get; set; } - - /// - /// The date and time when the order was edited in Shopify. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// A flag indicating whether the customer should be notified. - /// - [JsonProperty("notify_customer")] - public bool? NotifyCustomer { get; set; } - - /// - /// The unique numeric identifier for the order associated to this edit - /// - [JsonProperty("order_id")] - public long? OrderId { get; set; } - - /// - /// The text of an optional note that a shop owner can attach to the order. - /// - [JsonProperty("staff_note")] - public string StaffNote { get; set; } - - /// - /// The unique numerical identifier of the user that made this edit - /// - [JsonProperty("user_id")] - public long? UserId { get; set; } - - /// - /// Changes to line items - /// - [JsonProperty("line_items")] - public OrderEditLineItems LineItems { get; set; } - } -} + [JsonProperty("line_items")] + public OrderEditLineItems LineItems { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/OrderEditLineItemDelta.cs b/ShopifySharp/Entities/OrderEditLineItemDelta.cs index 8efe29c7..93e498f4 100644 --- a/ShopifySharp/Entities/OrderEditLineItemDelta.cs +++ b/ShopifySharp/Entities/OrderEditLineItemDelta.cs @@ -1,17 +1,16 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify line item addition or removal. +/// The Id of this object is the Id of the line item being edited +/// +public class OrderEditLineItemDelta : ShopifyObject { /// - /// An object representing a Shopify line item addition or removal. - /// The Id of this object is the Id of the line item being edited + /// The quantiy added or removed /// - public class OrderEditLineItemDelta : ShopifyObject - { - /// - /// The quantiy added or removed - /// - [JsonProperty("delta")] - public int? Delta { get; set; } - } -} + [JsonProperty("delta")] + public int? Delta { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/OrderEditLineItems.cs b/ShopifySharp/Entities/OrderEditLineItems.cs index fba6f4d3..ba33354a 100644 --- a/ShopifySharp/Entities/OrderEditLineItems.cs +++ b/ShopifySharp/Entities/OrderEditLineItems.cs @@ -1,24 +1,23 @@ using Newtonsoft.Json; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify line item edit. +/// The Id of this object is the Id of the line item being edited +/// +public class OrderEditLineItems { /// - /// An object representing a Shopify line item edit. - /// The Id of this object is the Id of the line item being edited + /// The additions to the line item /// - public class OrderEditLineItems - { - /// - /// The additions to the line item - /// - [JsonProperty("additions")] - public IEnumerable Additions { get; set; } + [JsonProperty("additions")] + public IEnumerable Additions { get; set; } - /// - /// The removals to the line item - /// - [JsonProperty("removals")] - public IEnumerable Removals { get; set; } - } -} + /// + /// The removals to the line item + /// + [JsonProperty("removals")] + public IEnumerable Removals { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/OrderEditWebhook.cs b/ShopifySharp/Entities/OrderEditWebhook.cs index 436e424a..e9f0c608 100644 --- a/ShopifySharp/Entities/OrderEditWebhook.cs +++ b/ShopifySharp/Entities/OrderEditWebhook.cs @@ -1,16 +1,15 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify order edit webhook (orders/edited topic) +/// +public class OrderEditWebhook { /// - /// An object representing a Shopify order edit webhook (orders/edited topic) + /// The OrderEdit object /// - public class OrderEditWebhook - { - /// - /// The OrderEdit object - /// - [JsonProperty("order_edit")] - public OrderEdit OrderEdit { get; set; } - } -} + [JsonProperty("order_edit")] + public OrderEdit OrderEdit { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/OrderRisk.cs b/ShopifySharp/Entities/OrderRisk.cs index 075a3969..20fdca48 100644 --- a/ShopifySharp/Entities/OrderRisk.cs +++ b/ShopifySharp/Entities/OrderRisk.cs @@ -1,59 +1,58 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify order risk. +/// +public class OrderRisk : ShopifyObject { /// - /// An object representing a Shopify order risk. - /// - public class OrderRisk : ShopifyObject - { - /// - /// Use this flag when a fraud check is accompanied with a call to the Orders API to cancel the order. This will indicate to the merchant that this risk was severe enough to force cancellation of the order. - /// Note: Setting this parameter does not cancel the order. This must be done by the Orders API. - /// - [JsonProperty("cause_cancel")] - public bool? CauseCancel { get; set; } - - /// - /// The ID of the checkout that the order risk belongs to. - /// - [JsonProperty("checkout_id")] - public long? CheckoutId { get; set; } - - /// - /// States whether or not the risk is displayed. Valid values are "true" or "false". - /// - [JsonProperty("display")] - public bool? Display { get; set; } - - /// - /// The id of the order the order risk belongs to - /// - [JsonProperty("order_id")] - public long? OrderId { get; set; } - - /// - /// A message that should be displayed to the merchant to indicate the results of the fraud check. - /// - [JsonProperty("message")] - public string Message { get; set; } - - /// - /// The recommended action given to the merchant. Known values are 'cancel', 'investigate' and 'accept'. - /// - [JsonProperty("recommendation")] - public string Recommendation { get; set; } - - /// - /// A number between 0 and 1 indicating percentage likelihood of being fraud. - /// - [JsonProperty("score")] - public decimal? Score { get; set; } - - /// - /// This indicates the source of the risk assessment. Known values are 'External', 'Internal' and 'Gateway'. - /// - [JsonProperty("source")] - public string Source { get; set; } - } -} + /// Use this flag when a fraud check is accompanied with a call to the Orders API to cancel the order. This will indicate to the merchant that this risk was severe enough to force cancellation of the order. + /// Note: Setting this parameter does not cancel the order. This must be done by the Orders API. + /// + [JsonProperty("cause_cancel")] + public bool? CauseCancel { get; set; } + + /// + /// The ID of the checkout that the order risk belongs to. + /// + [JsonProperty("checkout_id")] + public long? CheckoutId { get; set; } + + /// + /// States whether or not the risk is displayed. Valid values are "true" or "false". + /// + [JsonProperty("display")] + public bool? Display { get; set; } + + /// + /// The id of the order the order risk belongs to + /// + [JsonProperty("order_id")] + public long? OrderId { get; set; } + + /// + /// A message that should be displayed to the merchant to indicate the results of the fraud check. + /// + [JsonProperty("message")] + public string Message { get; set; } + + /// + /// The recommended action given to the merchant. Known values are 'cancel', 'investigate' and 'accept'. + /// + [JsonProperty("recommendation")] + public string Recommendation { get; set; } + + /// + /// A number between 0 and 1 indicating percentage likelihood of being fraud. + /// + [JsonProperty("score")] + public decimal? Score { get; set; } + + /// + /// This indicates the source of the risk assessment. Known values are 'External', 'Internal' and 'Gateway'. + /// + [JsonProperty("source")] + public string Source { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/OutgoingFulfillmentRequestOptions.cs b/ShopifySharp/Entities/OutgoingFulfillmentRequestOptions.cs index b28bdeec..cd805fb9 100644 --- a/ShopifySharp/Entities/OutgoingFulfillmentRequestOptions.cs +++ b/ShopifySharp/Entities/OutgoingFulfillmentRequestOptions.cs @@ -1,10 +1,9 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class OutgoingFulfillmentRequestOptions { - public class OutgoingFulfillmentRequestOptions - { - [JsonProperty("notify_customer")] - public bool? NotifyCustomer { get; set; } - } + [JsonProperty("notify_customer")] + public bool? NotifyCustomer { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/OutgoingRequest.cs b/ShopifySharp/Entities/OutgoingRequest.cs index b7d2f02f..a9bb1890 100644 --- a/ShopifySharp/Entities/OutgoingRequest.cs +++ b/ShopifySharp/Entities/OutgoingRequest.cs @@ -1,29 +1,28 @@ -using System; +using System; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class OutgoingRequest { - public class OutgoingRequest - { - /// - /// The message returned by the merchant, if any. - /// - [JsonProperty("message")] - public string Message { get; set; } + /// + /// The message returned by the merchant, if any. + /// + [JsonProperty("message")] + public string Message { get; set; } - /// - /// The request options returned by the merchant, if any. - /// - [JsonProperty("request_options")] - public OutgoingFulfillmentRequestOptions RequestOptions { get; set; } + /// + /// The request options returned by the merchant, if any. + /// + [JsonProperty("request_options")] + public OutgoingFulfillmentRequestOptions RequestOptions { get; set; } - [JsonProperty("sent_at")] - public DateTimeOffset? SentAt { get; set; } + [JsonProperty("sent_at")] + public DateTimeOffset? SentAt { get; set; } - /// - /// The kind of request. Known valid values: "fulfillment_request", "cancellation_request", or "legacy_fulfill_request". - /// - [JsonProperty("kind")] - public string Kind { get; set; } - } + /// + /// The kind of request. Known valid values: "fulfillment_request", "cancellation_request", or "legacy_fulfill_request". + /// + [JsonProperty("kind")] + public string Kind { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/Page.cs b/ShopifySharp/Entities/Page.cs index a31bca3f..1b7554b6 100644 --- a/ShopifySharp/Entities/Page.cs +++ b/ShopifySharp/Entities/Page.cs @@ -2,64 +2,63 @@ using System; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An entity representing a Shopify product. +/// +public class Page : ShopifyObject { /// - /// An entity representing a Shopify product. + /// The name of the page. /// - public class Page : ShopifyObject - { - /// - /// The name of the page. - /// - [JsonProperty("title")] - public string Title { get; set; } + [JsonProperty("title")] + public string Title { get; set; } - /// - /// The content of the page, complete with HTML formatting. - /// - [JsonProperty("body_html")] - public string BodyHtml { get; set; } + /// + /// The content of the page, complete with HTML formatting. + /// + [JsonProperty("body_html")] + public string BodyHtml { get; set; } - /// - /// The date and time when the page was created. The API returns this value in ISO 8601 format. - /// - [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? CreatedAt { get; set; } + /// + /// The date and time when the page was created. The API returns this value in ISO 8601 format. + /// + [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? CreatedAt { get; set; } - /// - /// The date and time when the page was last modified. The API returns this value in ISO 8601 format. - /// - [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? UpdatedAt { get; set; } + /// + /// The date and time when the page was last modified. The API returns this value in ISO 8601 format. + /// + [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? UpdatedAt { get; set; } - /// - /// The date and time when the page was published. The API returns this value in ISO 8601 format. - /// - [JsonProperty("published_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? PublishedAt { get; set; } + /// + /// The date and time when the page was published. The API returns this value in ISO 8601 format. + /// + [JsonProperty("published_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? PublishedAt { get; set; } - /// - /// A human-friendly unique string for the page automatically generated from its title. - /// They are used by the Liquid templating language to refer to objects. - /// - [JsonProperty("handle")] - public string Handle { get; set; } + /// + /// A human-friendly unique string for the page automatically generated from its title. + /// They are used by the Liquid templating language to refer to objects. + /// + [JsonProperty("handle")] + public string Handle { get; set; } - /// - /// The suffix of the liquid template being used. - /// By default, the original template is called product.liquid, without any suffix. - /// Any additional templates will be: product.suffix.liquid. - /// - [JsonProperty("template_suffix")] - public string TemplateSuffix { get; set; } + /// + /// The suffix of the liquid template being used. + /// By default, the original template is called product.liquid, without any suffix. + /// Any additional templates will be: product.suffix.liquid. + /// + [JsonProperty("template_suffix")] + public string TemplateSuffix { get; set; } - /// - /// Additional metadata about the . Note: This is not naturally returned with a response, as - /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . - /// Uses include: Creating, updating, & deserializing webhook bodies that include them. - /// - [JsonProperty("metafields")] - public IEnumerable Metafields { get; set; } - } -} + /// + /// Additional metadata about the . Note: This is not naturally returned with a response, as + /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . + /// Uses include: Creating, updating, & deserializing webhook bodies that include them. + /// + [JsonProperty("metafields")] + public IEnumerable Metafields { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/PaymentDetails.cs b/ShopifySharp/Entities/PaymentDetails.cs index 5d4e1a88..e5dbedbd 100644 --- a/ShopifySharp/Entities/PaymentDetails.cs +++ b/ShopifySharp/Entities/PaymentDetails.cs @@ -1,46 +1,45 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class PaymentDetails { - public class PaymentDetails - { - [JsonProperty("avs_result_code")] - public string AvsResultCode { get; set; } + [JsonProperty("avs_result_code")] + public string AvsResultCode { get; set; } - [JsonProperty("credit_card_bin")] - public string CreditCardBin { get; set; } + [JsonProperty("credit_card_bin")] + public string CreditCardBin { get; set; } - [JsonProperty("cvv_result_code")] - public string CvvResultCode { get; set; } + [JsonProperty("cvv_result_code")] + public string CvvResultCode { get; set; } - [JsonProperty("credit_card_number")] - public string CreditCardNumber { get; set; } + [JsonProperty("credit_card_number")] + public string CreditCardNumber { get; set; } - [JsonProperty("credit_card_company")] - public string CreditCardCompany { get; set; } + [JsonProperty("credit_card_company")] + public string CreditCardCompany { get; set; } - [JsonProperty("credit_card_name")] - public string CreditCardName { get; set; } + [JsonProperty("credit_card_name")] + public string CreditCardName { get; set; } - [JsonProperty("credit_card_wallet")] - public string CreditCardWallet { get; set; } + [JsonProperty("credit_card_wallet")] + public string CreditCardWallet { get; set; } - [JsonProperty("credit_card_expiration_month")] - public int? CreditCardExpirationMonth { get; set; } + [JsonProperty("credit_card_expiration_month")] + public int? CreditCardExpirationMonth { get; set; } - [JsonProperty("credit_card_expiration_year")] - public int? CreditCardExpirationYear { get; set; } + [JsonProperty("credit_card_expiration_year")] + public int? CreditCardExpirationYear { get; set; } - /// - /// The name of the payment method used by the buyer to complete the order transaction. - /// - [JsonProperty("payment_method_name")] - public string PaymentMethodName { get; set; } + /// + /// The name of the payment method used by the buyer to complete the order transaction. + /// + [JsonProperty("payment_method_name")] + public string PaymentMethodName { get; set; } - /// - /// Details for payment methods that require additional buyer action to complete the order transaction. - /// - [JsonProperty("buyer_action_info")] - public object BuyerActionInfo { get; set; } - } -} + /// + /// Details for payment methods that require additional buyer action to complete the order transaction. + /// + [JsonProperty("buyer_action_info")] + public object BuyerActionInfo { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/PaymentSchedule.cs b/ShopifySharp/Entities/PaymentSchedule.cs index 34e013f4..af5d7a25 100644 --- a/ShopifySharp/Entities/PaymentSchedule.cs +++ b/ShopifySharp/Entities/PaymentSchedule.cs @@ -1,44 +1,43 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +public class PaymentSchedule { - public class PaymentSchedule - { - /// - /// The amount that is owed according to the payment terms. - /// - [JsonProperty("amount")] - public decimal? amount { get; set; } + /// + /// The amount that is owed according to the payment terms. + /// + [JsonProperty("amount")] + public decimal? amount { get; set; } - /// - /// The presentment currency for the payment - /// - [JsonProperty("currency")] - public string Currency { get; set; } + /// + /// The presentment currency for the payment + /// + [JsonProperty("currency")] + public string Currency { get; set; } - /// - /// The date and time when the payment terms were initiated - /// - [JsonProperty("issued_at")] - public DateTimeOffset? IssuedAt { get; set; } + /// + /// The date and time when the payment terms were initiated + /// + [JsonProperty("issued_at")] + public DateTimeOffset? IssuedAt { get; set; } - /// - /// The date and time when the payment is due. Calculated based on issued_at and due_in_days or a customized fixed date if the type is fixed. - /// - [JsonProperty("due_at")] - public DateTimeOffset? DueAt { get; set; } + /// + /// The date and time when the payment is due. Calculated based on issued_at and due_in_days or a customized fixed date if the type is fixed. + /// + [JsonProperty("due_at")] + public DateTimeOffset? DueAt { get; set; } - /// - /// The date and time when the purchase is completed. Returns null initially and updates when the payment is captured - /// - [JsonProperty("completed_at")] - public DateTimeOffset? CompletedAt { get; set; } + /// + /// The date and time when the purchase is completed. Returns null initially and updates when the payment is captured + /// + [JsonProperty("completed_at")] + public DateTimeOffset? CompletedAt { get; set; } - /// - /// The name of the payment method gateway. - /// - [JsonProperty("expected_payment_method")] - public string ExpectedPaymentMethod { get; set; } - } -} + /// + /// The name of the payment method gateway. + /// + [JsonProperty("expected_payment_method")] + public string ExpectedPaymentMethod { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/PaymentTerms.cs b/ShopifySharp/Entities/PaymentTerms.cs index cfe98fb4..ce3ec51d 100644 --- a/ShopifySharp/Entities/PaymentTerms.cs +++ b/ShopifySharp/Entities/PaymentTerms.cs @@ -1,43 +1,42 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class PaymentTerms { - public class PaymentTerms - { - /// - /// The amount that is owed according to the payment terms. - /// - [JsonProperty("amount")] - public decimal? amount { get; set; } + /// + /// The amount that is owed according to the payment terms. + /// + [JsonProperty("amount")] + public decimal? amount { get; set; } - /// - /// The presentment currency for the payment - /// - [JsonProperty("currency")] - public string Currency { get; set; } + /// + /// The presentment currency for the payment + /// + [JsonProperty("currency")] + public string Currency { get; set; } - /// - /// The number of days between the invoice date and due date that is defined in the selected payment terms template. - /// - [JsonProperty("due_in_days")] - public int? DueInDays { get; set; } + /// + /// The number of days between the invoice date and due date that is defined in the selected payment terms template. + /// + [JsonProperty("due_in_days")] + public int? DueInDays { get; set; } - /// - /// The name of the selected payment terms template for the order. - /// - [JsonProperty("payment_terms_name")] - public string PaymentTermsName { get; set; } + /// + /// The name of the selected payment terms template for the order. + /// + [JsonProperty("payment_terms_name")] + public string PaymentTermsName { get; set; } - /// - /// The type of selected payment terms template for the order. - /// - [JsonProperty("payment_terms_type")] - public string PaymentTermsType { get; set; } + /// + /// The type of selected payment terms template for the order. + /// + [JsonProperty("payment_terms_type")] + public string PaymentTermsType { get; set; } - /// - /// An array of schedules associated to the payment terms. - /// - [JsonProperty("payment_schedules")] - public PaymentSchedule[] PaymentSchedules { get; set; } - } -} + /// + /// An array of schedules associated to the payment terms. + /// + [JsonProperty("payment_schedules")] + public PaymentSchedule[] PaymentSchedules { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/PaymentsRefundAttributes.cs b/ShopifySharp/Entities/PaymentsRefundAttributes.cs index bad0ea80..1c45bef1 100644 --- a/ShopifySharp/Entities/PaymentsRefundAttributes.cs +++ b/ShopifySharp/Entities/PaymentsRefundAttributes.cs @@ -1,20 +1,19 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class PaymentsRefundAttributes { - public class PaymentsRefundAttributes - { - /// - /// The current status of the refund. Valid values: pending, failure, success, and error. - /// - [JsonProperty("status")] - public string Status { get; set; } + /// + /// The current status of the refund. Valid values: pending, failure, success, and error. + /// + [JsonProperty("status")] + public string Status { get; set; } - /// - /// A unique number associated with the transaction that can be used to track the refund. - /// This property has a value only for transactions completed with Visa or Mastercard. - /// - [JsonProperty("acquirer_reference_number")] - public string AcquirerReferenceNumber { get; set; } - } -} + /// + /// A unique number associated with the transaction that can be used to track the refund. + /// This property has a value only for transactions completed with Visa or Mastercard. + /// + [JsonProperty("acquirer_reference_number")] + public string AcquirerReferenceNumber { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/Policy.cs b/ShopifySharp/Entities/Policy.cs index 5c5c029c..ebe834a6 100644 --- a/ShopifySharp/Entities/Policy.cs +++ b/ShopifySharp/Entities/Policy.cs @@ -1,38 +1,37 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +public class Policy { - public class Policy - { - /// - /// The name of the policy. - /// - [JsonProperty("title")] - public string Title { get; set; } + /// + /// The name of the policy. + /// + [JsonProperty("title")] + public string Title { get; set; } - /// - /// The content of the policy. - /// - [JsonProperty("body")] - public string Body { get; set; } + /// + /// The content of the policy. + /// + [JsonProperty("body")] + public string Body { get; set; } - /// - /// The public URL to policy. - /// - [JsonProperty("url")] - public string Url { get; set; } + /// + /// The public URL to policy. + /// + [JsonProperty("url")] + public string Url { get; set; } - /// - /// The date and time when the policy was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + /// + /// The date and time when the policy was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - /// - /// The date and time when the policy was last modified. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - } -} + /// + /// The date and time when the policy was last modified. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/PrerequisiteQuantityRange.cs b/ShopifySharp/Entities/PrerequisiteQuantityRange.cs index 9158e1c2..7c69fc4a 100644 --- a/ShopifySharp/Entities/PrerequisiteQuantityRange.cs +++ b/ShopifySharp/Entities/PrerequisiteQuantityRange.cs @@ -1,10 +1,9 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class PrerequisiteQuantityRange { - public class PrerequisiteQuantityRange - { - [JsonProperty("greater_than_or_equal_to")] - public int? GreaterThanOrEqualTo { get; set; } - } -} + [JsonProperty("greater_than_or_equal_to")] + public int? GreaterThanOrEqualTo { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/PrerequisiteToEntitlementPurchase.cs b/ShopifySharp/Entities/PrerequisiteToEntitlementPurchase.cs index 6ddd1b5e..cdcc45be 100644 --- a/ShopifySharp/Entities/PrerequisiteToEntitlementPurchase.cs +++ b/ShopifySharp/Entities/PrerequisiteToEntitlementPurchase.cs @@ -1,10 +1,9 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class PrerequisiteToEntitlementPurchase { - public class PrerequisiteToEntitlementPurchase - { - [JsonProperty("prerequisite_amount")] - public string PrerequisiteAmount { get; set; } - } + [JsonProperty("prerequisite_amount")] + public string PrerequisiteAmount { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/PrerequisiteToEntitlementQuantityRatio.cs b/ShopifySharp/Entities/PrerequisiteToEntitlementQuantityRatio.cs index 86abd583..99526b06 100644 --- a/ShopifySharp/Entities/PrerequisiteToEntitlementQuantityRatio.cs +++ b/ShopifySharp/Entities/PrerequisiteToEntitlementQuantityRatio.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class PrerequisiteToEntitlementQuantityRatio { - public class PrerequisiteToEntitlementQuantityRatio - { - [JsonProperty("prerequisite_quantity")] - public int? PrerequisiteQuantity { get; set; } + [JsonProperty("prerequisite_quantity")] + public int? PrerequisiteQuantity { get; set; } - [JsonProperty("entitled_quantity")] - public int? EntitledQuantity { get; set; } - } -} + [JsonProperty("entitled_quantity")] + public int? EntitledQuantity { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/PrerequisiteValueRange.cs b/ShopifySharp/Entities/PrerequisiteValueRange.cs index e37a95f2..b69b6981 100644 --- a/ShopifySharp/Entities/PrerequisiteValueRange.cs +++ b/ShopifySharp/Entities/PrerequisiteValueRange.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class PrerequisiteValueRange { - public class PrerequisiteValueRange - { - [JsonProperty("less_than_or_equal_to")] - public decimal? LessThanOrEqualTo { get; set; } + [JsonProperty("less_than_or_equal_to")] + public decimal? LessThanOrEqualTo { get; set; } - [JsonProperty("greater_than_or_equal_to")] - public decimal? GreaterThanOrEqualTo { get; set; } - } + [JsonProperty("greater_than_or_equal_to")] + public decimal? GreaterThanOrEqualTo { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/PresentmentPrice.cs b/ShopifySharp/Entities/PresentmentPrice.cs index dce8516f..7e86e692 100644 --- a/ShopifySharp/Entities/PresentmentPrice.cs +++ b/ShopifySharp/Entities/PresentmentPrice.cs @@ -1,19 +1,18 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class PresentmentPrice { - public class PresentmentPrice - { - /// - /// The price of the product variant. - /// - [JsonProperty("price")] - public Price Price { get; set; } + /// + /// The price of the product variant. + /// + [JsonProperty("price")] + public Price Price { get; set; } - /// - /// The competitors prices for the same item. - /// - [JsonProperty("compare_at_price")] - public Price CompareAtPrice { get; set; } - } + /// + /// The competitors prices for the same item. + /// + [JsonProperty("compare_at_price")] + public Price CompareAtPrice { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/Price.cs b/ShopifySharp/Entities/Price.cs index 9866437e..a3e30801 100644 --- a/ShopifySharp/Entities/Price.cs +++ b/ShopifySharp/Entities/Price.cs @@ -1,19 +1,18 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class Price { - public class Price - { - /// - /// The three-letter code (ISO 4217 format) for currency. - /// - [JsonProperty("currency_code")] - public string CurrencyCode { get; set; } + /// + /// The three-letter code (ISO 4217 format) for currency. + /// + [JsonProperty("currency_code")] + public string CurrencyCode { get; set; } - /// - /// The amount in the currency. - /// - [JsonProperty("amount")] - public decimal? Amount { get; set; } - } + /// + /// The amount in the currency. + /// + [JsonProperty("amount")] + public decimal? Amount { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/PriceBasedShippingRate.cs b/ShopifySharp/Entities/PriceBasedShippingRate.cs index 0b6c6454..20dc29ec 100644 --- a/ShopifySharp/Entities/PriceBasedShippingRate.cs +++ b/ShopifySharp/Entities/PriceBasedShippingRate.cs @@ -1,37 +1,36 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class PriceBasedShippingRate : ShopifyObject { - public class PriceBasedShippingRate : ShopifyObject - { - /// - /// The name of the price based shipping rate, specified by the user. - /// - [JsonProperty("name")] - public string Name { get; set; } + /// + /// The name of the price based shipping rate, specified by the user. + /// + [JsonProperty("name")] + public string Name { get; set; } - /// - /// Minimum order price - /// - [JsonProperty("min_order_subtotal")] - public decimal? MinOrderSubtotal { get; set; } + /// + /// Minimum order price + /// + [JsonProperty("min_order_subtotal")] + public decimal? MinOrderSubtotal { get; set; } - /// - /// Rate amount - /// - [JsonProperty("price")] - public decimal? Price { get; set; } + /// + /// Rate amount + /// + [JsonProperty("price")] + public decimal? Price { get; set; } - /// - /// Maximum order price - /// - [JsonProperty("max_order_subtotal")] - public decimal? MaxOrderSubtotal { get; set; } + /// + /// Maximum order price + /// + [JsonProperty("max_order_subtotal")] + public decimal? MaxOrderSubtotal { get; set; } - /// - /// Shipping zone id - /// - [JsonProperty("shipping_zone_id")] - public long? ShippingZoneId { get; set; } - } + /// + /// Shipping zone id + /// + [JsonProperty("shipping_zone_id")] + public long? ShippingZoneId { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/PriceRule.cs b/ShopifySharp/Entities/PriceRule.cs index 991b65ed..4988e4ff 100644 --- a/ShopifySharp/Entities/PriceRule.cs +++ b/ShopifySharp/Entities/PriceRule.cs @@ -2,276 +2,275 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class PriceRule : ShopifyObject { - public class PriceRule : ShopifyObject - { - /** - * The title of the price rule. - */ - [JsonProperty("title")] - public string Title { get; set; } + /** + * The title of the price rule. + */ + [JsonProperty("title")] + public string Title { get; set; } - /** - * The target type the price rule applies to. Known values are "line_item" or "shipping_line". - */ - [JsonProperty("target_type")] - public string TargetType { get; set; } + /** + * The target type the price rule applies to. Known values are "line_item" or "shipping_line". + */ + [JsonProperty("target_type")] + public string TargetType { get; set; } - /** - * The target selection method of the price rule. Use all to apply the discount to all line items - * in the checkout and use entitled to apply to selected entitlements. Known values are "all" or "entitled". - */ - [JsonProperty("target_selection")] - public string TargetSelection { get; set; } + /** + * The target selection method of the price rule. Use all to apply the discount to all line items + * in the checkout and use entitled to apply to selected entitlements. Known values are "all" or "entitled". + */ + [JsonProperty("target_selection")] + public string TargetSelection { get; set; } - /** - * The allocation method of the price rule. - * With an allocation method of each, the discount will be applied to each of the entitled items. For example, for a price rule that take $15 off, each entitled line item in a checkout will be discounted by $15. - * With an allocation method of across, the calculated discount amount will be applied across the entitled items.For example, for a price rule that takes $15 off, the discount will be applied across all the entitled items. - * Currently, if TargetType is shipping_line, then only each is accepted. Known values are "across" or "each". - */ - [JsonProperty("allocation_method")] - public string AllocationMethod { get; set; } + /** + * The allocation method of the price rule. + * With an allocation method of each, the discount will be applied to each of the entitled items. For example, for a price rule that take $15 off, each entitled line item in a checkout will be discounted by $15. + * With an allocation method of across, the calculated discount amount will be applied across the entitled items.For example, for a price rule that takes $15 off, the discount will be applied across all the entitled items. + * Currently, if TargetType is shipping_line, then only each is accepted. Known values are "across" or "each". + */ + [JsonProperty("allocation_method")] + public string AllocationMethod { get; set; } - /** - * The value type of the price rule. If target_type is shipping_line then only percentage is accepted. Known values are "fixed_amount" or "percentage". - */ - [JsonProperty("value_type")] - public string ValueType { get; set; } + /** + * The value type of the price rule. If target_type is shipping_line then only percentage is accepted. Known values are "fixed_amount" or "percentage". + */ + [JsonProperty("value_type")] + public string ValueType { get; set; } - /** - * The value of the price rule. If target_type is shipping_line, then only -100 is accepted. - * It's important to note that when discounting a resource, the value must be a negative number. - */ - [JsonProperty("value")] - public decimal Value { get; set; } + /** + * The value of the price rule. If target_type is shipping_line, then only -100 is accepted. + * It's important to note that when discounting a resource, the value must be a negative number. + */ + [JsonProperty("value")] + public decimal Value { get; set; } - /** - * The price rule can only be used once per customer (tracked by customer id). - */ - [JsonProperty("once_per_customer")] - public bool? OncePerCustomer { get; set; } + /** + * The price rule can only be used once per customer (tracked by customer id). + */ + [JsonProperty("once_per_customer")] + public bool? OncePerCustomer { get; set; } - /** - * The maximum number of times the price rule can be used, per discount code. - */ - [JsonProperty("usage_limit")] - public long? UsageLimit { get; set; } + /** + * The maximum number of times the price rule can be used, per discount code. + */ + [JsonProperty("usage_limit")] + public long? UsageLimit { get; set; } - /** - * The customer selection for the price rule.A customer selection of all means there are no restrictions - * on who's eligible for the price rule. Known values are "all" or "prerequisite". - */ - [JsonProperty("customer_selection")] - public string CustomerSelection { get; set; } + /** + * The customer selection for the price rule.A customer selection of all means there are no restrictions + * on who's eligible for the price rule. Known values are "all" or "prerequisite". + */ + [JsonProperty("customer_selection")] + public string CustomerSelection { get; set; } - /** - * The number of times the discount can be allocated on the cart - if eligible. For example a Buy 1 hat Get 1 hat - * for free discount can be applied 3 times on a cart having more than 6 hats, where maximum of 3 hats get - * discounted - if the allocation_limit is 3. Empty (null) allocation_limit means unlimited number of allocations. - */ - [JsonProperty("allocation_limit")] - public int? AllocationLimit { get; set; } + /** + * The number of times the discount can be allocated on the cart - if eligible. For example a Buy 1 hat Get 1 hat + * for free discount can be applied 3 times on a cart having more than 6 hats, where maximum of 3 hats get + * discounted - if the allocation_limit is 3. Empty (null) allocation_limit means unlimited number of allocations. + */ + [JsonProperty("allocation_limit")] + public int? AllocationLimit { get; set; } - /** - * The date and time when the price rule starts. - */ - [JsonProperty("starts_at")] - public DateTimeOffset? StartsAt { get; set; } + /** + * The date and time when the price rule starts. + */ + [JsonProperty("starts_at")] + public DateTimeOffset? StartsAt { get; set; } - /** - * The date and time when the price rule ends.Must be after starts_at. - */ - [JsonProperty("ends_at")] - public DateTimeOffset? EndsAt { get; set; } + /** + * The date and time when the price rule ends.Must be after starts_at. + */ + [JsonProperty("ends_at")] + public DateTimeOffset? EndsAt { get; set; } - /** - * The date and time the object was created. - */ - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + /** + * The date and time the object was created. + */ + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - /** - * The date and time the object was last updated. - */ - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } + /** + * The date and time the object was last updated. + */ + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } - /** - * A list of entitled product ids.Can be used in combination with entitled_variant_ids. entitled_product_ids can - * only be used in conjunction with target_type set to line_item if and target_selection set to entitled - */ - [JsonProperty("entitled_product_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public IEnumerable EntitledProductIds { get; set; } + /** + * A list of entitled product ids.Can be used in combination with entitled_variant_ids. entitled_product_ids can + * only be used in conjunction with target_type set to line_item if and target_selection set to entitled + */ + [JsonProperty("entitled_product_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public IEnumerable EntitledProductIds { get; set; } - /** - * A list of entitled product variant ids. Can be used in combination with entitled_product_ids. - * entitled_variant_ids can only be used in conjunction with target_type set to line_item if and target_selection set to - * entitled - */ - [JsonProperty("entitled_variant_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public IEnumerable EntitledVariantIds { get; set; } + /** + * A list of entitled product variant ids. Can be used in combination with entitled_product_ids. + * entitled_variant_ids can only be used in conjunction with target_type set to line_item if and target_selection set to + * entitled + */ + [JsonProperty("entitled_variant_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public IEnumerable EntitledVariantIds { get; set; } - /** - * A list of entitled collection ids. Cannot be used in combination with entitled_product_ids nor - * entitled_variant_ids. entitled_collection_ids can only be used in conjunction with target_typeset to line_item and - * target_selection set to entitled - */ - [JsonProperty("entitled_collection_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public IEnumerable EntitledCollectionIds { get; set; } + /** + * A list of entitled collection ids. Cannot be used in combination with entitled_product_ids nor + * entitled_variant_ids. entitled_collection_ids can only be used in conjunction with target_typeset to line_item and + * target_selection set to entitled + */ + [JsonProperty("entitled_collection_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public IEnumerable EntitledCollectionIds { get; set; } - /** - * A list of shipping country ids. entitled_country_ids can only be used in conjunction with target_type set to - * shipping_line and target_selection set to entitled. - */ - [JsonProperty("entitled_country_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public IEnumerable EntitledCountryIds { get; set; } + /** + * A list of shipping country ids. entitled_country_ids can only be used in conjunction with target_type set to + * shipping_line and target_selection set to entitled. + */ + [JsonProperty("entitled_country_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public IEnumerable EntitledCountryIds { get; set; } - /** - * A list of prerequisite customer ids. For the price rule to be applicable, - * the customer applying the price rule must be in the group of customers specified. - */ - [JsonProperty("prerequisite_customer_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public IEnumerable PrerequisiteCustomerIds { get; set; } + /** + * A list of prerequisite customer ids. For the price rule to be applicable, + * the customer applying the price rule must be in the group of customers specified. + */ + [JsonProperty("prerequisite_customer_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public IEnumerable PrerequisiteCustomerIds { get; set; } - /** - * Prerequisite cart subtotal range. - */ - [JsonProperty("prerequisite_subtotal_range", DefaultValueHandling = DefaultValueHandling.Ignore)] - public PrerequisiteValueRange PrerequisiteSubtotalRange { get; set; } + /** + * Prerequisite cart subtotal range. + */ + [JsonProperty("prerequisite_subtotal_range", DefaultValueHandling = DefaultValueHandling.Ignore)] + public PrerequisiteValueRange PrerequisiteSubtotalRange { get; set; } - /** - * Prerequisite shipping cost range.Can only be used when target_type is shipping_line. - */ - [JsonProperty("prerequisite_shipping_price_range", DefaultValueHandling = DefaultValueHandling.Ignore)] - public PrerequisiteValueRange PrerequisiteShippingPriceRange { get; set; } + /** + * Prerequisite shipping cost range.Can only be used when target_type is shipping_line. + */ + [JsonProperty("prerequisite_shipping_price_range", DefaultValueHandling = DefaultValueHandling.Ignore)] + public PrerequisiteValueRange PrerequisiteShippingPriceRange { get; set; } - /** - * Prerequisite cart quantity range. - */ - [JsonProperty("prerequisite_quantity_range", DefaultValueHandling = DefaultValueHandling.Ignore)] - public PrerequisiteQuantityRange PrerequisiteQuantityRange { get; set; } + /** + * Prerequisite cart quantity range. + */ + [JsonProperty("prerequisite_quantity_range", DefaultValueHandling = DefaultValueHandling.Ignore)] + public PrerequisiteQuantityRange PrerequisiteQuantityRange { get; set; } - /** - * A list of prerequisite customer saved search ids. For the price rule to be applicable, - * the customer applying the price rule must be in the group of customers matching the customer saved searches. - */ - [JsonProperty("prerequisite_saved_search_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public IEnumerable PrerequisiteSavedSearchIds { get; set; } + /** + * A list of prerequisite customer saved search ids. For the price rule to be applicable, + * the customer applying the price rule must be in the group of customers matching the customer saved searches. + */ + [JsonProperty("prerequisite_saved_search_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public IEnumerable PrerequisiteSavedSearchIds { get; set; } - /// - /// A list of customer segment IDs. For the price rule to be applicable, the customer must be in the group of - /// customers matching a customer segment. If this is populated, then - /// must be empty. - /// - [JsonProperty("customer_segment_prerequisite_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public IEnumerable CustomerSegmentPrerequisiteIds { get; set; } + /// + /// A list of customer segment IDs. For the price rule to be applicable, the customer must be in the group of + /// customers matching a customer segment. If this is populated, then + /// must be empty. + /// + [JsonProperty("customer_segment_prerequisite_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public IEnumerable CustomerSegmentPrerequisiteIds { get; set; } - /// - /// The prerequisite purchase for a Buy X Get Y discount. - /// - [JsonProperty("prerequisite_to_entitlement_purchase", DefaultValueHandling = DefaultValueHandling.Ignore)] - public PrerequisiteToEntitlementPurchase PrerequisiteToEntitlementPurchase { get; set; } + /// + /// The prerequisite purchase for a Buy X Get Y discount. + /// + [JsonProperty("prerequisite_to_entitlement_purchase", DefaultValueHandling = DefaultValueHandling.Ignore)] + public PrerequisiteToEntitlementPurchase PrerequisiteToEntitlementPurchase { get; set; } - /// - /// List of product ids that will be a prerequisites for a Buy X Get Y type discount. According to Shopify, - /// this can only be used when the following conditions are true: - /// - /// - /// is set to "line_item", - /// - /// - /// is set to "entitled", - /// - /// - /// is set to "each" and - /// - /// - /// is defined. - /// - /// - /// Caution: according to Shopify, if a product variant is included in , - /// then this can't include the ID of the product associated with that variant. - /// - [JsonProperty("prerequisite_product_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public IEnumerable PrerequisiteProductIds { get; set; } + /// + /// List of product ids that will be a prerequisites for a Buy X Get Y type discount. According to Shopify, + /// this can only be used when the following conditions are true: + /// + /// + /// is set to "line_item", + /// + /// + /// is set to "entitled", + /// + /// + /// is set to "each" and + /// + /// + /// is defined. + /// + /// + /// Caution: according to Shopify, if a product variant is included in , + /// then this can't include the ID of the product associated with that variant. + /// + [JsonProperty("prerequisite_product_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public IEnumerable PrerequisiteProductIds { get; set; } - /// - /// List of variant ids that will be a prerequisites for a Buy X Get Y type discount. According to Shopify, - /// this can only be used when the following conditions are true: - /// - /// - /// is set to "line_item", - /// - /// - /// is set to "entitled", - /// - /// - /// is set to "each" and - /// - /// - /// is defined. - /// - /// - /// Caution: according to Shopify, if a product is included in , then this - /// can't include the ID of any variants associated with that product. - /// - [JsonProperty("prerequisite_variant_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public IEnumerable PrerequisiteVariantIds { get; set; } + /// + /// List of variant ids that will be a prerequisites for a Buy X Get Y type discount. According to Shopify, + /// this can only be used when the following conditions are true: + /// + /// + /// is set to "line_item", + /// + /// + /// is set to "entitled", + /// + /// + /// is set to "each" and + /// + /// + /// is defined. + /// + /// + /// Caution: according to Shopify, if a product is included in , then this + /// can't include the ID of any variants associated with that product. + /// + [JsonProperty("prerequisite_variant_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public IEnumerable PrerequisiteVariantIds { get; set; } - /// - /// List of collection ids that will be a prerequisites for a Buy X Get Y discount. According to Shopify, - /// this can only be used when the following conditions are true: - /// - /// - /// is set to "line_item", - /// - /// - /// is set to "entitled", - /// - /// - /// is set to "each" and - /// - /// - /// is defined. - /// - /// - /// Caution: according to Shopify, this cannot be used in combination with either - /// or . - /// - [JsonProperty("prerequisite_collection_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public IEnumerable PrerequisiteCollectionIds { get; set; } + /// + /// List of collection ids that will be a prerequisites for a Buy X Get Y discount. According to Shopify, + /// this can only be used when the following conditions are true: + /// + /// + /// is set to "line_item", + /// + /// + /// is set to "entitled", + /// + /// + /// is set to "each" and + /// + /// + /// is defined. + /// + /// + /// Caution: according to Shopify, this cannot be used in combination with either + /// or . + /// + [JsonProperty("prerequisite_collection_ids", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public IEnumerable PrerequisiteCollectionIds { get; set; } - /// - /// Buy/Get ratio for a Buy X Get Y discount. - /// defines the necessary 'buy' quantity and - /// defines the offered 'get' quantity. According to Shopify, this can only be used when the following conditions - /// are true: - /// - /// - /// - /// is set to "percentage", - /// - /// - /// is set to "line_item", - /// - /// - /// is set to "entitled", - /// - /// - /// is set to "each", - /// - /// - /// or or are defined and - /// - /// - /// or or are defined. - /// - /// - /// Caution: according to Shopify, this cannot be used in combination with or or . - /// - [JsonProperty("prerequisite_to_entitlement_quantity_ratio", DefaultValueHandling = DefaultValueHandling.Ignore)] - public PrerequisiteToEntitlementQuantityRatio PrerequisiteToEntitlementQuantityRatio { get; set; } - } -} + /// + /// Buy/Get ratio for a Buy X Get Y discount. + /// defines the necessary 'buy' quantity and + /// defines the offered 'get' quantity. According to Shopify, this can only be used when the following conditions + /// are true: + /// + /// + /// + /// is set to "percentage", + /// + /// + /// is set to "line_item", + /// + /// + /// is set to "entitled", + /// + /// + /// is set to "each", + /// + /// + /// or or are defined and + /// + /// + /// or or are defined. + /// + /// + /// Caution: according to Shopify, this cannot be used in combination with or or . + /// + [JsonProperty("prerequisite_to_entitlement_quantity_ratio", DefaultValueHandling = DefaultValueHandling.Ignore)] + public PrerequisiteToEntitlementQuantityRatio PrerequisiteToEntitlementQuantityRatio { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/PriceRuleDiscountCode.cs b/ShopifySharp/Entities/PriceRuleDiscountCode.cs index 2ee46684..8ba47ce2 100644 --- a/ShopifySharp/Entities/PriceRuleDiscountCode.cs +++ b/ShopifySharp/Entities/PriceRuleDiscountCode.cs @@ -1,39 +1,38 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; -namespace ShopifySharp -{ - public class PriceRuleDiscountCode : ShopifyObject - { - /// - /// The discount code. - /// - [JsonProperty("code")] - public string Code { get; set; } +namespace ShopifySharp; - /// - /// Unique numeric identifier for the price rule. - /// - [JsonProperty("price_rule_id")] - public long? PriceRuleId { get; set; } +public class PriceRuleDiscountCode : ShopifyObject +{ + /// + /// The discount code. + /// + [JsonProperty("code")] + public string Code { get; set; } - /// - /// Number of times the discount code has been redeemed. - /// - [JsonProperty("usage_count")] - public int? UsageCount { get; set; } + /// + /// Unique numeric identifier for the price rule. + /// + [JsonProperty("price_rule_id")] + public long? PriceRuleId { get; set; } - /// - /// The date and time when the discount code was created. The API returns this value in ISO 8601 format. - /// - [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? CreatedAt { get; set; } + /// + /// Number of times the discount code has been redeemed. + /// + [JsonProperty("usage_count")] + public int? UsageCount { get; set; } - /// - /// The date and time when the discount code was last modified. The API returns this value in ISO 8601 format. - /// - [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? UpdatedAt { get; set; } + /// + /// The date and time when the discount code was created. The API returns this value in ISO 8601 format. + /// + [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? CreatedAt { get; set; } - } -} + /// + /// The date and time when the discount code was last modified. The API returns this value in ISO 8601 format. + /// + [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? UpdatedAt { get; set; } + +} \ No newline at end of file diff --git a/ShopifySharp/Entities/PriceSet.cs b/ShopifySharp/Entities/PriceSet.cs index e29565ee..24a9cc3f 100644 --- a/ShopifySharp/Entities/PriceSet.cs +++ b/ShopifySharp/Entities/PriceSet.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class PriceSet { - public class PriceSet - { - [JsonProperty("shop_money")] - public Price ShopMoney { get; set; } + [JsonProperty("shop_money")] + public Price ShopMoney { get; set; } - [JsonProperty("presentment_money")] - public Price PresentmentMoney { get; set; } - } + [JsonProperty("presentment_money")] + public Price PresentmentMoney { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/Product.cs b/ShopifySharp/Entities/Product.cs index e6aa5ffd..9ff3867d 100644 --- a/ShopifySharp/Entities/Product.cs +++ b/ShopifySharp/Entities/Product.cs @@ -2,126 +2,125 @@ using System; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An entity representing a Shopify product. +/// +public class Product : ShopifyObject { /// - /// An entity representing a Shopify product. - /// - public class Product : ShopifyObject - { - /// - /// The name of the product. In a shop's catalog, clicking on a product's title takes you to that product's page. - /// On a product's page, the product's title typically appears in a large font. - /// - [JsonProperty("title")] - public string Title { get; set; } - - /// - /// The description of the product, complete with HTML formatting. - /// - [JsonProperty("body_html")] - public string BodyHtml { get; set; } - - /// - /// The date and time when the product was created. The API returns this value in ISO 8601 format. - /// - [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// The date and time when the product was last modified. The API returns this value in ISO 8601 format. - /// - [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? UpdatedAt { get; set; } - - /// - /// The date and time when the product was published. The API returns this value in ISO 8601 format. - /// Set to NULL to unpublish a product - /// - [JsonProperty("published_at", DefaultValueHandling = DefaultValueHandling.Include, NullValueHandling = NullValueHandling.Include)] - public DateTimeOffset? PublishedAt { get; set; } - - /// - /// The name of the vendor of the product. - /// - [JsonProperty("vendor")] - public string Vendor { get; set; } - - /// - /// A categorization that a product can be tagged with, commonly used for filtering and searching. - /// - [JsonProperty("product_type")] - public string ProductType { get; set; } - - /// - /// A human-friendly unique string for the Product automatically generated from its title. - /// They are used by the Liquid templating language to refer to objects. - /// - [JsonProperty("handle")] - public string Handle { get; set; } - - /// - /// The suffix of the liquid template being used. - /// By default, the original template is called product.liquid, without any suffix. - /// Any additional templates will be: product.suffix.liquid. - /// - [JsonProperty("template_suffix")] - public string TemplateSuffix { get; set; } - - /// - /// The sales channels in which the product is visible. - /// - [JsonProperty("published_scope")] - public string PublishedScope { get; set; } - - /// - /// A categorization that a product can be tagged with, commonly used for filtering and searching. - /// Each comma-separated tag has a character limit of 255. - /// - [JsonProperty("tags")] - public string Tags { get; set; } - - /// - /// The status of the product - /// - [JsonProperty("status")] - public string Status { get; set; } - - /// - /// A list of variant objects, each one representing a slightly different version of the product. - /// For example, if a product comes in different sizes and colors, each size and color permutation (such as "small black", "medium black", "large blue"), would be a variant. - /// To reorder variants, update the product with the variants in the desired order.The position attribute on the variant will be ignored. - /// - [JsonProperty("variants")] - public IEnumerable Variants { get; set; } - - /// - /// Custom product property names like "Size", "Color", and "Material". - /// Products are based on permutations of these options. - /// A product may have a maximum of 3 options. 255 characters limit each. - /// - [JsonProperty("options")] - public IEnumerable Options { get; set; } - - /// - /// A list of image objects, each one representing an image associated with the product. - /// - [JsonProperty("images")] - public IEnumerable Images { get; set; } - - /// - /// Additional metadata about the . Note: This is not naturally returned with a response, as - /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . - /// Uses include: Creating, updating, & deserializing webhook bodies that include them. - /// - [JsonProperty("metafields")] - public IEnumerable Metafields { get; set; } - - /// - /// The GraphQL IDs of all of the product's variants - /// See https://shopify.dev/docs/api/admin/migrate/new-product-model/api-updates#webhook-updates - /// - [JsonProperty("variant_gids")] - public IEnumerable VariantGids { get; set; } - } -} + /// The name of the product. In a shop's catalog, clicking on a product's title takes you to that product's page. + /// On a product's page, the product's title typically appears in a large font. + /// + [JsonProperty("title")] + public string Title { get; set; } + + /// + /// The description of the product, complete with HTML formatting. + /// + [JsonProperty("body_html")] + public string BodyHtml { get; set; } + + /// + /// The date and time when the product was created. The API returns this value in ISO 8601 format. + /// + [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// The date and time when the product was last modified. The API returns this value in ISO 8601 format. + /// + [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? UpdatedAt { get; set; } + + /// + /// The date and time when the product was published. The API returns this value in ISO 8601 format. + /// Set to NULL to unpublish a product + /// + [JsonProperty("published_at", DefaultValueHandling = DefaultValueHandling.Include, NullValueHandling = NullValueHandling.Include)] + public DateTimeOffset? PublishedAt { get; set; } + + /// + /// The name of the vendor of the product. + /// + [JsonProperty("vendor")] + public string Vendor { get; set; } + + /// + /// A categorization that a product can be tagged with, commonly used for filtering and searching. + /// + [JsonProperty("product_type")] + public string ProductType { get; set; } + + /// + /// A human-friendly unique string for the Product automatically generated from its title. + /// They are used by the Liquid templating language to refer to objects. + /// + [JsonProperty("handle")] + public string Handle { get; set; } + + /// + /// The suffix of the liquid template being used. + /// By default, the original template is called product.liquid, without any suffix. + /// Any additional templates will be: product.suffix.liquid. + /// + [JsonProperty("template_suffix")] + public string TemplateSuffix { get; set; } + + /// + /// The sales channels in which the product is visible. + /// + [JsonProperty("published_scope")] + public string PublishedScope { get; set; } + + /// + /// A categorization that a product can be tagged with, commonly used for filtering and searching. + /// Each comma-separated tag has a character limit of 255. + /// + [JsonProperty("tags")] + public string Tags { get; set; } + + /// + /// The status of the product + /// + [JsonProperty("status")] + public string Status { get; set; } + + /// + /// A list of variant objects, each one representing a slightly different version of the product. + /// For example, if a product comes in different sizes and colors, each size and color permutation (such as "small black", "medium black", "large blue"), would be a variant. + /// To reorder variants, update the product with the variants in the desired order.The position attribute on the variant will be ignored. + /// + [JsonProperty("variants")] + public IEnumerable Variants { get; set; } + + /// + /// Custom product property names like "Size", "Color", and "Material". + /// Products are based on permutations of these options. + /// A product may have a maximum of 3 options. 255 characters limit each. + /// + [JsonProperty("options")] + public IEnumerable Options { get; set; } + + /// + /// A list of image objects, each one representing an image associated with the product. + /// + [JsonProperty("images")] + public IEnumerable Images { get; set; } + + /// + /// Additional metadata about the . Note: This is not naturally returned with a response, as + /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . + /// Uses include: Creating, updating, & deserializing webhook bodies that include them. + /// + [JsonProperty("metafields")] + public IEnumerable Metafields { get; set; } + + /// + /// The GraphQL IDs of all of the product's variants + /// See https://shopify.dev/docs/api/admin/migrate/new-product-model/api-updates#webhook-updates + /// + [JsonProperty("variant_gids")] + public IEnumerable VariantGids { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ProductImage.cs b/ShopifySharp/Entities/ProductImage.cs index 3b780e8b..4afc1645 100644 --- a/ShopifySharp/Entities/ProductImage.cs +++ b/ShopifySharp/Entities/ProductImage.cs @@ -2,76 +2,75 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a product image. +/// +public class ProductImage : ShopifyObject { /// - /// An object representing a product image. + /// The id of the product associated with the image. /// - public class ProductImage : ShopifyObject - { - /// - /// The id of the product associated with the image. - /// - [JsonProperty("product_id")] - public long? ProductId { get; set; } + [JsonProperty("product_id")] + public long? ProductId { get; set; } - /// - /// The order of the product image in the list. The first product image is at position 1 and is the "main" image for the product. - /// - [JsonProperty("position")] - public int? Position { get; set; } + /// + /// The order of the product image in the list. The first product image is at position 1 and is the "main" image for the product. + /// + [JsonProperty("position")] + public int? Position { get; set; } - /// - /// The date and time when the product image was created. The API returns this value in ISO 8601 format. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + /// + /// The date and time when the product image was created. The API returns this value in ISO 8601 format. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - /// - /// The date and time when the product image was last modified. The API returns this value in ISO 8601 format. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } + /// + /// The date and time when the product image was last modified. The API returns this value in ISO 8601 format. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } - /// - /// Specifies the location of the product image. - /// - [JsonProperty("src")] - public string Src { get; set; } + /// + /// Specifies the location of the product image. + /// + [JsonProperty("src")] + public string Src { get; set; } - /// - /// Specifies the file name of the image when creating a , where it's then converted into the path - /// - [JsonProperty("filename", DefaultValueHandling = DefaultValueHandling.Ignore)] - public string Filename { get; set; } + /// + /// Specifies the file name of the image when creating a , where it's then converted into the path + /// + [JsonProperty("filename", DefaultValueHandling = DefaultValueHandling.Ignore)] + public string Filename { get; set; } - /// - /// A base64 image attachment. Only used when creating a , where it's then converted into the . - /// - [JsonProperty("attachment")] - public string Attachment { get; set; } + /// + /// A base64 image attachment. Only used when creating a , where it's then converted into the . + /// + [JsonProperty("attachment")] + public string Attachment { get; set; } - /// - /// An array of variant ids associated with the image. - /// - [JsonProperty("variant_ids")] - public IEnumerable VariantIds { get; set; } + /// + /// An array of variant ids associated with the image. + /// + [JsonProperty("variant_ids")] + public IEnumerable VariantIds { get; set; } - [JsonProperty("height")] - public int? Height { get; set; } + [JsonProperty("height")] + public int? Height { get; set; } - [JsonProperty("width")] - public int? Width { get; set; } + [JsonProperty("width")] + public int? Width { get; set; } - [JsonProperty("alt")] - public string Alt { get; set; } + [JsonProperty("alt")] + public string Alt { get; set; } - /// - /// Additional metadata about the . Note: This is not naturally returned with a response, as - /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . - /// Uses include: Creating, updating, & deserializing webhook bodies that include them. - /// - [JsonProperty("metafields")] - public IEnumerable Metafields { get; set; } - } -} + /// + /// Additional metadata about the . Note: This is not naturally returned with a response, as + /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . + /// Uses include: Creating, updating, & deserializing webhook bodies that include them. + /// + [JsonProperty("metafields")] + public IEnumerable Metafields { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ProductListing.cs b/ShopifySharp/Entities/ProductListing.cs index 527e0155..fbb9d481 100644 --- a/ShopifySharp/Entities/ProductListing.cs +++ b/ShopifySharp/Entities/ProductListing.cs @@ -1,91 +1,90 @@ -using System; +using System; using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An entity representing a Shopify product listing. +/// +public class ProductListing: ShopifyObject { /// - /// An entity representing a Shopify product listing. + /// Available current product + /// + [JsonProperty("available")] + public bool Available { get; set; } + /// + /// The unique identifer of the product this listing is for. The primary key for this resource. + /// + [JsonProperty("product_id")] + public long? ProductId { get; set; } + /// + /// The description of the product, complete with HTML formatting. + /// + [JsonProperty("body_html")] + public string BodyHtml { get; set; } + /// + /// The date and time when the product was created. The API returns this value in ISO 8601 format. + /// + [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? CreatedAt { get; set; } + /// + /// A human-friendly unique string for the Product automatically generated from its title. + /// They are used by the Liquid templating language to refer to objects. + /// + [JsonProperty("handle")] + public string Handle { get; set; } + /// + /// A list of image objects, each one representing an image associated with the product. + /// + [JsonProperty("images")] + public IEnumerable Images { get; set; } + /// + /// Custom product property names like "Size", "Color", and "Material". + /// Products are based on permutations of these options. + /// A product may have a maximum of 3 options. 255 characters limit each. + /// + [JsonProperty("options")] + public IEnumerable Options { get; set; } + /// + /// A categorization that a product can be tagged with, commonly used for filtering and searching. + /// + [JsonProperty("product_type")] + public string ProductType { get; set; } + /// + /// The date and time when the product was published. The API returns this value in ISO 8601 format. + /// Set to NULL to unpublish a product + /// + [JsonProperty("published_at", DefaultValueHandling = DefaultValueHandling.Include, NullValueHandling = NullValueHandling.Include)] + public DateTimeOffset? PublishedAt { get; set; } + /// + /// A categorization that a product can be tagged with, commonly used for filtering and searching. + /// Each comma-separated tag has a character limit of 255. + /// + [JsonProperty("tags")] + public string Tags { get; set; } + /// + /// The name of the product. In a shop's catalog, clicking on a product's title takes you to that product's page. + /// On a product's page, the product's title typically appears in a large font. + /// + [JsonProperty("title")] + public string Title { get; set; } + /// + /// The date and time when the product was last modified. The API returns this value in ISO 8601 format. + /// + [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? UpdatedAt { get; set; } + /// + /// A list of variant objects, each one representing a slightly different version of the product. + /// For example, if a product comes in different sizes and colors, each size and color permutation (such as "small black", "medium black", "large blue"), would be a variant. + /// To reorder variants, update the product with the variants in the desired order.The position attribute on the variant will be ignored. + /// + [JsonProperty("variants")] + public IEnumerable Variants { get; set; } + /// + /// The name of the vendor of the product. /// - public class ProductListing: ShopifyObject - { - /// - /// Available current product - /// - [JsonProperty("available")] - public bool Available { get; set; } - /// - /// The unique identifer of the product this listing is for. The primary key for this resource. - /// - [JsonProperty("product_id")] - public long? ProductId { get; set; } - /// - /// The description of the product, complete with HTML formatting. - /// - [JsonProperty("body_html")] - public string BodyHtml { get; set; } - /// - /// The date and time when the product was created. The API returns this value in ISO 8601 format. - /// - [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? CreatedAt { get; set; } - /// - /// A human-friendly unique string for the Product automatically generated from its title. - /// They are used by the Liquid templating language to refer to objects. - /// - [JsonProperty("handle")] - public string Handle { get; set; } - /// - /// A list of image objects, each one representing an image associated with the product. - /// - [JsonProperty("images")] - public IEnumerable Images { get; set; } - /// - /// Custom product property names like "Size", "Color", and "Material". - /// Products are based on permutations of these options. - /// A product may have a maximum of 3 options. 255 characters limit each. - /// - [JsonProperty("options")] - public IEnumerable Options { get; set; } - /// - /// A categorization that a product can be tagged with, commonly used for filtering and searching. - /// - [JsonProperty("product_type")] - public string ProductType { get; set; } - /// - /// The date and time when the product was published. The API returns this value in ISO 8601 format. - /// Set to NULL to unpublish a product - /// - [JsonProperty("published_at", DefaultValueHandling = DefaultValueHandling.Include, NullValueHandling = NullValueHandling.Include)] - public DateTimeOffset? PublishedAt { get; set; } - /// - /// A categorization that a product can be tagged with, commonly used for filtering and searching. - /// Each comma-separated tag has a character limit of 255. - /// - [JsonProperty("tags")] - public string Tags { get; set; } - /// - /// The name of the product. In a shop's catalog, clicking on a product's title takes you to that product's page. - /// On a product's page, the product's title typically appears in a large font. - /// - [JsonProperty("title")] - public string Title { get; set; } - /// - /// The date and time when the product was last modified. The API returns this value in ISO 8601 format. - /// - [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? UpdatedAt { get; set; } - /// - /// A list of variant objects, each one representing a slightly different version of the product. - /// For example, if a product comes in different sizes and colors, each size and color permutation (such as "small black", "medium black", "large blue"), would be a variant. - /// To reorder variants, update the product with the variants in the desired order.The position attribute on the variant will be ignored. - /// - [JsonProperty("variants")] - public IEnumerable Variants { get; set; } - /// - /// The name of the vendor of the product. - /// - [JsonProperty("vendor")] - public string Vendor { get; set; } - } -} + [JsonProperty("vendor")] + public string Vendor { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ProductListingVariant.cs b/ShopifySharp/Entities/ProductListingVariant.cs index 78a4977b..75972bf5 100644 --- a/ShopifySharp/Entities/ProductListingVariant.cs +++ b/ShopifySharp/Entities/ProductListingVariant.cs @@ -1,131 +1,130 @@ -using System; +using System; using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class ProductListingVariant: ShopifyObject { - public class ProductListingVariant: ShopifyObject - { - /// - /// Available current product variant - /// - [JsonProperty("available")] - public bool? Available { get; set; } - - /// - /// Custom properties that a shop owner can use to define product variants. - /// - [JsonProperty("option_values")] - public IEnumerable OptionValues { get; set; } - - /// - /// The title of the product variant. - /// - [JsonProperty("title")] - public string Title { get; set; } - - /// - /// A unique identifier for the product in the shop. - /// - [JsonProperty("sku")] - public string SKU { get; set; } - - /// - /// The order of the product variant in the list of product variants. 1 is the first position. - /// - [JsonProperty("position")] - public int? Position { get; set; } - - /// - /// The weight of the product variant in grams. - /// - [JsonProperty("grams")] - public long? Grams { get; set; } - - /// - /// Specifies whether or not customers are allowed to place an order for a product variant when it's out of stock. Known values are 'deny' and 'continue'. - /// - [JsonProperty("inventory_policy")] - public string InventoryPolicy { get; set; } - - /// - /// Service that is doing the fulfillment. Can be 'manual' or any custom string. - /// - [JsonProperty("fulfillment_service")] - public string FulfillmentService { get; set; } - - /// - /// Specifies whether or not Shopify tracks the number of items in stock for this product variant. Known values are 'blank' and 'shopify'. - /// - [JsonProperty("inventory_management")] - public string InventoryManagement { get; set; } - - /// - /// The price of the product variant. - /// - [JsonProperty("price")] - public decimal? Price { get; set; } - - /// - /// The competitors prices for the same item. - /// - [JsonProperty("compare_at_price", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public decimal? CompareAtPrice { get; set; } - - /// - /// The date and time when the product variant was created. The API returns this value in ISO 8601 format. - /// - [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// The date and time when the product variant was last modified. The API returns this value in ISO 8601 format. - /// - [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? UpdatedAt { get; set; } - - /// - /// Specifies whether or not a tax is charged when the product variant is sold. - /// - [JsonProperty("taxable")] - public bool? Taxable { get; set; } - - /// - /// Specifies whether or not a customer needs to provide a shipping address when placing an order for this product variant. - /// - [JsonProperty("requires_shipping")] - public bool? RequiresShipping { get; set; } - - /// - /// The barcode, UPC or ISBN number for the product. - /// - [JsonProperty("barcode")] - public string Barcode { get; set; } - - /// - /// The number of items in stock for this product variant. - /// NOTE: After 2018-07-01, this field will be read-only in the Shopify API. Use the `InventoryLevelService` instead. - /// - [JsonProperty("inventory_quantity")] - public long? InventoryQuantity { get; set; } - - /// - /// The unique numeric identifier for one of the product's images. - /// - [JsonProperty("image_id", DefaultValueHandling = DefaultValueHandling.Ignore)] - public long? ImageId { get; set; } - - /// - /// The weight of the product variant in the unit system specified with weight_unit. - /// - [JsonProperty("weight")] - public decimal? Weight { get; set; } - - /// - /// The unit system that the product variant's weight is measure in. The weight_unit can be either "g", "kg, "oz", or "lb". - /// - [JsonProperty("weight_unit")] - public string WeightUnit { get; set; } - } + /// + /// Available current product variant + /// + [JsonProperty("available")] + public bool? Available { get; set; } + + /// + /// Custom properties that a shop owner can use to define product variants. + /// + [JsonProperty("option_values")] + public IEnumerable OptionValues { get; set; } + + /// + /// The title of the product variant. + /// + [JsonProperty("title")] + public string Title { get; set; } + + /// + /// A unique identifier for the product in the shop. + /// + [JsonProperty("sku")] + public string SKU { get; set; } + + /// + /// The order of the product variant in the list of product variants. 1 is the first position. + /// + [JsonProperty("position")] + public int? Position { get; set; } + + /// + /// The weight of the product variant in grams. + /// + [JsonProperty("grams")] + public long? Grams { get; set; } + + /// + /// Specifies whether or not customers are allowed to place an order for a product variant when it's out of stock. Known values are 'deny' and 'continue'. + /// + [JsonProperty("inventory_policy")] + public string InventoryPolicy { get; set; } + + /// + /// Service that is doing the fulfillment. Can be 'manual' or any custom string. + /// + [JsonProperty("fulfillment_service")] + public string FulfillmentService { get; set; } + + /// + /// Specifies whether or not Shopify tracks the number of items in stock for this product variant. Known values are 'blank' and 'shopify'. + /// + [JsonProperty("inventory_management")] + public string InventoryManagement { get; set; } + + /// + /// The price of the product variant. + /// + [JsonProperty("price")] + public decimal? Price { get; set; } + + /// + /// The competitors prices for the same item. + /// + [JsonProperty("compare_at_price", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public decimal? CompareAtPrice { get; set; } + + /// + /// The date and time when the product variant was created. The API returns this value in ISO 8601 format. + /// + [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// The date and time when the product variant was last modified. The API returns this value in ISO 8601 format. + /// + [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? UpdatedAt { get; set; } + + /// + /// Specifies whether or not a tax is charged when the product variant is sold. + /// + [JsonProperty("taxable")] + public bool? Taxable { get; set; } + + /// + /// Specifies whether or not a customer needs to provide a shipping address when placing an order for this product variant. + /// + [JsonProperty("requires_shipping")] + public bool? RequiresShipping { get; set; } + + /// + /// The barcode, UPC or ISBN number for the product. + /// + [JsonProperty("barcode")] + public string Barcode { get; set; } + + /// + /// The number of items in stock for this product variant. + /// NOTE: After 2018-07-01, this field will be read-only in the Shopify API. Use the `InventoryLevelService` instead. + /// + [JsonProperty("inventory_quantity")] + public long? InventoryQuantity { get; set; } + + /// + /// The unique numeric identifier for one of the product's images. + /// + [JsonProperty("image_id", DefaultValueHandling = DefaultValueHandling.Ignore)] + public long? ImageId { get; set; } + + /// + /// The weight of the product variant in the unit system specified with weight_unit. + /// + [JsonProperty("weight")] + public decimal? Weight { get; set; } + + /// + /// The unit system that the product variant's weight is measure in. The weight_unit can be either "g", "kg, "oz", or "lb". + /// + [JsonProperty("weight_unit")] + public string WeightUnit { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/ProductOption.cs b/ShopifySharp/Entities/ProductOption.cs index b35c7e69..510ae100 100644 --- a/ShopifySharp/Entities/ProductOption.cs +++ b/ShopifySharp/Entities/ProductOption.cs @@ -1,32 +1,31 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class ProductOption : ShopifyObject { - public class ProductOption : ShopifyObject - { - /// - /// The unique numeric identifier for the product. - /// - [JsonProperty("product_id")] - public long? ProductId { get; set; } + /// + /// The unique numeric identifier for the product. + /// + [JsonProperty("product_id")] + public long? ProductId { get; set; } - /// - /// The name of the option. - /// - [JsonProperty("name")] - public string Name { get; set; } + /// + /// The name of the option. + /// + [JsonProperty("name")] + public string Name { get; set; } - /// - /// The order of the product variant in the list of product variants. 1 is the first position. - /// - [JsonProperty("position")] - public int? Position { get; set; } + /// + /// The order of the product variant in the list of product variants. 1 is the first position. + /// + [JsonProperty("position")] + public int? Position { get; set; } - /// - /// The values for the options. - /// - [JsonProperty("values")] - public IEnumerable Values { get; set; } - } -} + /// + /// The values for the options. + /// + [JsonProperty("values")] + public IEnumerable Values { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ProductVariant.cs b/ShopifySharp/Entities/ProductVariant.cs index 5731be91..14bad59a 100644 --- a/ShopifySharp/Entities/ProductVariant.cs +++ b/ShopifySharp/Entities/ProductVariant.cs @@ -2,167 +2,166 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class ProductVariant : ShopifyObject { - public class ProductVariant : ShopifyObject - { - /// - /// The unique numeric identifier for the product. - /// - [JsonProperty("product_id")] - public long? ProductId { get; set; } - - /// - /// The title of the product variant. - /// - [JsonProperty("title")] - public string Title { get; set; } - - /// - /// A unique identifier for the product in the shop. - /// - [JsonProperty("sku")] - public string SKU { get; set; } - - /// - /// The order of the product variant in the list of product variants. 1 is the first position. - /// - [JsonProperty("position")] - public int? Position { get; set; } - - /// - /// The weight of the product variant in grams. - /// - [JsonProperty("grams")] - public long? Grams { get; set; } - - /// - /// Specifies whether or not customers are allowed to place an order for a product variant when it's out of stock. Known values are 'deny' and 'continue'. - /// - [JsonProperty("inventory_policy")] - public string InventoryPolicy { get; set; } - - /// - /// Service that is doing the fulfillment. Can be 'manual' or any custom string. - /// - [JsonProperty("fulfillment_service")] - public string FulfillmentService { get; set; } - - /// - /// The unique identifier for the inventory item, which is used in the Inventory API to query for inventory information. - /// - [JsonProperty("inventory_item_id")] - public long? InventoryItemId { get; set; } - - /// - /// Specifies whether or not Shopify tracks the number of items in stock for this product variant. Known values are 'blank' and 'shopify'. - /// - [JsonProperty("inventory_management")] - public string InventoryManagement { get; set; } - - /// - /// The price of the product variant. - /// - [JsonProperty("price")] - public decimal? Price { get; set; } - - /// - /// The competitors prices for the same item. - /// - [JsonProperty("compare_at_price", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] - public decimal? CompareAtPrice { get; set; } - - /// - /// Custom properties that a shop owner can use to define product variants. - /// - [JsonProperty("option1")] - public string Option1 { get; set; } - - /// - /// Custom properties that a shop owner can use to define product variants. - /// - [JsonProperty("option2")] - public string Option2 { get; set; } - - /// - /// Custom properties that a shop owner can use to define product variants. - /// - [JsonProperty("option3")] - public string Option3 { get; set; } - - /// - /// The date and time when the product variant was created. The API returns this value in ISO 8601 format. - /// - [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// The date and time when the product variant was last modified. The API returns this value in ISO 8601 format. - /// - [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] - public DateTimeOffset? UpdatedAt { get; set; } - - /// - /// Specifies whether or not a tax is charged when the product variant is sold. - /// - [JsonProperty("taxable")] - public bool? Taxable { get; set; } - - /// - /// Specifies a tax code which is used for Avalara tax integrations - /// - [JsonProperty("tax_code")] - public string TaxCode { get; set; } - - /// - /// Specifies whether or not a customer needs to provide a shipping address when placing an order for this product variant. - /// - [JsonProperty("requires_shipping")] - public bool? RequiresShipping { get; set; } - - /// - /// The barcode, UPC or ISBN number for the product. - /// - [JsonProperty("barcode")] - public string Barcode { get; set; } - - /// - /// The number of items in stock for this product variant. - /// NOTE: After 2018-07-01, this field will be read-only in the Shopify API. Use the `InventoryLevelService` instead. - /// - [JsonProperty("inventory_quantity")] - public long? InventoryQuantity { get; set; } - - /// - /// The unique numeric identifier for one of the product's images. - /// - [JsonProperty("image_id", DefaultValueHandling = DefaultValueHandling.Ignore)] - public long? ImageId { get; set; } - - /// - /// The weight of the product variant in the unit system specified with weight_unit. - /// - [JsonProperty("weight")] - public decimal? Weight { get; set; } - - /// - /// The unit system that the product variant's weight is measure in. The weight_unit can be either "g", "kg, "oz", or "lb". - /// - [JsonProperty("weight_unit")] - public string WeightUnit { get; set; } - - /// - /// Additional metadata about the . Note: This is not naturally returned with a response, as - /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . - /// Uses include: Creating, updating, & deserializing webhook bodies that include them. - /// - [JsonProperty("metafields")] - public IEnumerable Metafields { get; set; } - - /// - /// A list of the variant's presentment prices and compare-at prices in each of the shop's enabled presentment currencies - /// - [JsonProperty("presentment_prices")] - public IEnumerable PresentmentPrices { get; set; } - } -} + /// + /// The unique numeric identifier for the product. + /// + [JsonProperty("product_id")] + public long? ProductId { get; set; } + + /// + /// The title of the product variant. + /// + [JsonProperty("title")] + public string Title { get; set; } + + /// + /// A unique identifier for the product in the shop. + /// + [JsonProperty("sku")] + public string SKU { get; set; } + + /// + /// The order of the product variant in the list of product variants. 1 is the first position. + /// + [JsonProperty("position")] + public int? Position { get; set; } + + /// + /// The weight of the product variant in grams. + /// + [JsonProperty("grams")] + public long? Grams { get; set; } + + /// + /// Specifies whether or not customers are allowed to place an order for a product variant when it's out of stock. Known values are 'deny' and 'continue'. + /// + [JsonProperty("inventory_policy")] + public string InventoryPolicy { get; set; } + + /// + /// Service that is doing the fulfillment. Can be 'manual' or any custom string. + /// + [JsonProperty("fulfillment_service")] + public string FulfillmentService { get; set; } + + /// + /// The unique identifier for the inventory item, which is used in the Inventory API to query for inventory information. + /// + [JsonProperty("inventory_item_id")] + public long? InventoryItemId { get; set; } + + /// + /// Specifies whether or not Shopify tracks the number of items in stock for this product variant. Known values are 'blank' and 'shopify'. + /// + [JsonProperty("inventory_management")] + public string InventoryManagement { get; set; } + + /// + /// The price of the product variant. + /// + [JsonProperty("price")] + public decimal? Price { get; set; } + + /// + /// The competitors prices for the same item. + /// + [JsonProperty("compare_at_price", DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)] + public decimal? CompareAtPrice { get; set; } + + /// + /// Custom properties that a shop owner can use to define product variants. + /// + [JsonProperty("option1")] + public string Option1 { get; set; } + + /// + /// Custom properties that a shop owner can use to define product variants. + /// + [JsonProperty("option2")] + public string Option2 { get; set; } + + /// + /// Custom properties that a shop owner can use to define product variants. + /// + [JsonProperty("option3")] + public string Option3 { get; set; } + + /// + /// The date and time when the product variant was created. The API returns this value in ISO 8601 format. + /// + [JsonProperty("created_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// The date and time when the product variant was last modified. The API returns this value in ISO 8601 format. + /// + [JsonProperty("updated_at", DefaultValueHandling = DefaultValueHandling.Ignore)] + public DateTimeOffset? UpdatedAt { get; set; } + + /// + /// Specifies whether or not a tax is charged when the product variant is sold. + /// + [JsonProperty("taxable")] + public bool? Taxable { get; set; } + + /// + /// Specifies a tax code which is used for Avalara tax integrations + /// + [JsonProperty("tax_code")] + public string TaxCode { get; set; } + + /// + /// Specifies whether or not a customer needs to provide a shipping address when placing an order for this product variant. + /// + [JsonProperty("requires_shipping")] + public bool? RequiresShipping { get; set; } + + /// + /// The barcode, UPC or ISBN number for the product. + /// + [JsonProperty("barcode")] + public string Barcode { get; set; } + + /// + /// The number of items in stock for this product variant. + /// NOTE: After 2018-07-01, this field will be read-only in the Shopify API. Use the `InventoryLevelService` instead. + /// + [JsonProperty("inventory_quantity")] + public long? InventoryQuantity { get; set; } + + /// + /// The unique numeric identifier for one of the product's images. + /// + [JsonProperty("image_id", DefaultValueHandling = DefaultValueHandling.Ignore)] + public long? ImageId { get; set; } + + /// + /// The weight of the product variant in the unit system specified with weight_unit. + /// + [JsonProperty("weight")] + public decimal? Weight { get; set; } + + /// + /// The unit system that the product variant's weight is measure in. The weight_unit can be either "g", "kg, "oz", or "lb". + /// + [JsonProperty("weight_unit")] + public string WeightUnit { get; set; } + + /// + /// Additional metadata about the . Note: This is not naturally returned with a response, as + /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . + /// Uses include: Creating, updating, & deserializing webhook bodies that include them. + /// + [JsonProperty("metafields")] + public IEnumerable Metafields { get; set; } + + /// + /// A list of the variant's presentment prices and compare-at prices in each of the shop's enabled presentment currencies + /// + [JsonProperty("presentment_prices")] + public IEnumerable PresentmentPrices { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/Province.cs b/ShopifySharp/Entities/Province.cs index 420d896d..ca35a697 100644 --- a/ShopifySharp/Entities/Province.cs +++ b/ShopifySharp/Entities/Province.cs @@ -1,55 +1,54 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class Province : ShopifyObject { - public class Province : ShopifyObject - { - /// - /// The unique numeric identifier for the country. - /// - [JsonProperty("country_id")] - public long? CountryId { get; set; } - - /// - /// The name of the province or state. - /// - [JsonProperty("name")] - public string Name { get; set; } - - /// - /// The two letter province or state code. - /// - [JsonProperty("code")] - public string Code { get; set; } - - /// - /// The tax value in decimal format. - /// - [JsonProperty("tax")] - public decimal? Tax { get; set; } - - /// - /// The name of the tax as it is referred to in the applicable province/state. For example, in Ontario, Canada the tax is referred to as HST. - /// - [JsonProperty("tax_name")] - public string TaxName { get; set; } - - /// - /// A tax_type is applied for a compounded sales tax. For example, the Canadian HST is a compounded sales tax of both PST and GST. - /// - [JsonProperty("tax_type")] - public string TaxType { get; set; } - - /// - /// The unique numeric identifier for the shipping zone. - /// - [JsonProperty("shipping_zone_id")] - public long? ShippingZoneId { get; set; } - - /// - /// The tax value in percent format. - /// - [JsonProperty("tax_percentage")] - public decimal? TaxPercentage { get; set; } - } + /// + /// The unique numeric identifier for the country. + /// + [JsonProperty("country_id")] + public long? CountryId { get; set; } + + /// + /// The name of the province or state. + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// The two letter province or state code. + /// + [JsonProperty("code")] + public string Code { get; set; } + + /// + /// The tax value in decimal format. + /// + [JsonProperty("tax")] + public decimal? Tax { get; set; } + + /// + /// The name of the tax as it is referred to in the applicable province/state. For example, in Ontario, Canada the tax is referred to as HST. + /// + [JsonProperty("tax_name")] + public string TaxName { get; set; } + + /// + /// A tax_type is applied for a compounded sales tax. For example, the Canadian HST is a compounded sales tax of both PST and GST. + /// + [JsonProperty("tax_type")] + public string TaxType { get; set; } + + /// + /// The unique numeric identifier for the shipping zone. + /// + [JsonProperty("shipping_zone_id")] + public long? ShippingZoneId { get; set; } + + /// + /// The tax value in percent format. + /// + [JsonProperty("tax_percentage")] + public decimal? TaxPercentage { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/RecurringCharge.cs b/ShopifySharp/Entities/RecurringCharge.cs index 0d8aca87..3ab66cd0 100644 --- a/ShopifySharp/Entities/RecurringCharge.cs +++ b/ShopifySharp/Entities/RecurringCharge.cs @@ -2,105 +2,104 @@ using ShopifySharp.Converters; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a recurring application charge (i.e. a monthly subscription to your Shopify application). +/// +public class RecurringCharge : ShopifyObject { /// - /// An object representing a recurring application charge (i.e. a monthly subscription to your Shopify application). + /// The date and time when the customer activated the . Will be null if the charge + /// has not been activated. + /// + [JsonProperty("activated_on")] + public DateTimeOffset? ActivatedOn { get; set; } + + /// + /// The date and time when the customer will be billed. Will be null if the charge has not been activated by the customer. + /// + [JsonProperty("billing_on")] + public DateTimeOffset? BillingOn { get; set; } + + /// + /// The capped amount is the limit a customer can be charged for usage based billing. + /// + [JsonProperty("capped_amount")] + public decimal? CappedAmount { get; set; } + + /// + /// The date and time when the customer cancelled their recurring application charge. Will be null if the charge has not + /// been cancelled. + /// + [JsonProperty("cancelled_on")] + public DateTimeOffset? CancelledOn { get; set; } + + /// + /// The URL that the customer should be sent to, to accept or decline the recurring application charge. + /// + [JsonProperty("confirmation_url")] + public string ConfirmationUrl { get; set; } + + /// + /// The date and time when the recurring application charge was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// The name of the recurring application charge. + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// The price of the recurring application charge. + /// + /// Shopify returns this as a string, but JSON.net should be able to convert it to a decimal. + [JsonProperty("price")] + public decimal? Price { get; set; } + + /// + /// The URL the customer is sent to once they accept/decline a charge. + /// + [JsonProperty("return_url")] + public string ReturnUrl { get; set; } + + /// + /// Known values are 'pending', 'accepted', 'active', 'cancelled', 'declined' and 'expired'. + /// + [JsonProperty("status")] + public string Status { get; set; } + + /// + /// States the terms and conditions of usage based billing charges. Must be present in order to create usage charges. These are presented to the merchant when they approve the usage charges for your app. + /// + [JsonProperty("terms")] + public string Terms { get; set; } + + /// + /// States whether or not the application charge is a test transaction. + /// + /// Valid values are 'true' or null. Needs a special converter to convert null to false and vice-versa. + [JsonProperty("test", NullValueHandling = NullValueHandling.Include), JsonConverter(typeof(FalseToNullConverter))] + public bool? Test { get; set; } + + /// + /// Number of days that the customer is eligible for a free trial. + /// + [JsonProperty("trial_days")] + public int? TrialDays { get; set; } + + /// + /// The date and time when the free trial ends. Will be null if the charge has not been accepted. + /// + [JsonProperty("trial_ends_on")] + public DateTimeOffset? TrialEndsOn { get; set; } + + /// + /// The date and time when the recurring application charge was last updated. /// - public class RecurringCharge : ShopifyObject - { - /// - /// The date and time when the customer activated the . Will be null if the charge - /// has not been activated. - /// - [JsonProperty("activated_on")] - public DateTimeOffset? ActivatedOn { get; set; } - - /// - /// The date and time when the customer will be billed. Will be null if the charge has not been activated by the customer. - /// - [JsonProperty("billing_on")] - public DateTimeOffset? BillingOn { get; set; } - - /// - /// The capped amount is the limit a customer can be charged for usage based billing. - /// - [JsonProperty("capped_amount")] - public decimal? CappedAmount { get; set; } - - /// - /// The date and time when the customer cancelled their recurring application charge. Will be null if the charge has not - /// been cancelled. - /// - [JsonProperty("cancelled_on")] - public DateTimeOffset? CancelledOn { get; set; } - - /// - /// The URL that the customer should be sent to, to accept or decline the recurring application charge. - /// - [JsonProperty("confirmation_url")] - public string ConfirmationUrl { get; set; } - - /// - /// The date and time when the recurring application charge was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// The name of the recurring application charge. - /// - [JsonProperty("name")] - public string Name { get; set; } - - /// - /// The price of the recurring application charge. - /// - /// Shopify returns this as a string, but JSON.net should be able to convert it to a decimal. - [JsonProperty("price")] - public decimal? Price { get; set; } - - /// - /// The URL the customer is sent to once they accept/decline a charge. - /// - [JsonProperty("return_url")] - public string ReturnUrl { get; set; } - - /// - /// Known values are 'pending', 'accepted', 'active', 'cancelled', 'declined' and 'expired'. - /// - [JsonProperty("status")] - public string Status { get; set; } - - /// - /// States the terms and conditions of usage based billing charges. Must be present in order to create usage charges. These are presented to the merchant when they approve the usage charges for your app. - /// - [JsonProperty("terms")] - public string Terms { get; set; } - - /// - /// States whether or not the application charge is a test transaction. - /// - /// Valid values are 'true' or null. Needs a special converter to convert null to false and vice-versa. - [JsonProperty("test", NullValueHandling = NullValueHandling.Include), JsonConverter(typeof(FalseToNullConverter))] - public bool? Test { get; set; } - - /// - /// Number of days that the customer is eligible for a free trial. - /// - [JsonProperty("trial_days")] - public int? TrialDays { get; set; } - - /// - /// The date and time when the free trial ends. Will be null if the charge has not been accepted. - /// - [JsonProperty("trial_ends_on")] - public DateTimeOffset? TrialEndsOn { get; set; } - - /// - /// The date and time when the recurring application charge was last updated. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - } -} + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/RedactedCustomer.cs b/ShopifySharp/Entities/RedactedCustomer.cs index 2b241580..11f98b48 100644 --- a/ShopifySharp/Entities/RedactedCustomer.cs +++ b/ShopifySharp/Entities/RedactedCustomer.cs @@ -1,29 +1,28 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// Represents a customer that should be purged from your database after receiving a GDPR webhook. +/// In some cases, a customer record contains only the customer's email address +/// +public class RedactedCustomer { /// - /// Represents a customer that should be purged from your database after receiving a GDPR webhook. - /// In some cases, a customer record contains only the customer's email address + /// The customer's id. /// - public class RedactedCustomer - { - /// - /// The customer's id. - /// - [JsonProperty("id")] - public long? Id { get; set; } + [JsonProperty("id")] + public long? Id { get; set; } - /// - /// The customer's email address. - /// - [JsonProperty("email")] - public string Email { get; set; } + /// + /// The customer's email address. + /// + [JsonProperty("email")] + public string Email { get; set; } - /// - /// The customer's phone number. - /// - [JsonProperty("phone")] - public string Phone { get; set; } - } + /// + /// The customer's phone number. + /// + [JsonProperty("phone")] + public string Phone { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/Redirect.cs b/ShopifySharp/Entities/Redirect.cs index 4a12ea94..807e7bbc 100644 --- a/ShopifySharp/Entities/Redirect.cs +++ b/ShopifySharp/Entities/Redirect.cs @@ -1,23 +1,22 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An entity representing a Shopify redirect. +/// +public class Redirect : ShopifyObject { /// - /// An entity representing a Shopify redirect. + /// The "before" path to be redirected. When the user navigates to this path, they will be redirected to the path specified by target. /// - public class Redirect : ShopifyObject - { - /// - /// The "before" path to be redirected. When the user navigates to this path, they will be redirected to the path specified by target. - /// - [JsonProperty("path")] - public string Path { get; set; } + [JsonProperty("path")] + public string Path { get; set; } - /// - /// The "after" path or URL to be redirected to. This property can be set to any path on the shop's site, or any URL, even one on a - /// completely different domain. - /// - [JsonProperty("target")] - public string Target { get; set; } - } -} + /// + /// The "after" path or URL to be redirected to. This property can be set to any path on the shop's site, or any URL, even one on a + /// completely different domain. + /// + [JsonProperty("target")] + public string Target { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/Refund.cs b/ShopifySharp/Entities/Refund.cs index ce6f62de..ac2162b7 100644 --- a/ShopifySharp/Entities/Refund.cs +++ b/ShopifySharp/Entities/Refund.cs @@ -3,124 +3,123 @@ using System; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +public class Refund : ShopifyObject { - public class Refund : ShopifyObject - { - /// - /// The unique identifier of the order. - /// - [JsonProperty("order_id")] - public long? OrderId { get; set; } - - /// - /// The date and time when the refund was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// Whether to send a refund notification to the customer - /// - [JsonProperty("notify")] - public bool? Notify { get; set; } - - /// - /// Specify how much shipping to refund. - /// - [JsonProperty("shipping")] - public Shipping Shipping { get; set; } - - /// - /// The three-letter code (ISO 4217 format) for the currency used for the refund. Note: Required whenever the shipping amount property is provided. - /// - [JsonProperty("currency")] - public string Currency { get; set; } - - /// - /// The list of objects - /// - [JsonProperty("order_adjustments")] - public IEnumerable OrderAdjustments { get; set; } - - /// - /// The date and time when the refund was imported. - /// - /// - /// This value can be set to dates in the past when importing from other systems. If no value is provided, it will be auto-generated. - /// - [JsonProperty("processed_at")] - public DateTimeOffset? ProcessedAt { get; set; } - - /// - /// The optional note attached to a refund. - /// - [JsonProperty("note")] - public string Note { get; set; } - - /// - /// An optional comment that explains a discrepancy between calculated and actual refund amounts. - /// Used to populate the reason property of the resulting order adjustment object attached to the refund. - /// - /// restock, damage, customer, and other. - [JsonProperty("discrepancy_reason")] - public string DiscrepancyReason { get; set; } - - /// - /// The list of objects - /// - [JsonProperty("refund_line_items")] - public IEnumerable RefundLineItems { get; set; } - - /// - /// The list of objects - /// - [JsonProperty("transactions")] - public IEnumerable Transactions { get; set; } - - /// - /// The unique identifier of the user who performed the refund. - /// - [JsonProperty("user_id")] - public long? UserId { get; set; } - - /// - /// A list of duties that have been returned as part of the refund. - /// - [JsonProperty("duties")] - public IEnumerable Duties { get; set; } - - /// - /// A list of refunded duties - /// - [JsonProperty("refund_duties")] - public IEnumerable RefundDuties { get; set; } - - /// - /// Unique identifiers for the return. - /// - [JsonProperty("return")] - public Return Return { get; set; } - } - - public class Shipping - { - /// - /// Whether to refund all remaining shipping. - /// - [JsonProperty("full_refund")] - public bool? FullRefund { get; set; } - - /// - /// Set a specific amount to refund for shipping. Takes precedence over full_refund. - /// - [JsonProperty("amount")] - public decimal? Amount { get; set; } - - /// - /// The maximum amount that can be refunded - /// - [JsonProperty("maximum_refundable")] - public decimal? MaximumRefundable { get; set; } - } + /// + /// The unique identifier of the order. + /// + [JsonProperty("order_id")] + public long? OrderId { get; set; } + + /// + /// The date and time when the refund was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// Whether to send a refund notification to the customer + /// + [JsonProperty("notify")] + public bool? Notify { get; set; } + + /// + /// Specify how much shipping to refund. + /// + [JsonProperty("shipping")] + public Shipping Shipping { get; set; } + + /// + /// The three-letter code (ISO 4217 format) for the currency used for the refund. Note: Required whenever the shipping amount property is provided. + /// + [JsonProperty("currency")] + public string Currency { get; set; } + + /// + /// The list of objects + /// + [JsonProperty("order_adjustments")] + public IEnumerable OrderAdjustments { get; set; } + + /// + /// The date and time when the refund was imported. + /// + /// + /// This value can be set to dates in the past when importing from other systems. If no value is provided, it will be auto-generated. + /// + [JsonProperty("processed_at")] + public DateTimeOffset? ProcessedAt { get; set; } + + /// + /// The optional note attached to a refund. + /// + [JsonProperty("note")] + public string Note { get; set; } + + /// + /// An optional comment that explains a discrepancy between calculated and actual refund amounts. + /// Used to populate the reason property of the resulting order adjustment object attached to the refund. + /// + /// restock, damage, customer, and other. + [JsonProperty("discrepancy_reason")] + public string DiscrepancyReason { get; set; } + + /// + /// The list of objects + /// + [JsonProperty("refund_line_items")] + public IEnumerable RefundLineItems { get; set; } + + /// + /// The list of objects + /// + [JsonProperty("transactions")] + public IEnumerable Transactions { get; set; } + + /// + /// The unique identifier of the user who performed the refund. + /// + [JsonProperty("user_id")] + public long? UserId { get; set; } + + /// + /// A list of duties that have been returned as part of the refund. + /// + [JsonProperty("duties")] + public IEnumerable Duties { get; set; } + + /// + /// A list of refunded duties + /// + [JsonProperty("refund_duties")] + public IEnumerable RefundDuties { get; set; } + + /// + /// Unique identifiers for the return. + /// + [JsonProperty("return")] + public Return Return { get; set; } } + +public class Shipping +{ + /// + /// Whether to refund all remaining shipping. + /// + [JsonProperty("full_refund")] + public bool? FullRefund { get; set; } + + /// + /// Set a specific amount to refund for shipping. Takes precedence over full_refund. + /// + [JsonProperty("amount")] + public decimal? Amount { get; set; } + + /// + /// The maximum amount that can be refunded + /// + [JsonProperty("maximum_refundable")] + public decimal? MaximumRefundable { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/RefundDuty.cs b/ShopifySharp/Entities/RefundDuty.cs index 08846193..bc572705 100644 --- a/ShopifySharp/Entities/RefundDuty.cs +++ b/ShopifySharp/Entities/RefundDuty.cs @@ -1,13 +1,12 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class RefundDuty { - public class RefundDuty - { - [JsonProperty("duty_id")] - public long? DutyId { get; set; } + [JsonProperty("duty_id")] + public long? DutyId { get; set; } - [JsonProperty("amount_set")] - public PriceSet AmountSet { get; set; } - } -} + [JsonProperty("amount_set")] + public PriceSet AmountSet { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/RefundDutyType.cs b/ShopifySharp/Entities/RefundDutyType.cs index abe34861..7a6eee81 100644 --- a/ShopifySharp/Entities/RefundDutyType.cs +++ b/ShopifySharp/Entities/RefundDutyType.cs @@ -1,13 +1,12 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class RefundDutyType { - public class RefundDutyType - { - [JsonProperty("duty_id")] - public long? DutyId { get; set; } + [JsonProperty("duty_id")] + public long? DutyId { get; set; } - [JsonProperty("refund_type")] - public string RefundType { get; set; } - } -} + [JsonProperty("refund_type")] + public string RefundType { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/RefundLineItem.cs b/ShopifySharp/Entities/RefundLineItem.cs index ad1c2e51..84426889 100644 --- a/ShopifySharp/Entities/RefundLineItem.cs +++ b/ShopifySharp/Entities/RefundLineItem.cs @@ -1,62 +1,61 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class RefundLineItem : ShopifyObject { - public class RefundLineItem : ShopifyObject - { - /// - /// The single being returned. - /// - [JsonProperty("line_item")] - public LineItem LineItem { get; set; } - - /// - /// The unique identifier of the refund line item. - /// - [JsonProperty("line_item_id")] - public long? LineItemId { get; set; } - - /// - /// The quantity of the associated line item that was returned. - /// - [JsonProperty("quantity")] - public int? Quantity { get; set; } - - /// - /// Tax amount refunded - /// - [JsonProperty("total_tax")] - public decimal? TotalTax { get; set; } - - /// - /// Item subtotal - /// - [JsonProperty("subtotal")] - public decimal? SubTotal { get; set; } - - /// - /// The subtotal of the refund line item in shop and presentment currencies. - /// - [JsonProperty("subtotal_set")] - public PriceSet SubTotalTaxSet { get; set; } - - /// - /// The total tax of the line item in shop and presentment currencies. - /// - [JsonProperty("total_tax_set")] - public PriceSet TotalTaxSet { get; set; } - - /// - /// How this refund line item affects inventory levels. - /// - [JsonProperty("restock_type")] - public string RestockType { get; set; } - - /// - /// The unique identifier of the location where the items will be restocked. - /// Required when restock_type has the value return or cancel. - /// - [JsonProperty("location_id")] - public long? LocationId { get; set; } - } -} + /// + /// The single being returned. + /// + [JsonProperty("line_item")] + public LineItem LineItem { get; set; } + + /// + /// The unique identifier of the refund line item. + /// + [JsonProperty("line_item_id")] + public long? LineItemId { get; set; } + + /// + /// The quantity of the associated line item that was returned. + /// + [JsonProperty("quantity")] + public int? Quantity { get; set; } + + /// + /// Tax amount refunded + /// + [JsonProperty("total_tax")] + public decimal? TotalTax { get; set; } + + /// + /// Item subtotal + /// + [JsonProperty("subtotal")] + public decimal? SubTotal { get; set; } + + /// + /// The subtotal of the refund line item in shop and presentment currencies. + /// + [JsonProperty("subtotal_set")] + public PriceSet SubTotalTaxSet { get; set; } + + /// + /// The total tax of the line item in shop and presentment currencies. + /// + [JsonProperty("total_tax_set")] + public PriceSet TotalTaxSet { get; set; } + + /// + /// How this refund line item affects inventory levels. + /// + [JsonProperty("restock_type")] + public string RestockType { get; set; } + + /// + /// The unique identifier of the location where the items will be restocked. + /// Required when restock_type has the value return or cancel. + /// + [JsonProperty("location_id")] + public long? LocationId { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/RefundOrderAdjustment.cs b/ShopifySharp/Entities/RefundOrderAdjustment.cs index 7715ae68..0a0d9ade 100644 --- a/ShopifySharp/Entities/RefundOrderAdjustment.cs +++ b/ShopifySharp/Entities/RefundOrderAdjustment.cs @@ -1,54 +1,53 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class RefundOrderAdjustment : ShopifyObject { - public class RefundOrderAdjustment : ShopifyObject - { - /// - /// The unique identifier of the order - /// - [JsonProperty("order_id")] - public long? OrderId { get; set; } - - /// - /// The unique identifier of the refund - /// - [JsonProperty("refund_id")] - public long? RefundId { get; set; } - - /// - /// The amount refunded (it is negative and does not include tax). - /// - [JsonProperty("amount")] - public decimal? Amount { get; set; } - - /// - /// The tax amount refunded (negative). - /// - [JsonProperty("tax_amount")] - public decimal? TaxAmount { get; set; } - - /// - /// The type of adjustment. Values include "refund_discrepancy", "shipping_refund" - /// - [JsonProperty("kind")] - public string Kind { get; set; } - - /// - /// Reason for the refund - /// - public string Reason { get; set; } - - /// - /// The amount of the order adjustment in shop and presentment currencies. - /// - [JsonProperty("amount_set")] - public PriceSet AmountSet { get; set; } - - /// - /// The tax amount of the order adjustment in shop and presentment currencies. - /// - [JsonProperty("tax_amount_set")] - public PriceSet TaxAmountSet { get; set; } - } -} + /// + /// The unique identifier of the order + /// + [JsonProperty("order_id")] + public long? OrderId { get; set; } + + /// + /// The unique identifier of the refund + /// + [JsonProperty("refund_id")] + public long? RefundId { get; set; } + + /// + /// The amount refunded (it is negative and does not include tax). + /// + [JsonProperty("amount")] + public decimal? Amount { get; set; } + + /// + /// The tax amount refunded (negative). + /// + [JsonProperty("tax_amount")] + public decimal? TaxAmount { get; set; } + + /// + /// The type of adjustment. Values include "refund_discrepancy", "shipping_refund" + /// + [JsonProperty("kind")] + public string Kind { get; set; } + + /// + /// Reason for the refund + /// + public string Reason { get; set; } + + /// + /// The amount of the order adjustment in shop and presentment currencies. + /// + [JsonProperty("amount_set")] + public PriceSet AmountSet { get; set; } + + /// + /// The tax amount of the order adjustment in shop and presentment currencies. + /// + [JsonProperty("tax_amount_set")] + public PriceSet TaxAmountSet { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/Return.cs b/ShopifySharp/Entities/Return.cs index 75754294..7f4442e2 100644 --- a/ShopifySharp/Entities/Return.cs +++ b/ShopifySharp/Entities/Return.cs @@ -1,9 +1,8 @@ -namespace ShopifySharp.Entities +namespace ShopifySharp.Entities; + +/// +/// An object representing the Shopify Return +/// +public class Return : ShopifyObject { - /// - /// An object representing the Shopify Return - /// - public class Return : ShopifyObject - { - } -} +} \ No newline at end of file diff --git a/ShopifySharp/Entities/SalesChannel/CardVault.cs b/ShopifySharp/Entities/SalesChannel/CardVault.cs index 5339e353..e640259e 100644 --- a/ShopifySharp/Entities/SalesChannel/CardVault.cs +++ b/ShopifySharp/Entities/SalesChannel/CardVault.cs @@ -1,10 +1,9 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp.Entities.SalesChannel +namespace ShopifySharp.Entities.SalesChannel; + +public class CardVault { - public class CardVault - { - [JsonProperty("id")] - public string Id { get; set; } - } -} + [JsonProperty("id")] + public string Id { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/SalesChannel/CheckoutSalesChannel.cs b/ShopifySharp/Entities/SalesChannel/CheckoutSalesChannel.cs index 24d104a0..1f1f2dc5 100644 --- a/ShopifySharp/Entities/SalesChannel/CheckoutSalesChannel.cs +++ b/ShopifySharp/Entities/SalesChannel/CheckoutSalesChannel.cs @@ -1,172 +1,171 @@ -using System; +using System; using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp.Entities.SalesChannel +namespace ShopifySharp.Entities.SalesChannel; + +[JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] +public class CheckoutSalesChannel { - [JsonObject(ItemNullValueHandling = NullValueHandling.Ignore)] - public class CheckoutSalesChannel - { - [JsonProperty("completed_at")] - public DateTimeOffset? CompletedAt { get; set; } + [JsonProperty("completed_at")] + public DateTimeOffset? CompletedAt { get; set; } - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - [JsonProperty("currency")] - public string Currency { get; set; } + [JsonProperty("currency")] + public string Currency { get; set; } - [JsonProperty("presentment_currency")] - public string PresentmentCurrency { get; set; } + [JsonProperty("presentment_currency")] + public string PresentmentCurrency { get; set; } - [JsonProperty("customer_id")] - public long? CustomerId { get; set; } + [JsonProperty("customer_id")] + public long? CustomerId { get; set; } - [JsonProperty("customer_locale")] - public string CustomerLocale { get; set; } + [JsonProperty("customer_locale")] + public string CustomerLocale { get; set; } - [JsonProperty("device_id")] - public string DeviceId { get; set; } + [JsonProperty("device_id")] + public string DeviceId { get; set; } - [JsonProperty("discount_code")] - public string DiscountCode { get; set; } + [JsonProperty("discount_code")] + public string DiscountCode { get; set; } - [JsonProperty("email")] - public string Email { get; set; } + [JsonProperty("email")] + public string Email { get; set; } - [JsonProperty("legal_notice_url")] - public Uri LegalNoticeUrl { get; set; } + [JsonProperty("legal_notice_url")] + public Uri LegalNoticeUrl { get; set; } - [JsonProperty("location_id")] - public string LocationId { get; set; } + [JsonProperty("location_id")] + public string LocationId { get; set; } - [JsonProperty("name")] - public string Name { get; set; } + [JsonProperty("name")] + public string Name { get; set; } - [JsonProperty("note")] - public string Note { get; set; } + [JsonProperty("note")] + public string Note { get; set; } - [JsonProperty("note_attributes")] - public Dictionary NoteAttributes { get; set; } + [JsonProperty("note_attributes")] + public Dictionary NoteAttributes { get; set; } - [JsonProperty("order_id")] - public string OrderId { get; set; } + [JsonProperty("order_id")] + public string OrderId { get; set; } - [JsonProperty("order_status_url")] - public Uri OrderStatusUrl { get; set; } + [JsonProperty("order_status_url")] + public Uri OrderStatusUrl { get; set; } - [JsonProperty("order")] - public Order Order { get; set; } + [JsonProperty("order")] + public Order Order { get; set; } - [JsonProperty("payment_due")] - public string PaymentDue { get; set; } + [JsonProperty("payment_due")] + public string PaymentDue { get; set; } - [JsonProperty("payment_url")] - public Uri PaymentUrl { get; set; } + [JsonProperty("payment_url")] + public Uri PaymentUrl { get; set; } - [JsonProperty("payments")] - public PaymentSalesChannel[] Payments { get; set; } + [JsonProperty("payments")] + public PaymentSalesChannel[] Payments { get; set; } - [JsonProperty("phone")] - public string Phone { get; set; } + [JsonProperty("phone")] + public string Phone { get; set; } - [JsonProperty("shopify_payments_account_id")] - public string ShopifyPaymentsAccountId { get; set; } + [JsonProperty("shopify_payments_account_id")] + public string ShopifyPaymentsAccountId { get; set; } - [JsonProperty("privacy_policy_url")] - public Uri PrivacyPolicyUrl { get; set; } + [JsonProperty("privacy_policy_url")] + public Uri PrivacyPolicyUrl { get; set; } - [JsonProperty("refund_policy_url")] - public Uri RefundPolicyUrl { get; set; } + [JsonProperty("refund_policy_url")] + public Uri RefundPolicyUrl { get; set; } - [JsonProperty("requires_shipping")] - public bool RequiresShipping { get; set; } + [JsonProperty("requires_shipping")] + public bool RequiresShipping { get; set; } - [JsonProperty("reservation_time_left")] - public long ReservationTimeLeft { get; set; } + [JsonProperty("reservation_time_left")] + public long ReservationTimeLeft { get; set; } - [JsonProperty("source_identifier")] - public string SourceIdentifier { get; set; } + [JsonProperty("source_identifier")] + public string SourceIdentifier { get; set; } - [JsonProperty("source_name")] - public string SourceName { get; set; } + [JsonProperty("source_name")] + public string SourceName { get; set; } - [JsonProperty("source_url")] - public Uri SourceUrl { get; set; } + [JsonProperty("source_url")] + public Uri SourceUrl { get; set; } - [JsonProperty("subscription_policy_url")] - public Uri SubscriptionPolicyUrl { get; set; } + [JsonProperty("subscription_policy_url")] + public Uri SubscriptionPolicyUrl { get; set; } - [JsonProperty("subtotal_price")] - public string SubtotalPrice { get; set; } + [JsonProperty("subtotal_price")] + public string SubtotalPrice { get; set; } - [JsonProperty("shipping_policy_url")] - public Uri ShippingPolicyUrl { get; set; } + [JsonProperty("shipping_policy_url")] + public Uri ShippingPolicyUrl { get; set; } - [JsonProperty("tax_exempt")] - public bool TaxExempt { get; set; } + [JsonProperty("tax_exempt")] + public bool TaxExempt { get; set; } - [JsonProperty("taxes_included")] - public bool TaxesIncluded { get; set; } + [JsonProperty("taxes_included")] + public bool TaxesIncluded { get; set; } - [JsonProperty("terms_of_sale_url")] - public Uri TermsOfSaleUrl { get; set; } + [JsonProperty("terms_of_sale_url")] + public Uri TermsOfSaleUrl { get; set; } - [JsonProperty("terms_of_service_url")] - public Uri TermsOfServiceUrl { get; set; } + [JsonProperty("terms_of_service_url")] + public Uri TermsOfServiceUrl { get; set; } - [JsonProperty("token")] - public string Token { get; set; } + [JsonProperty("token")] + public string Token { get; set; } - [JsonProperty("total_price")] - public string TotalPrice { get; set; } + [JsonProperty("total_price")] + public string TotalPrice { get; set; } - [JsonProperty("total_tax")] - public string TotalTax { get; set; } + [JsonProperty("total_tax")] + public string TotalTax { get; set; } - [JsonProperty("total_tip_received")] - public string TotalTipReceived { get; set; } + [JsonProperty("total_tip_received")] + public string TotalTipReceived { get; set; } - [JsonProperty("total_line_items_price")] - public string TotalLineItemsPrice { get; set; } + [JsonProperty("total_line_items_price")] + public string TotalLineItemsPrice { get; set; } - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } - [JsonProperty("user_id")] - public string UserId { get; set; } + [JsonProperty("user_id")] + public string UserId { get; set; } - [JsonProperty("web_url")] - public Uri WebUrl { get; set; } + [JsonProperty("web_url")] + public Uri WebUrl { get; set; } - [JsonProperty("line_items")] - public IEnumerable LineItems { get; set; } + [JsonProperty("line_items")] + public IEnumerable LineItems { get; set; } - [JsonProperty("gift_cards")] - public IEnumerable GiftCards { get; set; } + [JsonProperty("gift_cards")] + public IEnumerable GiftCards { get; set; } - [JsonProperty("tax_lines")] - public IEnumerable TaxLines { get; set; } + [JsonProperty("tax_lines")] + public IEnumerable TaxLines { get; set; } - //[JsonProperty("tax_manipulations")] - //public object[] TaxManipulations { get; set; } + //[JsonProperty("tax_manipulations")] + //public object[] TaxManipulations { get; set; } - [JsonProperty("shipping_line")] - public CheckoutShippingRate ShippingLine { get; set; } + [JsonProperty("shipping_line")] + public CheckoutShippingRate ShippingLine { get; set; } - [JsonProperty("shipping_rate")] - public CheckoutShippingRate ShippingRate { get; set; } + [JsonProperty("shipping_rate")] + public CheckoutShippingRate ShippingRate { get; set; } - [JsonProperty("shipping_address")] - public Address ShippingAddress { get; set; } + [JsonProperty("shipping_address")] + public Address ShippingAddress { get; set; } - [JsonProperty("credit_card")] - public CreditCard CreditCard { get; set; } + [JsonProperty("credit_card")] + public CreditCard CreditCard { get; set; } - [JsonProperty("billing_address")] - public Address BillingAddress { get; set; } + [JsonProperty("billing_address")] + public Address BillingAddress { get; set; } - [JsonProperty("applied_discount")] - public AppliedDiscount AppliedDiscount { get; set; } - } -} + [JsonProperty("applied_discount")] + public AppliedDiscount AppliedDiscount { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/SalesChannel/CheckoutSalesChannelLineItem.cs b/ShopifySharp/Entities/SalesChannel/CheckoutSalesChannelLineItem.cs index 4df1375f..6bda3fae 100644 --- a/ShopifySharp/Entities/SalesChannel/CheckoutSalesChannelLineItem.cs +++ b/ShopifySharp/Entities/SalesChannel/CheckoutSalesChannelLineItem.cs @@ -1,75 +1,74 @@ -using System; +using System; using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp.Entities.SalesChannel +namespace ShopifySharp.Entities.SalesChannel; + +public class CheckoutSalesChannelLineItem { - public class CheckoutSalesChannelLineItem - { - [JsonProperty("id")] - public string Id { get; set; } + [JsonProperty("id")] + public string Id { get; set; } - [JsonProperty("key")] - public string Key { get; set; } + [JsonProperty("key")] + public string Key { get; set; } - [JsonProperty("product_id")] - public long? ProductId { get; set; } + [JsonProperty("product_id")] + public long? ProductId { get; set; } - [JsonProperty("variant_id")] - public long VariantId { get; set; } + [JsonProperty("variant_id")] + public long VariantId { get; set; } - [JsonProperty("sku")] - public string Sku { get; set; } + [JsonProperty("sku")] + public string Sku { get; set; } - [JsonProperty("vendor")] - public string Vendor { get; set; } + [JsonProperty("vendor")] + public string Vendor { get; set; } - [JsonProperty("title")] - public string Title { get; set; } + [JsonProperty("title")] + public string Title { get; set; } - [JsonProperty("variant_title")] - public string VariantTitle { get; set; } + [JsonProperty("variant_title")] + public string VariantTitle { get; set; } - [JsonProperty("image_url")] - public Uri ImageUrl { get; set; } + [JsonProperty("image_url")] + public Uri ImageUrl { get; set; } - [JsonProperty("taxable")] - public bool Taxable { get; set; } + [JsonProperty("taxable")] + public bool Taxable { get; set; } - [JsonProperty("requires_shipping")] - public bool RequiresShipping { get; set; } + [JsonProperty("requires_shipping")] + public bool RequiresShipping { get; set; } - [JsonProperty("gift_card")] - public bool GiftCard { get; set; } + [JsonProperty("gift_card")] + public bool GiftCard { get; set; } - [JsonProperty("price")] - public string Price { get; set; } + [JsonProperty("price")] + public string Price { get; set; } - [JsonProperty("compare_at_price")] - public decimal? CompareAtPrice { get; set; } + [JsonProperty("compare_at_price")] + public decimal? CompareAtPrice { get; set; } - [JsonProperty("line_price")] - public string LinePrice { get; set; } + [JsonProperty("line_price")] + public string LinePrice { get; set; } - [JsonProperty("properties")] - public Dictionary Properties { get; set; } + [JsonProperty("properties")] + public Dictionary Properties { get; set; } - [JsonProperty("quantity")] - public long Quantity { get; set; } + [JsonProperty("quantity")] + public long Quantity { get; set; } - [JsonProperty("grams")] - public long? Grams { get; set; } + [JsonProperty("grams")] + public long? Grams { get; set; } - [JsonProperty("fulfillment_service")] - public string FulfillmentService { get; set; } + [JsonProperty("fulfillment_service")] + public string FulfillmentService { get; set; } - [JsonProperty("applied_discounts")] - public IEnumerable AppliedDiscounts { get; set; } + [JsonProperty("applied_discounts")] + public IEnumerable AppliedDiscounts { get; set; } - [JsonProperty("discount_allocations")] - public IEnumerable DiscountAllocations { get; set; } + [JsonProperty("discount_allocations")] + public IEnumerable DiscountAllocations { get; set; } - [JsonProperty("tax_lines")] - public IEnumerable TaxLines { get; set; } - } + [JsonProperty("tax_lines")] + public IEnumerable TaxLines { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/SalesChannel/CreatePayment.cs b/ShopifySharp/Entities/SalesChannel/CreatePayment.cs index 0382bb02..3184caad 100644 --- a/ShopifySharp/Entities/SalesChannel/CreatePayment.cs +++ b/ShopifySharp/Entities/SalesChannel/CreatePayment.cs @@ -1,19 +1,18 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp.Entities.SalesChannel +namespace ShopifySharp.Entities.SalesChannel; + +public class CreatePayment { - public class CreatePayment - { - [JsonProperty("request_details")] - public SalesChannelPaymentRequestDetails SalesChannelPaymentRequestDetails { get; set; } + [JsonProperty("request_details")] + public SalesChannelPaymentRequestDetails SalesChannelPaymentRequestDetails { get; set; } - [JsonProperty("amount")] - public string Amount { get; set; } + [JsonProperty("amount")] + public string Amount { get; set; } - [JsonProperty("session_id")] - public string SessionId { get; set; } + [JsonProperty("session_id")] + public string SessionId { get; set; } - [JsonProperty("unique_token")] - public string UniqueToken { get; set; } - } -} + [JsonProperty("unique_token")] + public string UniqueToken { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/SalesChannel/CreditCard.cs b/ShopifySharp/Entities/SalesChannel/CreditCard.cs index 7a9e4d98..7055d1cd 100644 --- a/ShopifySharp/Entities/SalesChannel/CreditCard.cs +++ b/ShopifySharp/Entities/SalesChannel/CreditCard.cs @@ -1,25 +1,24 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp.Entities.SalesChannel +namespace ShopifySharp.Entities.SalesChannel; + +public class CreditCard { - public class CreditCard - { - [JsonProperty("number")] - public long? Number { get; set; } + [JsonProperty("number")] + public long? Number { get; set; } - [JsonProperty("first_name")] - public string FirstName { get; set; } + [JsonProperty("first_name")] + public string FirstName { get; set; } - [JsonProperty("last_name")] - public string LastName { get; set; } + [JsonProperty("last_name")] + public string LastName { get; set; } - [JsonProperty("month")] - public long? Month { get; set; } + [JsonProperty("month")] + public long? Month { get; set; } - [JsonProperty("year")] - public long? Year { get; set; } + [JsonProperty("year")] + public long? Year { get; set; } - [JsonProperty("verification_value")] - public long? VerificationValue { get; set; } - } -} + [JsonProperty("verification_value")] + public long? VerificationValue { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/SalesChannel/PaymentCreditCard.cs b/ShopifySharp/Entities/SalesChannel/PaymentCreditCard.cs index aeff72b2..e31f7500 100644 --- a/ShopifySharp/Entities/SalesChannel/PaymentCreditCard.cs +++ b/ShopifySharp/Entities/SalesChannel/PaymentCreditCard.cs @@ -1,31 +1,30 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp.Entities.SalesChannel +namespace ShopifySharp.Entities.SalesChannel; + +public class PaymentCreditCard { - public class PaymentCreditCard - { - [JsonProperty("first_name")] - public string FirstName { get; set; } + [JsonProperty("first_name")] + public string FirstName { get; set; } - [JsonProperty("last_name")] - public string LastName { get; set; } + [JsonProperty("last_name")] + public string LastName { get; set; } - [JsonProperty("first_digits")] - public long FirstDigits { get; set; } + [JsonProperty("first_digits")] + public long FirstDigits { get; set; } - [JsonProperty("last_digits")] - public long LastDigits { get; set; } + [JsonProperty("last_digits")] + public long LastDigits { get; set; } - [JsonProperty("brand")] - public string Brand { get; set; } + [JsonProperty("brand")] + public string Brand { get; set; } - [JsonProperty("expiry_month")] - public long ExpiryMonth { get; set; } + [JsonProperty("expiry_month")] + public long ExpiryMonth { get; set; } - [JsonProperty("expiry_year")] - public long ExpiryYear { get; set; } + [JsonProperty("expiry_year")] + public long ExpiryYear { get; set; } - [JsonProperty("customer_id")] - public long CustomerId { get; set; } - } + [JsonProperty("customer_id")] + public long CustomerId { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/SalesChannel/PaymentSalesChannel.cs b/ShopifySharp/Entities/SalesChannel/PaymentSalesChannel.cs index ddb77006..62c3cfbb 100644 --- a/ShopifySharp/Entities/SalesChannel/PaymentSalesChannel.cs +++ b/ShopifySharp/Entities/SalesChannel/PaymentSalesChannel.cs @@ -1,35 +1,34 @@ -using System; +using System; using Newtonsoft.Json; -namespace ShopifySharp.Entities.SalesChannel -{ - public class PaymentSalesChannel: ShopifyObject - { - [JsonProperty("unique_token")] - public string UniqueToken { get; set; } +namespace ShopifySharp.Entities.SalesChannel; - [JsonProperty("payment_processing_error_message")] - public object PaymentProcessingErrorMessage { get; set; } +public class PaymentSalesChannel: ShopifyObject +{ + [JsonProperty("unique_token")] + public string UniqueToken { get; set; } - [JsonProperty("next_action")] - public NextAction NextAction { get; set; } + [JsonProperty("payment_processing_error_message")] + public object PaymentProcessingErrorMessage { get; set; } - [JsonProperty("fraudulent")] - public bool Fraudulent { get; set; } + [JsonProperty("next_action")] + public NextAction NextAction { get; set; } - [JsonProperty("transaction")] - public Transaction Transaction { get; set; } + [JsonProperty("fraudulent")] + public bool Fraudulent { get; set; } - [JsonProperty("credit_card")] - public PaymentCreditCard CreditCard { get; set; } + [JsonProperty("transaction")] + public Transaction Transaction { get; set; } - [JsonProperty("checkout")] - public CheckoutSalesChannel Checkout { get; set; } - } + [JsonProperty("credit_card")] + public PaymentCreditCard CreditCard { get; set; } - public class NextAction - { - [JsonProperty("redirect_url")] - public Uri RedirectUrl { get; set; } - } + [JsonProperty("checkout")] + public CheckoutSalesChannel Checkout { get; set; } } + +public class NextAction +{ + [JsonProperty("redirect_url")] + public Uri RedirectUrl { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/SalesChannel/SalesChannelPaymentRequestDetails.cs b/ShopifySharp/Entities/SalesChannel/SalesChannelPaymentRequestDetails.cs index aeeae25d..ffed525d 100644 --- a/ShopifySharp/Entities/SalesChannel/SalesChannelPaymentRequestDetails.cs +++ b/ShopifySharp/Entities/SalesChannel/SalesChannelPaymentRequestDetails.cs @@ -1,16 +1,15 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp.Entities.SalesChannel +namespace ShopifySharp.Entities.SalesChannel; + +public class SalesChannelPaymentRequestDetails { - public class SalesChannelPaymentRequestDetails - { - [JsonProperty("ip_address")] - public string IpAddress { get; set; } + [JsonProperty("ip_address")] + public string IpAddress { get; set; } - [JsonProperty("accept_language")] - public string AcceptLanguage { get; set; } + [JsonProperty("accept_language")] + public string AcceptLanguage { get; set; } - [JsonProperty("user_agent")] - public string UserAgent { get; set; } - } + [JsonProperty("user_agent")] + public string UserAgent { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/ScriptTag.cs b/ShopifySharp/Entities/ScriptTag.cs index ead41399..b77dc098 100644 --- a/ShopifySharp/Entities/ScriptTag.cs +++ b/ShopifySharp/Entities/ScriptTag.cs @@ -1,41 +1,40 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing remote javascript tags that are loaded into the pages of a shop's storefront. +/// +public class ScriptTag: ShopifyObject { /// - /// An object representing remote javascript tags that are loaded into the pages of a shop's storefront. + /// The date and time when the was created. /// - public class ScriptTag: ShopifyObject - { - /// - /// The date and time when the was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - /// - /// Where the script tag should be included on the store. Known values are 'online_store', 'order_status' or 'all'. Defaults to 'all'. - /// - [JsonProperty("display_scope")] - public string DisplayScope { get; set; } + /// + /// Where the script tag should be included on the store. Known values are 'online_store', 'order_status' or 'all'. Defaults to 'all'. + /// + [JsonProperty("display_scope")] + public string DisplayScope { get; set; } - /// - /// DOM event which triggers the loading of the script. The only known value is 'onload'. - /// - [JsonProperty("event")] - public string Event { get; set; } + /// + /// DOM event which triggers the loading of the script. The only known value is 'onload'. + /// + [JsonProperty("event")] + public string Event { get; set; } - /// - /// Specifies the location of the ScriptTag. - /// - [JsonProperty("src")] - public string Src { get; set; } + /// + /// Specifies the location of the ScriptTag. + /// + [JsonProperty("src")] + public string Src { get; set; } - /// - /// The date and time when the was updated. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - } -} + /// + /// The date and time when the was updated. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ShippingLine.cs b/ShopifySharp/Entities/ShippingLine.cs index c7e7d30a..ed0693ad 100644 --- a/ShopifySharp/Entities/ShippingLine.cs +++ b/ShopifySharp/Entities/ShippingLine.cs @@ -1,80 +1,79 @@ using Newtonsoft.Json; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +public class ShippingLine : ShopifyObject { - public class ShippingLine : ShopifyObject - { - /// - /// The carrier provided identifier. - /// - [JsonProperty("carrier_identifier")] - public string CarrierIdentifier { get; set; } + /// + /// The carrier provided identifier. + /// + [JsonProperty("carrier_identifier")] + public string CarrierIdentifier { get; set; } - /// - /// A reference to the shipping method. - /// - [JsonProperty("code")] - public string Code { get; set; } + /// + /// A reference to the shipping method. + /// + [JsonProperty("code")] + public string Code { get; set; } - /// - /// Whether the shipping line has been removed from the order. - /// - [JsonProperty("is_removed")] - public bool? IsRemoved { get; set; } + /// + /// Whether the shipping line has been removed from the order. + /// + [JsonProperty("is_removed")] + public bool? IsRemoved { get; set; } - /// - /// The phone number used for the shipment. - /// - [JsonProperty("phone")] - public string Phone { get; set; } + /// + /// The phone number used for the shipment. + /// + [JsonProperty("phone")] + public string Phone { get; set; } - /// - /// The price of this shipping method. - /// - [JsonProperty("price")] - public decimal? Price { get; set; } + /// + /// The price of this shipping method. + /// + [JsonProperty("price")] + public decimal? Price { get; set; } - /// - /// The discounted price of this shipping method. - /// - [JsonProperty("discounted_price")] - public decimal? DiscountedPrice { get; set; } + /// + /// The discounted price of this shipping method. + /// + [JsonProperty("discounted_price")] + public decimal? DiscountedPrice { get; set; } - /// - /// An ordered list of amounts allocated by discount applications. Each discount allocation is associated to a particular discount application. - /// - [JsonProperty("discount_allocations")] - public IEnumerable DiscountAllocations { get; set; } + /// + /// An ordered list of amounts allocated by discount applications. Each discount allocation is associated to a particular discount application. + /// + [JsonProperty("discount_allocations")] + public IEnumerable DiscountAllocations { get; set; } - /// - /// The source of the shipping method. - /// - [JsonProperty("source")] - public string Source { get; set; } + /// + /// The source of the shipping method. + /// + [JsonProperty("source")] + public string Source { get; set; } - /// - /// The title of the shipping method. - /// - [JsonProperty("title")] - public string Title { get; set; } + /// + /// The title of the shipping method. + /// + [JsonProperty("title")] + public string Title { get; set; } - /// - /// A list of objects, each of which details the taxes applicable to this . - /// - [JsonProperty("tax_lines")] - public IEnumerable TaxLines { get; set; } + /// + /// A list of objects, each of which details the taxes applicable to this . + /// + [JsonProperty("tax_lines")] + public IEnumerable TaxLines { get; set; } - /// - /// The price of the shipping method in shop and presentment currencies. - /// - [JsonProperty("price_set")] - public PriceSet PriceSet { get; set; } + /// + /// The price of the shipping method in shop and presentment currencies. + /// + [JsonProperty("price_set")] + public PriceSet PriceSet { get; set; } - /// - /// The price of the shipping method in both shop and presentment currencies after line-level discounts have been applied. - /// - [JsonProperty("discounted_price_set")] - public PriceSet DiscountedPriceSet { get; set; } - } -} + /// + /// The price of the shipping method in both shop and presentment currencies after line-level discounts have been applied. + /// + [JsonProperty("discounted_price_set")] + public PriceSet DiscountedPriceSet { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ShippingZone.cs b/ShopifySharp/Entities/ShippingZone.cs index bed7af4a..a52d6047 100644 --- a/ShopifySharp/Entities/ShippingZone.cs +++ b/ShopifySharp/Entities/ShippingZone.cs @@ -1,41 +1,40 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// This is used to view shipping zones, their countries, provinces, and shipping rates. +/// +public class ShippingZone : ShopifyObject { /// - /// This is used to view shipping zones, their countries, provinces, and shipping rates. + /// The name of the shipping zone, specified by the user. /// - public class ShippingZone : ShopifyObject - { - /// - /// The name of the shipping zone, specified by the user. - /// - [JsonProperty("name")] - public string Name { get; set; } + [JsonProperty("name")] + public string Name { get; set; } - /// - /// A list of countries that belong to the shipping zone. - /// - [JsonProperty("countries")] - public IEnumerable Countries { get; set; } + /// + /// A list of countries that belong to the shipping zone. + /// + [JsonProperty("countries")] + public IEnumerable Countries { get; set; } - /// - /// Information about weight based shipping rates used. - /// - [JsonProperty("weight_based_shipping_rates")] - public IEnumerable WeightBasedShippingRates { get; set; } + /// + /// Information about weight based shipping rates used. + /// + [JsonProperty("weight_based_shipping_rates")] + public IEnumerable WeightBasedShippingRates { get; set; } - /// - /// Information about price based shipping rates used. - /// - [JsonProperty("price_based_shipping_rates")] - public IEnumerable PriceBasedShippingRates { get; set; } + /// + /// Information about price based shipping rates used. + /// + [JsonProperty("price_based_shipping_rates")] + public IEnumerable PriceBasedShippingRates { get; set; } - /// - /// Information about carrier shipping providers and the rates used. - /// - [JsonProperty("carrier_shipping_rate_providers")] - public IEnumerable CarrierShippingRateProviders { get; set; } - } + /// + /// Information about carrier shipping providers and the rates used. + /// + [JsonProperty("carrier_shipping_rate_providers")] + public IEnumerable CarrierShippingRateProviders { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/Shop.cs b/ShopifySharp/Entities/Shop.cs index 9ad5b148..6f8ab4d8 100644 --- a/ShopifySharp/Entities/Shop.cs +++ b/ShopifySharp/Entities/Shop.cs @@ -1,335 +1,334 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +public class Shop: ShopifyObject { - public class Shop: ShopifyObject - { - /// - /// The shop's street address. - /// - [JsonProperty("address1")] - public string Address1 { get; set; } + /// + /// The shop's street address. + /// + [JsonProperty("address1")] + public string Address1 { get; set; } - /// - /// The optional second line of the shop's street address. - /// - [JsonProperty("address2")] - public string Address2 { get; set; } - - /// - /// The city in which the shop is located. - /// - [JsonProperty("city")] - public string City { get; set; } - - /// - /// The shop's country (by default equal to the two-letter country code). - /// - [JsonProperty("country")] - public string Country { get; set; } - - /// - /// The two-letter country code corresponding to the shop's country. - /// - [JsonProperty("country_code")] - public string CountryCode { get; set; } - - /// - /// The shop's normalized country name. - /// - [JsonProperty("country_name")] - public string CountryName { get; set; } - - /// - /// The date and time when the shop was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// The customer's email. - /// - [JsonProperty("customer_email")] - public string CustomerEmail { get; set; } - - /// - /// The three-letter code for the currency that the shop accepts. - /// - [JsonProperty("currency")] - public string Currency { get; set; } - - /// - /// The shop's description. - /// - [JsonProperty("description")] - public string Description { get; set; } - - /// - /// The shop's domain. - /// - [JsonProperty("domain")] - public string Domain { get; set; } - - /// - /// The contact email address for the shop. - /// - [JsonProperty("email")] - public string Email { get; set; } - - /// - /// Enabled currencies - /// - [JsonProperty("enabled_presentment_currencies")] - public string[] EnabledPresentmentCurrencies { get; set; } - - /// - /// Present when a shop has a google app domain. It will be returned as a URL, else null. - /// - [JsonProperty("google_apps_domain")] - public string GoogleAppsDomain { get; set; } - - /// - /// Present if a shop has google apps enabled. Those shops with this feature will be able to login to the google apps login. - /// - [JsonProperty("google_apps_login_enabled")] - public string GoogleAppsLoginEnabled { get; set; } + /// + /// The optional second line of the shop's street address. + /// + [JsonProperty("address2")] + public string Address2 { get; set; } + + /// + /// The city in which the shop is located. + /// + [JsonProperty("city")] + public string City { get; set; } + + /// + /// The shop's country (by default equal to the two-letter country code). + /// + [JsonProperty("country")] + public string Country { get; set; } + + /// + /// The two-letter country code corresponding to the shop's country. + /// + [JsonProperty("country_code")] + public string CountryCode { get; set; } + + /// + /// The shop's normalized country name. + /// + [JsonProperty("country_name")] + public string CountryName { get; set; } + + /// + /// The date and time when the shop was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// The customer's email. + /// + [JsonProperty("customer_email")] + public string CustomerEmail { get; set; } + + /// + /// The three-letter code for the currency that the shop accepts. + /// + [JsonProperty("currency")] + public string Currency { get; set; } + + /// + /// The shop's description. + /// + [JsonProperty("description")] + public string Description { get; set; } + + /// + /// The shop's domain. + /// + [JsonProperty("domain")] + public string Domain { get; set; } + + /// + /// The contact email address for the shop. + /// + [JsonProperty("email")] + public string Email { get; set; } + + /// + /// Enabled currencies + /// + [JsonProperty("enabled_presentment_currencies")] + public string[] EnabledPresentmentCurrencies { get; set; } + + /// + /// Present when a shop has a google app domain. It will be returned as a URL, else null. + /// + [JsonProperty("google_apps_domain")] + public string GoogleAppsDomain { get; set; } + + /// + /// Present if a shop has google apps enabled. Those shops with this feature will be able to login to the google apps login. + /// + [JsonProperty("google_apps_login_enabled")] + public string GoogleAppsLoginEnabled { get; set; } - /// - /// Whether the shop is eligible to receive a free credit card reader from Shopify. - /// - [JsonProperty("eligible_for_card_reader_giveaway")] - public bool? EligibleForCardReaderGiveaway { get; set; } + /// + /// Whether the shop is eligible to receive a free credit card reader from Shopify. + /// + [JsonProperty("eligible_for_card_reader_giveaway")] + public bool? EligibleForCardReaderGiveaway { get; set; } - /// - /// Whether the shop is eligible to use Shopify Payments. - /// - [JsonProperty("eligible_for_payments")] - public bool? EligibleForPayments { get; set; } - - /// - /// Whether the shop is capable of accepting payments directly through the Checkout API. - /// - [JsonProperty("checkout_api_supported")] - public bool? CheckoutApiSupported { get; set; } - - /// - /// Whether any active discounts exist for the shop. - /// - [JsonProperty("has_discounts")] - public bool? HasDiscounts { get; set; } + /// + /// Whether the shop is eligible to use Shopify Payments. + /// + [JsonProperty("eligible_for_payments")] + public bool? EligibleForPayments { get; set; } + + /// + /// Whether the shop is capable of accepting payments directly through the Checkout API. + /// + [JsonProperty("checkout_api_supported")] + public bool? CheckoutApiSupported { get; set; } + + /// + /// Whether any active discounts exist for the shop. + /// + [JsonProperty("has_discounts")] + public bool? HasDiscounts { get; set; } - /// - /// Whether any active gift cards exist for the shop. - /// - [JsonProperty("has_gift_cards")] - public bool? HasGiftCards { get; set; } + /// + /// Whether any active gift cards exist for the shop. + /// + [JsonProperty("has_gift_cards")] + public bool? HasGiftCards { get; set; } - /// - /// Geographic coordinate specifying the north/south location of a shop. - /// - [JsonProperty("latitude")] - public string Latitude { get; set; } - - /// - /// Geographic coordinate specifying the east/west location of a shop. - /// - [JsonProperty("longitude")] - public string Longitude { get; set; } - - /// - /// A string representing the way currency is formatted when the currency isn't specified. - /// - [JsonProperty("money_format")] - public string MoneyFormat { get; set; } + /// + /// Geographic coordinate specifying the north/south location of a shop. + /// + [JsonProperty("latitude")] + public string Latitude { get; set; } + + /// + /// Geographic coordinate specifying the east/west location of a shop. + /// + [JsonProperty("longitude")] + public string Longitude { get; set; } + + /// + /// A string representing the way currency is formatted when the currency isn't specified. + /// + [JsonProperty("money_format")] + public string MoneyFormat { get; set; } - /// - /// A string representing the way currency is formatted in email notifications when the currency isn't specified. - /// - [JsonProperty("money_in_emails_format")] - public string MoneyInEmailsFormat { get; set; } + /// + /// A string representing the way currency is formatted in email notifications when the currency isn't specified. + /// + [JsonProperty("money_in_emails_format")] + public string MoneyInEmailsFormat { get; set; } - /// - /// A string representing the way currency is formatted when the currency is specified. - /// - [JsonProperty("money_with_currency_format")] - public string MoneyWithCurrencyFormat { get; set; } + /// + /// A string representing the way currency is formatted when the currency is specified. + /// + [JsonProperty("money_with_currency_format")] + public string MoneyWithCurrencyFormat { get; set; } - /// - /// A string representing the way currency is formatted in email notifications when the currency is specified. - /// - [JsonProperty("money_with_currency_in_emails_format")] - public string MoneyWithCurrencyInEmailsFormat { get; set; } + /// + /// A string representing the way currency is formatted in email notifications when the currency is specified. + /// + [JsonProperty("money_with_currency_in_emails_format")] + public string MoneyWithCurrencyInEmailsFormat { get; set; } - /// - /// Whether multi-location is enabled - /// - [JsonProperty("multi_location_enabled")] - public bool? MultiLocationEnabled { get; set; } + /// + /// Whether multi-location is enabled + /// + [JsonProperty("multi_location_enabled")] + public bool? MultiLocationEnabled { get; set; } - /// - /// Whether the pre-launch page is enabled on the online storefront. - /// - [JsonProperty("pre_launch_enabled")] - public bool? PreLaunchEnabled { get; set; } + /// + /// Whether the pre-launch page is enabled on the online storefront. + /// + [JsonProperty("pre_launch_enabled")] + public bool? PreLaunchEnabled { get; set; } - /// - /// Whether the shop requires an extra Shopify Payments agreement. - /// - [JsonProperty("requires_extra_payments_agreement")] - public bool? RequiresExtraPaymentsAgreement { get; set; } - - /// - /// The shop's 'myshopify.com' domain. - /// - [JsonProperty("myshopify_domain")] - public string MyShopifyDomain { get; set; } - - /// - /// The name of the shop. - /// - [JsonProperty("name")] - public string Name { get; set; } - - /// - /// The name of the Shopify plan the shop is on. - /// - [JsonProperty("plan_name")] - public string PlanName { get; set; } - - /// - /// The display name of the Shopify plan the shop is on. - /// - [JsonProperty("plan_display_name")] - public string PlanDisplayName { get; set; } - - /// - /// Indicates whether the Storefront password protection is enabled. - /// - [JsonProperty("password_enabled")] - public bool? PasswordEnabled { get; set; } - - /// - /// The contact phone number for the shop. - /// - [JsonProperty("phone")] - public string Phone { get; set; } - - /// - /// The shop's primary locale. - /// - [JsonProperty("primary_locale")] - public string PrimaryLocale { get; set; } - - /// - /// The shop's normalized province or state name. - /// - [JsonProperty("province")] - public string Province { get; set; } - - /// - /// The two-letter code for the shop's province or state. - /// - [JsonProperty("province_code")] - public string ProvinceCode { get; set; } - - /// - /// A list of countries the shop ships products to, separated by a comma. - /// - [JsonProperty("ships_to_countries")] - public string ShipsToCountries { get; set; } - - /// - /// The username of the shop owner. - /// - [JsonProperty("shop_owner")] - public string ShopOwner { get; set; } - - /// - /// Unkown. Shopify documentation does not currently indicate what this property actually is. - /// - [JsonProperty("source")] - public string Source { get; set; } - - /// - /// Specifies whether or not taxes were charged for shipping. - /// - /// Although the Shopify docs don't indicate this, it's possible for the value to be null. - [JsonProperty("tax_shipping")] - public bool? TaxShipping { get; set; } - - /// - /// The setting for whether applicable taxes are included in product prices. - /// - [JsonProperty("taxes_included")] - public bool? TaxesIncluded { get; set; } - - /// - /// The setting for whether the shop is applying taxes on a per-county basis or not (US-only). Valid values are: "true" or "null." - /// - [JsonProperty("county_taxes")] - public bool? CountyTaxes { get; set; } - - /// - /// The name of the timezone the shop is in. - /// - [JsonProperty("timezone")] - public string Timezone { get; set; } - - /// - /// The named timezone assigned by the IANA. - /// - [JsonProperty("iana_timezone")] - public string IANATimezone { get; set; } - - /// - /// The zip or postal code of the shop's address. - /// - [JsonProperty("zip")] - public string Zip { get; set; } - - /// - /// Indicates whether the shop has web-based storefront or not. - /// - [JsonProperty("has_storefront")] - public bool? HasStorefront { get; set; } - - /// - /// Indicates whether the shop has any outstanding setup steps or not. - /// - [JsonProperty("setup_required")] - public bool? SetupRequired { get; set; } - - /// - /// The default unit of weight measurement - /// - [JsonProperty("weight_unit")] - public string WeightUnit { get; set; } - - /// - /// The date and time when the shop was last updated. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - - /// - /// The default location of the shop - /// - [JsonProperty("primary_location_id")] - public long? PrimaryLocationId { get; set; } - - /// - /// Whether transactional SMS sent by Shopify are disabled on the shop's online store - /// - [JsonProperty("transactional_sms_disabled")] - public bool? TransactionalSmsDisabled { get; set; } - - /// - /// Whether SMS marketing has been enabled on the shop's checkout configuration settings - /// - [JsonProperty("marketing_sms_consent_enabled_at_checkout")] - public bool? MarketingSmsConsentEnabledAtCheckout { get; set; } - } -} + /// + /// Whether the shop requires an extra Shopify Payments agreement. + /// + [JsonProperty("requires_extra_payments_agreement")] + public bool? RequiresExtraPaymentsAgreement { get; set; } + + /// + /// The shop's 'myshopify.com' domain. + /// + [JsonProperty("myshopify_domain")] + public string MyShopifyDomain { get; set; } + + /// + /// The name of the shop. + /// + [JsonProperty("name")] + public string Name { get; set; } + + /// + /// The name of the Shopify plan the shop is on. + /// + [JsonProperty("plan_name")] + public string PlanName { get; set; } + + /// + /// The display name of the Shopify plan the shop is on. + /// + [JsonProperty("plan_display_name")] + public string PlanDisplayName { get; set; } + + /// + /// Indicates whether the Storefront password protection is enabled. + /// + [JsonProperty("password_enabled")] + public bool? PasswordEnabled { get; set; } + + /// + /// The contact phone number for the shop. + /// + [JsonProperty("phone")] + public string Phone { get; set; } + + /// + /// The shop's primary locale. + /// + [JsonProperty("primary_locale")] + public string PrimaryLocale { get; set; } + + /// + /// The shop's normalized province or state name. + /// + [JsonProperty("province")] + public string Province { get; set; } + + /// + /// The two-letter code for the shop's province or state. + /// + [JsonProperty("province_code")] + public string ProvinceCode { get; set; } + + /// + /// A list of countries the shop ships products to, separated by a comma. + /// + [JsonProperty("ships_to_countries")] + public string ShipsToCountries { get; set; } + + /// + /// The username of the shop owner. + /// + [JsonProperty("shop_owner")] + public string ShopOwner { get; set; } + + /// + /// Unkown. Shopify documentation does not currently indicate what this property actually is. + /// + [JsonProperty("source")] + public string Source { get; set; } + + /// + /// Specifies whether or not taxes were charged for shipping. + /// + /// Although the Shopify docs don't indicate this, it's possible for the value to be null. + [JsonProperty("tax_shipping")] + public bool? TaxShipping { get; set; } + + /// + /// The setting for whether applicable taxes are included in product prices. + /// + [JsonProperty("taxes_included")] + public bool? TaxesIncluded { get; set; } + + /// + /// The setting for whether the shop is applying taxes on a per-county basis or not (US-only). Valid values are: "true" or "null." + /// + [JsonProperty("county_taxes")] + public bool? CountyTaxes { get; set; } + + /// + /// The name of the timezone the shop is in. + /// + [JsonProperty("timezone")] + public string Timezone { get; set; } + + /// + /// The named timezone assigned by the IANA. + /// + [JsonProperty("iana_timezone")] + public string IANATimezone { get; set; } + + /// + /// The zip or postal code of the shop's address. + /// + [JsonProperty("zip")] + public string Zip { get; set; } + + /// + /// Indicates whether the shop has web-based storefront or not. + /// + [JsonProperty("has_storefront")] + public bool? HasStorefront { get; set; } + + /// + /// Indicates whether the shop has any outstanding setup steps or not. + /// + [JsonProperty("setup_required")] + public bool? SetupRequired { get; set; } + + /// + /// The default unit of weight measurement + /// + [JsonProperty("weight_unit")] + public string WeightUnit { get; set; } + + /// + /// The date and time when the shop was last updated. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } + + /// + /// The default location of the shop + /// + [JsonProperty("primary_location_id")] + public long? PrimaryLocationId { get; set; } + + /// + /// Whether transactional SMS sent by Shopify are disabled on the shop's online store + /// + [JsonProperty("transactional_sms_disabled")] + public bool? TransactionalSmsDisabled { get; set; } + + /// + /// Whether SMS marketing has been enabled on the shop's checkout configuration settings + /// + [JsonProperty("marketing_sms_consent_enabled_at_checkout")] + public bool? MarketingSmsConsentEnabledAtCheckout { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ShopRedactedWebhook.cs b/ShopifySharp/Entities/ShopRedactedWebhook.cs index 26372eb6..cb53c7eb 100644 --- a/ShopifySharp/Entities/ShopRedactedWebhook.cs +++ b/ShopifySharp/Entities/ShopRedactedWebhook.cs @@ -1,22 +1,21 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// Sent via the shop/redacted GDPR webhook, indicating that you should purge the shop's data from your systems. +/// +public class ShopRedactedWebhook { /// - /// Sent via the shop/redacted GDPR webhook, indicating that you should purge the shop's data from your systems. + /// The shop's id. /// - public class ShopRedactedWebhook - { - /// - /// The shop's id. - /// - [JsonProperty("shop_id")] - public long ShopId { get; set; } + [JsonProperty("shop_id")] + public long ShopId { get; set; } - /// - /// The shop's *.myshopify.com domain. - /// - [JsonProperty("shop_domain")] - public string ShopDomain { get; set; } - } + /// + /// The shop's *.myshopify.com domain. + /// + [JsonProperty("shop_domain")] + public string ShopDomain { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/ShopifyObject.cs b/ShopifySharp/Entities/ShopifyObject.cs index a7c97085..dc94aaf0 100644 --- a/ShopifySharp/Entities/ShopifyObject.cs +++ b/ShopifySharp/Entities/ShopifyObject.cs @@ -1,23 +1,22 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public abstract class ShopifyObject { - public abstract class ShopifyObject - { - /// - /// The object's unique id. - /// - /// - /// Some object ids are longer than the max int32 value. Using long instead. - /// Marked as nullable due to issues I've run into when trying to create a resource. If Id is present when creating, - /// Shopify will try to find that resource. By default it's set to 0 when not null, so the resource won't exist and - /// Shopify will return a 404 Not Found. This is most obvious when creating a customer with a - /// and the Id set to 0. - /// - [JsonProperty("id")] - public long? Id { get; set; } + /// + /// The object's unique id. + /// + /// + /// Some object ids are longer than the max int32 value. Using long instead. + /// Marked as nullable due to issues I've run into when trying to create a resource. If Id is present when creating, + /// Shopify will try to find that resource. By default it's set to 0 when not null, so the resource won't exist and + /// Shopify will return a 404 Not Found. This is most obvious when creating a customer with a + /// and the Id set to 0. + /// + [JsonProperty("id")] + public long? Id { get; set; } - [JsonProperty("admin_graphql_api_id")] - public string AdminGraphQLAPIId { get; set; } - } -} + [JsonProperty("admin_graphql_api_id")] + public string AdminGraphQLAPIId { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ShopifyObjectGid.cs b/ShopifySharp/Entities/ShopifyObjectGid.cs index 59912c8a..73e2b3bb 100644 --- a/ShopifySharp/Entities/ShopifyObjectGid.cs +++ b/ShopifySharp/Entities/ShopifyObjectGid.cs @@ -1,11 +1,10 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class ShopifyObjectGid { - public class ShopifyObjectGid - { - //The GraphQL ID of the object - [JsonProperty("admin_graphql_api_id")] - public string AdminGraphQLAPIId { get; set; } - } -} + //The GraphQL ID of the object + [JsonProperty("admin_graphql_api_id")] + public string AdminGraphQLAPIId { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ShopifyPaymentsBalance.cs b/ShopifySharp/Entities/ShopifyPaymentsBalance.cs index 4730f729..ce5e8a0b 100644 --- a/ShopifySharp/Entities/ShopifyPaymentsBalance.cs +++ b/ShopifySharp/Entities/ShopifyPaymentsBalance.cs @@ -1,16 +1,15 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify payments balance. +/// +public class ShopifyPaymentsBalance { - /// - /// An object representing a Shopify payments balance. - /// - public class ShopifyPaymentsBalance - { - [JsonProperty("currency")] - public string Currency { get; set; } + [JsonProperty("currency")] + public string Currency { get; set; } - [JsonProperty("amount")] - public decimal? Amount { get; set; } - } -} + [JsonProperty("amount")] + public decimal? Amount { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ShopifyPaymentsDispute.cs b/ShopifySharp/Entities/ShopifyPaymentsDispute.cs index 4fb8290b..4e38becd 100644 --- a/ShopifySharp/Entities/ShopifyPaymentsDispute.cs +++ b/ShopifySharp/Entities/ShopifyPaymentsDispute.cs @@ -1,46 +1,45 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify payments dispute. +/// +public class ShopifyPaymentsDispute : ShopifyObject { - /// - /// An object representing a Shopify payments dispute. - /// - public class ShopifyPaymentsDispute : ShopifyObject - { - [JsonProperty("order_id")] - public long? OrderId { get; set; } + [JsonProperty("order_id")] + public long? OrderId { get; set; } - [JsonProperty("type")] - public string Type { get; set; } + [JsonProperty("type")] + public string Type { get; set; } - [JsonProperty("currency")] - public string Currency { get; set; } + [JsonProperty("currency")] + public string Currency { get; set; } - [JsonProperty("amount")] - public decimal? Amount { get; set; } + [JsonProperty("amount")] + public decimal? Amount { get; set; } - [JsonProperty("reason")] - public string Reason { get; set; } + [JsonProperty("reason")] + public string Reason { get; set; } - [JsonProperty("network_reason_code")] - public string NetworkReasonCode { get; set; } + [JsonProperty("network_reason_code")] + public string NetworkReasonCode { get; set; } - [JsonProperty("status")] - public string Status { get; set; } + [JsonProperty("status")] + public string Status { get; set; } - [JsonProperty("evidence_due_by")] - public DateTimeOffset? EvidenceDueBy { get; set; } + [JsonProperty("evidence_due_by")] + public DateTimeOffset? EvidenceDueBy { get; set; } - [JsonProperty("initiated_at")] - public DateTimeOffset? InitiatedAt { get; set; } + [JsonProperty("initiated_at")] + public DateTimeOffset? InitiatedAt { get; set; } - [JsonProperty("evidence_sent_on")] - public DateTimeOffset? EvidenceSentOn { get; set; } + [JsonProperty("evidence_sent_on")] + public DateTimeOffset? EvidenceSentOn { get; set; } - [JsonProperty("finalized_on")] - public DateTimeOffset? FinalizedOn { get; set; } + [JsonProperty("finalized_on")] + public DateTimeOffset? FinalizedOn { get; set; } - } -} +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidence.cs b/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidence.cs index 8dce9a6d..0967ecea 100644 --- a/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidence.cs +++ b/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidence.cs @@ -1,69 +1,68 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify payment dispute evidence. +/// +public class ShopifyPaymentsDisputeEvidence : ShopifyObject { - /// - /// An object representing a Shopify payment dispute evidence. - /// - public class ShopifyPaymentsDisputeEvidence : ShopifyObject - { - [JsonProperty("payments_dispute_id")] - public long? PaymentsDisputeId { get; set; } + [JsonProperty("payments_dispute_id")] + public long? PaymentsDisputeId { get; set; } - [JsonProperty("access_activity_log")] - public string AccessActivityLog { get; set; } + [JsonProperty("access_activity_log")] + public string AccessActivityLog { get; set; } - [JsonProperty("customer_email_address")] - public string CustomerEmailAddress { get; set; } + [JsonProperty("customer_email_address")] + public string CustomerEmailAddress { get; set; } - [JsonProperty("customer_first_name")] - public string CustomerFirstName { get; set; } + [JsonProperty("customer_first_name")] + public string CustomerFirstName { get; set; } - [JsonProperty("customer_last_name")] - public string CustomerLastName { get; set; } + [JsonProperty("customer_last_name")] + public string CustomerLastName { get; set; } - [JsonProperty("uncategorized_text")] - public string UncategorizedText { get; set; } + [JsonProperty("uncategorized_text")] + public string UncategorizedText { get; set; } - [JsonProperty("shipping_address")] - public ShopifyPaymentsDisputeEvidenceAddress ShippingAddress { get; set; } + [JsonProperty("shipping_address")] + public ShopifyPaymentsDisputeEvidenceAddress ShippingAddress { get; set; } - [JsonProperty("cancellation_policy_disclosure")] - public string CancellationPolicyDisclosure { get; set; } + [JsonProperty("cancellation_policy_disclosure")] + public string CancellationPolicyDisclosure { get; set; } - [JsonProperty("cancellation_rebuttal")] - public string CancellationRebuttal { get; set; } + [JsonProperty("cancellation_rebuttal")] + public string CancellationRebuttal { get; set; } - [JsonProperty("refund_policy_disclosure")] - public string RefundPolicyDisclosure { get; set; } + [JsonProperty("refund_policy_disclosure")] + public string RefundPolicyDisclosure { get; set; } - [JsonProperty("refund_refusal_explanation")] - public string RefundRefusalExplanation { get; set; } + [JsonProperty("refund_refusal_explanation")] + public string RefundRefusalExplanation { get; set; } - [JsonProperty("submitted")] - public bool? Submitted { get; set; } + [JsonProperty("submitted")] + public bool? Submitted { get; set; } - [JsonProperty("product_description")] - public ShopifyPaymentsDisputeEvidenceProductDescription ProductDescription { get; set; } + [JsonProperty("product_description")] + public ShopifyPaymentsDisputeEvidenceProductDescription ProductDescription { get; set; } - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - [JsonProperty("updated_on")] - public DateTimeOffset? UpdatedOn { get; set; } + [JsonProperty("updated_on")] + public DateTimeOffset? UpdatedOn { get; set; } - [JsonProperty("dispute_evidence_files")] - public ShopifyPaymentsDisputeEvidenceFiles DisputeEvidenceFiles { get; set; } + [JsonProperty("dispute_evidence_files")] + public ShopifyPaymentsDisputeEvidenceFiles DisputeEvidenceFiles { get; set; } - [JsonProperty("billing_address")] - public ShopifyPaymentsDisputeEvidenceAddress BillingAddress { get; set; } + [JsonProperty("billing_address")] + public ShopifyPaymentsDisputeEvidenceAddress BillingAddress { get; set; } - [JsonProperty("fulfillments")] - public IEnumerable Fulfillments { get; set; } - } -} + [JsonProperty("fulfillments")] + public IEnumerable Fulfillments { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceBillingAddress.cs b/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceBillingAddress.cs index 314b0fa5..74e9f70e 100644 --- a/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceBillingAddress.cs +++ b/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceBillingAddress.cs @@ -1,54 +1,53 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ShopifySharp +namespace ShopifySharp; + +public class ShopifyPaymentsDisputeEvidenceAddress { - public class ShopifyPaymentsDisputeEvidenceAddress - { - /// - /// The street address of the shipping / billing location. - /// - [JsonProperty("address1")] - public string Address1 { get; set; } - - /// - /// The second line of the address. Typically the number of the apartment, suite, or unit. - /// - [JsonProperty("address2")] - public string Address2 { get; set; } - - /// - /// The city of the shipping / billing location. - /// - [JsonProperty("city")] - public string City { get; set; } - - /// - /// The zip code of the shipping / billing location. - /// - [JsonProperty("zip")] - public string Zip { get; set; } - - /// - /// (Required) The two-letter country code (ISO 3166-1 alpha-2 format) of the shipping / billing location. - /// - [JsonProperty("country_code")] - public string CountryCode { get; set; } - - /// - /// The province of the shipping / billing location. - /// - [JsonProperty("province")] - public string Province { get; set; } - - /// - /// The province code of the shipping / billing location. - /// - [JsonProperty("province_code")] - public string ProvinceCode { get; set; } - } -} + /// + /// The street address of the shipping / billing location. + /// + [JsonProperty("address1")] + public string Address1 { get; set; } + + /// + /// The second line of the address. Typically the number of the apartment, suite, or unit. + /// + [JsonProperty("address2")] + public string Address2 { get; set; } + + /// + /// The city of the shipping / billing location. + /// + [JsonProperty("city")] + public string City { get; set; } + + /// + /// The zip code of the shipping / billing location. + /// + [JsonProperty("zip")] + public string Zip { get; set; } + + /// + /// (Required) The two-letter country code (ISO 3166-1 alpha-2 format) of the shipping / billing location. + /// + [JsonProperty("country_code")] + public string CountryCode { get; set; } + + /// + /// The province of the shipping / billing location. + /// + [JsonProperty("province")] + public string Province { get; set; } + + /// + /// The province code of the shipping / billing location. + /// + [JsonProperty("province_code")] + public string ProvinceCode { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceFiles.cs b/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceFiles.cs index a563a52b..24e84515 100644 --- a/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceFiles.cs +++ b/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceFiles.cs @@ -1,33 +1,32 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ShopifySharp +namespace ShopifySharp; + +public class ShopifyPaymentsDisputeEvidenceFiles { - public class ShopifyPaymentsDisputeEvidenceFiles - { - [JsonProperty("cancellation_policy_file_id")] - public long? CancellationPolicyFileId { get; set; } + [JsonProperty("cancellation_policy_file_id")] + public long? CancellationPolicyFileId { get; set; } - [JsonProperty("customer_communication_file_id")] - public long? CustomerCommunicationFileId { get; set; } + [JsonProperty("customer_communication_file_id")] + public long? CustomerCommunicationFileId { get; set; } - [JsonProperty("customer_signature_file_id")] - public long? CustomerSignatureFileId { get; set; } + [JsonProperty("customer_signature_file_id")] + public long? CustomerSignatureFileId { get; set; } - [JsonProperty("refund_policy_file_id")] - public long? RefundPolicyFileId { get; set; } + [JsonProperty("refund_policy_file_id")] + public long? RefundPolicyFileId { get; set; } - [JsonProperty("service_documentation_file_id")] - public long? ServiceDocumentationFileId { get; set; } + [JsonProperty("service_documentation_file_id")] + public long? ServiceDocumentationFileId { get; set; } - [JsonProperty("shipping_documentation_file_id")] - public long? ShippingDocumentationFileId { get; set; } + [JsonProperty("shipping_documentation_file_id")] + public long? ShippingDocumentationFileId { get; set; } - [JsonProperty("uncategorized_file_id")] - public long? UncategorizedFileId { get; set; } - } -} + [JsonProperty("uncategorized_file_id")] + public long? UncategorizedFileId { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceFulfillment.cs b/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceFulfillment.cs index 526bd7f8..b461ea5d 100644 --- a/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceFulfillment.cs +++ b/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceFulfillment.cs @@ -1,21 +1,20 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ShopifySharp +namespace ShopifySharp; + +public class ShopifyPaymentsDisputeEvidenceFulfillment { - public class ShopifyPaymentsDisputeEvidenceFulfillment - { - [JsonProperty("shipping_carrier")] - public string ShippingCarrier { get; set; } + [JsonProperty("shipping_carrier")] + public string ShippingCarrier { get; set; } - [JsonProperty("shipping_tracking_number")] - public long? ShippingTrackingNumber { get; set; } + [JsonProperty("shipping_tracking_number")] + public long? ShippingTrackingNumber { get; set; } - [JsonProperty("shipping_date")] - public DateTimeOffset? ShippingDate { get; set; } - } -} + [JsonProperty("shipping_date")] + public DateTimeOffset? ShippingDate { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceProductDescription.cs b/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceProductDescription.cs index 02865256..48745a97 100644 --- a/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceProductDescription.cs +++ b/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceProductDescription.cs @@ -1,21 +1,20 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ShopifySharp +namespace ShopifySharp; + +public class ShopifyPaymentsDisputeEvidenceProductDescription { - public class ShopifyPaymentsDisputeEvidenceProductDescription - { - [JsonProperty("Product name")] - public string ProductName { get; set; } - public string Title { get; set; } - public string Price { get; set; } - public string Quantity { get; set; } + [JsonProperty("Product name")] + public string ProductName { get; set; } + public string Title { get; set; } + public string Price { get; set; } + public string Quantity { get; set; } - [JsonProperty("Product Description")] - public string ProductDescription { get; set; } - } -} + [JsonProperty("Product Description")] + public string ProductDescription { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceUpdate.cs b/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceUpdate.cs index 10fbf9c1..74b895ce 100644 --- a/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceUpdate.cs +++ b/ShopifySharp/Entities/ShopifyPaymentsDisputeEvidenceUpdate.cs @@ -1,39 +1,38 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; -namespace ShopifySharp +namespace ShopifySharp; + +public class ShopifyPaymentsDisputeEvidenceUpdate { - public class ShopifyPaymentsDisputeEvidenceUpdate - { - [JsonProperty("access_activity_log")] - public string AccessActivityLog { get; set; } + [JsonProperty("access_activity_log")] + public string AccessActivityLog { get; set; } - [JsonProperty("cancellation_policy_disclosure")] - public string CancellationPolicyDisclosure { get; set; } + [JsonProperty("cancellation_policy_disclosure")] + public string CancellationPolicyDisclosure { get; set; } - [JsonProperty("cancellation_rebuttal")] - public string CancellationRebuttal { get; set; } + [JsonProperty("cancellation_rebuttal")] + public string CancellationRebuttal { get; set; } - [JsonProperty("customer_email_address")] - public string CustomerEmailAddress { get; set; } + [JsonProperty("customer_email_address")] + public string CustomerEmailAddress { get; set; } - [JsonProperty("customer_first_name")] - public string CustomerFirstName { get; set; } + [JsonProperty("customer_first_name")] + public string CustomerFirstName { get; set; } - [JsonProperty("customer_last_name")] - public string CustomerLastName { get; set; } + [JsonProperty("customer_last_name")] + public string CustomerLastName { get; set; } - [JsonProperty("refund_policy_disclosure")] - public string RefundPolicyDisclosure { get; set; } + [JsonProperty("refund_policy_disclosure")] + public string RefundPolicyDisclosure { get; set; } - [JsonProperty("refund_refusal_explanation")] - public string RefundRefusalExplanation { get; set; } + [JsonProperty("refund_refusal_explanation")] + public string RefundRefusalExplanation { get; set; } - [JsonProperty("uncategorized_text")] - public string UncategorizedText { get; set; } - } -} + [JsonProperty("uncategorized_text")] + public string UncategorizedText { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ShopifyPaymentsPayout.cs b/ShopifySharp/Entities/ShopifyPaymentsPayout.cs index 0ac15d08..b0dfdeab 100644 --- a/ShopifySharp/Entities/ShopifyPaymentsPayout.cs +++ b/ShopifySharp/Entities/ShopifyPaymentsPayout.cs @@ -1,26 +1,25 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify payments payout. +/// +public class ShopifyPaymentsPayout : ShopifyObject { - /// - /// An object representing a Shopify payments payout. - /// - public class ShopifyPaymentsPayout : ShopifyObject - { - [JsonProperty("status")] - public string Status { get; set; } + [JsonProperty("status")] + public string Status { get; set; } - [JsonProperty("date")] - public DateTime? Date { get; set; } + [JsonProperty("date")] + public DateTime? Date { get; set; } - [JsonProperty("currency")] - public string Currency { get; set; } + [JsonProperty("currency")] + public string Currency { get; set; } - [JsonProperty("amount")] - public decimal? Amount { get; set; } + [JsonProperty("amount")] + public decimal? Amount { get; set; } - [JsonProperty("summary")] - public ShopifyPaymentsPayoutSummary Summary { get; set; } - } -} + [JsonProperty("summary")] + public ShopifyPaymentsPayoutSummary Summary { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ShopifyPaymentsPayoutSummary.cs b/ShopifySharp/Entities/ShopifyPaymentsPayoutSummary.cs index e3d6e667..61fd1f28 100644 --- a/ShopifySharp/Entities/ShopifyPaymentsPayoutSummary.cs +++ b/ShopifySharp/Entities/ShopifyPaymentsPayoutSummary.cs @@ -1,40 +1,39 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify payments payout summary. +/// +public class ShopifyPaymentsPayoutSummary { - /// - /// An object representing a Shopify payments payout summary. - /// - public class ShopifyPaymentsPayoutSummary - { - [JsonProperty("adjustments_fee_amount")] - public decimal? AdjustmentsFeeAmount { get; set; } + [JsonProperty("adjustments_fee_amount")] + public decimal? AdjustmentsFeeAmount { get; set; } - [JsonProperty("adjustments_gross_amount")] - public decimal? AdjustmentsGrossAmount { get; set; } + [JsonProperty("adjustments_gross_amount")] + public decimal? AdjustmentsGrossAmount { get; set; } - [JsonProperty("charges_fee_amount")] - public decimal? ChargesFeeAmount { get; set; } + [JsonProperty("charges_fee_amount")] + public decimal? ChargesFeeAmount { get; set; } - [JsonProperty("charges_gross_amount")] - public decimal? ChargesGrossAmount { get; set; } + [JsonProperty("charges_gross_amount")] + public decimal? ChargesGrossAmount { get; set; } - [JsonProperty("refunds_fee_amount")] - public decimal? RefundsFeeAmount { get; set; } + [JsonProperty("refunds_fee_amount")] + public decimal? RefundsFeeAmount { get; set; } - [JsonProperty("refunds_gross_amount")] - public decimal? RefundsGrossAmount { get; set; } + [JsonProperty("refunds_gross_amount")] + public decimal? RefundsGrossAmount { get; set; } - [JsonProperty("reserved_funds_fee_amount")] - public decimal? ReservedFundsFeeAmount { get; set; } + [JsonProperty("reserved_funds_fee_amount")] + public decimal? ReservedFundsFeeAmount { get; set; } - [JsonProperty("reserved_funds_gross_amount")] - public decimal? ReservedFundsGrossAmount { get; set; } + [JsonProperty("reserved_funds_gross_amount")] + public decimal? ReservedFundsGrossAmount { get; set; } - [JsonProperty("retried_payouts_fee_amount")] - public decimal? RetriedPayoutsFeeAmount { get; set; } + [JsonProperty("retried_payouts_fee_amount")] + public decimal? RetriedPayoutsFeeAmount { get; set; } - [JsonProperty("retried_payouts_gross_amount")] - public decimal? RetriedPayoutsGrossAmount { get; set; } - } -} + [JsonProperty("retried_payouts_gross_amount")] + public decimal? RetriedPayoutsGrossAmount { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/ShopifyPaymentsTransaction.cs b/ShopifySharp/Entities/ShopifyPaymentsTransaction.cs index c2c2357a..047f6f3f 100644 --- a/ShopifySharp/Entities/ShopifyPaymentsTransaction.cs +++ b/ShopifySharp/Entities/ShopifyPaymentsTransaction.cs @@ -1,52 +1,51 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify payments transction. +/// +public class ShopifyPaymentsTransaction : ShopifyObject { - /// - /// An object representing a Shopify payments transction. - /// - public class ShopifyPaymentsTransaction : ShopifyObject - { - [JsonProperty("type")] - public string Type { get; set; } + [JsonProperty("type")] + public string Type { get; set; } - [JsonProperty("test")] - public bool Test { get; set; } + [JsonProperty("test")] + public bool Test { get; set; } - [JsonProperty("payout_id")] - public long? PayoutId { get; set; } + [JsonProperty("payout_id")] + public long? PayoutId { get; set; } - [JsonProperty("payout_status")] - public string PayoutStatus { get; set; } + [JsonProperty("payout_status")] + public string PayoutStatus { get; set; } - [JsonProperty("currency")] - public string Currency { get; set; } + [JsonProperty("currency")] + public string Currency { get; set; } - [JsonProperty("amount")] - public decimal? Amount { get; set; } + [JsonProperty("amount")] + public decimal? Amount { get; set; } - [JsonProperty("fee")] - public decimal? Fee { get; set; } + [JsonProperty("fee")] + public decimal? Fee { get; set; } - [JsonProperty("net")] - public decimal? Net { get; set; } + [JsonProperty("net")] + public decimal? Net { get; set; } - [JsonProperty("source_id")] - public long? SourceId { get; set; } + [JsonProperty("source_id")] + public long? SourceId { get; set; } - [JsonProperty("source_type")] - public string SourceType { get; set; } + [JsonProperty("source_type")] + public string SourceType { get; set; } - [JsonProperty("source_order_transaction_id")] - public long? SourceOrderTransactionId { get; set; } + [JsonProperty("source_order_transaction_id")] + public long? SourceOrderTransactionId { get; set; } - [JsonProperty("source_order_id")] - public long? SourceOrderId { get; set; } + [JsonProperty("source_order_id")] + public long? SourceOrderId { get; set; } - [JsonProperty("processed_at")] - public DateTimeOffset? ProcessedAt { get; set; } + [JsonProperty("processed_at")] + public DateTimeOffset? ProcessedAt { get; set; } - } -} +} \ No newline at end of file diff --git a/ShopifySharp/Entities/SmartCollection.cs b/ShopifySharp/Entities/SmartCollection.cs index 777f5144..5a824001 100644 --- a/ShopifySharp/Entities/SmartCollection.cs +++ b/ShopifySharp/Entities/SmartCollection.cs @@ -2,87 +2,86 @@ using System; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An entity representing a Shopify Smart Collection Object. +/// +public class SmartCollection : ShopifyObject { /// - /// An entity representing a Shopify Smart Collection Object. + /// The description of the smart collection, complete with HTML markup. Many templates display this on their smart collection page. /// - public class SmartCollection : ShopifyObject - { - /// - /// The description of the smart collection, complete with HTML markup. Many templates display this on their smart collection page. - /// - [JsonProperty("body_html")] - public string BodyHtml { get; set; } + [JsonProperty("body_html")] + public string BodyHtml { get; set; } - /// - /// A human-friendly unique string for the smart collection automatically generated from its title. This is used in shop themes by the Liquid templating language to refer to the smart collection. Limit of 255 characters. - /// - [JsonProperty("handle")] - public string Handle { get; set; } + /// + /// A human-friendly unique string for the smart collection automatically generated from its title. This is used in shop themes by the Liquid templating language to refer to the smart collection. Limit of 255 characters. + /// + [JsonProperty("handle")] + public string Handle { get; set; } - /// - /// The collection image. - /// - [JsonProperty("image")] - public SmartCollectionImage Image { get; set; } + /// + /// The collection image. + /// + [JsonProperty("image")] + public SmartCollectionImage Image { get; set; } - /// - /// This can have two different types of values, depending on whether the smart collection has been published (i.e., made visible to customers): - /// If the smart collection is published, this value is the date and time when it was published.The API returns this value in ISO 8601 format. - /// If the smart collection is hidden (i.e., not published), this value is null. Changing a smart collection's status from published to hidden changes its published_at property to null. - /// - [JsonProperty("published_at")] - public DateTimeOffset? PublishedAt { get; set; } + /// + /// This can have two different types of values, depending on whether the smart collection has been published (i.e., made visible to customers): + /// If the smart collection is published, this value is the date and time when it was published.The API returns this value in ISO 8601 format. + /// If the smart collection is hidden (i.e., not published), this value is null. Changing a smart collection's status from published to hidden changes its published_at property to null. + /// + [JsonProperty("published_at")] + public DateTimeOffset? PublishedAt { get; set; } - /// - /// The sales channels in which the smart collection is visible. The only currently known value is 'global'. - /// - [JsonProperty("published_scope")] - public string PublishedScope { get; set; } + /// + /// The sales channels in which the smart collection is visible. The only currently known value is 'global'. + /// + [JsonProperty("published_scope")] + public string PublishedScope { get; set; } - /// - /// The list of rules that define what products go into the smart collection. - /// - [JsonProperty("rules")] - public IEnumerable Rules { get; set; } + /// + /// The list of rules that define what products go into the smart collection. + /// + [JsonProperty("rules")] + public IEnumerable Rules { get; set; } - /// - /// If false, products must match all of the rules to be included in the collection. If true, products can only match one of the rules. - /// - [JsonProperty("disjunctive")] - public bool? Disjunctive { get; set; } + /// + /// If false, products must match all of the rules to be included in the collection. If true, products can only match one of the rules. + /// + [JsonProperty("disjunctive")] + public bool? Disjunctive { get; set; } - /// - /// The order in which products in the smart collection appear. Known values are 'alpha-asc', 'alpha-desc', 'best-selling', 'created', 'created-desc', 'manual', 'price-asc', 'price-desc'. - /// - [JsonProperty("sort_order")] - public string SortOrder { get; set; } + /// + /// The order in which products in the smart collection appear. Known values are 'alpha-asc', 'alpha-desc', 'best-selling', 'created', 'created-desc', 'manual', 'price-asc', 'price-desc'. + /// + [JsonProperty("sort_order")] + public string SortOrder { get; set; } - /// - /// The suffix of the template you are using. By default, the original template is called product.liquid, without any suffix. Any additional templates will be: product.suffix.liquid. - /// - [JsonProperty("template_suffix")] - public string TemplateSuffix { get; set; } + /// + /// The suffix of the template you are using. By default, the original template is called product.liquid, without any suffix. Any additional templates will be: product.suffix.liquid. + /// + [JsonProperty("template_suffix")] + public string TemplateSuffix { get; set; } - /// - /// The name of the smart collection. Limit of 255 characters. - /// - [JsonProperty("title")] - public string Title { get; set; } + /// + /// The name of the smart collection. Limit of 255 characters. + /// + [JsonProperty("title")] + public string Title { get; set; } - /// - /// The date and time when the smart collection was last modified. The API returns this value in ISO 8601 format. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } + /// + /// The date and time when the smart collection was last modified. The API returns this value in ISO 8601 format. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } - /// - /// Additional metadata about the . Note: This is not naturally returned with a response, as - /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . - /// Uses include: Creating, updating, & deserializing webhook bodies that include them. - /// - [JsonProperty("metafields")] - public IEnumerable Metafields { get; set; } - } -} + /// + /// Additional metadata about the . Note: This is not naturally returned with a response, as + /// Shopify will not return metafields unless specified. Instead, you need to query metafields with . + /// Uses include: Creating, updating, & deserializing webhook bodies that include them. + /// + [JsonProperty("metafields")] + public IEnumerable Metafields { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/SmartCollectionImage.cs b/ShopifySharp/Entities/SmartCollectionImage.cs index 50a8dc28..878fa5bb 100644 --- a/ShopifySharp/Entities/SmartCollectionImage.cs +++ b/ShopifySharp/Entities/SmartCollectionImage.cs @@ -1,47 +1,46 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing the image for a . +/// +public class SmartCollectionImage { /// - /// An object representing the image for a . + /// The date the image was created. /// - public class SmartCollectionImage - { - /// - /// The date the image was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - /// - /// The image's source URL. - /// - [JsonProperty("src")] - public string Src { get; set; } + /// + /// The image's source URL. + /// + [JsonProperty("src")] + public string Src { get; set; } - /// - /// The image's base64 attachment, used when creating an image. - /// - [JsonProperty("attachment")] - public string Attachment { get; set; } + /// + /// The image's base64 attachment, used when creating an image. + /// + [JsonProperty("attachment")] + public string Attachment { get; set; } - /// - /// Width of the image in pixels. - /// - [JsonProperty("width")] - public int? Width { get; set; } + /// + /// Width of the image in pixels. + /// + [JsonProperty("width")] + public int? Width { get; set; } - /// - /// Height of the image in pixels. - /// - [JsonProperty("height")] - public int? Height { get; set; } + /// + /// Height of the image in pixels. + /// + [JsonProperty("height")] + public int? Height { get; set; } - /// - /// Alternative text that describes the collection image. - /// - [JsonProperty("alt")] - public string Alt { get; set; } - } -} + /// + /// Alternative text that describes the collection image. + /// + [JsonProperty("alt")] + public string Alt { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/SmartCollectionRules.cs b/ShopifySharp/Entities/SmartCollectionRules.cs index 95991124..a95653d5 100644 --- a/ShopifySharp/Entities/SmartCollectionRules.cs +++ b/ShopifySharp/Entities/SmartCollectionRules.cs @@ -1,34 +1,33 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An entity representing a Shopify Smart Collection Rule. +/// +public class SmartCollectionRules { /// - /// An entity representing a Shopify Smart Collection Rule. + /// The relationship between the column choice, and the condition. /// - public class SmartCollectionRules - { - /// - /// The relationship between the column choice, and the condition. - /// - [JsonProperty("relation")] - public string Relation { get; set; } + [JsonProperty("relation")] + public string Relation { get; set; } - /// - /// Select products for a collection using a condition. Conditions are either strings or numbers, depending on the relation. - /// - [JsonProperty("condition")] - public string Condition { get; set; } + /// + /// Select products for a collection using a condition. Conditions are either strings or numbers, depending on the relation. + /// + [JsonProperty("condition")] + public string Condition { get; set; } - /// - /// The properties of a product that can be used to to populate a collection. - /// - [JsonProperty("column")] - public string Column { get; set; } + /// + /// The properties of a product that can be used to to populate a collection. + /// + [JsonProperty("column")] + public string Column { get; set; } - /// - /// The id of the object that points to additional attributes for the collection rule. This is only required when using metafield definition rules. - /// - [JsonProperty("condition_object_id")] - public long? ConditionObjectId { get; set; } - } -} + /// + /// The id of the object that points to additional attributes for the collection rule. This is only required when using metafield definition rules. + /// + [JsonProperty("condition_object_id")] + public long? ConditionObjectId { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/StorefrontAccessToken.cs b/ShopifySharp/Entities/StorefrontAccessToken.cs index 10b01941..a8c79618 100644 --- a/ShopifySharp/Entities/StorefrontAccessToken.cs +++ b/ShopifySharp/Entities/StorefrontAccessToken.cs @@ -1,33 +1,32 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class StorefrontAccessToken : ShopifyObject { - public class StorefrontAccessToken : ShopifyObject - { - /// - /// The issued public access token. - /// - [JsonProperty("access_token")] - public string AccessToken { get; set; } + /// + /// The issued public access token. + /// + [JsonProperty("access_token")] + public string AccessToken { get; set; } - /// - /// An application-dependant, comma separated list of permissions associated with the token. - /// - [JsonProperty("access_scope")] - public string AccessScope { get; set; } + /// + /// An application-dependant, comma separated list of permissions associated with the token. + /// + [JsonProperty("access_scope")] + public string AccessScope { get; set; } - /// - /// The date and time when the public access token was created. The API returns this value in ISO 8601 format. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + /// + /// The date and time when the public access token was created. The API returns this value in ISO 8601 format. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - /// - /// An arbitrary title for each token determined by the developer/application, used for reference purposes. - /// No constraint on uniqueness. - /// - [JsonProperty("title")] - public string Title { get; set; } - } + /// + /// An arbitrary title for each token determined by the developer/application, used for reference purposes. + /// No constraint on uniqueness. + /// + [JsonProperty("title")] + public string Title { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Entities/TaxLine.cs b/ShopifySharp/Entities/TaxLine.cs index 90b23b2b..59a5ee90 100644 --- a/ShopifySharp/Entities/TaxLine.cs +++ b/ShopifySharp/Entities/TaxLine.cs @@ -1,31 +1,30 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class TaxLine { - public class TaxLine - { - /// - /// The amount of tax to be charged. - /// - [JsonProperty("price")] - public decimal? Price { get; set; } + /// + /// The amount of tax to be charged. + /// + [JsonProperty("price")] + public decimal? Price { get; set; } - /// - /// The rate of tax to be applied. - /// - [JsonProperty("rate")] - public decimal? Rate { get; set; } + /// + /// The rate of tax to be applied. + /// + [JsonProperty("rate")] + public decimal? Rate { get; set; } - /// - /// The name of the tax. - /// - [JsonProperty("title")] - public string Title { get; set; } + /// + /// The name of the tax. + /// + [JsonProperty("title")] + public string Title { get; set; } - /// - /// The amount added to the order for this tax in shop and presentment currencies. - /// - [JsonProperty("price_set")] - public PriceSet PriceSet { get; set; } - } -} + /// + /// The amount added to the order for this tax in shop and presentment currencies. + /// + [JsonProperty("price_set")] + public PriceSet PriceSet { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/TenderTransaction.cs b/ShopifySharp/Entities/TenderTransaction.cs index b250f980..d7cf0e4c 100644 --- a/ShopifySharp/Entities/TenderTransaction.cs +++ b/ShopifySharp/Entities/TenderTransaction.cs @@ -1,69 +1,68 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify tender transaction. +/// Each tender transaction represents money passing between the merchant and a customer. +/// A tender transaction with a positive amount represents a transaction where the customer paid money to the merchant. +/// A negative amount represents a transaction where the merchant refunded money back to the customer. +/// Tender transactions represent transactions that modify the shop's balance. +/// +public class TenderTransaction : ShopifyObject { /// - /// An object representing a Shopify tender transaction. - /// Each tender transaction represents money passing between the merchant and a customer. - /// A tender transaction with a positive amount represents a transaction where the customer paid money to the merchant. - /// A negative amount represents a transaction where the merchant refunded money back to the customer. - /// Tender transactions represent transactions that modify the shop's balance. + /// The ID of the order that the tender transaction belongs to. /// - public class TenderTransaction : ShopifyObject - { - /// - /// The ID of the order that the tender transaction belongs to. - /// - [JsonProperty("order_id")] - public long? OrderId { get; set; } + [JsonProperty("order_id")] + public long? OrderId { get; set; } - /// - /// The amount of the tender transaction in the shop's currency. - /// - [JsonProperty("amount")] - public decimal? Amount { get; set; } + /// + /// The amount of the tender transaction in the shop's currency. + /// + [JsonProperty("amount")] + public decimal? Amount { get; set; } - /// - /// The three letter code (ISO 4217) for the currency used for the tender transaction. - /// - [JsonProperty("currency")] - public string Currency { get; set; } + /// + /// The three letter code (ISO 4217) for the currency used for the tender transaction. + /// + [JsonProperty("currency")] + public string Currency { get; set; } - /// - /// The ID of the user logged into the Shopify POS device that processed the tender transaction, if applicable. - /// - [JsonProperty("user_id")] - public long? UserId { get; set; } + /// + /// The ID of the user logged into the Shopify POS device that processed the tender transaction, if applicable. + /// + [JsonProperty("user_id")] + public long? UserId { get; set; } - /// - /// Whether the tender transaction is a test transaction. - /// - [JsonProperty("test")] - public bool? Test { get; set; } + /// + /// Whether the tender transaction is a test transaction. + /// + [JsonProperty("test")] + public bool? Test { get; set; } - /// - /// The date and time when the tender transaction was processed. - /// - [JsonProperty("processed_at")] - public DateTimeOffset? ProcessedAt { get; set; } + /// + /// The date and time when the tender transaction was processed. + /// + [JsonProperty("processed_at")] + public DateTimeOffset? ProcessedAt { get; set; } - /// - /// The remote (gateway) reference associated with the tender. - /// - [JsonProperty("remote_reference")] - public string RemoteReference { get; set; } + /// + /// The remote (gateway) reference associated with the tender. + /// + [JsonProperty("remote_reference")] + public string RemoteReference { get; set; } - /// - /// An object containing information about the payment instrument used for this transaction. - /// - [JsonProperty("payment_details")] - public PaymentDetails PaymentDetails { get; set; } + /// + /// An object containing information about the payment instrument used for this transaction. + /// + [JsonProperty("payment_details")] + public PaymentDetails PaymentDetails { get; set; } - /// - /// The payment method used for this transaction. - /// - [JsonProperty("payment_method")] - public string PaymentMethod { get; set; } - } -} + /// + /// The payment method used for this transaction. + /// + [JsonProperty("payment_method")] + public string PaymentMethod { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/Theme.cs b/ShopifySharp/Entities/Theme.cs index 9d7f62e6..dc05b62c 100644 --- a/ShopifySharp/Entities/Theme.cs +++ b/ShopifySharp/Entities/Theme.cs @@ -1,53 +1,52 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An entity representing a Shopify theme. +/// +public class Theme : ShopifyObject { /// - /// An entity representing a Shopify theme. + /// The date and time when the theme was created. /// - public class Theme : ShopifyObject - { - /// - /// The date and time when the theme was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - /// - /// The name of the theme. - /// - [JsonProperty("name")] - public string Name { get; set; } + /// + /// The name of the theme. + /// + [JsonProperty("name")] + public string Name { get; set; } - /// - /// Specifies how the theme is being used within the shop. Known values are 'main', 'mobile' and 'unpublished'. - /// - [JsonProperty("role")] - public string Role { get; set; } + /// + /// Specifies how the theme is being used within the shop. Known values are 'main', 'mobile' and 'unpublished'. + /// + [JsonProperty("role")] + public string Role { get; set; } - /// - /// The date and time when the theme was last updated. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } + /// + /// The date and time when the theme was last updated. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } - /// - /// Indicates if the theme can currently be previewed. - /// - [JsonProperty("previewable")] - public bool? Previewable { get; set; } + /// + /// Indicates if the theme can currently be previewed. + /// + [JsonProperty("previewable")] + public bool? Previewable { get; set; } - /// - /// Indicates if files are still being copied into place for this theme. - /// - [JsonProperty("processing")] - public bool? Processing { get; set; } + /// + /// Indicates if files are still being copied into place for this theme. + /// + [JsonProperty("processing")] + public bool? Processing { get; set; } - /// - /// The theme's store id. Can be null if not published in the store. - /// - [JsonProperty("theme_store_id")] - public long? ThemeStoreId { get; set; } - } -} + /// + /// The theme's store id. Can be null if not published in the store. + /// + [JsonProperty("theme_store_id")] + public long? ThemeStoreId { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/TrackingInfo.cs b/ShopifySharp/Entities/TrackingInfo.cs index 52164b18..27644292 100644 --- a/ShopifySharp/Entities/TrackingInfo.cs +++ b/ShopifySharp/Entities/TrackingInfo.cs @@ -1,25 +1,24 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class TrackingInfo { - public class TrackingInfo - { - /// - /// The tracking number. - /// - [JsonProperty("number")] - public string Number { get; set; } + /// + /// The tracking number. + /// + [JsonProperty("number")] + public string Number { get; set; } - /// - /// The public URL to the tracking company. - /// - [JsonProperty("url")] - public string Url { get; set; } + /// + /// The public URL to the tracking company. + /// + [JsonProperty("url")] + public string Url { get; set; } - /// - /// The tracking company name. - /// - [JsonProperty("company")] - public string Company { get; set; } - } -} + /// + /// The tracking company name. + /// + [JsonProperty("company")] + public string Company { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/Transaction.cs b/ShopifySharp/Entities/Transaction.cs index 1a74fc87..a8534bd8 100644 --- a/ShopifySharp/Entities/Transaction.cs +++ b/ShopifySharp/Entities/Transaction.cs @@ -1,174 +1,173 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An object representing a Shopify transaction. +/// +public class Transaction : ShopifyObject { /// - /// An object representing a Shopify transaction. - /// - public class Transaction : ShopifyObject - { - /// - /// The amount of money that the transaction was for. - /// - [JsonProperty("amount")] - public decimal? Amount { get; set; } - - /// - /// The authorization code associated with the transaction. - /// - [JsonProperty("authorization")] - public string Authorization { get; set; } - - /// - /// The date and time when the Shopify Payments authorization expires. - /// - [JsonProperty("authorization_expires_at")] - public DateTimeOffset? AuthorizationExpiresAt { get; set; } - - /// - /// The date and time when the transaction was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// The unique identifier for the device. - /// - [JsonProperty("device_id")] - public long? DeviceId { get; set; } - - /// - /// The name of the gateway the transaction was issued through. - /// - [JsonProperty("gateway")] - public string Gateway { get; set; } - - /// - /// The origin of the transaction. This is set by Shopify and cannot be overridden. Example values include: 'web', 'pos', 'iphone', 'android'. - /// - [JsonProperty("source_name")] - public string SourceName { get; private set; } - - /// - /// The origin of the transaction. Set to "external" to create a cash transaction for the associated order. - /// - [JsonProperty("source")] - public string Source { get; set; } - - /// - /// An object containing information about the credit card used for this transaction. - /// - [JsonProperty("payment_details")] - public PaymentDetails PaymentDetails { get; set; } - - /// - /// The kind of transaction. Known values are 'authorization', 'capture', 'sale', 'void' and 'refund'. - /// - [JsonProperty("kind")] - public string Kind { get; set; } - - /// - /// A unique numeric identifier for the order. - /// - [JsonProperty("order_id")] - public long? OrderId { get; set; } - - /// - /// Shopify does not currently offer documentation for this object. - /// - [JsonProperty("receipt")] - public object Receipt { get; set; } - - /// - /// A standardized error code, e.g. 'incorrect_number', independent of the payment provider. Value can be null. A full list of known values can be found at https://help.shopify.com/api/reference/transaction. - /// - [JsonProperty("error_code")] - public string ErrorCode { get; set; } - - /// - /// The status of the transaction. Valid values are: pending, failure, success or error. - /// - [JsonProperty("status")] - public string Status { get; set; } - - /// - /// Whether the transaction is for testing purposes. - /// - [JsonProperty("test")] - public bool? Test { get; set; } - - /// - /// The unique identifier for the user. - /// - [JsonProperty("user_id")] - public long? UserId { get; set; } - - /// - /// The three letter code (ISO 4217) for the currency used for the payment. - /// - [JsonProperty("currency")] - public string Currency { get; set; } - - /// - /// This property is undocumented by Shopify. - /// - [JsonProperty("message")] - public string Message { get; set; } - - /// - /// This property is undocumented by Shopify. - /// - [JsonProperty("location_id")] - public long? LocationId { get; set; } - - /// - /// This property is undocumented by Shopify. - /// - [JsonProperty("parent_id")] - public long? ParentId { get; set; } + /// The amount of money that the transaction was for. + /// + [JsonProperty("amount")] + public decimal? Amount { get; set; } + + /// + /// The authorization code associated with the transaction. + /// + [JsonProperty("authorization")] + public string Authorization { get; set; } + + /// + /// The date and time when the Shopify Payments authorization expires. + /// + [JsonProperty("authorization_expires_at")] + public DateTimeOffset? AuthorizationExpiresAt { get; set; } + + /// + /// The date and time when the transaction was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// The unique identifier for the device. + /// + [JsonProperty("device_id")] + public long? DeviceId { get; set; } + + /// + /// The name of the gateway the transaction was issued through. + /// + [JsonProperty("gateway")] + public string Gateway { get; set; } + + /// + /// The origin of the transaction. This is set by Shopify and cannot be overridden. Example values include: 'web', 'pos', 'iphone', 'android'. + /// + [JsonProperty("source_name")] + public string SourceName { get; private set; } + + /// + /// The origin of the transaction. Set to "external" to create a cash transaction for the associated order. + /// + [JsonProperty("source")] + public string Source { get; set; } + + /// + /// An object containing information about the credit card used for this transaction. + /// + [JsonProperty("payment_details")] + public PaymentDetails PaymentDetails { get; set; } + + /// + /// The kind of transaction. Known values are 'authorization', 'capture', 'sale', 'void' and 'refund'. + /// + [JsonProperty("kind")] + public string Kind { get; set; } + + /// + /// A unique numeric identifier for the order. + /// + [JsonProperty("order_id")] + public long? OrderId { get; set; } + + /// + /// Shopify does not currently offer documentation for this object. + /// + [JsonProperty("receipt")] + public object Receipt { get; set; } + + /// + /// A standardized error code, e.g. 'incorrect_number', independent of the payment provider. Value can be null. A full list of known values can be found at https://help.shopify.com/api/reference/transaction. + /// + [JsonProperty("error_code")] + public string ErrorCode { get; set; } + + /// + /// The status of the transaction. Valid values are: pending, failure, success or error. + /// + [JsonProperty("status")] + public string Status { get; set; } + + /// + /// Whether the transaction is for testing purposes. + /// + [JsonProperty("test")] + public bool? Test { get; set; } + + /// + /// The unique identifier for the user. + /// + [JsonProperty("user_id")] + public long? UserId { get; set; } + + /// + /// The three letter code (ISO 4217) for the currency used for the payment. + /// + [JsonProperty("currency")] + public string Currency { get; set; } + + /// + /// This property is undocumented by Shopify. + /// + [JsonProperty("message")] + public string Message { get; set; } + + /// + /// This property is undocumented by Shopify. + /// + [JsonProperty("location_id")] + public long? LocationId { get; set; } + + /// + /// This property is undocumented by Shopify. + /// + [JsonProperty("parent_id")] + public long? ParentId { get; set; } - /// - /// This property is undocumented by Shopify. - /// - [JsonProperty("processed_at")] - public DateTimeOffset? ProcessedAt { get; set; } - - /// - /// The maximum amount that can be refunded - /// - [JsonProperty("maximum_refundable")] - public decimal? MaximumRefundable { get; set; } - - /// - /// An adjustment on the transaction showing the amount lost or gained due to fluctuations in the currency exchange rate - /// Requires the header X-Shopify-Api-Features = include-currency-exchange-adjustments - /// - [JsonProperty("currency_exchange_adjustment")] - public CurrencyExchangeAdjustment CurrencyExchangeAdjustment { get; set; } - - /// - /// payments_refund_attributes are available only if the following criteria apply: - /// The store is on a Shopify Plus plan. - /// The store uses Shopify Payments. - /// The order transaction kind is either refund or void. - /// If the criteria isn't met, then the payments_refund_attributes property is omitted. - /// - [JsonProperty("payments_refund_attributes")] - public PaymentsRefundAttributes PaymentsRefundAttributes { get; set; } - - /// - /// Unique ID is now sent to payment providers when a customer pays at checkout. - /// This ID can be used to match order information between Shopify and payment providers. An Order can have more than one Payment ID. - /// It only includes successful or pending payments. It does not include captures and refunds. - /// - [JsonProperty("payment_id")] - public string PaymentId { get; set; } - - /// - /// Specifies the available amount with currency to capture on the gateway in shop and presentment currencies. Only available when an amount is capturable or manually mark as paid. - /// - [JsonProperty("total_unsettled_set")] - public PriceSet TotalUnsettledSet { get; set; } - } -} + /// + /// This property is undocumented by Shopify. + /// + [JsonProperty("processed_at")] + public DateTimeOffset? ProcessedAt { get; set; } + + /// + /// The maximum amount that can be refunded + /// + [JsonProperty("maximum_refundable")] + public decimal? MaximumRefundable { get; set; } + + /// + /// An adjustment on the transaction showing the amount lost or gained due to fluctuations in the currency exchange rate + /// Requires the header X-Shopify-Api-Features = include-currency-exchange-adjustments + /// + [JsonProperty("currency_exchange_adjustment")] + public CurrencyExchangeAdjustment CurrencyExchangeAdjustment { get; set; } + + /// + /// payments_refund_attributes are available only if the following criteria apply: + /// The store is on a Shopify Plus plan. + /// The store uses Shopify Payments. + /// The order transaction kind is either refund or void. + /// If the criteria isn't met, then the payments_refund_attributes property is omitted. + /// + [JsonProperty("payments_refund_attributes")] + public PaymentsRefundAttributes PaymentsRefundAttributes { get; set; } + + /// + /// Unique ID is now sent to payment providers when a customer pays at checkout. + /// This ID can be used to match order information between Shopify and payment providers. An Order can have more than one Payment ID. + /// It only includes successful or pending payments. It does not include captures and refunds. + /// + [JsonProperty("payment_id")] + public string PaymentId { get; set; } + + /// + /// Specifies the available amount with currency to capture on the gateway in shop and presentment currencies. Only available when an amount is capturable or manually mark as paid. + /// + [JsonProperty("total_unsettled_set")] + public PriceSet TotalUnsettledSet { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/UsageCharge.cs b/ShopifySharp/Entities/UsageCharge.cs index bf24c736..72918d13 100644 --- a/ShopifySharp/Entities/UsageCharge.cs +++ b/ShopifySharp/Entities/UsageCharge.cs @@ -1,41 +1,40 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// Represents a variable monthly fee for an app or a service. +/// +public class UsageCharge : ShopifyObject { /// - /// Represents a variable monthly fee for an app or a service. + /// The date and time when the usage charge was created. /// - public class UsageCharge : ShopifyObject - { - /// - /// The date and time when the usage charge was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } - /// - /// The name of the usage charge. - /// - [JsonProperty("description")] - public string Description { get; set; } + /// + /// The name of the usage charge. + /// + [JsonProperty("description")] + public string Description { get; set; } - /// - /// The price of the usage charge. - /// - [JsonProperty("price")] - public decimal? Price { get; set; } + /// + /// The price of the usage charge. + /// + [JsonProperty("price")] + public decimal? Price { get; set; } - /// - /// The recurring application charge the usage charge belongs to. - /// - [JsonProperty("recurring_application_charge_id")] - public long? RecurringApplicationChargeId { get; set; } + /// + /// The recurring application charge the usage charge belongs to. + /// + [JsonProperty("recurring_application_charge_id")] + public long? RecurringApplicationChargeId { get; set; } - /// - /// The date and time when the usage charge was last updated. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - } -} + /// + /// The date and time when the usage charge was last updated. + /// + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/User.cs b/ShopifySharp/Entities/User.cs index 98ce2413..b656773c 100644 --- a/ShopifySharp/Entities/User.cs +++ b/ShopifySharp/Entities/User.cs @@ -1,96 +1,95 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class User : ShopifyObject { - public class User : ShopifyObject - { - /// - /// Identifies if the user is the owner of the Shopify account. - /// - [JsonProperty("account_owner")] - public bool? AccountOwner { get; set; } + /// + /// Identifies if the user is the owner of the Shopify account. + /// + [JsonProperty("account_owner")] + public bool? AccountOwner { get; set; } - /// - /// User specified description of oneself. - /// - [JsonProperty("bio")] - public string Bio { get; set; } + /// + /// User specified description of oneself. + /// + [JsonProperty("bio")] + public string Bio { get; set; } - /// - /// Email address associated with this account. - /// - [JsonProperty("email")] - public string Email { get; set; } + /// + /// Email address associated with this account. + /// + [JsonProperty("email")] + public string Email { get; set; } - /// - /// The first name of the account user. - /// - [JsonProperty("first_name")] - public string FirstName { get; set; } + /// + /// The first name of the account user. + /// + [JsonProperty("first_name")] + public string FirstName { get; set; } - /// - /// The IM account address. - /// - [JsonProperty("im")] - public string IM { get; set; } + /// + /// The IM account address. + /// + [JsonProperty("im")] + public string IM { get; set; } - /// - /// The last name of the account user. - /// - [JsonProperty("last_name")] - public string LastName { get; set; } + /// + /// The last name of the account user. + /// + [JsonProperty("last_name")] + public string LastName { get; set; } - /// - /// The permissions that the account has. Users will either have "full" or "limited" permissions. - /// Limited permissions are scoped to a user in that they can only view certain parts of the Shopify Admin - /// The types of permissions a limited user can have are as follows: - /// dashboard: Can see Shop performance and statistics - /// orders: Can view and modify orders - /// customers: Can view and modify customers - /// marketing: Can view and modify marketing related products such as discount codes - /// products: Can view and modify products - /// gift_cards: Can view and modify gift cards - /// pages: Can view and modify shop pages - /// links: Can view and modify links and menus - /// themes: Can view and modify shop themes - /// applications: Can authorize the installation of third party applications - /// preferences: Can view the preferences and configuration of a shop - /// reports: Can view and create reports - /// billing_charges: The user can view and export billing charges. - /// billing_invoices_view: The user can view billing invoices. - /// billing_payment_methods_view: The user can view billing payment methods. - /// staff_management_activation: The user can activate or deactivate staff in the store. - /// staff_management_create: The user can add staff to the store. - /// staff_management_delete: The user can delete staff from the store. - /// - [JsonProperty("permissions")] - public string[] Permissions { get; set; } + /// + /// The permissions that the account has. Users will either have "full" or "limited" permissions. + /// Limited permissions are scoped to a user in that they can only view certain parts of the Shopify Admin + /// The types of permissions a limited user can have are as follows: + /// dashboard: Can see Shop performance and statistics + /// orders: Can view and modify orders + /// customers: Can view and modify customers + /// marketing: Can view and modify marketing related products such as discount codes + /// products: Can view and modify products + /// gift_cards: Can view and modify gift cards + /// pages: Can view and modify shop pages + /// links: Can view and modify links and menus + /// themes: Can view and modify shop themes + /// applications: Can authorize the installation of third party applications + /// preferences: Can view the preferences and configuration of a shop + /// reports: Can view and create reports + /// billing_charges: The user can view and export billing charges. + /// billing_invoices_view: The user can view billing invoices. + /// billing_payment_methods_view: The user can view billing payment methods. + /// staff_management_activation: The user can activate or deactivate staff in the store. + /// staff_management_create: The user can add staff to the store. + /// staff_management_delete: The user can delete staff from the store. + /// + [JsonProperty("permissions")] + public string[] Permissions { get; set; } - /// - /// Phone number associated with the account. - /// - [JsonProperty("phone")] - public string Phone { get; set; } + /// + /// Phone number associated with the account. + /// + [JsonProperty("phone")] + public string Phone { get; set; } - /// - /// Whether or not this account will receive email announcements from Shopify. - /// - [JsonProperty("receive_announcements")] - public bool? ReceiveAnnouncements { get; set; } + /// + /// Whether or not this account will receive email announcements from Shopify. + /// + [JsonProperty("receive_announcements")] + public bool? ReceiveAnnouncements { get; set; } - /// - /// Homepage or other web address - /// - [JsonProperty("url")] - public string Url { get; set; } + /// + /// Homepage or other web address + /// + [JsonProperty("url")] + public string Url { get; set; } - /// - /// The type that the account is: - /// regular - A normal account that can access the web admin - /// restricted - A user account that cannot access the web admin - /// - [JsonProperty("user_type")] - public string UserType { get; set; } - } -} + /// + /// The type that the account is: + /// regular - A normal account that can access the web admin + /// restricted - A user account that cannot access the web admin + /// + [JsonProperty("user_type")] + public string UserType { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/Webhook.cs b/ShopifySharp/Entities/Webhook.cs index 3c0629df..a0cb5d9d 100644 --- a/ShopifySharp/Entities/Webhook.cs +++ b/ShopifySharp/Entities/Webhook.cs @@ -2,53 +2,52 @@ using System; using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An entity representing a Shopify webhook. +/// +public class Webhook : ShopifyObject { /// - /// An entity representing a Shopify webhook. + /// The URL where the webhook should send the POST request when the event occurs. + /// + [JsonProperty("address")] + public string Address { get; set; } + + /// + /// The date and time when the webhook was created. + /// + [JsonProperty("created_at")] + public DateTimeOffset? CreatedAt { get; set; } + + /// + /// An optional array of fields which should be included in webhooks. + /// + [JsonProperty("fields")] + public IEnumerable Fields { get; set; } + + /// + /// The format in which the webhook should send the data. Valid values are json and xml. + /// + [JsonProperty("format")] + public string Format { get; set; } + + /// + /// An optional array of namespaces for metafields that should be included in webhooks. + /// + [JsonProperty("metafield_namespaces")] + public IEnumerable MetafieldNamespaces { get; set; } + + /// + /// The event that will trigger the webhook, e.g. 'orders/create' or 'app/uninstalled'. A full list of webhook topics can be found at https://help.shopify.com/api/reference/webhook. + /// + [JsonProperty("topic")] + public string Topic { get; set; } + + /// + /// The date and time when the webhook was updated. /// - public class Webhook : ShopifyObject - { - /// - /// The URL where the webhook should send the POST request when the event occurs. - /// - [JsonProperty("address")] - public string Address { get; set; } - - /// - /// The date and time when the webhook was created. - /// - [JsonProperty("created_at")] - public DateTimeOffset? CreatedAt { get; set; } - - /// - /// An optional array of fields which should be included in webhooks. - /// - [JsonProperty("fields")] - public IEnumerable Fields { get; set; } - - /// - /// The format in which the webhook should send the data. Valid values are json and xml. - /// - [JsonProperty("format")] - public string Format { get; set; } - - /// - /// An optional array of namespaces for metafields that should be included in webhooks. - /// - [JsonProperty("metafield_namespaces")] - public IEnumerable MetafieldNamespaces { get; set; } - - /// - /// The event that will trigger the webhook, e.g. 'orders/create' or 'app/uninstalled'. A full list of webhook topics can be found at https://help.shopify.com/api/reference/webhook. - /// - [JsonProperty("topic")] - public string Topic { get; set; } - - /// - /// The date and time when the webhook was updated. - /// - [JsonProperty("updated_at")] - public DateTimeOffset? UpdatedAt { get; set; } - } -} + [JsonProperty("updated_at")] + public DateTimeOffset? UpdatedAt { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/WeightBasedShippingRate.cs b/ShopifySharp/Entities/WeightBasedShippingRate.cs index 211aec9a..e470c724 100644 --- a/ShopifySharp/Entities/WeightBasedShippingRate.cs +++ b/ShopifySharp/Entities/WeightBasedShippingRate.cs @@ -1,37 +1,36 @@ using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class WeightBasedShippingRate : ShopifyObject { - public class WeightBasedShippingRate : ShopifyObject - { - /// - /// Minimum order weight - /// - [JsonProperty("weight_low")] - public decimal? WeightLow { get; set; } + /// + /// Minimum order weight + /// + [JsonProperty("weight_low")] + public decimal? WeightLow { get; set; } - /// - /// Maximum order weight - /// - [JsonProperty("weight_high")] - public decimal? WeightHigh { get; set; } + /// + /// Maximum order weight + /// + [JsonProperty("weight_high")] + public decimal? WeightHigh { get; set; } - /// - /// Name of weight based rate - /// - [JsonProperty("name")] - public string Name { get; set; } + /// + /// Name of weight based rate + /// + [JsonProperty("name")] + public string Name { get; set; } - /// - /// Rate amount - /// - [JsonProperty("price")] - public decimal? Price { get; set; } + /// + /// Rate amount + /// + [JsonProperty("price")] + public decimal? Price { get; set; } - /// - /// Shipping zone id - /// - [JsonProperty("shipping_zone_id")] - public long? ShippingZoneId { get; set; } - } + /// + /// Shipping zone id + /// + [JsonProperty("shipping_zone_id")] + public long? ShippingZoneId { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Enums/AuthorizationScope.cs b/ShopifySharp/Enums/AuthorizationScope.cs index 11891b43..1ba9540a 100644 --- a/ShopifySharp/Enums/AuthorizationScope.cs +++ b/ShopifySharp/Enums/AuthorizationScope.cs @@ -1,205 +1,204 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using ShopifySharp.Converters; using System.Runtime.Serialization; -namespace ShopifySharp.Enums +namespace ShopifySharp.Enums; + +[JsonConverter(typeof(NullableEnumConverter))] +public enum AuthorizationScope { - [JsonConverter(typeof(NullableEnumConverter))] - public enum AuthorizationScope - { - [EnumMember(Value = "read_content")] - ReadContent, + [EnumMember(Value = "read_content")] + ReadContent, - [EnumMember(Value = "write_content")] - WriteContent, + [EnumMember(Value = "write_content")] + WriteContent, - [EnumMember(Value = "read_themes")] - ReadThemes, + [EnumMember(Value = "read_themes")] + ReadThemes, - [EnumMember(Value = "write_themes")] - WriteThemes, + [EnumMember(Value = "write_themes")] + WriteThemes, - [EnumMember(Value = "read_products")] - ReadProducts, + [EnumMember(Value = "read_products")] + ReadProducts, - [EnumMember(Value = "write_products")] - WriteProducts, + [EnumMember(Value = "write_products")] + WriteProducts, - [EnumMember(Value = "read_customers")] - ReadCustomers, + [EnumMember(Value = "read_customers")] + ReadCustomers, - [EnumMember(Value = "write_customers")] - WriteCustomers, + [EnumMember(Value = "write_customers")] + WriteCustomers, - [EnumMember(Value = "read_orders")] - ReadOrders, + [EnumMember(Value = "read_orders")] + ReadOrders, - [EnumMember( Value = "read_all_orders" )] - ReadAllOrders, + [EnumMember( Value = "read_all_orders" )] + ReadAllOrders, - [EnumMember(Value = "write_orders")] - WriteOrders, + [EnumMember(Value = "write_orders")] + WriteOrders, - [EnumMember(Value = "read_script_tags")] - ReadScriptTags, + [EnumMember(Value = "read_script_tags")] + ReadScriptTags, - [EnumMember(Value = "write_script_tags")] - WriteScriptTags, + [EnumMember(Value = "write_script_tags")] + WriteScriptTags, - [EnumMember(Value = "read_fulfillments")] - ReadFulfillments, + [EnumMember(Value = "read_fulfillments")] + ReadFulfillments, - [EnumMember(Value = "write_fulfillments")] - WriteFulfillments, + [EnumMember(Value = "write_fulfillments")] + WriteFulfillments, - [EnumMember(Value = "read_shipping")] - ReadShipping, + [EnumMember(Value = "read_shipping")] + ReadShipping, - [EnumMember(Value = "write_shipping")] - WriteShipping, + [EnumMember(Value = "write_shipping")] + WriteShipping, - [EnumMember(Value = "read_analytics")] - ReadAnalytics, + [EnumMember(Value = "read_analytics")] + ReadAnalytics, - [EnumMember(Value = "read_users")] - ReadUsers, + [EnumMember(Value = "read_users")] + ReadUsers, - [EnumMember(Value = "write_users")] - WriteUsers, + [EnumMember(Value = "write_users")] + WriteUsers, - [EnumMember(Value = "read_checkouts")] - ReadCheckouts, + [EnumMember(Value = "read_checkouts")] + ReadCheckouts, - [EnumMember(Value = "write_checkouts")] - WriteCheckouts, + [EnumMember(Value = "write_checkouts")] + WriteCheckouts, - [EnumMember(Value = "read_reports")] - ReadReports, + [EnumMember(Value = "read_reports")] + ReadReports, - [EnumMember(Value = "write_reports")] - WriteReports, + [EnumMember(Value = "write_reports")] + WriteReports, - [EnumMember(Value = "read_price_rules")] - ReadPriceRules, + [EnumMember(Value = "read_price_rules")] + ReadPriceRules, - [EnumMember(Value = "write_price_rules")] - WritePriceRules, + [EnumMember(Value = "write_price_rules")] + WritePriceRules, - [EnumMember(Value = "read_inventory")] - ReadInventory, + [EnumMember(Value = "read_inventory")] + ReadInventory, - [EnumMember(Value = "write_inventory")] - WriteInventory, + [EnumMember(Value = "write_inventory")] + WriteInventory, - [EnumMember(Value = "read_product_listings")] - ReadProductListings, + [EnumMember(Value = "read_product_listings")] + ReadProductListings, - [EnumMember(Value = "read_collection_listings")] - ReadCollectionListings, + [EnumMember(Value = "read_collection_listings")] + ReadCollectionListings, - [EnumMember(Value = "read_draft_orders")] - ReadDraftOrders, + [EnumMember(Value = "read_draft_orders")] + ReadDraftOrders, - [EnumMember(Value = "write_draft_orders")] - WriteDraftOrders, + [EnumMember(Value = "write_draft_orders")] + WriteDraftOrders, - [EnumMember(Value = "write_merchant_managed_fulfillment_orders")] - WriteMerchantManagedFulfillmentOrders, + [EnumMember(Value = "write_merchant_managed_fulfillment_orders")] + WriteMerchantManagedFulfillmentOrders, - [EnumMember(Value = "read_merchant_managed_fulfillment_orders")] - ReadMerchantManagedFulfillmentOrders, + [EnumMember(Value = "read_merchant_managed_fulfillment_orders")] + ReadMerchantManagedFulfillmentOrders, - [EnumMember(Value = "read_assigned_fulfillment_orders")] - ReadAssignedFulfillmentOrders, + [EnumMember(Value = "read_assigned_fulfillment_orders")] + ReadAssignedFulfillmentOrders, - [EnumMember(Value = "write_assigned_fulfillment_orders")] - WriteAssignedFulfillmentOrders, + [EnumMember(Value = "write_assigned_fulfillment_orders")] + WriteAssignedFulfillmentOrders, - [EnumMember(Value = "read_cart_transforms")] - ReadCartTransforms, + [EnumMember(Value = "read_cart_transforms")] + ReadCartTransforms, - [EnumMember(Value = "write_cart_transforms")] - WriteCartTransforms, + [EnumMember(Value = "write_cart_transforms")] + WriteCartTransforms, - [EnumMember(Value = "read_marketing_events")] - ReadMarketingEvents, + [EnumMember(Value = "read_marketing_events")] + ReadMarketingEvents, - [EnumMember(Value = "write_marketing_events")] - WriteMarketingEvents, + [EnumMember(Value = "write_marketing_events")] + WriteMarketingEvents, - [EnumMember(Value = "read_resource_feedbacks")] - ReadResourceFeedbacks, + [EnumMember(Value = "read_resource_feedbacks")] + ReadResourceFeedbacks, - [EnumMember(Value = "write_resource_feedbacks")] - WriteResourceFeedbacks, + [EnumMember(Value = "write_resource_feedbacks")] + WriteResourceFeedbacks, - [EnumMember(Value = "unauthenticated_read_collection_listings")] - UnauthenticatedReadCollectionListings, + [EnumMember(Value = "unauthenticated_read_collection_listings")] + UnauthenticatedReadCollectionListings, - [EnumMember(Value = "unauthenticated_read_product_listings")] - UnauthenticatedReadProductListings, + [EnumMember(Value = "unauthenticated_read_product_listings")] + UnauthenticatedReadProductListings, - [EnumMember(Value = "unauthenticated_write_checkouts")] - UnauthenticatedWriteCheckouts, + [EnumMember(Value = "unauthenticated_write_checkouts")] + UnauthenticatedWriteCheckouts, - [EnumMember(Value = "unauthenticated_write_customers")] - UnauthenticatedWriteCustomers, + [EnumMember(Value = "unauthenticated_write_customers")] + UnauthenticatedWriteCustomers, - [EnumMember(Value = "unauthenticated_read_content")] - UnauthenticatedReadContent, + [EnumMember(Value = "unauthenticated_read_content")] + UnauthenticatedReadContent, - [EnumMember(Value = "read_locations")] - ReadLocations, + [EnumMember(Value = "read_locations")] + ReadLocations, - [EnumMember(Value = "write_order_edits")] - WriteOrderEdits, + [EnumMember(Value = "write_order_edits")] + WriteOrderEdits, - [EnumMember(Value = "read_third_party_fulfillment_orders")] - ReadThirdPartyFulfillmentOrders, + [EnumMember(Value = "read_third_party_fulfillment_orders")] + ReadThirdPartyFulfillmentOrders, - [EnumMember(Value = "write_third_party_fulfillment_orders")] - WriteThirdPartyFulfillmentOrders, + [EnumMember(Value = "write_third_party_fulfillment_orders")] + WriteThirdPartyFulfillmentOrders, - [EnumMember(Value = "read_gift_cards")] - ReadGiftCards, + [EnumMember(Value = "read_gift_cards")] + ReadGiftCards, - [EnumMember(Value = "write_gift_cards")] - WriteGiftCards, + [EnumMember(Value = "write_gift_cards")] + WriteGiftCards, - [EnumMember(Value = "read_discounts")] - ReadDiscounts, + [EnumMember(Value = "read_discounts")] + ReadDiscounts, - [EnumMember(Value = "write_discounts")] - WriteDiscounts, + [EnumMember(Value = "write_discounts")] + WriteDiscounts, - [EnumMember(Value = "read_shopify_payments_payouts")] - ReadShopifyPaymentsPayouts, + [EnumMember(Value = "read_shopify_payments_payouts")] + ReadShopifyPaymentsPayouts, - [EnumMember(Value = "read_shopify_payments_disputes")] - ReadShopifyPaymentsDisputes, + [EnumMember(Value = "read_shopify_payments_disputes")] + ReadShopifyPaymentsDisputes, - [EnumMember(Value = "read_translations")] - ReadTranslations, + [EnumMember(Value = "read_translations")] + ReadTranslations, - [EnumMember(Value = "write_translations")] - WriteTranslations, + [EnumMember(Value = "write_translations")] + WriteTranslations, - [EnumMember(Value = "read_locales")] - ReadLocales, + [EnumMember(Value = "read_locales")] + ReadLocales, - [EnumMember(Value = "write_locales")] - WriteLocales, + [EnumMember(Value = "write_locales")] + WriteLocales, - [EnumMember(Value = "read_gates")] - ReadGates, + [EnumMember(Value = "read_gates")] + ReadGates, - [EnumMember(Value = "write_gates")] - WriteGates, + [EnumMember(Value = "write_gates")] + WriteGates, - [EnumMember(Value = "read_returns")] - ReadReturns, + [EnumMember(Value = "read_returns")] + ReadReturns, - [EnumMember(Value = "write_returns")] - WriteReturns - } -} + [EnumMember(Value = "write_returns")] + WriteReturns +} \ No newline at end of file diff --git a/ShopifySharp/Extensions/DictionaryExtensions.cs b/ShopifySharp/Extensions/DictionaryExtensions.cs index e826eaed..1d024aa5 100644 --- a/ShopifySharp/Extensions/DictionaryExtensions.cs +++ b/ShopifySharp/Extensions/DictionaryExtensions.cs @@ -1,15 +1,14 @@ using System.Collections.Generic; -namespace ShopifySharp +namespace ShopifySharp; + +internal static class DictionaryExtensions { - internal static class DictionaryExtensions + public static void AddRange(this IDictionary dictionary, IEnumerable> kvps) { - public static void AddRange(this IDictionary dictionary, IEnumerable> kvps) + foreach (var kvp in kvps) { - foreach (var kvp in kvps) - { - dictionary.Add(kvp.Key, kvp.Value); - } + dictionary.Add(kvp.Key, kvp.Value); } } } \ No newline at end of file diff --git a/ShopifySharp/Extensions/EnumExtensions.cs b/ShopifySharp/Extensions/EnumExtensions.cs index 6d1cfd23..c9e83b7b 100644 --- a/ShopifySharp/Extensions/EnumExtensions.cs +++ b/ShopifySharp/Extensions/EnumExtensions.cs @@ -1,54 +1,53 @@ -using System; +using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Runtime.Serialization; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// Enum Extension Method +/// +internal static class EnumExtensions { /// - /// Enum Extension Method + /// Reads and uses the enum's for serialization. /// - internal static class EnumExtensions + /// + /// + public static string ToSerializedString(this Enum input) { - /// - /// Reads and uses the enum's for serialization. - /// - /// - /// - public static string ToSerializedString(this Enum input) + string name = input.ToString(); + var info = input.GetType().GetTypeInfo().DeclaredMembers.Where(i => i.Name == name); + + if (info.Any()) { - string name = input.ToString(); - var info = input.GetType().GetTypeInfo().DeclaredMembers.Where(i => i.Name == name); + var attribute = info.First().GetCustomAttribute(); - if (info.Any()) + if (attribute != null) { - var attribute = info.First().GetCustomAttribute(); - - if (attribute != null) - { - return attribute.Value; - } + return attribute.Value; } - - return name.ToLower(); } - /// - /// Convert list of Enums to a comma separated string - /// - public static string EnumListToString(IEnumerable enumList) - { - var list = new List(); + return name.ToLower(); + } - if (enumList != null && enumList.Any()) + /// + /// Convert list of Enums to a comma separated string + /// + public static string EnumListToString(IEnumerable enumList) + { + var list = new List(); + + if (enumList != null && enumList.Any()) + { + foreach (var enumItem in enumList) { - foreach (var enumItem in enumList) - { - list.Add(EnumExtensions.ToSerializedString(enumItem as Enum)); - } + list.Add(EnumExtensions.ToSerializedString(enumItem as Enum)); } - return string.Join(",", list); } + return string.Join(",", list); } -} +} \ No newline at end of file diff --git a/ShopifySharp/Extensions/ObjectExtensions.cs b/ShopifySharp/Extensions/ObjectExtensions.cs index e5103997..0c295114 100644 --- a/ShopifySharp/Extensions/ObjectExtensions.cs +++ b/ShopifySharp/Extensions/ObjectExtensions.cs @@ -1,45 +1,44 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; -namespace ShopifySharp +namespace ShopifySharp; + +internal static class ObjectExtensions { - internal static class ObjectExtensions + /// + /// Converts the object to a dictionary./> + /// + /// The object as a . + public static IDictionary ToDictionary(this object obj) { - /// - /// Converts the object to a dictionary./> - /// - /// The object as a . - public static IDictionary ToDictionary(this object obj) + IDictionary output = new Dictionary(); + + //Inspiration for this code from https://github.com/jaymedavis/stripe.net + foreach (PropertyInfo property in obj.GetType().GetAllDeclaredProperties()) { - IDictionary output = new Dictionary(); + object value = property.GetValue(obj, null); + string propName = property.Name; + if (value == null) continue; - //Inspiration for this code from https://github.com/jaymedavis/stripe.net - foreach (PropertyInfo property in obj.GetType().GetAllDeclaredProperties()) + if (property.CustomAttributes.Any(x => x.AttributeType == typeof(JsonPropertyAttribute))) { - object value = property.GetValue(obj, null); - string propName = property.Name; - if (value == null) continue; - - if (property.CustomAttributes.Any(x => x.AttributeType == typeof(JsonPropertyAttribute))) - { - //Get the JsonPropertyAttribute for this property, which will give us its JSON name - JsonPropertyAttribute attribute = property.GetCustomAttributes(typeof(JsonPropertyAttribute), false).Cast().FirstOrDefault(); - - propName = attribute != null ? attribute.PropertyName : property.Name; - } + //Get the JsonPropertyAttribute for this property, which will give us its JSON name + JsonPropertyAttribute attribute = property.GetCustomAttributes(typeof(JsonPropertyAttribute), false).Cast().FirstOrDefault(); - if (value.GetType().GetTypeInfo().IsEnum) - { - value = ((Enum)value).ToSerializedString(); - } + propName = attribute != null ? attribute.PropertyName : property.Name; + } - output.Add(propName, value); + if (value.GetType().GetTypeInfo().IsEnum) + { + value = ((Enum)value).ToSerializedString(); } - return output; + output.Add(propName, value); } + + return output; } -} +} \ No newline at end of file diff --git a/ShopifySharp/Extensions/StringExtensions.cs b/ShopifySharp/Extensions/StringExtensions.cs index 396be7c1..9001bac7 100644 --- a/ShopifySharp/Extensions/StringExtensions.cs +++ b/ShopifySharp/Extensions/StringExtensions.cs @@ -1,20 +1,19 @@ -namespace ShopifySharp +namespace ShopifySharp; + +internal static class StringExtensions { - internal static class StringExtensions - { - /// - /// Checks if a string starts with another string, ignoring case. - /// - public static bool StartsWithIgnoreCase(this string str, string a) => str.ToLower().StartsWith(a.ToLower()); + /// + /// Checks if a string starts with another string, ignoring case. + /// + public static bool StartsWithIgnoreCase(this string str, string a) => str.ToLower().StartsWith(a.ToLower()); - /// - /// Checks if a string ends with another string, ignoring case. - /// - public static bool EndsWithIgnoreCase(this string str, string a) => str.ToLower().EndsWith(a.ToLower()); + /// + /// Checks if a string ends with another string, ignoring case. + /// + public static bool EndsWithIgnoreCase(this string str, string a) => str.ToLower().EndsWith(a.ToLower()); - /// - /// Checks if a string contains another string, ignorning case. - /// - public static bool ContainsIgnoreCase(this string str, string a) => str.ToLower().Contains(a.ToLower()); - } + /// + /// Checks if a string contains another string, ignorning case. + /// + public static bool ContainsIgnoreCase(this string str, string a) => str.ToLower().Contains(a.ToLower()); } \ No newline at end of file diff --git a/ShopifySharp/Extensions/TypeExtensions.cs b/ShopifySharp/Extensions/TypeExtensions.cs index 5d3b606c..717d6e25 100644 --- a/ShopifySharp/Extensions/TypeExtensions.cs +++ b/ShopifySharp/Extensions/TypeExtensions.cs @@ -3,24 +3,23 @@ using System.Linq; using System.Reflection; -namespace ShopifySharp +namespace ShopifySharp; + +internal static class TypeExtensions { - internal static class TypeExtensions + public static IEnumerable GetAllDeclaredProperties(this Type type) { - public static IEnumerable GetAllDeclaredProperties(this Type type) - { - // .NET Core did not add Type.GetProperties until 1.5, so we need a recursive function - // to return a list of this properties DeclareProperties, and its base type's DeclaredProperties. - - var info = type.GetTypeInfo(); - var props = info.DeclaredProperties.ToList(); + // .NET Core did not add Type.GetProperties until 1.5, so we need a recursive function + // to return a list of this properties DeclareProperties, and its base type's DeclaredProperties. - if (info.BaseType != null) - { - props.AddRange(info.BaseType.GetAllDeclaredProperties()); - } + var info = type.GetTypeInfo(); + var props = info.DeclaredProperties.ToList(); - return props; + if (info.BaseType != null) + { + props.AddRange(info.BaseType.GetAllDeclaredProperties()); } + + return props; } } \ No newline at end of file diff --git a/ShopifySharp/Factories/IServiceFactory.cs b/ShopifySharp/Factories/IServiceFactory.cs index 949c2574..dcfcec2b 100644 --- a/ShopifySharp/Factories/IServiceFactory.cs +++ b/ShopifySharp/Factories/IServiceFactory.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Credentials; +using ShopifySharp.Credentials; namespace ShopifySharp.Factories; diff --git a/ShopifySharp/Filters/ApplicationCreditListFilter.cs b/ShopifySharp/Filters/ApplicationCreditListFilter.cs index d6e0eb88..5a96a59c 100644 --- a/ShopifySharp/Filters/ApplicationCreditListFilter.cs +++ b/ShopifySharp/Filters/ApplicationCreditListFilter.cs @@ -1,6 +1,5 @@ -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class ApplicationCreditListFilter : ListFilter { - public class ApplicationCreditListFilter : ListFilter - { - } } \ No newline at end of file diff --git a/ShopifySharp/Filters/ArticleCountFilter.cs b/ShopifySharp/Filters/ArticleCountFilter.cs index 1c5da74d..ba5318e8 100644 --- a/ShopifySharp/Filters/ArticleCountFilter.cs +++ b/ShopifySharp/Filters/ArticleCountFilter.cs @@ -1,51 +1,50 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class ArticleCountFilter : Parameterizable { - public class ArticleCountFilter : Parameterizable - { - /// - /// Restricts results to those created after date (format: 2008-12-31 03:00). - /// - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } + /// + /// Restricts results to those created after date (format: 2008-12-31 03:00). + /// + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } - /// - /// Restricts results to those created before date (format: 2008-12-31 03:00). - /// - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } + /// + /// Restricts results to those created before date (format: 2008-12-31 03:00). + /// + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } - /// - /// Restricts results to those last updated after date (format: 2008-12-31 03:00). - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Restricts results to those last updated after date (format: 2008-12-31 03:00). + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Restricts results to those last updated before date (format: 2008-12-31 03:00). - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } + /// + /// Restricts results to those last updated before date (format: 2008-12-31 03:00). + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } - /// - /// Restricts results to those published after date (format: 2008-12-31 03:00). - /// - [JsonProperty("published_at_min")] - public DateTimeOffset? PublishedAtMin { get; set; } + /// + /// Restricts results to those published after date (format: 2008-12-31 03:00). + /// + [JsonProperty("published_at_min")] + public DateTimeOffset? PublishedAtMin { get; set; } - /// - /// Restricts results to those published before date (format: 2008-12-31 03:00). - /// - [JsonProperty("published_at_max")] - public DateTimeOffset? PublishedAtMax { get; set; } + /// + /// Restricts results to those published before date (format: 2008-12-31 03:00). + /// + [JsonProperty("published_at_max")] + public DateTimeOffset? PublishedAtMax { get; set; } - /// - /// Published Status. - /// published - Show only published objects, unpublished - Show only unpublished objects, any - Show all objects(default) - /// - [JsonProperty("published_status")] - public string PublishedStatus { get; set; } - } + /// + /// Published Status. + /// published - Show only published objects, unpublished - Show only unpublished objects, any - Show all objects(default) + /// + [JsonProperty("published_status")] + public string PublishedStatus { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/ArticleListFilter.cs b/ShopifySharp/Filters/ArticleListFilter.cs index 986db3c2..b1402964 100644 --- a/ShopifySharp/Filters/ArticleListFilter.cs +++ b/ShopifySharp/Filters/ArticleListFilter.cs @@ -1,78 +1,77 @@ -using System; +using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering the results of listing articles. +/// +public class ArticleListFilter : ListFilter
{ /// - /// Options for filtering the results of listing articles. + /// Filter the results to this article handle. /// - public class ArticleListFilter : ListFilter
- { - /// - /// Filter the results to this article handle. - /// - [JsonProperty("handle")] - public string Handle { get; set; } + [JsonProperty("handle")] + public string Handle { get; set; } - /// - /// Filter the articles to just those by a given author. - /// - [JsonProperty("author")] - public string Author { get; set; } + /// + /// Filter the articles to just those by a given author. + /// + [JsonProperty("author")] + public string Author { get; set; } - /// - /// Filter the articles to just those with a given tag. - /// - [JsonProperty("tag")] - public string Tag { get; set; } + /// + /// Filter the articles to just those with a given tag. + /// + [JsonProperty("tag")] + public string Tag { get; set; } - /// - /// Restricts results to those created after date (format: 2008-12-31 03:00). - /// - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } + /// + /// Restricts results to those created after date (format: 2008-12-31 03:00). + /// + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } - /// - /// Restricts results to those created before date (format: 2008-12-31 03:00). - /// - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } + /// + /// Restricts results to those created before date (format: 2008-12-31 03:00). + /// + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } - /// - /// Restricts results to those last updated after date (format: 2008-12-31 03:00). - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Restricts results to those last updated after date (format: 2008-12-31 03:00). + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Restricts results to those last updated before date (format: 2008-12-31 03:00). - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } + /// + /// Restricts results to those last updated before date (format: 2008-12-31 03:00). + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Show objects published after date (format: 2008-12-31 03:00). - /// - [JsonProperty("published_at_min")] - public DateTimeOffset? PublishedAtMin { get; set; } + /// + /// Show objects published after date (format: 2008-12-31 03:00). + /// + [JsonProperty("published_at_min")] + public DateTimeOffset? PublishedAtMin { get; set; } - /// - /// Show objects published before date (format: 2008-12-31 03:00). - /// - [JsonProperty("published_at_max")] - public DateTimeOffset? PublishedAtMax { get; set; } + /// + /// Show objects published before date (format: 2008-12-31 03:00). + /// + [JsonProperty("published_at_max")] + public DateTimeOffset? PublishedAtMax { get; set; } - /// - /// Published Status. - /// published - Show only published objects, unpublished - Show only unpublished objects, any - Show all objects(default) - /// - [JsonProperty("published_status")] - public string PublishedStatus { get; set; } - } -} + /// + /// Published Status. + /// published - Show only published objects, unpublished - Show only unpublished objects, any - Show all objects(default) + /// + [JsonProperty("published_status")] + public string PublishedStatus { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/AssetListFilter.cs b/ShopifySharp/Filters/AssetListFilter.cs index 81eaa08f..898cecbd 100644 --- a/ShopifySharp/Filters/AssetListFilter.cs +++ b/ShopifySharp/Filters/AssetListFilter.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class AssetListFilter : Parameterizable { - public class AssetListFilter : Parameterizable - { - /// - /// Retrieve only certain fields, specified by a comma-separated list of field names. - /// - [JsonProperty("fields")] - public string Fields { get; set; } - } + /// + /// Retrieve only certain fields, specified by a comma-separated list of field names. + /// + [JsonProperty("fields")] + public string Fields { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/AssignedFulfillmentOrderFilter.cs b/ShopifySharp/Filters/AssignedFulfillmentOrderFilter.cs index 0b2f70b0..32969af9 100644 --- a/ShopifySharp/Filters/AssignedFulfillmentOrderFilter.cs +++ b/ShopifySharp/Filters/AssignedFulfillmentOrderFilter.cs @@ -1,32 +1,31 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class AssignedFulfillmentOrderFilter : ListFilter { - public class AssignedFulfillmentOrderFilter : ListFilter - { - /// - /// - /// The assignment status of the fulfillment orders that should be returned: - /// - /// - /// "fulfillment_unsubmitted": Fulfillment orders for which the merchant hasn't yet requested fulfillment. Filtering by this value is supported as of the 2023-04 API version. - /// "cancellation_requested": Fulfillment orders for which the merchant has requested cancellation of the previously accepted fulfillment request. - /// - /// - /// "fulfillment_requested": Fulfillment orders for which the merchant has requested fulfillment. - /// - /// - /// "fulfillment_accepted": Fulfillment orders for which the merchant's fulfillment request has been accepted. Any number of fulfillments can be created on these fulfillment orders to completely fulfill the requested items. - /// - /// - [JsonProperty("assignment_status")] - public string AssignmentStatus { get; set; } + /// + /// + /// The assignment status of the fulfillment orders that should be returned: + /// + /// + /// "fulfillment_unsubmitted": Fulfillment orders for which the merchant hasn't yet requested fulfillment. Filtering by this value is supported as of the 2023-04 API version. + /// "cancellation_requested": Fulfillment orders for which the merchant has requested cancellation of the previously accepted fulfillment request. + /// + /// + /// "fulfillment_requested": Fulfillment orders for which the merchant has requested fulfillment. + /// + /// + /// "fulfillment_accepted": Fulfillment orders for which the merchant's fulfillment request has been accepted. Any number of fulfillments can be created on these fulfillment orders to completely fulfill the requested items. + /// + /// + [JsonProperty("assignment_status")] + public string AssignmentStatus { get; set; } - /// - /// The IDs of the assigned locations of the fulfillment orders that should be returned. - /// - [JsonProperty("location_ids[]")] - public IEnumerable LocationIds { get; set; } - } + /// + /// The IDs of the assigned locations of the fulfillment orders that should be returned. + /// + [JsonProperty("location_ids[]")] + public IEnumerable LocationIds { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/BlogListFilter.cs b/ShopifySharp/Filters/BlogListFilter.cs index 933ca91d..fe9ee3db 100644 --- a/ShopifySharp/Filters/BlogListFilter.cs +++ b/ShopifySharp/Filters/BlogListFilter.cs @@ -1,10 +1,9 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class BlogListFilter : ListFilter { - public class BlogListFilter : ListFilter - { - [JsonProperty("handle")] - public string Handle { get; set; } - } + [JsonProperty("handle")] + public string Handle { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/ChargeListFilter.cs b/ShopifySharp/Filters/ChargeListFilter.cs index 5d3c1bc8..8dd6afaa 100644 --- a/ShopifySharp/Filters/ChargeListFilter.cs +++ b/ShopifySharp/Filters/ChargeListFilter.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class ChargeListFilter : Parameterizable { - public class ChargeListFilter : Parameterizable - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } - } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/CheckoutCountFilter.cs b/ShopifySharp/Filters/CheckoutCountFilter.cs index 14366f1b..e024422a 100644 --- a/ShopifySharp/Filters/CheckoutCountFilter.cs +++ b/ShopifySharp/Filters/CheckoutCountFilter.cs @@ -1,44 +1,43 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class CheckoutCountFilter : Parameterizable { - public class CheckoutCountFilter : Parameterizable - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Restrict results to those created at or after date. - /// - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } + /// + /// Restrict results to those created at or after date. + /// + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } - /// - /// Restrict results to those created at or after date. - /// - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } + /// + /// Restrict results to those created at or after date. + /// + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } - /// - /// Restrict results to those created at or before date. - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Restrict results to those created at or before date. + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Restrict results to those last updated at or before date. - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } + /// + /// Restrict results to those last updated at or before date. + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } - /// - /// Restrict results to those with the given status. Known values: "open", "closed". Default: "open". - /// - [JsonProperty("status")] - public string Status { get; set; } - } + /// + /// Restrict results to those with the given status. Known values: "open", "closed". Default: "open". + /// + [JsonProperty("status")] + public string Status { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/CheckoutListFilter.cs b/ShopifySharp/Filters/CheckoutListFilter.cs index dbe382b6..4a9a41fb 100644 --- a/ShopifySharp/Filters/CheckoutListFilter.cs +++ b/ShopifySharp/Filters/CheckoutListFilter.cs @@ -1,44 +1,43 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class CheckoutListFilter : ListFilter { - public class CheckoutListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Restrict results to those created at or after date. - /// - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } + /// + /// Restrict results to those created at or after date. + /// + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } - /// - /// Restrict results to those created at or after date. - /// - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } + /// + /// Restrict results to those created at or after date. + /// + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } - /// - /// Restrict results to those created at or before date. - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Restrict results to those created at or before date. + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Restrict results to those last updated at or before date. - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } + /// + /// Restrict results to those last updated at or before date. + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } - /// - /// Restrict results to those with the given status. Known values: "open", "closed". Default: "open". - /// - [JsonProperty("status")] - public string Status { get; set; } - } + /// + /// Restrict results to those with the given status. Known values: "open", "closed". Default: "open". + /// + [JsonProperty("status")] + public string Status { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/CollectCountFilter.cs b/ShopifySharp/Filters/CollectCountFilter.cs index f967f165..6fd22fb4 100644 --- a/ShopifySharp/Filters/CollectCountFilter.cs +++ b/ShopifySharp/Filters/CollectCountFilter.cs @@ -1,22 +1,21 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering a count of Collects. +/// +public class CollectCountFilter : Parameterizable { /// - /// Options for filtering a count of Collects. + /// An optional product id to retrieve. /// - public class CollectCountFilter : Parameterizable - { - /// - /// An optional product id to retrieve. - /// - [JsonProperty("product_id")] - public long? ProductId { get; set; } + [JsonProperty("product_id")] + public long? ProductId { get; set; } - /// - /// An optional collection id to retrieve. - /// - [JsonProperty("collection_id")] - public long? CollectionId { get; set; } - } -} + /// + /// An optional collection id to retrieve. + /// + [JsonProperty("collection_id")] + public long? CollectionId { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/CollectListFilter.cs b/ShopifySharp/Filters/CollectListFilter.cs index 9c0a4222..6417ba61 100644 --- a/ShopifySharp/Filters/CollectListFilter.cs +++ b/ShopifySharp/Filters/CollectListFilter.cs @@ -1,25 +1,24 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class CollectListFilter : ListFilter { - public class CollectListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("collection_id")] - public long? CollectionId { get; set; } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("collection_id")] + public long? CollectionId { get; set; } - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("product_id")] - public long? ProductId { get; set; } - } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("product_id")] + public long? ProductId { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/CollectionProductsListFilter.cs b/ShopifySharp/Filters/CollectionProductsListFilter.cs index e1e68f25..ac0f51e2 100644 --- a/ShopifySharp/Filters/CollectionProductsListFilter.cs +++ b/ShopifySharp/Filters/CollectionProductsListFilter.cs @@ -1,9 +1,8 @@ -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering lists of products belonging to a collection. +/// +public class CollectionProductsListFilter : ListFilter { - /// - /// Options for filtering lists of products belonging to a collection. - /// - public class CollectionProductsListFilter : ListFilter - { - } } \ No newline at end of file diff --git a/ShopifySharp/Filters/CountryCountFilter.cs b/ShopifySharp/Filters/CountryCountFilter.cs index ac44f07a..790bc94d 100644 --- a/ShopifySharp/Filters/CountryCountFilter.cs +++ b/ShopifySharp/Filters/CountryCountFilter.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class CountryCountFilter : Parameterizable { - public class CountryCountFilter : Parameterizable - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } - } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/CountryListFilter.cs b/ShopifySharp/Filters/CountryListFilter.cs index d8b94bdd..aff5578b 100644 --- a/ShopifySharp/Filters/CountryListFilter.cs +++ b/ShopifySharp/Filters/CountryListFilter.cs @@ -1,16 +1,15 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering lists of Countries. +/// +public class CountryListFilter : ListFilter { /// - /// Options for filtering lists of Countries. + /// Restrict results to after the specified ID. /// - public class CountryListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } - } -} + [JsonProperty("since_id")] + public long? SinceId { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/CustomCollectionCountFilter.cs b/ShopifySharp/Filters/CustomCollectionCountFilter.cs index 07e21785..90df1358 100644 --- a/ShopifySharp/Filters/CustomCollectionCountFilter.cs +++ b/ShopifySharp/Filters/CustomCollectionCountFilter.cs @@ -1,50 +1,49 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class CustomCollectionCountFilter : Parameterizable { - public class CustomCollectionCountFilter : Parameterizable - { - /// - /// Restricts results to those with given title - /// - [JsonProperty("title")] - public string Title { get; set; } + /// + /// Restricts results to those with given title + /// + [JsonProperty("title")] + public string Title { get; set; } - /// - /// Restricts results to those that includes given product - /// - [JsonProperty("product_id")] - public long? ProductId { get; set; } + /// + /// Restricts results to those that includes given product + /// + [JsonProperty("product_id")] + public long? ProductId { get; set; } - /// - /// Restricts results to those last updated after date. - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Restricts results to those last updated after date. + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Restricts results to those last updated before date. - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } + /// + /// Restricts results to those last updated before date. + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } - /// - /// Restricts results to those published after date. - /// - [JsonProperty("published_at_min")] - public DateTimeOffset? PublishedAtMin { get; set; } + /// + /// Restricts results to those published after date. + /// + [JsonProperty("published_at_min")] + public DateTimeOffset? PublishedAtMin { get; set; } - /// - /// Restricts results to those published before date. - /// - [JsonProperty("published_at_max")] - public DateTimeOffset? PublishedAtMax { get; set; } + /// + /// Restricts results to those published before date. + /// + [JsonProperty("published_at_max")] + public DateTimeOffset? PublishedAtMax { get; set; } - /// - /// Restricts results to those with the given published status. Known values: published, unpublished, any. Default: any. - /// - [JsonProperty("published_status")] - public string PublishedStatus { get; set; } - } + /// + /// Restricts results to those with the given published status. Known values: published, unpublished, any. Default: any. + /// + [JsonProperty("published_status")] + public string PublishedStatus { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/CustomCollectionListFilter.cs b/ShopifySharp/Filters/CustomCollectionListFilter.cs index 6f9bf4ed..660da5ee 100644 --- a/ShopifySharp/Filters/CustomCollectionListFilter.cs +++ b/ShopifySharp/Filters/CustomCollectionListFilter.cs @@ -2,53 +2,52 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering custom collection lists. +/// +public class CustomCollectionListFilter : ListFilter { /// - /// Options for filtering custom collection lists. + /// Restrict results to after the specified ID. /// - public class CustomCollectionListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Show smart collections with given title - /// - [JsonProperty("title")] - public string Title { get; set; } + /// + /// Show smart collections with given title + /// + [JsonProperty("title")] + public string Title { get; set; } - /// - /// Show smart collections that includes given product - /// - [JsonProperty("product_id")] - public long? ProductId { get; set; } + /// + /// Show smart collections that includes given product + /// + [JsonProperty("product_id")] + public long? ProductId { get; set; } - /// - /// Filter by smart collection handle - /// - [JsonProperty("handle")] - public string Handle { get; set; } + /// + /// Filter by smart collection handle + /// + [JsonProperty("handle")] + public string Handle { get; set; } - [JsonProperty("ids")] - public IEnumerable Ids { get; set; } + [JsonProperty("ids")] + public IEnumerable Ids { get; set; } - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } - [JsonProperty("published_at_min")] - public DateTimeOffset? PublishedAtMin { get; set; } + [JsonProperty("published_at_min")] + public DateTimeOffset? PublishedAtMin { get; set; } - [JsonProperty("published_at_max")] - public DateTimeOffset? PublishedAtMax { get; set; } + [JsonProperty("published_at_max")] + public DateTimeOffset? PublishedAtMax { get; set; } - [JsonProperty("published_status")] - public string PublishedStatus { get; set; } - } -} + [JsonProperty("published_status")] + public string PublishedStatus { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/CustomerListFilter.cs b/ShopifySharp/Filters/CustomerListFilter.cs index 159770c2..c06d1623 100644 --- a/ShopifySharp/Filters/CustomerListFilter.cs +++ b/ShopifySharp/Filters/CustomerListFilter.cs @@ -2,32 +2,31 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class CustomerListFilter : ListFilter { - public class CustomerListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Retrieve only those specified by a comma-separated list of order IDs. - /// - [JsonProperty("ids")] - public IEnumerable Ids { get; set; } + /// + /// Retrieve only those specified by a comma-separated list of order IDs. + /// + [JsonProperty("ids")] + public IEnumerable Ids { get; set; } - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } - } + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/CustomerOrderListFilter.cs b/ShopifySharp/Filters/CustomerOrderListFilter.cs index c973d494..7f434ab0 100644 --- a/ShopifySharp/Filters/CustomerOrderListFilter.cs +++ b/ShopifySharp/Filters/CustomerOrderListFilter.cs @@ -1,14 +1,13 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class CustomerOrderListFilter : Parameterizable { - public class CustomerOrderListFilter : Parameterizable - { - /// - /// Restricts results to those with the given status. Known values are "open", "closed", "cancelled" and "any". - /// - [JsonProperty("status"), Obsolete("This filter property is undocumented, and Shopify may remove support for it at any time. Use with caution.")] - public string Status { get; set; } - } + /// + /// Restricts results to those with the given status. Known values are "open", "closed", "cancelled" and "any". + /// + [JsonProperty("status"), Obsolete("This filter property is undocumented, and Shopify may remove support for it at any time. Use with caution.")] + public string Status { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/CustomerSearchListFilter.cs b/ShopifySharp/Filters/CustomerSearchListFilter.cs index 72566695..909bc25e 100644 --- a/ShopifySharp/Filters/CustomerSearchListFilter.cs +++ b/ShopifySharp/Filters/CustomerSearchListFilter.cs @@ -1,19 +1,18 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class CustomerSearchListFilter : ListFilter { - public class CustomerSearchListFilter : ListFilter - { - /// - /// Set the field and direction by which to order results, e.g. "last_order_date DESC". - /// - [JsonProperty("order")] - public string Order { get; set; } + /// + /// Set the field and direction by which to order results, e.g. "last_order_date DESC". + /// + [JsonProperty("order")] + public string Order { get; set; } - /// - /// Text to search for in the shop's customer data. - /// - [JsonProperty("query")] - public string Query { get; set; } - } + /// + /// Text to search for in the shop's customer data. + /// + [JsonProperty("query")] + public string Query { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/DraftOrderCountFilter.cs b/ShopifySharp/Filters/DraftOrderCountFilter.cs index 0198d20f..fc35f8f8 100644 --- a/ShopifySharp/Filters/DraftOrderCountFilter.cs +++ b/ShopifySharp/Filters/DraftOrderCountFilter.cs @@ -1,32 +1,31 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class DraftOrderCountFilter : Parameterizable { - public class DraftOrderCountFilter : Parameterizable - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Restricts results to those last updated after date. - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Restricts results to those last updated after date. + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Restricts results to those last updated before date. - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } + /// + /// Restricts results to those last updated before date. + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } - /// - /// Only return orders with the given status. Known values are "open" (default), "invoice_sent", and "completed". - /// - [JsonProperty("status")] - public string Status { get; set; } - } + /// + /// Only return orders with the given status. Known values are "open" (default), "invoice_sent", and "completed". + /// + [JsonProperty("status")] + public string Status { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/DraftOrderListFilter.cs b/ShopifySharp/Filters/DraftOrderListFilter.cs index b92f2477..b49c5268 100644 --- a/ShopifySharp/Filters/DraftOrderListFilter.cs +++ b/ShopifySharp/Filters/DraftOrderListFilter.cs @@ -2,38 +2,37 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class DraftOrderListFilter : ListFilter { - public class DraftOrderListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Retrieve only those specified by a comma-separated list of order IDs. - /// - [JsonProperty("ids")] - public IEnumerable Ids { get; set; } + /// + /// Retrieve only those specified by a comma-separated list of order IDs. + /// + [JsonProperty("ids")] + public IEnumerable Ids { get; set; } - /// - /// Only return orders with the given status. Known values are "open" (default), "invoice_sent", and "completed". - /// - [JsonProperty("status")] - public string Status { get; set; } + /// + /// Only return orders with the given status. Known values are "open" (default), "invoice_sent", and "completed". + /// + [JsonProperty("status")] + public string Status { get; set; } - /// - /// Restricts results to those last updated after date (format: 2008-12-31 03:00). - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Restricts results to those last updated after date (format: 2008-12-31 03:00). + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Restricts results to those last updated before date (format: 2008-12-31 03:00). - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } - } + /// + /// Restricts results to those last updated before date (format: 2008-12-31 03:00). + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/EventCountFilter.cs b/ShopifySharp/Filters/EventCountFilter.cs index 30b2bca4..ea7422f5 100644 --- a/ShopifySharp/Filters/EventCountFilter.cs +++ b/ShopifySharp/Filters/EventCountFilter.cs @@ -1,20 +1,19 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class EventCountFilter : Parameterizable { - public class EventCountFilter : Parameterizable - { - /// - /// Show events created at or after date and time - /// - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } + /// + /// Show events created at or after date and time + /// + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } - /// - /// Show events created at or before date and time - /// - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } - } + /// + /// Show events created at or before date and time + /// + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/EventListFilter.cs b/ShopifySharp/Filters/EventListFilter.cs index 0e3aaf91..bc249625 100644 --- a/ShopifySharp/Filters/EventListFilter.cs +++ b/ShopifySharp/Filters/EventListFilter.cs @@ -1,41 +1,40 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// A generic class for filtering the results of a .CountAsync command. +/// +public class EventListFilter : ListFilter { /// - /// A generic class for filtering the results of a .CountAsync command. + /// Restrict results to after the specified ID /// - public class EventListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Show events created at or after date and time - /// - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } + /// + /// Show events created at or after date and time + /// + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } - /// - /// Show events created at or before date and time - /// - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } + /// + /// Show events created at or before date and time + /// + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } - /// - /// Only show events specified in filter (comma , separated). A full list of events can be found at https://help.shopify.com/api/reference/event - /// - [JsonProperty("filter")] - public string Filter { get; set; } + /// + /// Only show events specified in filter (comma , separated). A full list of events can be found at https://help.shopify.com/api/reference/event + /// + [JsonProperty("filter")] + public string Filter { get; set; } - /// - /// Only show events of a certain kind (comma , separated). A full list of events can be found at https://help.shopify.com/api/reference/event - /// - [JsonProperty("verb")] - public string Verbs { get; set; } - } -} + /// + /// Only show events of a certain kind (comma , separated). A full list of events can be found at https://help.shopify.com/api/reference/event + /// + [JsonProperty("verb")] + public string Verbs { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/FulfillmentCountFilter.cs b/ShopifySharp/Filters/FulfillmentCountFilter.cs index 3a724492..c64049d5 100644 --- a/ShopifySharp/Filters/FulfillmentCountFilter.cs +++ b/ShopifySharp/Filters/FulfillmentCountFilter.cs @@ -1,32 +1,31 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class FulfillmentCountFilter : Parameterizable { - public class FulfillmentCountFilter : Parameterizable - { - /// - /// Restricts results to those last updated after date and time. - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Restricts results to those last updated after date and time. + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Restricts results to those last updated before date and time. - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } + /// + /// Restricts results to those last updated before date and time. + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } - /// - /// Restricts results to those created at or after date and time. - /// - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } + /// + /// Restricts results to those created at or after date and time. + /// + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } - /// - /// Restricts results to those created at or before date and time. - /// - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } - } + /// + /// Restricts results to those created at or before date and time. + /// + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/FulfillmentListFilter.cs b/ShopifySharp/Filters/FulfillmentListFilter.cs index f1f64e28..f2e2125e 100644 --- a/ShopifySharp/Filters/FulfillmentListFilter.cs +++ b/ShopifySharp/Filters/FulfillmentListFilter.cs @@ -1,26 +1,25 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class FulfillmentListFilter : ListFilter { - public class FulfillmentListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + /// + /// Restrict results to after the specified ID + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } - } + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/FulfillmentServiceListFilter.cs b/ShopifySharp/Filters/FulfillmentServiceListFilter.cs index c758bb72..934ee400 100644 --- a/ShopifySharp/Filters/FulfillmentServiceListFilter.cs +++ b/ShopifySharp/Filters/FulfillmentServiceListFilter.cs @@ -1,21 +1,20 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class FulfillmentServiceListFilter : Parameterizable { - public class FulfillmentServiceListFilter : Parameterizable - { - /// - /// - /// Restricts results to those with the given scope value. Known values: - /// - /// - /// "current_client": Returns fulfillment providers that have been created by the app sending the request (default) - /// - /// - /// "all": Returns all the fulfillment providers - /// - /// - [JsonProperty("scope")] - public string Scope { get; set; } - } + /// + /// + /// Restricts results to those with the given scope value. Known values: + /// + /// + /// "current_client": Returns fulfillment providers that have been created by the app sending the request (default) + /// + /// + /// "all": Returns all the fulfillment providers + /// + /// + [JsonProperty("scope")] + public string Scope { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/GiftCardCountFilter.cs b/ShopifySharp/Filters/GiftCardCountFilter.cs index fb3817b3..295a8e53 100644 --- a/ShopifySharp/Filters/GiftCardCountFilter.cs +++ b/ShopifySharp/Filters/GiftCardCountFilter.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class GiftCardCountFilter : Parameterizable { - public class GiftCardCountFilter : Parameterizable - { - /// - /// Restricts results to those with the given status. Known values are "enabled", "disabled". - /// - [JsonProperty("status")] - public string Status { get; set; } - } + /// + /// Restricts results to those with the given status. Known values are "enabled", "disabled". + /// + [JsonProperty("status")] + public string Status { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/GiftCardListFilter.cs b/ShopifySharp/Filters/GiftCardListFilter.cs index 8320adb6..9b6970aa 100644 --- a/ShopifySharp/Filters/GiftCardListFilter.cs +++ b/ShopifySharp/Filters/GiftCardListFilter.cs @@ -1,22 +1,21 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering gift cards. +/// +public class GiftCardListFilter : ListFilter { /// - /// Options for filtering gift cards. + /// Restrict results to after the specified ID /// - public class GiftCardListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Restricts results to those with the given status. Known values are "enabled", "disabled". - /// - [JsonProperty("status")] - public string Status { get; set; } - } -} + /// + /// Restricts results to those with the given status. Known values are "enabled", "disabled". + /// + [JsonProperty("status")] + public string Status { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/GiftCardSearchFilter.cs b/ShopifySharp/Filters/GiftCardSearchFilter.cs index 4d37deae..964c269f 100644 --- a/ShopifySharp/Filters/GiftCardSearchFilter.cs +++ b/ShopifySharp/Filters/GiftCardSearchFilter.cs @@ -1,45 +1,44 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class GiftCardSearchFilter : ListFilter { - public class GiftCardSearchFilter : ListFilter - { - /// - /// The field and direction to order results by. - /// Default: `disabled_at DESC` - /// - [JsonProperty("order")] - public string Order { get; set; } + /// + /// The field and direction to order results by. + /// Default: `disabled_at DESC` + /// + [JsonProperty("order")] + public string Order { get; set; } - /// - /// The text to search for. - /// - [JsonProperty("query")] - public string Query { get; set; } + /// + /// The text to search for. + /// + [JsonProperty("query")] + public string Query { get; set; } - /// - /// Restricts results to those created after date (format: 2008-12-31 03:00). - /// - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } + /// + /// Restricts results to those created after date (format: 2008-12-31 03:00). + /// + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } - /// - /// Restricts results to those created before date (format: 2008-12-31 03:00). - /// - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } + /// + /// Restricts results to those created before date (format: 2008-12-31 03:00). + /// + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } - /// - /// Restricts results to those last updated after date (format: 2008-12-31 03:00). - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Restricts results to those last updated after date (format: 2008-12-31 03:00). + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Restricts results to those last updated before date (format: 2008-12-31 03:00). - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } - } + /// + /// Restricts results to those last updated before date (format: 2008-12-31 03:00). + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/InventoryItemListFilter.cs b/ShopifySharp/Filters/InventoryItemListFilter.cs index 2dd99c78..eec3d020 100644 --- a/ShopifySharp/Filters/InventoryItemListFilter.cs +++ b/ShopifySharp/Filters/InventoryItemListFilter.cs @@ -1,14 +1,13 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System.Collections.Generic; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class InventoryItemListFilter : ListFilter { - public class InventoryItemListFilter : ListFilter - { - /// - /// Show only inventory items specified by a comma-separated list of IDs. - /// - [JsonProperty("ids")] - public IEnumerable Ids { get; set; } - } -} + /// + /// Show only inventory items specified by a comma-separated list of IDs. + /// + [JsonProperty("ids")] + public IEnumerable Ids { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/InventoryLevelListFilter.cs b/ShopifySharp/Filters/InventoryLevelListFilter.cs index 7f2f6931..86d4babc 100644 --- a/ShopifySharp/Filters/InventoryLevelListFilter.cs +++ b/ShopifySharp/Filters/InventoryLevelListFilter.cs @@ -1,21 +1,20 @@ -using System; +using System; using Newtonsoft.Json; using System.Collections.Generic; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// You **must** include InventoryItemIds, LocationIds, or both as filter parameters. +/// +public class InventoryLevelListFilter : ListFilter { - /// - /// You **must** include InventoryItemIds, LocationIds, or both as filter parameters. - /// - public class InventoryLevelListFilter : ListFilter - { - [JsonProperty("inventory_item_ids")] - public IEnumerable InventoryItemIds { get; set; } + [JsonProperty("inventory_item_ids")] + public IEnumerable InventoryItemIds { get; set; } - [JsonProperty("location_ids")] - public IEnumerable LocationIds { get; set; } + [JsonProperty("location_ids")] + public IEnumerable LocationIds { get; set; } - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } - } -} + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/ListFilter.cs b/ShopifySharp/Filters/ListFilter.cs index 8e2a9d89..53a0556c 100644 --- a/ShopifySharp/Filters/ListFilter.cs +++ b/ShopifySharp/Filters/ListFilter.cs @@ -1,49 +1,48 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// A generic class for filtering the results of a .ListAsync command. +/// +public class ListFilter : Parameterizable { /// - /// A generic class for filtering the results of a .ListAsync command. + /// A unique ID used to access a page of results. Must be present to list more than the first page of results. /// - public class ListFilter : Parameterizable - { - /// - /// A unique ID used to access a page of results. Must be present to list more than the first page of results. - /// - [JsonProperty("page_info")] - public string PageInfo { get; } + [JsonProperty("page_info")] + public string PageInfo { get; } - /// - /// The number of items which should be returned. Default is 50, maximum is 250. - /// - [JsonProperty("limit")] - public int? Limit { get; set; } + /// + /// The number of items which should be returned. Default is 50, maximum is 250. + /// + [JsonProperty("limit")] + public int? Limit { get; set; } - /// - /// Comma-separated list of which fields to show in the results. This parameter only works for some endpoints. - /// - [JsonProperty("fields")] - public string Fields { get; set; } + /// + /// Comma-separated list of which fields to show in the results. This parameter only works for some endpoints. + /// + [JsonProperty("fields")] + public string Fields { get; set; } - /// - /// This constructor is protected to prevent developers from using `new ListFilter()`, but to make creating your - /// own ListFilter easier. - /// https://github.com/nozzlegear/shopifysharp/issues/515 - /// - protected ListFilter() - { + /// + /// This constructor is protected to prevent developers from using `new ListFilter()`, but to make creating your + /// own ListFilter easier. + /// https://github.com/nozzlegear/shopifysharp/issues/515 + /// + protected ListFilter() + { - } + } - public ListFilter(string pageInfo, int? limit, string fields = null) - { - PageInfo = pageInfo; - Limit = limit; - Fields = fields; - } + public ListFilter(string pageInfo, int? limit, string fields = null) + { + PageInfo = pageInfo; + Limit = limit; + Fields = fields; + } - public ListFilter AsListFilter() => this; + public ListFilter AsListFilter() => this; - public static readonly ListFilter Empty = new ListFilter(); - } -} + public static readonly ListFilter Empty = new ListFilter(); +} \ No newline at end of file diff --git a/ShopifySharp/Filters/LocationListFilter.cs b/ShopifySharp/Filters/LocationListFilter.cs index 5f977d77..82844379 100644 --- a/ShopifySharp/Filters/LocationListFilter.cs +++ b/ShopifySharp/Filters/LocationListFilter.cs @@ -1,6 +1,5 @@ -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class LocationListFilter : ListFilter { - public class LocationListFilter : ListFilter - { - } } \ No newline at end of file diff --git a/ShopifySharp/Filters/MetaFieldFilter.cs b/ShopifySharp/Filters/MetaFieldFilter.cs index 92b02386..aaf6195d 100644 --- a/ShopifySharp/Filters/MetaFieldFilter.cs +++ b/ShopifySharp/Filters/MetaFieldFilter.cs @@ -1,54 +1,53 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering and +/// results. +/// +public class MetaFieldFilter : ListFilter { /// - /// Options for filtering and - /// results. + /// Filter by namespace. + /// + [JsonProperty("namespace")] + public string Namespace { get; set; } + + /// + /// Filter by key value. + /// + [JsonProperty("key")] + public string Key { get; set; } + + /// + /// Filter by value_type. + /// + [JsonProperty("value_type")] + public string ValueType { get; set; } + + /// + /// Show metafields created after date + /// + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } + + /// + /// Show metafields created before date + /// + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } + + /// + /// Show metafields last updated after date + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } + + /// + /// Show metafields last updated before date /// - public class MetaFieldFilter : ListFilter - { - /// - /// Filter by namespace. - /// - [JsonProperty("namespace")] - public string Namespace { get; set; } - - /// - /// Filter by key value. - /// - [JsonProperty("key")] - public string Key { get; set; } - - /// - /// Filter by value_type. - /// - [JsonProperty("value_type")] - public string ValueType { get; set; } - - /// - /// Show metafields created after date - /// - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } - - /// - /// Show metafields created before date - /// - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } - - /// - /// Show metafields last updated after date - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } - - /// - /// Show metafields last updated before date - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } - } -} + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/OrderCountFilter.cs b/ShopifySharp/Filters/OrderCountFilter.cs index 946bce98..55488658 100644 --- a/ShopifySharp/Filters/OrderCountFilter.cs +++ b/ShopifySharp/Filters/OrderCountFilter.cs @@ -1,68 +1,67 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class OrderCountFilter : Parameterizable { - public class OrderCountFilter : Parameterizable - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Restricts results to those with the given status. Known values are "open", "closed", "cancelled" and "any". - /// - [JsonProperty("status")] - public string Status { get; set; } + /// + /// Restricts results to those with the given status. Known values are "open", "closed", "cancelled" and "any". + /// + [JsonProperty("status")] + public string Status { get; set; } - /// - /// Restricts results to those with the given financial status. Known values are "authorized", "paid", "pending", "partially_paid", "partially_refunded", "refunded" and "voided". - /// - [JsonProperty("financial_status")] - public string FinancialStatus { get; set; } + /// + /// Restricts results to those with the given financial status. Known values are "authorized", "paid", "pending", "partially_paid", "partially_refunded", "refunded" and "voided". + /// + [JsonProperty("financial_status")] + public string FinancialStatus { get; set; } - /// - /// Restricts results to those with the given fulfillment status. Known values are "shipped", "partial", "unshipped", "any" and "unfulfilled". Default: any. - /// - [JsonProperty("fulfillment_status")] - public string FulfillmentStatus { get; set; } + /// + /// Restricts results to those with the given fulfillment status. Known values are "shipped", "partial", "unshipped", "any" and "unfulfilled". Default: any. + /// + [JsonProperty("fulfillment_status")] + public string FulfillmentStatus { get; set; } - /// - /// Restrict results to those created at or after date. - /// - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } + /// + /// Restrict results to those created at or after date. + /// + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } - /// - /// Restrict results to those created at or after date. - /// - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } + /// + /// Restrict results to those created at or after date. + /// + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } - /// - /// Restrict results to those created at or before date. - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Restrict results to those created at or before date. + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Restrict results to those last updated at or before date. - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } + /// + /// Restrict results to those last updated at or before date. + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } - /// - /// Restrict results to those processed at or before date. - /// - [JsonProperty("processed_at_min")] - public DateTimeOffset? ProcessedAtMin { get; set; } + /// + /// Restrict results to those processed at or before date. + /// + [JsonProperty("processed_at_min")] + public DateTimeOffset? ProcessedAtMin { get; set; } - /// - /// Restrict results to those last processed at or before date. - /// - [JsonProperty("processed_at_max")] - public DateTimeOffset? ProcessedAtMax { get; set; } - } + /// + /// Restrict results to those last processed at or before date. + /// + [JsonProperty("processed_at_max")] + public DateTimeOffset? ProcessedAtMax { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/OrderListFilter.cs b/ShopifySharp/Filters/OrderListFilter.cs index f80b90f8..06112032 100644 --- a/ShopifySharp/Filters/OrderListFilter.cs +++ b/ShopifySharp/Filters/OrderListFilter.cs @@ -1,84 +1,83 @@ -using System; +using System; using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering lists of orders. +/// +public class OrderListFilter : ListFilter { /// - /// Options for filtering lists of orders. + /// Restricts results to those with the given status. Known values are "open", "closed", "cancelled" and "any". /// - public class OrderListFilter : ListFilter - { - /// - /// Restricts results to those with the given status. Known values are "open", "closed", "cancelled" and "any". - /// - [JsonProperty("status")] - public string Status { get; set; } + [JsonProperty("status")] + public string Status { get; set; } - /// - /// Restricts results to those with the given financial status. Known values are "authorized", "paid", "pending", "partially_paid", "partially_refunded", "refunded" and "voided". - /// - [JsonProperty("financial_status")] - public string FinancialStatus { get; set; } + /// + /// Restricts results to those with the given financial status. Known values are "authorized", "paid", "pending", "partially_paid", "partially_refunded", "refunded" and "voided". + /// + [JsonProperty("financial_status")] + public string FinancialStatus { get; set; } - /// - /// Restricts results to those with the given fulfillment status. Known values are "shipped", "partial", "unshipped", "any" and "unfulfilled". Default: any. - /// - [JsonProperty("fulfillment_status")] - public string FulfillmentStatus { get; set; } + /// + /// Restricts results to those with the given fulfillment status. Known values are "shipped", "partial", "unshipped", "any" and "unfulfilled". Default: any. + /// + [JsonProperty("fulfillment_status")] + public string FulfillmentStatus { get; set; } - /// - /// Restrict results to those created at or after date. - /// - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } + /// + /// Restrict results to those created at or after date. + /// + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } - /// - /// Restrict results to those created at or after date. - /// - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } + /// + /// Restrict results to those created at or after date. + /// + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } - /// - /// Restrict results to those created at or before date. - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Restrict results to those created at or before date. + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Restrict results to those last updated at or before date. - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } + /// + /// Restrict results to those last updated at or before date. + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } - /// - /// Show orders imported after date. - /// - [JsonProperty("processed_at_min")] - public DateTimeOffset? ProcessedAtMin { get; set; } + /// + /// Show orders imported after date. + /// + [JsonProperty("processed_at_min")] + public DateTimeOffset? ProcessedAtMin { get; set; } - /// - /// Show orders imported before date. - /// - [JsonProperty("processed_at_max")] - public DateTimeOffset? ProcessedAtMax { get; set; } + /// + /// Show orders imported before date. + /// + [JsonProperty("processed_at_max")] + public DateTimeOffset? ProcessedAtMax { get; set; } - /// - /// Show orders attributed to a specific app. Valid values are the app ID to filter on (eg. 123) or a value of "current" to only show orders for the app currently consuming the API. - /// - [JsonProperty("attribution_app_id")] - public string AttributionAppId { get; set; } + /// + /// Show orders attributed to a specific app. Valid values are the app ID to filter on (eg. 123) or a value of "current" to only show orders for the app currently consuming the API. + /// + [JsonProperty("attribution_app_id")] + public string AttributionAppId { get; set; } - /// - /// Retrieve only orders specified by a comma-separated list of order IDs. - /// - [JsonProperty("ids")] - public IEnumerable Ids { get; set; } + /// + /// Retrieve only orders specified by a comma-separated list of order IDs. + /// + [JsonProperty("ids")] + public IEnumerable Ids { get; set; } - /// - /// Retrieve only orders specified by a comma-separated list of order IDs. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } - } -} + /// + /// Retrieve only orders specified by a comma-separated list of order IDs. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/PageCountFilter.cs b/ShopifySharp/Filters/PageCountFilter.cs index 4c29907b..ce592683 100644 --- a/ShopifySharp/Filters/PageCountFilter.cs +++ b/ShopifySharp/Filters/PageCountFilter.cs @@ -1,56 +1,55 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class PageCountFilter : Parameterizable { - public class PageCountFilter : Parameterizable - { - /// - /// Filter by page title. - /// - [JsonProperty("title")] - public string Title { get; set; } + /// + /// Filter by page title. + /// + [JsonProperty("title")] + public string Title { get; set; } - /// - /// Restrict results to those created at or after date. - /// - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } + /// + /// Restrict results to those created at or after date. + /// + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } - /// - /// Restrict results to those created at or after date. - /// - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } + /// + /// Restrict results to those created at or after date. + /// + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } - /// - /// Restrict results to those created at or before date. - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Restrict results to those created at or before date. + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Restrict results to those last updated at or before date. - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } + /// + /// Restrict results to those last updated at or before date. + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } - /// - /// Restricts results to those published after date. - /// - [JsonProperty("published_at_min")] - public DateTimeOffset? PublishedAtMin { get; set; } + /// + /// Restricts results to those published after date. + /// + [JsonProperty("published_at_min")] + public DateTimeOffset? PublishedAtMin { get; set; } - /// - /// Restricts results to those published before date. - /// - [JsonProperty("published_at_max")] - public DateTimeOffset? PublishedAtMax { get; set; } + /// + /// Restricts results to those published before date. + /// + [JsonProperty("published_at_max")] + public DateTimeOffset? PublishedAtMax { get; set; } - /// - /// Restricts results to those with the given published status. Known values: published, unpublished, any. Default: any. - /// - [JsonProperty("published_status")] - public string PublishedStatus { get; set; } - } + /// + /// Restricts results to those with the given published status. Known values: published, unpublished, any. Default: any. + /// + [JsonProperty("published_status")] + public string PublishedStatus { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/PageListFilter.cs b/ShopifySharp/Filters/PageListFilter.cs index b38a9d87..1661c3eb 100644 --- a/ShopifySharp/Filters/PageListFilter.cs +++ b/ShopifySharp/Filters/PageListFilter.cs @@ -1,71 +1,70 @@ -using System; +using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering lists of Pages. +/// +public class PageListFilter : ListFilter { /// - /// Options for filtering lists of Pages. + /// Filter by page title. /// - public class PageListFilter : ListFilter - { - /// - /// Filter by page title. - /// - [JsonProperty("title")] - public string Title { get; set; } + [JsonProperty("title")] + public string Title { get; set; } - /// - /// Filter by page handle. - /// - [JsonProperty("handle")] - public string Handle { get; set; } + /// + /// Filter by page handle. + /// + [JsonProperty("handle")] + public string Handle { get; set; } - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Show those created at or after date. - /// - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } + /// + /// Show those created at or after date. + /// + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } - /// - /// Show those created at or after date. - /// - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } + /// + /// Show those created at or after date. + /// + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } - /// - /// Show those updated at or before date. - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Show those updated at or before date. + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Show those last updated at or before date. - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } + /// + /// Show those last updated at or before date. + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } - /// - /// Show those published at or before date. - /// - [JsonProperty("published_at_min")] - public DateTimeOffset? PublishedAtMin { get; set; } + /// + /// Show those published at or before date. + /// + [JsonProperty("published_at_min")] + public DateTimeOffset? PublishedAtMin { get; set; } - /// - /// Show those last published at or before date. - /// - [JsonProperty("published_at_max")] - public DateTimeOffset? PublishedAtMax { get; set; } + /// + /// Show those last published at or before date. + /// + [JsonProperty("published_at_max")] + public DateTimeOffset? PublishedAtMax { get; set; } - /// - /// Restrict results to pages with a given published status. Known values: published, unpublished, any. Default: any. - /// - [JsonProperty("published_status")] - public string PublishedStatus { get; set; } - } -} + /// + /// Restrict results to pages with a given published status. Known values: published, unpublished, any. Default: any. + /// + [JsonProperty("published_status")] + public string PublishedStatus { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/PriceRuleDiscountCodeFilter.cs b/ShopifySharp/Filters/PriceRuleDiscountCodeFilter.cs index f0bb24d4..b69e2f1d 100644 --- a/ShopifySharp/Filters/PriceRuleDiscountCodeFilter.cs +++ b/ShopifySharp/Filters/PriceRuleDiscountCodeFilter.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// A filter for retrieving a single discount code. +/// +public class PriceRuleDiscountCodeFilter : Parameterizable { - /// - /// A filter for retrieving a single discount code. - /// - public class PriceRuleDiscountCodeFilter : Parameterizable - { - [JsonProperty("code")] - public string Code { get; set; } - } -} + [JsonProperty("code")] + public string Code { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/PriceRuleDiscountCodeListFilter.cs b/ShopifySharp/Filters/PriceRuleDiscountCodeListFilter.cs index b440dabc..0493ba2f 100644 --- a/ShopifySharp/Filters/PriceRuleDiscountCodeListFilter.cs +++ b/ShopifySharp/Filters/PriceRuleDiscountCodeListFilter.cs @@ -1,10 +1,9 @@ -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering lists of price rule discount codes. +/// +public class PriceRuleDiscountCodeListFilter : ListFilter { - /// - /// Options for filtering lists of price rule discount codes. - /// - public class PriceRuleDiscountCodeListFilter : ListFilter - { - } } \ No newline at end of file diff --git a/ShopifySharp/Filters/PriceRuleListFilter.cs b/ShopifySharp/Filters/PriceRuleListFilter.cs index 4761a28d..936a3c65 100644 --- a/ShopifySharp/Filters/PriceRuleListFilter.cs +++ b/ShopifySharp/Filters/PriceRuleListFilter.cs @@ -1,71 +1,70 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering lists of PriceRules. +/// +public class PriceRuleListFilter : ListFilter { /// - /// Options for filtering lists of PriceRules. + /// Restrict results to after the specified ID. /// - public class PriceRuleListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Restricts results to those created after date (format: 2008-12-31 03:00). - /// - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } + /// + /// Restricts results to those created after date (format: 2008-12-31 03:00). + /// + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } - /// - /// Restricts results to those created before date (format: 2008-12-31 03:00). - /// - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } + /// + /// Restricts results to those created before date (format: 2008-12-31 03:00). + /// + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } - /// - /// Restricts results to those last updated after date (format: 2008-12-31 03:00). - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Restricts results to those last updated after date (format: 2008-12-31 03:00). + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Restricts results to those last updated before date (format: 2008-12-31 03:00). - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } + /// + /// Restricts results to those last updated before date (format: 2008-12-31 03:00). + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } - /// - /// Show price rules starting after date. - /// - [JsonProperty("starts_at_min")] - public DateTimeOffset? StartsAtMin { get; set; } + /// + /// Show price rules starting after date. + /// + [JsonProperty("starts_at_min")] + public DateTimeOffset? StartsAtMin { get; set; } - /// - /// Show price rules starting before date. - /// - [JsonProperty("starts_at_max")] - public DateTimeOffset? StartsAtMax { get; set; } + /// + /// Show price rules starting before date. + /// + [JsonProperty("starts_at_max")] + public DateTimeOffset? StartsAtMax { get; set; } - /// - /// Show price rules ending after date. - /// - [JsonProperty("ends_at_min")] - public DateTimeOffset? EndsAtMin { get; set; } + /// + /// Show price rules ending after date. + /// + [JsonProperty("ends_at_min")] + public DateTimeOffset? EndsAtMin { get; set; } - /// - /// Show price rules ending before date. - /// - [JsonProperty("ends_at_max")] - public DateTimeOffset? EndsAtMax { get; set; } + /// + /// Show price rules ending before date. + /// + [JsonProperty("ends_at_max")] + public DateTimeOffset? EndsAtMax { get; set; } - /// - /// Show price rules with times used. - /// - [JsonProperty("times_used")] - public int? TimesUsed { get; set; } - } + /// + /// Show price rules with times used. + /// + [JsonProperty("times_used")] + public int? TimesUsed { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/ProductCountFilter.cs b/ShopifySharp/Filters/ProductCountFilter.cs index a3e0c1f7..ae7b3dae 100644 --- a/ShopifySharp/Filters/ProductCountFilter.cs +++ b/ShopifySharp/Filters/ProductCountFilter.cs @@ -1,68 +1,67 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class ProductCountFilter : Parameterizable { - public class ProductCountFilter : Parameterizable - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Filter by product type. - /// - [JsonProperty("product_type")] - public string ProductType { get; set; } + /// + /// Filter by product type. + /// + [JsonProperty("product_type")] + public string ProductType { get; set; } - /// - /// Filter by collection id. - /// - [JsonProperty("collection_id")] - public long? CollectionId { get; set; } + /// + /// Filter by collection id. + /// + [JsonProperty("collection_id")] + public long? CollectionId { get; set; } - /// - /// Filter by product vendor. - /// - [JsonProperty("vendor")] - public string Vendor { get; set; } + /// + /// Filter by product vendor. + /// + [JsonProperty("vendor")] + public string Vendor { get; set; } - /// - /// Restrict results to those created at or after date. - /// - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } + /// + /// Restrict results to those created at or after date. + /// + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } - /// - /// Restrict results to those created at or before date. - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Restrict results to those created at or before date. + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Restrict results to those last updated at or before date. - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } + /// + /// Restrict results to those last updated at or before date. + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } - /// - /// Restricts results to those published after date. - /// - [JsonProperty("published_at_min")] - public DateTimeOffset? PublishedAtMin { get; set; } + /// + /// Restricts results to those published after date. + /// + [JsonProperty("published_at_min")] + public DateTimeOffset? PublishedAtMin { get; set; } - /// - /// Restricts results to those published before date. - /// - [JsonProperty("published_at_max")] - public DateTimeOffset? PublishedAtMax { get; set; } + /// + /// Restricts results to those published before date. + /// + [JsonProperty("published_at_max")] + public DateTimeOffset? PublishedAtMax { get; set; } - /// - /// Restricts results to those with the given published status. Known values: published, unpublished, any. Default: any. - /// - [JsonProperty("published_status")] - public string PublishedStatus { get; set; } - } + /// + /// Restricts results to those with the given published status. Known values: published, unpublished, any. Default: any. + /// + [JsonProperty("published_status")] + public string PublishedStatus { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/ProductImageCountFilter.cs b/ShopifySharp/Filters/ProductImageCountFilter.cs index 295bd213..477fce9d 100644 --- a/ShopifySharp/Filters/ProductImageCountFilter.cs +++ b/ShopifySharp/Filters/ProductImageCountFilter.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class ProductImageCountFilter : Parameterizable { - public class ProductImageCountFilter : Parameterizable - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } - } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/ProductListFilter.cs b/ShopifySharp/Filters/ProductListFilter.cs index da98a27d..dff2b32a 100644 --- a/ShopifySharp/Filters/ProductListFilter.cs +++ b/ShopifySharp/Filters/ProductListFilter.cs @@ -1,111 +1,110 @@ -using System; +using System; using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering lists of Products. +/// +public class ProductListFilter : ListFilter { /// - /// Options for filtering lists of Products. + /// Restrict results to after the specified ID. /// - public class ProductListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Filter by product title. - /// - [JsonProperty("title")] - public string Title { get; set; } + /// + /// Filter by product title. + /// + [JsonProperty("title")] + public string Title { get; set; } - /// - /// Filter by product vendor. - /// - [JsonProperty("vendor")] - public string Vendor { get; set; } + /// + /// Filter by product vendor. + /// + [JsonProperty("vendor")] + public string Vendor { get; set; } - /// - /// Filter by product handle. - /// - [JsonProperty("handle")] - public string Handle { get; set; } + /// + /// Filter by product handle. + /// + [JsonProperty("handle")] + public string Handle { get; set; } - /// - /// Filter by product type. - /// - [JsonProperty("product_type")] - public string ProductType { get; set; } + /// + /// Filter by product type. + /// + [JsonProperty("product_type")] + public string ProductType { get; set; } - /// - /// The status of the product. Valid Values: - /// active: The product is ready to sell and is available to customers on the online store, sales channels, and apps. By default, existing products are set to active. - /// archived: The product is no longer being sold and isn't available to customers on sales channels and apps. - /// draft: The product isn't ready to sell and is unavailable to customers on sales channels and apps. By default, duplicated and unarchived products are set to draft. - /// - [JsonProperty("status")] - public string Status { get; set; } + /// + /// The status of the product. Valid Values: + /// active: The product is ready to sell and is available to customers on the online store, sales channels, and apps. By default, existing products are set to active. + /// archived: The product is no longer being sold and isn't available to customers on sales channels and apps. + /// draft: The product isn't ready to sell and is unavailable to customers on sales channels and apps. By default, duplicated and unarchived products are set to draft. + /// + [JsonProperty("status")] + public string Status { get; set; } - /// - /// Filter by collection id. - /// - [JsonProperty("collection_id")] - public long? CollectionId { get; set; } + /// + /// Filter by collection id. + /// + [JsonProperty("collection_id")] + public long? CollectionId { get; set; } - /// - /// Show those created at or after date. - /// - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } + /// + /// Show those created at or after date. + /// + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } - /// - /// Show those created at or after date. - /// - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } + /// + /// Show those created at or after date. + /// + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } - /// - /// Show those updated at or before date. - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Show those updated at or before date. + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Show those last updated at or before date. - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } + /// + /// Show those last updated at or before date. + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } - /// - /// Show those published at or before date. - /// - [JsonProperty("published_at_min")] - public DateTimeOffset? PublishedAtMin { get; set; } + /// + /// Show those published at or before date. + /// + [JsonProperty("published_at_min")] + public DateTimeOffset? PublishedAtMin { get; set; } - /// - /// Show those last published at or before date. - /// - [JsonProperty("published_at_max")] - public DateTimeOffset? PublishedAtMax { get; set; } + /// + /// Show those last published at or before date. + /// + [JsonProperty("published_at_max")] + public DateTimeOffset? PublishedAtMax { get; set; } - /// - /// Restricts results to those with the given published status. Known values: published, unpublished, any. Default: any. - /// - [JsonProperty("published_status")] - public string PublishedStatus { get; set; } + /// + /// Restricts results to those with the given published status. Known values: published, unpublished, any. Default: any. + /// + [JsonProperty("published_status")] + public string PublishedStatus { get; set; } - /// - /// Return presentment prices in only certain currencies. Each entry must be an ISO 4217 valid currency code. - /// - [JsonProperty("presentment_currencies")] - public IEnumerable PresentmentCurrencies { get; set; } + /// + /// Return presentment prices in only certain currencies. Each entry must be an ISO 4217 valid currency code. + /// + [JsonProperty("presentment_currencies")] + public IEnumerable PresentmentCurrencies { get; set; } - /// - /// Retrieve only those specified by a comma-separated list of order IDs. - /// - [JsonProperty("ids")] - public IEnumerable Ids { get; set; } - } -} + /// + /// Retrieve only those specified by a comma-separated list of order IDs. + /// + [JsonProperty("ids")] + public IEnumerable Ids { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/ProductListingListFilter.cs b/ShopifySharp/Filters/ProductListingListFilter.cs index e299f1cf..d32fc96d 100644 --- a/ShopifySharp/Filters/ProductListingListFilter.cs +++ b/ShopifySharp/Filters/ProductListingListFilter.cs @@ -1,35 +1,34 @@ -using System; +using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering lists of ProductListings. +/// +public class ProductListingListFilter : ListFilter { /// - /// Options for filtering lists of ProductListings. + /// Filter by collection id. /// - public class ProductListingListFilter : ListFilter - { - /// - /// Filter by collection id. - /// - [JsonProperty("collection_id")] - public long? CollectionId { get; set; } + [JsonProperty("collection_id")] + public long? CollectionId { get; set; } - /// - /// Filter by product handle. - /// - [JsonProperty("handle")] - public string Handle { get; set; } + /// + /// Filter by product handle. + /// + [JsonProperty("handle")] + public string Handle { get; set; } - /// - /// A comma-separated list of product ids - /// - [JsonProperty("product_ids")] - public string ProductIds { get; set; } + /// + /// A comma-separated list of product ids + /// + [JsonProperty("product_ids")] + public string ProductIds { get; set; } - /// - /// Show those updated at or before date (formatted in ISO 8601) - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } - } -} + /// + /// Show those updated at or before date (formatted in ISO 8601) + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/ProductVariantListFilter.cs b/ShopifySharp/Filters/ProductVariantListFilter.cs index b8ffdbb0..04cde66c 100644 --- a/ShopifySharp/Filters/ProductVariantListFilter.cs +++ b/ShopifySharp/Filters/ProductVariantListFilter.cs @@ -1,23 +1,22 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering lists of Product Variants. +/// +public class ProductVariantListFilter : ListFilter { /// - /// Options for filtering lists of Product Variants. + /// Restrict results to after the specified ID. /// - public class ProductVariantListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Return presentment prices in only certain currencies. Each entry must be an ISO 4217 valid currency code. - /// - [JsonProperty("presentment_currencies")] - public IEnumerable PresentmentCurrencies { get; set; } - } + /// + /// Return presentment prices in only certain currencies. Each entry must be an ISO 4217 valid currency code. + /// + [JsonProperty("presentment_currencies")] + public IEnumerable PresentmentCurrencies { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/RecurringChargeListFilter.cs b/ShopifySharp/Filters/RecurringChargeListFilter.cs index 28af318f..e5c53b9a 100644 --- a/ShopifySharp/Filters/RecurringChargeListFilter.cs +++ b/ShopifySharp/Filters/RecurringChargeListFilter.cs @@ -1,16 +1,15 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering lists of Recurring Charges. +/// +public class RecurringChargeListFilter : Parameterizable { /// - /// Options for filtering lists of Recurring Charges. + /// Restrict results to after the specified ID. /// - public class RecurringChargeListFilter : Parameterizable - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } - } + [JsonProperty("since_id")] + public long? SinceId { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/RedirectCountFilter.cs b/ShopifySharp/Filters/RedirectCountFilter.cs index b70d2c33..023e96d0 100644 --- a/ShopifySharp/Filters/RedirectCountFilter.cs +++ b/ShopifySharp/Filters/RedirectCountFilter.cs @@ -1,19 +1,18 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class RedirectCountFilter : Parameterizable { - public class RedirectCountFilter : Parameterizable - { - /// - /// An optional parameter that filters the result to redirects with the given path. - /// - [JsonProperty("path")] - public string Path { get; set; } + /// + /// An optional parameter that filters the result to redirects with the given path. + /// + [JsonProperty("path")] + public string Path { get; set; } - /// - /// An optional parameter that filters the result to redirects with the given target. - /// - [JsonProperty("target")] - public string Target { get; set; } - } + /// + /// An optional parameter that filters the result to redirects with the given target. + /// + [JsonProperty("target")] + public string Target { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/RedirectListFilter.cs b/ShopifySharp/Filters/RedirectListFilter.cs index 308e4338..a88fac05 100644 --- a/ShopifySharp/Filters/RedirectListFilter.cs +++ b/ShopifySharp/Filters/RedirectListFilter.cs @@ -1,22 +1,21 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering lists of Redirects. +/// +public class RedirectListFilter : ListFilter { /// - /// Options for filtering lists of Redirects. + /// Filters the result to those with the given path. /// - public class RedirectListFilter : ListFilter - { - /// - /// Filters the result to those with the given path. - /// - [JsonProperty("path")] - public string Path { get; set; } + [JsonProperty("path")] + public string Path { get; set; } - /// - /// Filters the result to those with the given target. - /// - [JsonProperty("target")] - public string Target { get; set; } - } -} + /// + /// Filters the result to those with the given target. + /// + [JsonProperty("target")] + public string Target { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/RefundListFilter.cs b/ShopifySharp/Filters/RefundListFilter.cs index 123cb1a0..8c78a236 100644 --- a/ShopifySharp/Filters/RefundListFilter.cs +++ b/ShopifySharp/Filters/RefundListFilter.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class RefundListFilter : ListFilter { - public class RefundListFilter : ListFilter - { - /// - /// Show amounts in the shop currency for the underlying transaction. Default: false. - /// - [JsonProperty("in_shop_currency")] - public bool? InShopCurrency { get; set; } - } + /// + /// Show amounts in the shop currency for the underlying transaction. Default: false. + /// + [JsonProperty("in_shop_currency")] + public bool? InShopCurrency { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/ScriptTagCountFilter.cs b/ShopifySharp/Filters/ScriptTagCountFilter.cs index 4a1033b6..a425e9be 100644 --- a/ShopifySharp/Filters/ScriptTagCountFilter.cs +++ b/ShopifySharp/Filters/ScriptTagCountFilter.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class ScriptTagCountFilter : Parameterizable { - public class ScriptTagCountFilter : Parameterizable - { - /// - /// Restricts results to those with the given src value. - /// - [JsonProperty("src")] - public string Src { get; set; } - } + /// + /// Restricts results to those with the given src value. + /// + [JsonProperty("src")] + public string Src { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/ScriptTagListFilter.cs b/ShopifySharp/Filters/ScriptTagListFilter.cs index d4eb3bd9..a243df5b 100644 --- a/ShopifySharp/Filters/ScriptTagListFilter.cs +++ b/ShopifySharp/Filters/ScriptTagListFilter.cs @@ -1,16 +1,15 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering lists of Script Tags. +/// +public class ScriptTagListFilter : ListFilter { /// - /// Options for filtering lists of Script Tags. + /// Restricts results to those with the given src value. /// - public class ScriptTagListFilter : ListFilter - { - /// - /// Restricts results to those with the given src value. - /// - [JsonProperty("src")] - public string Src { get; set; } - } -} + [JsonProperty("src")] + public string Src { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/ShippingZoneListFilter.cs b/ShopifySharp/Filters/ShippingZoneListFilter.cs index f5fa0462..9f6f8c04 100644 --- a/ShopifySharp/Filters/ShippingZoneListFilter.cs +++ b/ShopifySharp/Filters/ShippingZoneListFilter.cs @@ -1,9 +1,8 @@ -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering lists of Shipping Zones. +/// +public class ShippingZoneListFilter : Parameterizable { - /// - /// Options for filtering lists of Shipping Zones. - /// - public class ShippingZoneListFilter : Parameterizable - { - } } \ No newline at end of file diff --git a/ShopifySharp/Filters/ShopifyPaymentsDisputeListFilter.cs b/ShopifySharp/Filters/ShopifyPaymentsDisputeListFilter.cs index ec1364ad..7946d905 100644 --- a/ShopifySharp/Filters/ShopifyPaymentsDisputeListFilter.cs +++ b/ShopifySharp/Filters/ShopifyPaymentsDisputeListFilter.cs @@ -1,32 +1,31 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class ShopifyPaymentsDisputeListFilter : ListFilter { - public class ShopifyPaymentsDisputeListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Return only disputes before the specified ID. - /// - [JsonProperty("last_id")] - public long? LastId { get; set; } + /// + /// Return only disputes before the specified ID. + /// + [JsonProperty("last_id")] + public long? LastId { get; set; } - /// - /// Return only disputes with the specified status. - /// - [JsonProperty("status")] - public string Status { get; set; } + /// + /// Return only disputes with the specified status. + /// + [JsonProperty("status")] + public string Status { get; set; } - /// - /// Return only disputes with the specified initiated_at date. - /// - [JsonProperty("initiated_at ")] - public DateTimeOffset? InitiatedAt { get; set; } - } + /// + /// Return only disputes with the specified initiated_at date. + /// + [JsonProperty("initiated_at ")] + public DateTimeOffset? InitiatedAt { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/ShopifyPaymentsPayoutListFilter.cs b/ShopifySharp/Filters/ShopifyPaymentsPayoutListFilter.cs index 19f41101..a30c2ab5 100644 --- a/ShopifySharp/Filters/ShopifyPaymentsPayoutListFilter.cs +++ b/ShopifySharp/Filters/ShopifyPaymentsPayoutListFilter.cs @@ -1,44 +1,43 @@ using Newtonsoft.Json; using System; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class ShopifyPaymentsPayoutListFilter : ListFilter { - public class ShopifyPaymentsPayoutListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Filter response to payouts exclusively before the specified ID - /// - [JsonProperty("last_id")] - public long? LastId { get; set; } + /// + /// Filter response to payouts exclusively before the specified ID + /// + [JsonProperty("last_id")] + public long? LastId { get; set; } - /// - /// Filter response to payouts inclusively after the specified date. - /// - [JsonProperty("date_min")] - public DateTimeOffset? DateMin { get; set; } + /// + /// Filter response to payouts inclusively after the specified date. + /// + [JsonProperty("date_min")] + public DateTimeOffset? DateMin { get; set; } - /// - /// Filter response to payouts inclusively before the specified date. - /// - [JsonProperty("date_max")] - public DateTimeOffset? DateMax { get; set; } + /// + /// Filter response to payouts inclusively before the specified date. + /// + [JsonProperty("date_max")] + public DateTimeOffset? DateMax { get; set; } - /// - /// Filter response to payouts on the specified date. - /// - [JsonProperty("date")] - public DateTimeOffset? Date { get; set; } + /// + /// Filter response to payouts on the specified date. + /// + [JsonProperty("date")] + public DateTimeOffset? Date { get; set; } - /// - /// Filter response to payouts with the specified status - /// - [JsonProperty("status")] - public string Status { get; set; } - } + /// + /// Filter response to payouts with the specified status + /// + [JsonProperty("status")] + public string Status { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/ShopifyPaymentsTransactionListFilter.cs b/ShopifySharp/Filters/ShopifyPaymentsTransactionListFilter.cs index e771307c..aff67754 100644 --- a/ShopifySharp/Filters/ShopifyPaymentsTransactionListFilter.cs +++ b/ShopifySharp/Filters/ShopifyPaymentsTransactionListFilter.cs @@ -1,37 +1,36 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class ShopifyPaymentsTransactionListFilter : ListFilter { - public class ShopifyPaymentsTransactionListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Filter response to transactions exclusively before the specified ID - /// - [JsonProperty("last_id")] - public long? LastId { get; set; } + /// + /// Filter response to transactions exclusively before the specified ID + /// + [JsonProperty("last_id")] + public long? LastId { get; set; } - /// - /// Filter response to transactions placed in test mode. - /// - [JsonProperty("test")] - public bool? Test { get; set; } + /// + /// Filter response to transactions placed in test mode. + /// + [JsonProperty("test")] + public bool? Test { get; set; } - /// - /// Filter response to transactions paid out in the specified payout. - /// - [JsonProperty("payout_id")] - public long? PayoutId { get; set; } + /// + /// Filter response to transactions paid out in the specified payout. + /// + [JsonProperty("payout_id")] + public long? PayoutId { get; set; } - /// - /// Filter response to transactions with the specified payout status - /// - [JsonProperty("payout_status")] - public string PayoutStatus { get; set; } - } + /// + /// Filter response to transactions with the specified payout status + /// + [JsonProperty("payout_status")] + public string PayoutStatus { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/SmartCollectionCountFilter.cs b/ShopifySharp/Filters/SmartCollectionCountFilter.cs index ab03f977..2051660f 100644 --- a/ShopifySharp/Filters/SmartCollectionCountFilter.cs +++ b/ShopifySharp/Filters/SmartCollectionCountFilter.cs @@ -1,50 +1,49 @@ using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class SmartCollectionCountFilter : Parameterizable { - public class SmartCollectionCountFilter : Parameterizable - { - /// - /// Restricts results to those with given title - /// - [JsonProperty("title")] - public string Title { get; set; } + /// + /// Restricts results to those with given title + /// + [JsonProperty("title")] + public string Title { get; set; } - /// - /// Restricts results to those that includes given product - /// - [JsonProperty("product_id")] - public long? ProductId { get; set; } + /// + /// Restricts results to those that includes given product + /// + [JsonProperty("product_id")] + public long? ProductId { get; set; } - /// - /// Restricts results to those last updated after date. - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Restricts results to those last updated after date. + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Restricts results to those last updated before date. - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } + /// + /// Restricts results to those last updated before date. + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } - /// - /// Restricts results to those published after date. - /// - [JsonProperty("published_at_min")] - public DateTimeOffset? PublishedAtMin { get; set; } + /// + /// Restricts results to those published after date. + /// + [JsonProperty("published_at_min")] + public DateTimeOffset? PublishedAtMin { get; set; } - /// - /// Restricts results to those published before date. - /// - [JsonProperty("published_at_max")] - public DateTimeOffset? PublishedAtMax { get; set; } + /// + /// Restricts results to those published before date. + /// + [JsonProperty("published_at_max")] + public DateTimeOffset? PublishedAtMax { get; set; } - /// - /// Restricts results to those with the given published status. Known values: published, unpublished, any. Default: any. - /// - [JsonProperty("published_status")] - public string PublishedStatus { get; set; } - } + /// + /// Restricts results to those with the given published status. Known values: published, unpublished, any. Default: any. + /// + [JsonProperty("published_status")] + public string PublishedStatus { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/SmartCollectionListFilter.cs b/ShopifySharp/Filters/SmartCollectionListFilter.cs index c620dad6..0e31a572 100644 --- a/ShopifySharp/Filters/SmartCollectionListFilter.cs +++ b/ShopifySharp/Filters/SmartCollectionListFilter.cs @@ -1,72 +1,71 @@ -using System; +using System; using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering lists of Smart Collections. +/// +public class SmartCollectionListFilter : ListFilter { /// - /// Options for filtering lists of Smart Collections. + /// Restrict results to after the specified ID. /// - public class SmartCollectionListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Show only those with ids in the list. - /// - [JsonProperty("ids")] - public IEnumerable Ids { get; set; } + /// + /// Show only those with ids in the list. + /// + [JsonProperty("ids")] + public IEnumerable Ids { get; set; } - /// - /// Filter to smart collections with the given title. - /// - [JsonProperty("title")] - public string Title { get; set; } + /// + /// Filter to smart collections with the given title. + /// + [JsonProperty("title")] + public string Title { get; set; } - /// - /// Filter by smart collection handle. - /// - [JsonProperty("handle")] - public string Handle { get; set; } + /// + /// Filter by smart collection handle. + /// + [JsonProperty("handle")] + public string Handle { get; set; } - /// - /// Filter to smart collections that includes given product. - /// - [JsonProperty("product_id")] - public long? ProductId { get; set; } + /// + /// Filter to smart collections that includes given product. + /// + [JsonProperty("product_id")] + public long? ProductId { get; set; } - /// - /// Show those updated at or before date. - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Show those updated at or before date. + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Show those last updated at or before date. - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } + /// + /// Show those last updated at or before date. + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } - /// - /// Show those published at or before date. - /// - [JsonProperty("published_at_min")] - public DateTimeOffset? PublishedAtMin { get; set; } + /// + /// Show those published at or before date. + /// + [JsonProperty("published_at_min")] + public DateTimeOffset? PublishedAtMin { get; set; } - /// - /// Show those last published at or before date. - /// - [JsonProperty("published_at_max")] - public DateTimeOffset? PublishedAtMax { get; set; } + /// + /// Show those last published at or before date. + /// + [JsonProperty("published_at_max")] + public DateTimeOffset? PublishedAtMax { get; set; } - /// - /// Restrict results to those with a given published status. Known values: published, unpublished, any. Default: any. - /// - [JsonProperty("published_status")] - public string PublishedStatus { get; set; } - } -} + /// + /// Restrict results to those with a given published status. Known values: published, unpublished, any. Default: any. + /// + [JsonProperty("published_status")] + public string PublishedStatus { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/TenderTransactionListFilter.cs b/ShopifySharp/Filters/TenderTransactionListFilter.cs index 647e02a6..d544d72b 100644 --- a/ShopifySharp/Filters/TenderTransactionListFilter.cs +++ b/ShopifySharp/Filters/TenderTransactionListFilter.cs @@ -1,39 +1,38 @@ -using System; +using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class TenderTransactionListFilter : ListFilter { - public class TenderTransactionListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Show tender transactions ordered by processed_at in ascending or descending order (default is descending). - /// Example values: "processed_at+ASC", "processed_at+DESC". - /// - [JsonProperty("order")] - public string Order { get; set; } + /// + /// Show tender transactions ordered by processed_at in ascending or descending order (default is descending). + /// Example values: "processed_at+ASC", "processed_at+DESC". + /// + [JsonProperty("order")] + public string Order { get; set; } - /// - /// Show tender transactions processed at the specified date. - /// - [JsonProperty("processed_at")] - public DateTimeOffset? ProcessedAt { get; set; } + /// + /// Show tender transactions processed at the specified date. + /// + [JsonProperty("processed_at")] + public DateTimeOffset? ProcessedAt { get; set; } - /// - /// Show tender transactions processed at or after the specified date. - /// - [JsonProperty("processed_at_min")] - public DateTimeOffset? ProcessedAtMin { get; set; } + /// + /// Show tender transactions processed at or after the specified date. + /// + [JsonProperty("processed_at_min")] + public DateTimeOffset? ProcessedAtMin { get; set; } - /// - /// Show tender transactions processed at or before the specified date. - /// - [JsonProperty("processed_at_max")] - public DateTimeOffset? ProcessedAtMax { get; set; } - } + /// + /// Show tender transactions processed at or before the specified date. + /// + [JsonProperty("processed_at_max")] + public DateTimeOffset? ProcessedAtMax { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/ThemeListFilter.cs b/ShopifySharp/Filters/ThemeListFilter.cs index d5d7518d..de00c6bf 100644 --- a/ShopifySharp/Filters/ThemeListFilter.cs +++ b/ShopifySharp/Filters/ThemeListFilter.cs @@ -1,16 +1,15 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering lists of Themes. +/// +public class ThemeListFilter : Parameterizable { /// - /// Options for filtering lists of Themes. + /// Retrieve only certain fields, specified by a comma-separated list of field names. /// - public class ThemeListFilter : Parameterizable - { - /// - /// Retrieve only certain fields, specified by a comma-separated list of field names. - /// - [JsonProperty("fields")] - public string Fields { get; set; } - } -} + [JsonProperty("fields")] + public string Fields { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/TransactionGetFilter.cs b/ShopifySharp/Filters/TransactionGetFilter.cs index e3ccb2e7..449caa2c 100644 --- a/ShopifySharp/Filters/TransactionGetFilter.cs +++ b/ShopifySharp/Filters/TransactionGetFilter.cs @@ -1,19 +1,18 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class TransactionGetFilter : Parameterizable { - public class TransactionGetFilter : Parameterizable - { - /// - /// Retrieve only certain fields, specified by a comma-separated list of field names. - /// - [JsonProperty("fields")] - public string Fields { get; set; } + /// + /// Retrieve only certain fields, specified by a comma-separated list of field names. + /// + [JsonProperty("fields")] + public string Fields { get; set; } - /// - /// Show amounts in the shop currency. - /// - [JsonProperty("in_shop_currency")] - public bool? InShopCurrency { get; set; } - } + /// + /// Show amounts in the shop currency. + /// + [JsonProperty("in_shop_currency")] + public bool? InShopCurrency { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/TransactionListFilter.cs b/ShopifySharp/Filters/TransactionListFilter.cs index 955764ed..827a754c 100644 --- a/ShopifySharp/Filters/TransactionListFilter.cs +++ b/ShopifySharp/Filters/TransactionListFilter.cs @@ -1,25 +1,24 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class TransactionListFilter : Parameterizable { - public class TransactionListFilter : Parameterizable - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + /// + /// Restrict results to after the specified ID. + /// + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Retrieve only certain fields, specified by a comma-separated list of field names. - /// - [JsonProperty("fields")] - public string Fields { get; set; } + /// + /// Retrieve only certain fields, specified by a comma-separated list of field names. + /// + [JsonProperty("fields")] + public string Fields { get; set; } - /// - /// Show amounts in the shop currency. - /// - [JsonProperty("in_shop_currency")] - public bool? InShopCurrency { get; set; } - } + /// + /// Show amounts in the shop currency. + /// + [JsonProperty("in_shop_currency")] + public bool? InShopCurrency { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/UsageChargeListFilter.cs b/ShopifySharp/Filters/UsageChargeListFilter.cs index 557d3216..e3840388 100644 --- a/ShopifySharp/Filters/UsageChargeListFilter.cs +++ b/ShopifySharp/Filters/UsageChargeListFilter.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class UsageChargeListFilter : Parameterizable { - public class UsageChargeListFilter : Parameterizable - { - /// - /// Retrieve only certain fields, specified by a comma-separated list of field names. - /// - [JsonProperty("fields")] - public string Fields { get; set; } - } + /// + /// Retrieve only certain fields, specified by a comma-separated list of field names. + /// + [JsonProperty("fields")] + public string Fields { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/UserListFilter.cs b/ShopifySharp/Filters/UserListFilter.cs index 2728dd5d..bcf6f732 100644 --- a/ShopifySharp/Filters/UserListFilter.cs +++ b/ShopifySharp/Filters/UserListFilter.cs @@ -1,6 +1,5 @@ -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class UserListFilter : ListFilter { - public class UserListFilter : ListFilter - { - } } \ No newline at end of file diff --git a/ShopifySharp/Filters/WebhookCountFilter.cs b/ShopifySharp/Filters/WebhookCountFilter.cs index 71048c6b..6c4a8364 100644 --- a/ShopifySharp/Filters/WebhookCountFilter.cs +++ b/ShopifySharp/Filters/WebhookCountFilter.cs @@ -1,19 +1,18 @@ using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +public class WebhookCountFilter : Parameterizable { - public class WebhookCountFilter : Parameterizable - { - /// - /// Restricts results to those with the given address. - /// - [JsonProperty("address")] - public string Address { get; set; } + /// + /// Restricts results to those with the given address. + /// + [JsonProperty("address")] + public string Address { get; set; } - /// - /// Restricts results to those with the given topic. - /// - [JsonProperty("topic")] - public string Topic { get; set; } - } + /// + /// Restricts results to those with the given topic. + /// + [JsonProperty("topic")] + public string Topic { get; set; } } \ No newline at end of file diff --git a/ShopifySharp/Filters/WebhookFilter.cs b/ShopifySharp/Filters/WebhookFilter.cs index 45df0936..c42ac0e7 100644 --- a/ShopifySharp/Filters/WebhookFilter.cs +++ b/ShopifySharp/Filters/WebhookFilter.cs @@ -1,22 +1,21 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering results. +/// +public class WebhookFilter : ListFilter { /// - /// Options for filtering results. + /// An optional filter for the address property. When used, the method will only return webhooks with the given address. /// - public class WebhookFilter : ListFilter - { - /// - /// An optional filter for the address property. When used, the method will only return webhooks with the given address. - /// - [JsonProperty("address")] - public string Address { get; set; } + [JsonProperty("address")] + public string Address { get; set; } - /// - /// An optional filter for the topic property. When used, the method will only return webhooks with the given topic. A full list of topics can be found at https://help.shopify.com/api/reference/webhook. - /// - [JsonProperty("topic")] - public string Topic { get; set; } - } -} + /// + /// An optional filter for the topic property. When used, the method will only return webhooks with the given topic. A full list of topics can be found at https://help.shopify.com/api/reference/webhook. + /// + [JsonProperty("topic")] + public string Topic { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Filters/WebhookListFilter.cs b/ShopifySharp/Filters/WebhookListFilter.cs index d16947fc..d2a601cb 100644 --- a/ShopifySharp/Filters/WebhookListFilter.cs +++ b/ShopifySharp/Filters/WebhookListFilter.cs @@ -1,53 +1,52 @@ -using System; +using System; using Newtonsoft.Json; -namespace ShopifySharp.Filters +namespace ShopifySharp.Filters; + +/// +/// Options for filtering lists of Webhooks. +/// +public class WebhookListFilter : ListFilter { /// - /// Options for filtering lists of Webhooks. + /// Restrict results to after the specified ID. /// - public class WebhookListFilter : ListFilter - { - /// - /// Restrict results to after the specified ID. - /// - [JsonProperty("since_id")] - public long? SinceId { get; set; } + [JsonProperty("since_id")] + public long? SinceId { get; set; } - /// - /// Restricts results to those with the given address. - /// - [JsonProperty("address")] - public string Address { get; set; } + /// + /// Restricts results to those with the given address. + /// + [JsonProperty("address")] + public string Address { get; set; } - /// - /// Restricts results to those with the given topic. - /// - [JsonProperty("topic")] - public string Topic { get; set; } + /// + /// Restricts results to those with the given topic. + /// + [JsonProperty("topic")] + public string Topic { get; set; } - /// - /// Show those created at or after date. - /// - [JsonProperty("created_at_min")] - public DateTimeOffset? CreatedAtMin { get; set; } + /// + /// Show those created at or after date. + /// + [JsonProperty("created_at_min")] + public DateTimeOffset? CreatedAtMin { get; set; } - /// - /// Show those created at or after date. - /// - [JsonProperty("created_at_max")] - public DateTimeOffset? CreatedAtMax { get; set; } + /// + /// Show those created at or after date. + /// + [JsonProperty("created_at_max")] + public DateTimeOffset? CreatedAtMax { get; set; } - /// - /// Show those updated at or before date. - /// - [JsonProperty("updated_at_min")] - public DateTimeOffset? UpdatedAtMin { get; set; } + /// + /// Show those updated at or before date. + /// + [JsonProperty("updated_at_min")] + public DateTimeOffset? UpdatedAtMin { get; set; } - /// - /// Show those last updated at or before date. - /// - [JsonProperty("updated_at_max")] - public DateTimeOffset? UpdatedAtMax { get; set; } - } -} + /// + /// Show those last updated at or before date. + /// + [JsonProperty("updated_at_max")] + public DateTimeOffset? UpdatedAtMax { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Infrastructure/AssemblyInfo.cs b/ShopifySharp/Infrastructure/AssemblyInfo.cs index aca73654..ae7c217e 100644 --- a/ShopifySharp/Infrastructure/AssemblyInfo.cs +++ b/ShopifySharp/Infrastructure/AssemblyInfo.cs @@ -1 +1 @@ -[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("ShopifySharp.Tests")] +[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("ShopifySharp.Tests")] diff --git a/ShopifySharp/Infrastructure/BucketStates/GraphQLBucketState.cs b/ShopifySharp/Infrastructure/BucketStates/GraphQLBucketState.cs index 3dfafae7..d33508a2 100644 --- a/ShopifySharp/Infrastructure/BucketStates/GraphQLBucketState.cs +++ b/ShopifySharp/Infrastructure/BucketStates/GraphQLBucketState.cs @@ -1,40 +1,39 @@ -namespace ShopifySharp +namespace ShopifySharp; + +public class GraphQLBucketState { - public class GraphQLBucketState - { - public int MaxAvailable { get; private set; } + public int MaxAvailable { get; private set; } + + public int RestoreRate { get; private set; } - public int RestoreRate { get; private set; } + public int CurrentlyAvailable { get; private set; } - public int CurrentlyAvailable { get; private set; } + public int RequestedQueryCost { get; private set; } + + public int? ActualQueryCost { get; private set; } + + public static GraphQLBucketState Get(System.Text.Json.JsonDocument response) + { + if (!response.RootElement.TryGetProperty("extensions", out var extensions)) + return null; + if (!extensions.TryGetProperty("cost", out var cost)) + return null; - public int RequestedQueryCost { get; private set; } + int requestedQueryCost = cost.GetProperty("requestedQueryCost").GetInt32(); + int? actualQueryCost = cost.TryGetProperty("actualQueryCost", out var actualQueryCostElt) && actualQueryCostElt.ValueKind != System.Text.Json.JsonValueKind.Null ? actualQueryCostElt.GetInt32() : null;//actual query cost is null if THROTTLED - public int? ActualQueryCost { get; private set; } + var throttleStatus = cost.GetProperty("throttleStatus"); + decimal maximumAvailable = throttleStatus.GetProperty("maximumAvailable").GetDecimal(); + decimal restoreRate = throttleStatus.GetProperty("restoreRate").GetDecimal(); + decimal currentlyAvailable = throttleStatus.GetProperty("currentlyAvailable").GetDecimal(); - public static GraphQLBucketState Get(System.Text.Json.JsonDocument response) + return new GraphQLBucketState { - if (!response.RootElement.TryGetProperty("extensions", out var extensions)) - return null; - if (!extensions.TryGetProperty("cost", out var cost)) - return null; - - int requestedQueryCost = cost.GetProperty("requestedQueryCost").GetInt32(); - int? actualQueryCost = cost.TryGetProperty("actualQueryCost", out var actualQueryCostElt) && actualQueryCostElt.ValueKind != System.Text.Json.JsonValueKind.Null ? actualQueryCostElt.GetInt32() : null;//actual query cost is null if THROTTLED - - var throttleStatus = cost.GetProperty("throttleStatus"); - decimal maximumAvailable = throttleStatus.GetProperty("maximumAvailable").GetDecimal(); - decimal restoreRate = throttleStatus.GetProperty("restoreRate").GetDecimal(); - decimal currentlyAvailable = throttleStatus.GetProperty("currentlyAvailable").GetDecimal(); - - return new GraphQLBucketState - { - MaxAvailable = (int)maximumAvailable, - RestoreRate = (int)restoreRate, - CurrentlyAvailable = (int)currentlyAvailable, - RequestedQueryCost = requestedQueryCost, - ActualQueryCost = actualQueryCost, - }; - } + MaxAvailable = (int)maximumAvailable, + RestoreRate = (int)restoreRate, + CurrentlyAvailable = (int)currentlyAvailable, + RequestedQueryCost = requestedQueryCost, + ActualQueryCost = actualQueryCost, + }; } -} +} \ No newline at end of file diff --git a/ShopifySharp/Infrastructure/BucketStates/RestBucketState.cs b/ShopifySharp/Infrastructure/BucketStates/RestBucketState.cs index e2985a44..e88ce167 100644 --- a/ShopifySharp/Infrastructure/BucketStates/RestBucketState.cs +++ b/ShopifySharp/Infrastructure/BucketStates/RestBucketState.cs @@ -1,36 +1,35 @@ -using System.Linq; +using System.Linq; using System.Net.Http.Headers; -namespace ShopifySharp +namespace ShopifySharp; + +public class RestBucketState { - public class RestBucketState - { - public int CurrentlyUsed { get; private set; } + public int CurrentlyUsed { get; private set; } - public int MaxAvailable { get; private set; } + public int MaxAvailable { get; private set; } - public const string RESPONSE_HEADER_API_CALL_LIMIT = "X-Shopify-Shop-Api-Call-Limit"; + public const string RESPONSE_HEADER_API_CALL_LIMIT = "X-Shopify-Shop-Api-Call-Limit"; - public static RestBucketState Get(HttpResponseHeaders responseHeaders) - { - string headerValue = responseHeaders.TryGetValues(RESPONSE_HEADER_API_CALL_LIMIT, out var values) ? values?.FirstOrDefault() : null; + public static RestBucketState Get(HttpResponseHeaders responseHeaders) + { + string headerValue = responseHeaders.TryGetValues(RESPONSE_HEADER_API_CALL_LIMIT, out var values) ? values?.FirstOrDefault() : null; - if (headerValue == null) - return null; + if (headerValue == null) + return null; - var split = headerValue.Split('/'); - if (split.Length == 2 && int.TryParse(split[0], out int currentlyUsed) && - int.TryParse(split[1], out int maxAvailable)) + var split = headerValue.Split('/'); + if (split.Length == 2 && int.TryParse(split[0], out int currentlyUsed) && + int.TryParse(split[1], out int maxAvailable)) + { + return new RestBucketState { - return new RestBucketState - { - CurrentlyUsed = currentlyUsed, - MaxAvailable = maxAvailable - }; - } - - return null; + CurrentlyUsed = currentlyUsed, + MaxAvailable = maxAvailable + }; } + + return null; } -} +} \ No newline at end of file diff --git a/ShopifySharp/Infrastructure/CloneableRequestMessage.cs b/ShopifySharp/Infrastructure/CloneableRequestMessage.cs index 3eda4851..0a227833 100644 --- a/ShopifySharp/Infrastructure/CloneableRequestMessage.cs +++ b/ShopifySharp/Infrastructure/CloneableRequestMessage.cs @@ -3,68 +3,68 @@ using System.Net.Http; using System.Threading.Tasks; -namespace ShopifySharp.Infrastructure +namespace ShopifySharp.Infrastructure; + +public class CloneableRequestMessage: HttpRequestMessage { - public class CloneableRequestMessage: HttpRequestMessage + public CloneableRequestMessage(Uri url, HttpMethod method, HttpContent content = null) : base(method, url) { - public CloneableRequestMessage(Uri url, HttpMethod method, HttpContent content = null) : base(method, url) + if (content != null) { - if (content != null) - { - Content = content; - } + Content = content; } + } - [Obsolete("This method has been replaced with " + nameof(CloneAsync) + ", it will be removed in a future version of ShopifySharp.")] - public CloneableRequestMessage Clone() + [Obsolete("This method has been replaced with " + nameof(CloneAsync) + ", it will be removed in a future version of ShopifySharp.")] + public CloneableRequestMessage Clone() + { + var newContent = Content; + + if (newContent is JsonContent c) { - var newContent = Content; + newContent = c.Clone(); - if (newContent is JsonContent c) + foreach (var header in Content.Headers) { - newContent = c.Clone(); - - foreach (var header in Content.Headers) + if (!newContent.Headers.Contains(header.Key)) { - if (!newContent.Headers.Contains(header.Key)) - { - newContent.Headers.Add(header.Key, header.Value); - } + newContent.Headers.Add(header.Key, header.Value); } } + } - var cloned = new CloneableRequestMessage(RequestUri, Method, newContent); - - // Copy over the request's headers which includes the access token if set - foreach (var header in Headers) - { - cloned.Headers.Add(header.Key, header.Value); - } + var cloned = new CloneableRequestMessage(RequestUri, Method, newContent); - return cloned; + // Copy over the request's headers which includes the access token if set + foreach (var header in Headers) + { + cloned.Headers.Add(header.Key, header.Value); } - public async Task CloneAsync() - { - var newContent = Content is null ? null : await CloneToStreamOrReadOnlyMemoryContent(Content); - var cloned = new CloneableRequestMessage(RequestUri, Method, newContent); + return cloned; + } - // Copy over the request's headers which includes the access token if set - foreach (var header in Headers) - { - cloned.Headers.Add(header.Key, header.Value); - } + public async Task CloneAsync() + { + var newContent = Content is null ? null : await CloneToStreamOrReadOnlyMemoryContent(Content); + var cloned = new CloneableRequestMessage(RequestUri, Method, newContent); - return cloned; + // Copy over the request's headers which includes the access token if set + foreach (var header in Headers) + { + cloned.Headers.Add(header.Key, header.Value); } - private static async Task CloneToStreamOrReadOnlyMemoryContent(HttpContent originalStreamContent) - { - HttpContent clonedContent; + return cloned; + } + + private static async Task CloneToStreamOrReadOnlyMemoryContent(HttpContent originalStreamContent) + { + HttpContent clonedContent; #if NET6_0_OR_GREATER - var rs = new ReadOnlyMemory(await originalStreamContent.ReadAsByteArrayAsync()); - clonedContent = new ReadOnlyMemoryContent(rs); + var rs = new ReadOnlyMemory(await originalStreamContent.ReadAsByteArrayAsync()); + clonedContent = new ReadOnlyMemoryContent(rs); #else var ms = new System.IO.MemoryStream(); await originalStreamContent.CopyToAsync(ms); @@ -72,34 +72,33 @@ private static async Task CloneToStreamOrReadOnlyMemoryContent(Http clonedContent = new StreamContent(ms); #endif - foreach (var header in originalStreamContent.Headers) - { - clonedContent.Headers.Add(header.Key, header.Value); - } - - return clonedContent; + foreach (var header in originalStreamContent.Headers) + { + clonedContent.Headers.Add(header.Key, header.Value); } - public async Task GetRequestInfo() + return clonedContent; + } + + public async Task GetRequestInfo() + { + var headers = this.Headers.Where(kv => kv.Value != null && kv.Key != ShopifyService.REQUEST_HEADER_ACCESS_TOKEN) + .Select(kv => $"\t{kv.Key}: {string.Join(", ", kv.Value)}"); + var contents = this.Content switch { - var headers = this.Headers.Where(kv => kv.Value != null && kv.Key != ShopifyService.REQUEST_HEADER_ACCESS_TOKEN) - .Select(kv => $"\t{kv.Key}: {string.Join(", ", kv.Value)}"); - var contents = this.Content switch - { - StringContent strContent => await strContent.ReadAsStringAsync(), - null => "(none)", - _ => this.Content.GetType().Name - }; - - return $""" - Method: {this.Method} - RequestUri: {this.RequestUri} - Headers: - [ - {string.Join(Environment.NewLine, headers)} - ] - Content: {contents} - """; - } + StringContent strContent => await strContent.ReadAsStringAsync(), + null => "(none)", + _ => this.Content.GetType().Name + }; + + return $""" + Method: {this.Method} + RequestUri: {this.RequestUri} + Headers: + [ + {string.Join(Environment.NewLine, headers)} + ] + Content: {contents} + """; } -} +} \ No newline at end of file diff --git a/ShopifySharp/Infrastructure/DefaultHttpClientFactory.cs b/ShopifySharp/Infrastructure/DefaultHttpClientFactory.cs index 6715aa85..28fa499a 100644 --- a/ShopifySharp/Infrastructure/DefaultHttpClientFactory.cs +++ b/ShopifySharp/Infrastructure/DefaultHttpClientFactory.cs @@ -1,18 +1,17 @@ using System; using System.Net.Http; -namespace ShopifySharp.Infrastructure +namespace ShopifySharp.Infrastructure; + +/// +/// ShopifySharp's internal , which uses a static . +/// +internal class InternalHttpClientFactory : IHttpClientFactory { - /// - /// ShopifySharp's internal , which uses a static . - /// - internal class InternalHttpClientFactory : IHttpClientFactory - { - private static readonly HttpClient Client = new HttpClient(); + private static readonly HttpClient Client = new HttpClient(); - public HttpClient CreateClient(string name) - { - return Client; - } + public HttpClient CreateClient(string name) + { + return Client; } -} +} \ No newline at end of file diff --git a/ShopifySharp/Infrastructure/JsonContent.cs b/ShopifySharp/Infrastructure/JsonContent.cs index 7d575111..17cff187 100644 --- a/ShopifySharp/Infrastructure/JsonContent.cs +++ b/ShopifySharp/Infrastructure/JsonContent.cs @@ -1,29 +1,28 @@ -using System.Net.Http; +using System.Net.Http; using System.Net.Http.Headers; using System.Text; -namespace ShopifySharp.Infrastructure +namespace ShopifySharp.Infrastructure; + +public class JsonContent : ByteArrayContent { - public class JsonContent : ByteArrayContent - { - private object Data { get; set; } + private object Data { get; set; } - public JsonContent(object data) : base(ToBytes(data)) - { - Data = data; - Headers.ContentType = new MediaTypeHeaderValue("application/json"); - } + public JsonContent(object data) : base(ToBytes(data)) + { + Data = data; + Headers.ContentType = new MediaTypeHeaderValue("application/json"); + } - private static byte[] ToBytes(object data) - { - var rawData = Serializer.Serialize(data); + private static byte[] ToBytes(object data) + { + var rawData = Serializer.Serialize(data); - return Encoding.UTF8.GetBytes(rawData); - } + return Encoding.UTF8.GetBytes(rawData); + } - public JsonContent Clone() - { - return new JsonContent(Data); - } + public JsonContent Clone() + { + return new JsonContent(Data); } -} +} \ No newline at end of file diff --git a/ShopifySharp/Infrastructure/Parameterizable.cs b/ShopifySharp/Infrastructure/Parameterizable.cs index 0c888a7d..abf3deb1 100644 --- a/ShopifySharp/Infrastructure/Parameterizable.cs +++ b/ShopifySharp/Infrastructure/Parameterizable.cs @@ -1,100 +1,99 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// An abstract class for parameterizing certain objects. +/// +public abstract class Parameterizable { /// - /// An abstract class for parameterizing certain objects. + /// Converts the object to an array of KVPs. /// - public abstract class Parameterizable + public virtual IEnumerable> ToQueryParameters() { - /// - /// Converts the object to an array of KVPs. - /// - public virtual IEnumerable> ToQueryParameters() + var output = new List>(); + + //Inspiration for this code from https://github.com/jaymedavis/stripe.net + foreach (PropertyInfo property in GetType().GetAllDeclaredProperties()) { - var output = new List>(); + object value = property.GetValue(this, null); + string propName = property.Name; - //Inspiration for this code from https://github.com/jaymedavis/stripe.net - foreach (PropertyInfo property in GetType().GetAllDeclaredProperties()) + if (value == null) { - object value = property.GetValue(this, null); - string propName = property.Name; + continue; + } - if (value == null) - { - continue; - } + if (property.CustomAttributes.Any(x => x.AttributeType == typeof(JsonPropertyAttribute))) + { + //Get the JsonPropertyAttribute for this property, which will give us its JSON name + JsonPropertyAttribute attribute = property.GetCustomAttributes(typeof(JsonPropertyAttribute), false).Cast().FirstOrDefault(); - if (property.CustomAttributes.Any(x => x.AttributeType == typeof(JsonPropertyAttribute))) - { - //Get the JsonPropertyAttribute for this property, which will give us its JSON name - JsonPropertyAttribute attribute = property.GetCustomAttributes(typeof(JsonPropertyAttribute), false).Cast().FirstOrDefault(); + propName = attribute != null ? attribute.PropertyName : property.Name; + } - propName = attribute != null ? attribute.PropertyName : property.Name; - } + var parameter = ToSingleParameter(propName, value, property); - var parameter = ToSingleParameter(propName, value, property); + output.Add(parameter); + } - output.Add(parameter); - } + return output; + } - return output; + /// + /// Converts the given property and value to a KeyValuePair for use as a query parameter. Can be overriden to customize parameterization of a property. + /// Will NOT be called by the method if the value + /// is null. + /// + /// The name of the property. Will match the property's name — + /// rather than the real property name — where applicable. Use .Name to get the real name. + /// The property's value. + /// The property itself. + /// The new parameter. + protected virtual KeyValuePair ToSingleParameter(string propName, object value, PropertyInfo property) + { + KeyValuePair Join(IEnumerable values) + { + return new KeyValuePair(propName, string.Join(",", values)); } - /// - /// Converts the given property and value to a KeyValuePair for use as a query parameter. Can be overriden to customize parameterization of a property. - /// Will NOT be called by the method if the value - /// is null. - /// - /// The name of the property. Will match the property's name — - /// rather than the real property name — where applicable. Use .Name to get the real name. - /// The property's value. - /// The property itself. - /// The new parameter. - protected virtual KeyValuePair ToSingleParameter(string propName, object value, PropertyInfo property) + switch (value) { - KeyValuePair Join(IEnumerable values) - { - return new KeyValuePair(propName, string.Join(",", values)); - } - - switch (value) - { - case IEnumerable longs: - return Join(longs); + case IEnumerable longs: + return Join(longs); - case IEnumerable ints: - return Join(ints); + case IEnumerable ints: + return Join(ints); - case IEnumerable strings: - return Join(strings); + case IEnumerable strings: + return Join(strings); - case IEnumerable bools: - return Join(bools); - } - - var valueType = value.GetType(); + case IEnumerable bools: + return Join(bools); + } - if (valueType.GetTypeInfo().IsEnum) - { - value = ((Enum)value).ToSerializedString(); - } + var valueType = value.GetType(); - //Dates must be serialized in YYYY-MM-DD HH:MM format. - if (valueType == typeof(DateTime) || valueType == typeof(DateTime?)) - { - value = ((DateTime)value).ToString("o"); - } - else if (valueType == typeof(DateTimeOffset) || valueType == typeof(DateTimeOffset?)) - { - value = ((DateTimeOffset)value).ToString("o"); - } + if (valueType.GetTypeInfo().IsEnum) + { + value = ((Enum)value).ToSerializedString(); + } - return new KeyValuePair(propName, value); + //Dates must be serialized in YYYY-MM-DD HH:MM format. + if (valueType == typeof(DateTime) || valueType == typeof(DateTime?)) + { + value = ((DateTime)value).ToString("o"); } + else if (valueType == typeof(DateTimeOffset) || valueType == typeof(DateTimeOffset?)) + { + value = ((DateTimeOffset)value).ToString("o"); + } + + return new KeyValuePair(propName, value); } -} +} \ No newline at end of file diff --git a/ShopifySharp/Infrastructure/Policies/DefaultRequestExecutionPolicy.cs b/ShopifySharp/Infrastructure/Policies/DefaultRequestExecutionPolicy.cs index cb2e9071..48b15369 100644 --- a/ShopifySharp/Infrastructure/Policies/DefaultRequestExecutionPolicy.cs +++ b/ShopifySharp/Infrastructure/Policies/DefaultRequestExecutionPolicy.cs @@ -1,4 +1,4 @@ -using System.Threading; +using System.Threading; using System.Threading.Tasks; using ShopifySharp.Infrastructure; diff --git a/ShopifySharp/Infrastructure/Policies/IRequestExecutionPolicy.cs b/ShopifySharp/Infrastructure/Policies/IRequestExecutionPolicy.cs index cc2a2eb9..c5540c60 100644 --- a/ShopifySharp/Infrastructure/Policies/IRequestExecutionPolicy.cs +++ b/ShopifySharp/Infrastructure/Policies/IRequestExecutionPolicy.cs @@ -1,4 +1,4 @@ -using System.Threading; +using System.Threading; using System.Threading.Tasks; using ShopifySharp.Infrastructure; diff --git a/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/ContextAwareQueue.cs b/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/ContextAwareQueue.cs index 98183fbe..b723e74a 100644 --- a/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/ContextAwareQueue.cs +++ b/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/ContextAwareQueue.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; namespace ShopifySharp; diff --git a/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/LeakyBucket.cs b/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/LeakyBucket.cs index 984ce551..7af4359c 100644 --- a/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/LeakyBucket.cs +++ b/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/LeakyBucket.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading; using System.Threading.Tasks; diff --git a/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/LeakyBucketExecutionPolicy.cs b/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/LeakyBucketExecutionPolicy.cs index fd2cfd12..01935d90 100644 --- a/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/LeakyBucketExecutionPolicy.cs +++ b/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/LeakyBucketExecutionPolicy.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Concurrent; using System.Linq; using System.Net.Http; diff --git a/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/MultiShopifyApiBucket.cs b/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/MultiShopifyApiBucket.cs index 33d29618..33b250f4 100644 --- a/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/MultiShopifyApiBucket.cs +++ b/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/MultiShopifyApiBucket.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading; using System.Threading.Tasks; diff --git a/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/RequestContext.cs b/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/RequestContext.cs index fd31a307..dde690b9 100644 --- a/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/RequestContext.cs +++ b/ShopifySharp/Infrastructure/Policies/LeakyBucketPolicy/RequestContext.cs @@ -1,4 +1,4 @@ -// ReSharper disable once CheckNamespace +// ReSharper disable once CheckNamespace namespace ShopifySharp; public enum RequestContext diff --git a/ShopifySharp/Infrastructure/Policies/RetryExecutionPolicy.cs b/ShopifySharp/Infrastructure/Policies/RetryExecutionPolicy.cs index 99b8570f..840e9f36 100644 --- a/ShopifySharp/Infrastructure/Policies/RetryExecutionPolicy.cs +++ b/ShopifySharp/Infrastructure/Policies/RetryExecutionPolicy.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Threading; using System.Threading.Tasks; using ShopifySharp.Infrastructure; diff --git a/ShopifySharp/Infrastructure/RequestResult.cs b/ShopifySharp/Infrastructure/RequestResult.cs index 1ed04da5..8001d5fd 100644 --- a/ShopifySharp/Infrastructure/RequestResult.cs +++ b/ShopifySharp/Infrastructure/RequestResult.cs @@ -1,61 +1,61 @@ -using System; +#nullable enable +using System; using System.Net.Http; using System.Net.Http.Headers; -namespace ShopifySharp +namespace ShopifySharp; + +public class RequestResult { - public class RequestResult + public string? RequestInfo { get; } + + [Obsolete("This property is obsolete and will be removed in a future version of ShopifySharp. If you need to use the response headers, please use the " + nameof(ResponseHeaders) + " property instead.")] + public HttpResponseMessage Response { get; } + + public HttpResponseHeaders ResponseHeaders { get; } + + public T Result { get; } + + public string RawResult { get; } + + /// + /// Only exists for list requests, will be null or empty for all others. + /// + public string? RawLinkHeaderValue { get; } + + [Obsolete("This constructor is obsolete and will be removed in a future version of ShopifySharp.")] + public RequestResult(HttpResponseMessage response, T result, string rawResult, string rawLinkHeaderValue) + { + this.Response = response; + this.ResponseHeaders = response.Headers; + this.Result = result; + this.RawResult = rawResult; + this.RawLinkHeaderValue = rawLinkHeaderValue; + } + + public RequestResult( + string requestInfo, + HttpResponseMessage httpResponseMessage, + HttpResponseHeaders httpResponseHeaders, + T result, + string rawResult, + string rawLinkHeaderValue) + { + RequestInfo = requestInfo; + Response = httpResponseMessage; + ResponseHeaders = httpResponseHeaders; + Result = result; + RawResult = rawResult; + RawLinkHeaderValue = rawLinkHeaderValue; + } + + public RestBucketState GetRestBucketState() + { + return RestBucketState.Get(ResponseHeaders); + } + + public GraphQLBucketState GetGraphQLBucketState(System.Text.Json.JsonDocument response) { - public string RequestInfo { get; } - - [Obsolete("This property is obsolete and will be removed in a future version of ShopifySharp. If you need to use the response headers, please use the " + nameof(ResponseHeaders) + " property instead.")] - public HttpResponseMessage Response { get; } - - public HttpResponseHeaders ResponseHeaders { get; } - - public T Result { get; } - - public string RawResult { get; } - - /// - /// Only exists for list requests, will be null or empty for all others. - /// - public string RawLinkHeaderValue { get; } - - [Obsolete("This constructor is obsolete and will be removed in a future version of ShopifySharp.")] - public RequestResult(HttpResponseMessage response, T result, string rawResult, string rawLinkHeaderValue) - { - this.Response = response; - this.ResponseHeaders = response.Headers; - this.Result = result; - this.RawResult = rawResult; - this.RawLinkHeaderValue = rawLinkHeaderValue; - } - - public RequestResult( - string requestInfo, - HttpResponseMessage httpResponseMessage, - HttpResponseHeaders httpResponseHeaders, - T result, - string rawResult, - string rawLinkHeaderValue) - { - RequestInfo = requestInfo; - Response = httpResponseMessage; - ResponseHeaders = httpResponseHeaders; - Result = result; - RawResult = rawResult; - RawLinkHeaderValue = rawLinkHeaderValue; - } - - public RestBucketState GetRestBucketState() - { - return RestBucketState.Get(ResponseHeaders); - } - - public GraphQLBucketState GetGraphQLBucketState(System.Text.Json.JsonDocument response) - { - return GraphQLBucketState.Get(response); - } + return GraphQLBucketState.Get(response); } } diff --git a/ShopifySharp/Infrastructure/RequestUri.cs b/ShopifySharp/Infrastructure/RequestUri.cs index 41ba4731..9b76dbf9 100644 --- a/ShopifySharp/Infrastructure/RequestUri.cs +++ b/ShopifySharp/Infrastructure/RequestUri.cs @@ -2,34 +2,33 @@ using System.Linq; using System.Collections.Generic; -namespace ShopifySharp.Infrastructure +namespace ShopifySharp.Infrastructure; + +public class RequestUri { - public class RequestUri + public RequestUri(Uri uri) { - public RequestUri(Uri uri) - { - Url = uri; - } + Url = uri; + } - private Uri Url; + private Uri Url; - public Dictionary QueryParams { get; } = new Dictionary(); + public Dictionary QueryParams { get; } = new Dictionary(); - public Uri ToUri() + public Uri ToUri() + { + // Combine the url and the query param dictionary into a uri + var query = QueryParams.Select(kvp => { - // Combine the url and the query param dictionary into a uri - var query = QueryParams.Select(kvp => - { - return $"{kvp.Key}={Uri.EscapeDataString(kvp.Value.ToString())}"; - }); - var ub = new UriBuilder(Url) - { - Query = string.Join("&", query) - }; - - return ub.Uri; - } + return $"{kvp.Key}={Uri.EscapeDataString(kvp.Value.ToString())}"; + }); + var ub = new UriBuilder(Url) + { + Query = string.Join("&", query) + }; - public override string ToString() => ToUri().ToString(); + return ub.Uri; } + + public override string ToString() => ToUri().ToString(); } \ No newline at end of file diff --git a/ShopifySharp/Infrastructure/Serializer.cs b/ShopifySharp/Infrastructure/Serializer.cs index 73440167..b5b8443d 100644 --- a/ShopifySharp/Infrastructure/Serializer.cs +++ b/ShopifySharp/Infrastructure/Serializer.cs @@ -4,64 +4,63 @@ using System; using System.Collections.Generic; -namespace ShopifySharp.Infrastructure +namespace ShopifySharp.Infrastructure; + +/// +/// Contains JSON serialization settings and methods used by the rest of the ShopifySharp package. +/// +public static class Serializer { - /// - /// Contains JSON serialization settings and methods used by the rest of the ShopifySharp package. - /// - public static class Serializer + public static JsonSerializerSettings CreateNewtonsoftSettings() { - public static JsonSerializerSettings CreateNewtonsoftSettings() + return new JsonSerializerSettings { - return new JsonSerializerSettings + DateParseHandling = DateParseHandling.DateTimeOffset, + NullValueHandling = NullValueHandling.Ignore, + Converters = new List { - DateParseHandling = DateParseHandling.DateTimeOffset, - NullValueHandling = NullValueHandling.Ignore, - Converters = new List - { - new InvalidDateConverter() - } - }; - } + new InvalidDateConverter() + } + }; + } - public static string Serialize(object data) => JsonConvert.SerializeObject(data, CreateNewtonsoftSettings()); + public static string Serialize(object data) => JsonConvert.SerializeObject(data, CreateNewtonsoftSettings()); - public static T Deserialize(string json, string rootElementPath = null, DateParseHandling? dateParseHandlingOverride = null) - { - if (typeof(T) == typeof(System.Text.Json.JsonDocument)) - return DeserializeWithSystemTextJson(json); - else - return DeserializeWithNewtonsoft(json, rootElementPath, dateParseHandlingOverride); - } + public static T Deserialize(string json, string rootElementPath = null, DateParseHandling? dateParseHandlingOverride = null) + { + if (typeof(T) == typeof(System.Text.Json.JsonDocument)) + return DeserializeWithSystemTextJson(json); + else + return DeserializeWithNewtonsoft(json, rootElementPath, dateParseHandlingOverride); + } - /// This method is not used internally by ShopifySharp but can be used to deserialize webhook JSON payloads into objects - public static object Deserialize(string json, Type objectType) - { - var settings = CreateNewtonsoftSettings(); - return JsonConvert.DeserializeObject(json, objectType, settings); - } + /// This method is not used internally by ShopifySharp but can be used to deserialize webhook JSON payloads into objects + public static object Deserialize(string json, Type objectType) + { + var settings = CreateNewtonsoftSettings(); + return JsonConvert.DeserializeObject(json, objectType, settings); + } - private static T DeserializeWithNewtonsoft(string json, string rootElementPath, DateParseHandling? dateParseHandlingOverride) - { - var settings = CreateNewtonsoftSettings(); - if (dateParseHandlingOverride != null) - settings.DateParseHandling = dateParseHandlingOverride.Value; + private static T DeserializeWithNewtonsoft(string json, string rootElementPath, DateParseHandling? dateParseHandlingOverride) + { + var settings = CreateNewtonsoftSettings(); + if (dateParseHandlingOverride != null) + settings.DateParseHandling = dateParseHandlingOverride.Value; - if (rootElementPath != null) - { - var jToken = JsonConvert.DeserializeObject(json, settings); - jToken = jToken.SelectToken(rootElementPath); - return jToken.ToObject(JsonSerializer.Create(settings)); - } - else - { - return JsonConvert.DeserializeObject(json, settings); - } + if (rootElementPath != null) + { + var jToken = JsonConvert.DeserializeObject(json, settings); + jToken = jToken.SelectToken(rootElementPath); + return jToken.ToObject(JsonSerializer.Create(settings)); } - - private static T DeserializeWithSystemTextJson(string json) + else { - return System.Text.Json.JsonSerializer.Deserialize(json); + return JsonConvert.DeserializeObject(json, settings); } } + + private static T DeserializeWithSystemTextJson(string json) + { + return System.Text.Json.JsonSerializer.Deserialize(json); + } } \ No newline at end of file diff --git a/ShopifySharp/Infrastructure/ShopifyException.cs b/ShopifySharp/Infrastructure/ShopifyException.cs index 39af5685..c4c1bbe8 100644 --- a/ShopifySharp/Infrastructure/ShopifyException.cs +++ b/ShopifySharp/Infrastructure/ShopifyException.cs @@ -1,4 +1,4 @@ -#nullable enable +#nullable enable using System; using System.Collections.Generic; using System.Linq; @@ -6,42 +6,41 @@ using System.Net.Http; using ShopifySharp.Infrastructure; -namespace ShopifySharp +namespace ShopifySharp; + +public class ShopifyException : Exception { - public class ShopifyException : Exception + /// The Http response status code. + [Obsolete("This property has been moved to the " + nameof(ShopifyHttpException) + " and will be removed in a future version of ShopifySharp.")] + public HttpStatusCode HttpStatusCode { get; } + + /// The X-Request-Id header returned by Shopify. Can be used when working with the Shopify support team to identify the failed request. + [Obsolete("This property has been moved to the " + nameof(ShopifyHttpException) + " and will be removed in a future version of ShopifySharp.")] + public string? RequestId { get; } + + /// A list of error messages returned by Shopify. + [Obsolete("This property has been moved to the " + nameof(ShopifyHttpException) + " and will be removed in a future version of ShopifySharp.")] + public IEnumerable Errors { get; } = Enumerable.Empty(); + + /// The raw string body returned by Shopify. + [Obsolete("This property has been moved to the " + nameof(ShopifyHttpException) + " and will be removed in a future version of ShopifySharp.")] + public string RawBody { get; } + + public ShopifyException() { } + + public ShopifyException(string message, Exception? innerException = null) : base(message, innerException) { } + + public ShopifyException( + HttpStatusCode httpStatusCode, + IEnumerable errors, + string message, + string rawBody, + string? requestId + ) : base(message) { - /// The Http response status code. - [Obsolete("This property has been moved to the " + nameof(ShopifyHttpException) + " and will be removed in a future version of ShopifySharp.")] - public HttpStatusCode HttpStatusCode { get; } - - /// The X-Request-Id header returned by Shopify. Can be used when working with the Shopify support team to identify the failed request. - [Obsolete("This property has been moved to the " + nameof(ShopifyHttpException) + " and will be removed in a future version of ShopifySharp.")] - public string? RequestId { get; } - - /// A list of error messages returned by Shopify. - [Obsolete("This property has been moved to the " + nameof(ShopifyHttpException) + " and will be removed in a future version of ShopifySharp.")] - public IEnumerable Errors { get; } = Enumerable.Empty(); - - /// The raw string body returned by Shopify. - [Obsolete("This property has been moved to the " + nameof(ShopifyHttpException) + " and will be removed in a future version of ShopifySharp.")] - public string RawBody { get; } - - public ShopifyException() { } - - public ShopifyException(string message, Exception? innerException = null) : base(message, innerException) { } - - public ShopifyException( - HttpStatusCode httpStatusCode, - IEnumerable errors, - string message, - string rawBody, - string? requestId - ) : base(message) - { - HttpStatusCode = httpStatusCode; - Errors = (errors ?? Enumerable.Empty()).ToArray(); - RawBody = rawBody; - RequestId = requestId; - } + HttpStatusCode = httpStatusCode; + Errors = (errors ?? Enumerable.Empty()).ToArray(); + RawBody = rawBody; + RequestId = requestId; } -} +} \ No newline at end of file diff --git a/ShopifySharp/Infrastructure/ShopifyRateLimitException.cs b/ShopifySharp/Infrastructure/ShopifyRateLimitException.cs index a1c6fb10..2d05eb34 100644 --- a/ShopifySharp/Infrastructure/ShopifyRateLimitException.cs +++ b/ShopifySharp/Infrastructure/ShopifyRateLimitException.cs @@ -1,4 +1,4 @@ -#nullable enable +#nullable enable using System.Collections.Generic; using System.Net; using System.Net.Http; diff --git a/ShopifySharp/Infrastructure/ShopifyRateLimitReason.cs b/ShopifySharp/Infrastructure/ShopifyRateLimitReason.cs index 6a6aedf2..8779d182 100644 --- a/ShopifySharp/Infrastructure/ShopifyRateLimitReason.cs +++ b/ShopifySharp/Infrastructure/ShopifyRateLimitReason.cs @@ -1,8 +1,7 @@ -namespace ShopifySharp +namespace ShopifySharp; + +public enum ShopifyRateLimitReason { - public enum ShopifyRateLimitReason - { - BucketFull, - Other - } -} + BucketFull, + Other +} \ No newline at end of file diff --git a/ShopifySharp/Lists/LinkHeaderParser.cs b/ShopifySharp/Lists/LinkHeaderParser.cs index 0526af7c..f810ce09 100644 --- a/ShopifySharp/Lists/LinkHeaderParser.cs +++ b/ShopifySharp/Lists/LinkHeaderParser.cs @@ -1,65 +1,64 @@ -using System; +using System; using System.Linq; using System.Text.RegularExpressions; -namespace ShopifySharp.Lists +namespace ShopifySharp.Lists; + +public static class LinkHeaderParser { - public static class LinkHeaderParser + private static Regex _regexPrevLink = new Regex(@"<(https://[^>]*)>\s*;\s*rel=""previous""", RegexOptions.Compiled | RegexOptions.CultureInvariant); + private static Regex _regexNextLink = new Regex(@"<(https://[^>]*)>\s*;\s*rel=""next""", RegexOptions.Compiled | RegexOptions.CultureInvariant); + + public static LinkHeaderParseResult Parse(string linkHeaderValue) { - private static Regex _regexPrevLink = new Regex(@"<(https://[^>]*)>\s*;\s*rel=""previous""", RegexOptions.Compiled | RegexOptions.CultureInvariant); - private static Regex _regexNextLink = new Regex(@"<(https://[^>]*)>\s*;\s*rel=""next""", RegexOptions.Compiled | RegexOptions.CultureInvariant); + var prevLink = GetPageInfoParam(linkHeaderValue, _regexPrevLink); + var nextLink = GetPageInfoParam(linkHeaderValue, _regexNextLink); - public static LinkHeaderParseResult Parse(string linkHeaderValue) + if (prevLink == null && nextLink == null) { - var prevLink = GetPageInfoParam(linkHeaderValue, _regexPrevLink); - var nextLink = GetPageInfoParam(linkHeaderValue, _regexNextLink); + throw new ShopifyException($"Found neither a 'previous' or 'next' url in the link header: '{linkHeaderValue}'"); + } - if (prevLink == null && nextLink == null) - { - throw new ShopifyException($"Found neither a 'previous' or 'next' url in the link header: '{linkHeaderValue}'"); - } + return new LinkHeaderParseResult(prevLink, nextLink); + } - return new LinkHeaderParseResult(prevLink, nextLink); - } + private static PagingLink GetPageInfoParam(string linkHeaderValue, Regex linkRegex) + { + var match = linkRegex.Match(linkHeaderValue); - private static PagingLink GetPageInfoParam(string linkHeaderValue, Regex linkRegex) + if (!match.Success || match.Groups.Count < 2 || !match.Groups[1].Success) { - var match = linkRegex.Match(linkHeaderValue); - - if (!match.Success || match.Groups.Count < 2 || !match.Groups[1].Success) - { - return null; - } + return null; + } - string matchedUrl = match.Groups[1].Value; + string matchedUrl = match.Groups[1].Value; - // TODO: refactor this to use the domain utility? - if (!Uri.TryCreate(matchedUrl, UriKind.Absolute, out var uri)) - { - throw new ShopifyException($"Cannot parse page link url: '{matchedUrl}'"); - } + // TODO: refactor this to use the domain utility? + if (!Uri.TryCreate(matchedUrl, UriKind.Absolute, out var uri)) + { + throw new ShopifyException($"Cannot parse page link url: '{matchedUrl}'"); + } - var decodedUriQuery = Uri.UnescapeDataString(uri.Query); + var decodedUriQuery = Uri.UnescapeDataString(uri.Query); - string GetQueryParam(string name) - { - return decodedUriQuery.Split('?', '&') - .FirstOrDefault(p => p.StartsWith($"{name}=")) - ?.Substring ($"{name}=".Length); - } + string GetQueryParam(string name) + { + return decodedUriQuery.Split('?', '&') + .FirstOrDefault(p => p.StartsWith($"{name}=")) + ?.Substring ($"{name}=".Length); + } - string pageInfo = GetQueryParam("page_info"); - string fields = GetQueryParam("fields"); + string pageInfo = GetQueryParam("page_info"); + string fields = GetQueryParam("fields"); - if (pageInfo == null) - { - throw new ShopifyException($"Cannot parse page link's page info parameter: '{matchedUrl}'"); - } + if (pageInfo == null) + { + throw new ShopifyException($"Cannot parse page link's page info parameter: '{matchedUrl}'"); + } - int.TryParse(GetQueryParam("limit"), out int limit); + int.TryParse(GetQueryParam("limit"), out int limit); - return new PagingLink(matchedUrl, pageInfo, limit != 0 ? (int?)limit : null, fields ?? null); - } + return new PagingLink(matchedUrl, pageInfo, limit != 0 ? (int?)limit : null, fields ?? null); } -} +} \ No newline at end of file diff --git a/ShopifySharp/Lists/LinkHeaderParserResult.cs b/ShopifySharp/Lists/LinkHeaderParserResult.cs index 02f7764a..c49a0351 100644 --- a/ShopifySharp/Lists/LinkHeaderParserResult.cs +++ b/ShopifySharp/Lists/LinkHeaderParserResult.cs @@ -1,15 +1,14 @@ -namespace ShopifySharp.Lists +namespace ShopifySharp.Lists; + +public class LinkHeaderParseResult { - public class LinkHeaderParseResult - { - public PagingLink PreviousLink { get; } + public PagingLink PreviousLink { get; } - public PagingLink NextLink { get; } + public PagingLink NextLink { get; } - public LinkHeaderParseResult(PagingLink previousLink, PagingLink nextLink) - { - PreviousLink = previousLink; - NextLink = nextLink; - } + public LinkHeaderParseResult(PagingLink previousLink, PagingLink nextLink) + { + PreviousLink = previousLink; + NextLink = nextLink; } -} +} \ No newline at end of file diff --git a/ShopifySharp/Lists/ListResult.cs b/ShopifySharp/Lists/ListResult.cs index db1e51f0..f621a6d1 100644 --- a/ShopifySharp/Lists/ListResult.cs +++ b/ShopifySharp/Lists/ListResult.cs @@ -1,32 +1,31 @@ using ShopifySharp.Filters; using System.Collections.Generic; -namespace ShopifySharp.Lists +namespace ShopifySharp.Lists; + +public class ListResult { - public class ListResult - { - public IEnumerable Items { get; } + public IEnumerable Items { get; } - public LinkHeaderParseResult LinkHeader { get; } + public LinkHeaderParseResult LinkHeader { get; } - public bool HasNextPage => LinkHeader?.NextLink != null; + public bool HasNextPage => LinkHeader?.NextLink != null; - public bool HasPreviousPage => LinkHeader?.PreviousLink != null; + public bool HasPreviousPage => LinkHeader?.PreviousLink != null; - public ListFilter GetNextPageFilter(int? limit = null, string fields = null) - { - return LinkHeader?.NextLink?.GetFollowingPageFilter(limit, fields); - } + public ListFilter GetNextPageFilter(int? limit = null, string fields = null) + { + return LinkHeader?.NextLink?.GetFollowingPageFilter(limit, fields); + } - public ListFilter GetPreviousPageFilter(int? limit = null, string fields = null) - { - return LinkHeader?.PreviousLink?.GetFollowingPageFilter(limit, fields); - } + public ListFilter GetPreviousPageFilter(int? limit = null, string fields = null) + { + return LinkHeader?.PreviousLink?.GetFollowingPageFilter(limit, fields); + } - public ListResult(IEnumerable items, LinkHeaderParseResult linkHeader) - { - Items = items; - LinkHeader = linkHeader; - } + public ListResult(IEnumerable items, LinkHeaderParseResult linkHeader) + { + Items = items; + LinkHeader = linkHeader; } } \ No newline at end of file diff --git a/ShopifySharp/Lists/PagingLink.cs b/ShopifySharp/Lists/PagingLink.cs index a8b8ba86..1de73613 100644 --- a/ShopifySharp/Lists/PagingLink.cs +++ b/ShopifySharp/Lists/PagingLink.cs @@ -1,29 +1,27 @@ using ShopifySharp.Filters; -namespace ShopifySharp.Lists +namespace ShopifySharp.Lists; + +public class PagingLink { - public class PagingLink - { - public string Url { get; } + public string Url { get; } - public int? Limit { get; } + public int? Limit { get; } - public string PageInfo { get; } + public string PageInfo { get; } - public string Fields { get; } - - public PagingLink(string url, string pageInfo, int? limit, string fields = null) - { - Url = url; - PageInfo = pageInfo; - Limit = limit; - Fields = fields; - } + public string Fields { get; } - public ListFilter GetFollowingPageFilter(int? limit = null, string fields = null) - { - return new ListFilter(this.PageInfo, limit ?? this.Limit, fields ?? this.Fields); - } + public PagingLink(string url, string pageInfo, int? limit, string fields = null) + { + Url = url; + PageInfo = pageInfo; + Limit = limit; + Fields = fields; } -} + public ListFilter GetFollowingPageFilter(int? limit = null, string fields = null) + { + return new ListFilter(this.PageInfo, limit ?? this.Limit, fields ?? this.Fields); + } +} \ No newline at end of file diff --git a/ShopifySharp/Services/AccessScope/AccessScopeService.cs b/ShopifySharp/Services/AccessScope/AccessScopeService.cs index 0356f601..1f565dfc 100644 --- a/ShopifySharp/Services/AccessScope/AccessScopeService.cs +++ b/ShopifySharp/Services/AccessScope/AccessScopeService.cs @@ -1,54 +1,51 @@ -using ShopifySharp.Enums; +using ShopifySharp.Enums; using System.Collections.Generic; using System.Linq; using System.Threading; using System.Threading.Tasks; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for getting the access scopes associated with the access token +/// +public class AccessScopeService : ShopifyService, IAccessScopeService { + //oauth endpoints don't support versioning + public override bool SupportsAPIVersioning => false; + /// - /// A service for getting the access scopes associated with the access token + /// Creates a new instance of the service. /// - public class AccessScopeService : ShopifyService, IAccessScopeService - { - //oauth endpoints don't support versioning - public override bool SupportsAPIVersioning => false; - - /// - /// Creates a new instance of the service. - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public AccessScopeService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal AccessScopeService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public AccessScopeService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal AccessScopeService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(CancellationToken cancellationToken = default) - { - return await ExecuteGetAsync>("oauth/access_scopes.json", "access_scopes", cancellationToken: cancellationToken); - } + /// + public virtual async Task> ListAsync(CancellationToken cancellationToken = default) + { + return await ExecuteGetAsync>("oauth/access_scopes.json", "access_scopes", cancellationToken: cancellationToken); + } - /// - /// Requests a subset of granular access scopes for an individual shop installation. - /// - public virtual async Task> RequestGranularAccessScopesAsync(IEnumerable requestedScopes, CancellationToken cancellationToken = default) - { - return await RequestGranularAccessScopesAsync(requestedScopes.Select(s => s.ToSerializedString()), cancellationToken); - } + /// + /// Requests a subset of granular access scopes for an individual shop installation. + /// + public virtual async Task> RequestGranularAccessScopesAsync(IEnumerable requestedScopes, CancellationToken cancellationToken = default) + { + return await RequestGranularAccessScopesAsync(requestedScopes.Select(s => s.ToSerializedString()), cancellationToken); + } - /// - /// Requests a subset of granular access scopes for an individual shop installation. - /// - public virtual async Task> RequestGranularAccessScopesAsync(IEnumerable requestedScopes, CancellationToken cancellationToken = default) + /// + /// Requests a subset of granular access scopes for an individual shop installation. + /// + public virtual async Task> RequestGranularAccessScopesAsync(IEnumerable requestedScopes, CancellationToken cancellationToken = default) + { + var content = new { - var content = new - { - requested_scopes = requestedScopes, - }; - return await ExecutePostAsync>("request_granular_access_scopes.json", "access_scopes", cancellationToken: cancellationToken, content); - } + requested_scopes = requestedScopes, + }; + return await ExecutePostAsync>("request_granular_access_scopes.json", "access_scopes", cancellationToken: cancellationToken, content); } -} - - +} \ No newline at end of file diff --git a/ShopifySharp/Services/AccessScope/IAccessScopeService.cs b/ShopifySharp/Services/AccessScope/IAccessScopeService.cs index c98a70f2..bd2bc979 100644 --- a/ShopifySharp/Services/AccessScope/IAccessScopeService.cs +++ b/ShopifySharp/Services/AccessScope/IAccessScopeService.cs @@ -3,23 +3,22 @@ using System.Threading; using System.Threading.Tasks; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IAccessScopeService : IShopifyService { - public interface IAccessScopeService : IShopifyService - { - /// - /// Retrieves a list of access scopes associated to the access token. - /// - Task> ListAsync(CancellationToken cancellationToken = default); + /// + /// Retrieves a list of access scopes associated to the access token. + /// + Task> ListAsync(CancellationToken cancellationToken = default); - /// - /// Requests a subset of granular access scopes for an individual shop installation. - /// - Task> RequestGranularAccessScopesAsync(IEnumerable requestedScopes, CancellationToken cancellationToken = default); + /// + /// Requests a subset of granular access scopes for an individual shop installation. + /// + Task> RequestGranularAccessScopesAsync(IEnumerable requestedScopes, CancellationToken cancellationToken = default); - /// - /// Requests a subset of granular access scopes for an individual shop installation. - /// - Task> RequestGranularAccessScopesAsync(IEnumerable requestedScopes, CancellationToken cancellationToken = default); - } + /// + /// Requests a subset of granular access scopes for an individual shop installation. + /// + Task> RequestGranularAccessScopesAsync(IEnumerable requestedScopes, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/ApplicationCredit/ApplicationCreditService.cs b/ShopifySharp/Services/ApplicationCredit/ApplicationCreditService.cs index 6cb587a2..4fde844f 100644 --- a/ShopifySharp/Services/ApplicationCredit/ApplicationCreditService.cs +++ b/ShopifySharp/Services/ApplicationCredit/ApplicationCreditService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Net.Http; @@ -6,45 +6,44 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for offering credits for payments made via the Application Charge, Recurring Application Charge, and Usage Charge APIs. +/// +public class ApplicationCreditService : ShopifyService, IApplicationCreditService { /// - /// A service for offering credits for payments made via the Application Charge, Recurring Application Charge, and Usage Charge APIs. + /// Creates a new instance of . /// - public class ApplicationCreditService : ShopifyService, IApplicationCreditService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public ApplicationCreditService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal ApplicationCreditService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public ApplicationCreditService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal ApplicationCreditService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("application_credits.json", "application_credits", filter, cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("application_credits.json", "application_credits", filter, cancellationToken); - /// - public virtual async Task> ListAsync(ApplicationCreditListFilter filter, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListAsync(ApplicationCreditListFilter filter, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"application_credits/{id}.json", "application_credit", fields, cancellationToken); + /// + public virtual async Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"application_credits/{id}.json", "application_credit", fields, cancellationToken); - /// - public virtual async Task CreateAsync(ApplicationCredit credit, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(ApplicationCredit credit, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"application_credits.json"); + var body = new JsonContent(new { - var req = BuildRequestUri($"application_credits.json"); - var body = new JsonContent(new - { - application_credit = credit, - }); + application_credit = credit, + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, body, "application_credit"); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, body, "application_credit"); - return response.Result; - } + return response.Result; } -} +} \ No newline at end of file diff --git a/ShopifySharp/Services/ApplicationCredit/IApplicationCreditService.cs b/ShopifySharp/Services/ApplicationCredit/IApplicationCreditService.cs index 8d6eaf3f..222265e8 100644 --- a/ShopifySharp/Services/ApplicationCredit/IApplicationCreditService.cs +++ b/ShopifySharp/Services/ApplicationCredit/IApplicationCreditService.cs @@ -3,33 +3,32 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IApplicationCreditService : IShopifyService { - public interface IApplicationCreditService : IShopifyService - { - /// - /// Gets a list of all past and present application credits. - /// - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of all past and present application credits. + /// + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - /// - /// Gets a list of all past and present application credits. - /// - Task> ListAsync(ApplicationCreditListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of all past and present application credits. + /// + Task> ListAsync(ApplicationCreditListFilter filter, CancellationToken cancellationToken = default); - /// - /// Retrieves the application credit with the given id. - /// - /// The application credit's id. - /// A comma-separated list of fields to include in the response. - /// Cancellation Token - Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the application credit with the given id. + /// + /// The application credit's id. + /// A comma-separated list of fields to include in the response. + /// Cancellation Token + Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default); - /// - /// Creates a new . - /// - /// A new . Id should be set to null. - /// Cancellation Token - Task CreateAsync(ApplicationCredit credit, CancellationToken cancellationToken = default); - } + /// + /// Creates a new . + /// + /// A new . Id should be set to null. + /// Cancellation Token + Task CreateAsync(ApplicationCredit credit, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Article/ArticleService.cs b/ShopifySharp/Services/Article/ArticleService.cs index 74707f6c..f5eb5c6a 100644 --- a/ShopifySharp/Services/Article/ArticleService.cs +++ b/ShopifySharp/Services/Article/ArticleService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Collections.Generic; @@ -7,140 +7,139 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating a blog's articles. +/// +public class ArticleService : ShopifyService, IArticleService { /// - /// A service for manipulating a blog's articles. + /// Creates a new instance of the service. /// - public class ArticleService : ShopifyService, IArticleService - { - /// - /// Creates a new instance of the service. - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public ArticleService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal ArticleService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public ArticleService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal ArticleService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(long blogId, ListFilter
filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync($"blogs/{blogId}/articles.json", "articles", filter, cancellationToken); + /// + public virtual async Task> ListAsync(long blogId, ListFilter
filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync($"blogs/{blogId}/articles.json", "articles", filter, cancellationToken); - /// - public virtual async Task> ListAsync(int blogId, ArticleListFilter filter, CancellationToken cancellationToken = default) => - await ListAsync(blogId, (ListFilter
) filter, cancellationToken); + /// + public virtual async Task> ListAsync(int blogId, ArticleListFilter filter, CancellationToken cancellationToken = default) => + await ListAsync(blogId, (ListFilter
) filter, cancellationToken); - /// - public virtual async Task CountAsync(long blogId, ArticleCountFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"blogs/{blogId}/articles/count.json", "count", filter, cancellationToken); + /// + public virtual async Task CountAsync(long blogId, ArticleCountFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"blogs/{blogId}/articles/count.json", "count", filter, cancellationToken); + + /// + public virtual async Task
GetAsync(long blogId, long articleId, string fields = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"blogs/{blogId}/articles/{articleId}.json"); - /// - public virtual async Task
GetAsync(long blogId, long articleId, string fields = null, CancellationToken cancellationToken = default) + if (fields != null) { - var req = BuildRequestUri($"blogs/{blogId}/articles/{articleId}.json"); + req.QueryParams.Add("fields", fields); + } + + var response = await ExecuteRequestAsync
(req, HttpMethod.Get, cancellationToken, rootElement: "article"); + return response.Result; + } - if (fields != null) - { - req.QueryParams.Add("fields", fields); - } + /// + public virtual async Task
CreateAsync(long blogId, Article article, IEnumerable metafields = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"blogs/{blogId}/articles.json"); + var body = article.ToDictionary(); - var response = await ExecuteRequestAsync
(req, HttpMethod.Get, cancellationToken, rootElement: "article"); - return response.Result; + if (metafields != null) + { + body.Add("metafields", metafields); } - /// - public virtual async Task
CreateAsync(long blogId, Article article, IEnumerable metafields = null, CancellationToken cancellationToken = default) + var content = new JsonContent(new { - var req = BuildRequestUri($"blogs/{blogId}/articles.json"); - var body = article.ToDictionary(); + article = body + }); - if (metafields != null) - { - body.Add("metafields", metafields); - } + var response = await ExecuteRequestAsync
(req, HttpMethod.Post, cancellationToken, content, "article"); + return response.Result; + } - var content = new JsonContent(new - { - article = body - }); + /// + public virtual async Task
UpdateAsync(long blogId, long articleId, Article article, IEnumerable metafields = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"blogs/{blogId}/articles/{articleId}.json"); + var body = article.ToDictionary(); - var response = await ExecuteRequestAsync
(req, HttpMethod.Post, cancellationToken, content, "article"); - return response.Result; + if (metafields != null) + { + body.Add("metafields", metafields); } - /// - public virtual async Task
UpdateAsync(long blogId, long articleId, Article article, IEnumerable metafields = null, CancellationToken cancellationToken = default) + var content = new JsonContent(new { - var req = BuildRequestUri($"blogs/{blogId}/articles/{articleId}.json"); - var body = article.ToDictionary(); + article = body + }); - if (metafields != null) - { - body.Add("metafields", metafields); - } + var response = await ExecuteRequestAsync
(req, HttpMethod.Put, cancellationToken, content, "article"); + return response.Result; + } - var content = new JsonContent(new - { - article = body - }); + /// + public virtual async Task DeleteAsync(long blogId, long articleId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"blogs/{blogId}/articles/{articleId}.json"); - var response = await ExecuteRequestAsync
(req, HttpMethod.Put, cancellationToken, content, "article"); - return response.Result; - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); + } - /// - public virtual async Task DeleteAsync(long blogId, long articleId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"blogs/{blogId}/articles/{articleId}.json"); + /// + public virtual async Task> ListAuthorsAsync(CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"articles/authors.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "authors"); + return response.Result; + } - /// - public virtual async Task> ListAuthorsAsync(CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"articles/authors.json"); + /// + public virtual async Task> ListTagsAsync(int? popular = null, int? limit = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"articles/tags.json"); - var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "authors"); - return response.Result; + if (popular.HasValue) + { + req.QueryParams.Add("popular", popular.Value); } - /// - public virtual async Task> ListTagsAsync(int? popular = null, int? limit = null, CancellationToken cancellationToken = default) + if (limit.HasValue) { - var req = BuildRequestUri($"articles/tags.json"); + req.QueryParams.Add("limit", limit.Value); + } - if (popular.HasValue) - { - req.QueryParams.Add("popular", popular.Value); - } + var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "tags"); + return response.Result; + } - if (limit.HasValue) - { - req.QueryParams.Add("limit", limit.Value); - } + /// + public virtual async Task> ListTagsForBlogAsync(long blogId, int? popular = null, int? limit = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"blogs/{blogId}/articles/tags.json"); - var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "tags"); - return response.Result; + if (popular.HasValue) + { + req.QueryParams.Add("popular", popular.Value); } - /// - public virtual async Task> ListTagsForBlogAsync(long blogId, int? popular = null, int? limit = null, CancellationToken cancellationToken = default) + if (limit.HasValue) { - var req = BuildRequestUri($"blogs/{blogId}/articles/tags.json"); - - if (popular.HasValue) - { - req.QueryParams.Add("popular", popular.Value); - } - - if (limit.HasValue) - { - req.QueryParams.Add("limit", limit.Value); - } - - var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "tags"); - return response.Result; + req.QueryParams.Add("limit", limit.Value); } + + var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "tags"); + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/Article/IArticleService.cs b/ShopifySharp/Services/Article/IArticleService.cs index a1c424f4..53ce365e 100644 --- a/ShopifySharp/Services/Article/IArticleService.cs +++ b/ShopifySharp/Services/Article/IArticleService.cs @@ -4,84 +4,83 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IArticleService : IShopifyService { - public interface IArticleService : IShopifyService - { - /// - /// Gets a list of up to 250 articles belonging to the given blog. - /// - Task> ListAsync(long blogId, ListFilter
filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 articles belonging to the given blog. + /// + Task> ListAsync(long blogId, ListFilter
filter = null, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 articles belonging to the given blog. - /// - Task> ListAsync(int blogId, ArticleListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 articles belonging to the given blog. + /// + Task> ListAsync(int blogId, ArticleListFilter filter, CancellationToken cancellationToken = default); - /// - /// Gets a count of the articles belonging to the given blog. - /// - /// The blog that the articles belong to. - /// Options for filtering the result. - /// Cancellation Token - Task CountAsync(long blogId, ArticleCountFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a count of the articles belonging to the given blog. + /// + /// The blog that the articles belong to. + /// Options for filtering the result. + /// Cancellation Token + Task CountAsync(long blogId, ArticleCountFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Gets an article with the given id. - /// - /// The blog that the article belongs to. - /// The article's id. - /// A comma-separated list of fields to return. - /// Cancellation Token - Task
GetAsync(long blogId, long articleId, string fields = null, CancellationToken cancellationToken = default); + /// + /// Gets an article with the given id. + /// + /// The blog that the article belongs to. + /// The article's id. + /// A comma-separated list of fields to return. + /// Cancellation Token + Task
GetAsync(long blogId, long articleId, string fields = null, CancellationToken cancellationToken = default); - /// - /// Creates a new article on the given blog. - /// - /// The blog that the article will belong to. - /// The article being created. Id should be null. - /// Optional metafield data that can be returned by the . - /// Cancellation Token - Task
CreateAsync(long blogId, Article article, IEnumerable metafields = null, CancellationToken cancellationToken = default); + /// + /// Creates a new article on the given blog. + /// + /// The blog that the article will belong to. + /// The article being created. Id should be null. + /// Optional metafield data that can be returned by the . + /// Cancellation Token + Task
CreateAsync(long blogId, Article article, IEnumerable metafields = null, CancellationToken cancellationToken = default); - /// - /// Updates an article. - /// - /// The blog that the article belongs to. - /// Id of the object being updated. - /// The article being updated. - /// Optional metafield data that can be returned by the . - /// Cancellation Token - Task
UpdateAsync(long blogId, long articleId, Article article, IEnumerable metafields = null, CancellationToken cancellationToken = default); + /// + /// Updates an article. + /// + /// The blog that the article belongs to. + /// Id of the object being updated. + /// The article being updated. + /// Optional metafield data that can be returned by the . + /// Cancellation Token + Task
UpdateAsync(long blogId, long articleId, Article article, IEnumerable metafields = null, CancellationToken cancellationToken = default); - /// - /// Deletes an article with the given id. - /// - /// The blog that the article belongs to. - /// The article benig deleted. - /// Cancellation Token - Task DeleteAsync(long blogId, long articleId, CancellationToken cancellationToken = default); + /// + /// Deletes an article with the given id. + /// + /// The blog that the article belongs to. + /// The article benig deleted. + /// Cancellation Token + Task DeleteAsync(long blogId, long articleId, CancellationToken cancellationToken = default); - /// - /// Gets a list of all article authors. - /// - Task> ListAuthorsAsync(CancellationToken cancellationToken = default); + /// + /// Gets a list of all article authors. + /// + Task> ListAuthorsAsync(CancellationToken cancellationToken = default); - /// - /// Gets a list of all article tags. - /// - /// The number of tags to return - /// A flag to indicate only to a certain number of the most popular tags. - /// Cancellation Token - Task> ListTagsAsync(int? popular = null, int? limit = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of all article tags. + /// + /// The number of tags to return + /// A flag to indicate only to a certain number of the most popular tags. + /// Cancellation Token + Task> ListTagsAsync(int? popular = null, int? limit = null, CancellationToken cancellationToken = default); - /// - /// Gets a list of all article tags for the given blog. - /// - /// The blog that the tags belong to. - /// The number of tags to return - /// A flag to indicate only to a certain number of the most popular tags. - /// Cancellation Token - Task> ListTagsForBlogAsync(long blogId, int? popular = null, int? limit = null, CancellationToken cancellationToken = default); - } + /// + /// Gets a list of all article tags for the given blog. + /// + /// The blog that the tags belong to. + /// The number of tags to return + /// A flag to indicate only to a certain number of the most popular tags. + /// Cancellation Token + Task> ListTagsForBlogAsync(long blogId, int? popular = null, int? limit = null, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Asset/AssetService.cs b/ShopifySharp/Services/Asset/AssetService.cs index d7ab99a4..73b1b1f1 100644 --- a/ShopifySharp/Services/Asset/AssetService.cs +++ b/ShopifySharp/Services/Asset/AssetService.cs @@ -1,4 +1,4 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Threading.Tasks; using System.Net.Http; using System.Threading; @@ -6,80 +6,79 @@ using ShopifySharp.Infrastructure; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify's Assets API. +/// +public class AssetService : ShopifyService, IAssetService { /// - /// A service for manipulating Shopify's Assets API. + /// Creates a new instance of . /// - public class AssetService : ShopifyService, IAssetService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public AssetService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal AssetService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public AssetService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal AssetService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task GetAsync(long themeId, string key, string fields = null, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"themes/{themeId}/assets.json"); - // Add the proper asset querystring - req = SetAssetQuerystring(req, key, themeId); + /// + public virtual async Task GetAsync(long themeId, string key, string fields = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"themes/{themeId}/assets.json"); + // Add the proper asset querystring + req = SetAssetQuerystring(req, key, themeId); - if (string.IsNullOrEmpty(fields) == false) - { - req.QueryParams.Add("fields", fields); - } + if (string.IsNullOrEmpty(fields) == false) + { + req.QueryParams.Add("fields", fields); + } - var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "asset"); + var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "asset"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task> ListAsync(long themeId, AssetListFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync>($"themes/{themeId}/assets.json", "assets", filter, cancellationToken); + /// + public virtual async Task> ListAsync(long themeId, AssetListFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync>($"themes/{themeId}/assets.json", "assets", filter, cancellationToken); - /// - public virtual async Task CreateOrUpdateAsync(long themeId, Asset asset, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateOrUpdateAsync(long themeId, Asset asset, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"themes/{themeId}/assets.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"themes/{themeId}/assets.json"); - var content = new JsonContent(new - { - asset = asset - }); + asset = asset + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "asset"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "asset"); + return response.Result; + } - /// - public virtual async Task DeleteAsync(long themeId, string key, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"themes/{themeId}/assets.json"); + /// + public virtual async Task DeleteAsync(long themeId, string key, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"themes/{themeId}/assets.json"); - req = SetAssetQuerystring(req, key, themeId); + req = SetAssetQuerystring(req, key, themeId); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); + } - /// - /// Sets the proper querystring for getting or deleting a single asset. - /// - /// The request to modify. - /// The key value of the asset, e.g. 'templates/index.liquid' or 'assets/bg-body.gif'. - /// The id of the theme that the asset belongs to. - /// The request with the proper querystring. - protected virtual RequestUri SetAssetQuerystring(RequestUri req, string key, long themeId) - { - //QS should look like: - //?asset[key]={key}&theme_id={themeId} - req.QueryParams.Add("asset[key]", key); - req.QueryParams.Add("theme_id", themeId); + /// + /// Sets the proper querystring for getting or deleting a single asset. + /// + /// The request to modify. + /// The key value of the asset, e.g. 'templates/index.liquid' or 'assets/bg-body.gif'. + /// The id of the theme that the asset belongs to. + /// The request with the proper querystring. + protected virtual RequestUri SetAssetQuerystring(RequestUri req, string key, long themeId) + { + //QS should look like: + //?asset[key]={key}&theme_id={themeId} + req.QueryParams.Add("asset[key]", key); + req.QueryParams.Add("theme_id", themeId); - return req; - } + return req; } } \ No newline at end of file diff --git a/ShopifySharp/Services/Asset/IAssetService.cs b/ShopifySharp/Services/Asset/IAssetService.cs index d4b6c018..764ff3ee 100644 --- a/ShopifySharp/Services/Asset/IAssetService.cs +++ b/ShopifySharp/Services/Asset/IAssetService.cs @@ -3,49 +3,48 @@ using System.Threading.Tasks; using ShopifySharp.Filters; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IAssetService : IShopifyService { - public interface IAssetService : IShopifyService - { - /// - /// Retrieves the with the given id. - /// - /// The id of the theme that the asset belongs to. Assets themselves do not have ids. - /// The key value of the asset, e.g. 'templates/index.liquid' or 'assets/bg-body.gif'. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long themeId, string key, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the theme that the asset belongs to. Assets themselves do not have ids. + /// The key value of the asset, e.g. 'templates/index.liquid' or 'assets/bg-body.gif'. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long themeId, string key, string fields = null, CancellationToken cancellationToken = default); - /// - /// Retrieves a list of all objects. Listing theme assets only returns metadata about each asset. - /// You need to request assets individually in order to get their contents. - /// - /// The id of the theme that the asset belongs to. - /// Options for filtering the list. - /// Cancellation Token - Task> ListAsync(long themeId, AssetListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Retrieves a list of all objects. Listing theme assets only returns metadata about each asset. + /// You need to request assets individually in order to get their contents. + /// + /// The id of the theme that the asset belongs to. + /// Options for filtering the list. + /// Cancellation Token + Task> ListAsync(long themeId, AssetListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Creates or updates a . Both tasks use the same method due to the - /// way Shopify API handles assets. If an asset has a unique value, - /// it will be created. If not, it will be updated. Copy an asset by setting the - /// to the target's value. - /// Note: This will not return the asset's property. You should - /// use to refresh the value after creating or updating. - /// - /// The id of the theme that the asset belongs to. - /// The asset. - /// Cancellation Token - /// The created or updated asset. - Task CreateOrUpdateAsync(long themeId, Asset asset, CancellationToken cancellationToken = default); + /// + /// Creates or updates a . Both tasks use the same method due to the + /// way Shopify API handles assets. If an asset has a unique value, + /// it will be created. If not, it will be updated. Copy an asset by setting the + /// to the target's value. + /// Note: This will not return the asset's property. You should + /// use to refresh the value after creating or updating. + /// + /// The id of the theme that the asset belongs to. + /// The asset. + /// Cancellation Token + /// The created or updated asset. + Task CreateOrUpdateAsync(long themeId, Asset asset, CancellationToken cancellationToken = default); - /// - /// Deletes a with the given key. - /// - /// The id of the theme that the asset belongs to. - /// The key value of the asset, e.g. 'templates/index.liquid' or 'assets/bg-body.gif'. - /// Cancellation Token - Task DeleteAsync(long themeId, string key, CancellationToken cancellationToken = default); - } + /// + /// Deletes a with the given key. + /// + /// The id of the theme that the asset belongs to. + /// The key value of the asset, e.g. 'templates/index.liquid' or 'assets/bg-body.gif'. + /// Cancellation Token + Task DeleteAsync(long themeId, string key, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/AssignedFulfillmentOrder/AssignedFulfillmentOrderService.cs b/ShopifySharp/Services/AssignedFulfillmentOrder/AssignedFulfillmentOrderService.cs index d8e2f35a..6ada2df2 100644 --- a/ShopifySharp/Services/AssignedFulfillmentOrder/AssignedFulfillmentOrderService.cs +++ b/ShopifySharp/Services/AssignedFulfillmentOrder/AssignedFulfillmentOrderService.cs @@ -1,30 +1,29 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Lists; using System.Threading; using System.Threading.Tasks; using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +public class AssignedFulfillmentOrderService : ShopifyService, IAssignedFulfillmentOrderService { - public class AssignedFulfillmentOrderService : ShopifyService, IAssignedFulfillmentOrderService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public AssignedFulfillmentOrderService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal AssignedFulfillmentOrderService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// + /// Creates a new instance of . + /// + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public AssignedFulfillmentOrderService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal AssignedFulfillmentOrderService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) - { - return await ExecuteGetListAsync("assigned_fulfillment_orders.json", "fulfillment_orders", filter, cancellationToken); - } + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) + { + return await ExecuteGetListAsync("assigned_fulfillment_orders.json", "fulfillment_orders", filter, cancellationToken); + } - public virtual async Task> ListAsync(AssignedFulfillmentOrderFilter filter = null, CancellationToken cancellationToken = default) - { - return await ListAsync(filter?.AsListFilter(), cancellationToken); - } + public virtual async Task> ListAsync(AssignedFulfillmentOrderFilter filter = null, CancellationToken cancellationToken = default) + { + return await ListAsync(filter?.AsListFilter(), cancellationToken); } -} +} \ No newline at end of file diff --git a/ShopifySharp/Services/AssignedFulfillmentOrder/IAssignedFulfillmentOrderService.cs b/ShopifySharp/Services/AssignedFulfillmentOrder/IAssignedFulfillmentOrderService.cs index 0a5de365..1da51398 100644 --- a/ShopifySharp/Services/AssignedFulfillmentOrder/IAssignedFulfillmentOrderService.cs +++ b/ShopifySharp/Services/AssignedFulfillmentOrder/IAssignedFulfillmentOrderService.cs @@ -1,32 +1,31 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Lists; using System.Threading; using System.Threading.Tasks; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IAssignedFulfillmentOrderService : IShopifyService { - public interface IAssignedFulfillmentOrderService : IShopifyService - { - /// - /// The AssignedFulfillmentOrder resource allows you to retrieve all the fulfillment orders that are assigned to an app at the shop level. - /// The list of fulfillment orders can be filtered by location and assignment status such as cancellation_requested and fulfillment_requested. - /// API Reference - /// - /// The filter object. - /// The cancellation token. - /// Retrieves a list of fulfillment orders on a shop for a specific app. - /// - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + /// + /// The AssignedFulfillmentOrder resource allows you to retrieve all the fulfillment orders that are assigned to an app at the shop level. + /// The list of fulfillment orders can be filtered by location and assignment status such as cancellation_requested and fulfillment_requested. + /// API Reference + /// + /// The filter object. + /// The cancellation token. + /// Retrieves a list of fulfillment orders on a shop for a specific app. + /// + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - /// - /// The AssignedFulfillmentOrder resource allows you to retrieve all the fulfillment orders that are assigned to an app at the shop level. - /// The list of fulfillment orders can be filtered by location and assignment status such as cancellation_requested and fulfillment_requested. - /// API Reference - /// - /// The filter object. - /// The cancellation token. - /// Retrieves a list of fulfillment orders on a shop for a specific app. - /// - Task> ListAsync(AssignedFulfillmentOrderFilter filter = null, CancellationToken cancellationToken = default); - } -} + /// + /// The AssignedFulfillmentOrder resource allows you to retrieve all the fulfillment orders that are assigned to an app at the shop level. + /// The list of fulfillment orders can be filtered by location and assignment status such as cancellation_requested and fulfillment_requested. + /// API Reference + /// + /// The filter object. + /// The cancellation token. + /// Retrieves a list of fulfillment orders on a shop for a specific app. + /// + Task> ListAsync(AssignedFulfillmentOrderFilter filter = null, CancellationToken cancellationToken = default); +} \ No newline at end of file diff --git a/ShopifySharp/Services/Authorization/AuthorizationResult.cs b/ShopifySharp/Services/Authorization/AuthorizationResult.cs index 56171e34..04e6069c 100644 --- a/ShopifySharp/Services/Authorization/AuthorizationResult.cs +++ b/ShopifySharp/Services/Authorization/AuthorizationResult.cs @@ -1,10 +1,9 @@ -#nullable enable +#nullable enable -namespace ShopifySharp +namespace ShopifySharp; + +public class AuthorizationResult(string accessToken, string[]? grantedScopes) { - public class AuthorizationResult(string accessToken, string[]? grantedScopes) - { - public string AccessToken { get; } = accessToken; - public string[]? GrantedScopes { get; } = grantedScopes; - } -} + public string AccessToken { get; } = accessToken; + public string[]? GrantedScopes { get; } = grantedScopes; +} \ No newline at end of file diff --git a/ShopifySharp/Services/Authorization/AuthorizationService.cs b/ShopifySharp/Services/Authorization/AuthorizationService.cs index 7dcd9a99..367d9ff8 100644 --- a/ShopifySharp/Services/Authorization/AuthorizationService.cs +++ b/ShopifySharp/Services/Authorization/AuthorizationService.cs @@ -1,4 +1,4 @@ -using System; +using System; #if NET6_0_OR_GREATER using System.Buffers; #endif @@ -10,193 +10,192 @@ using ShopifySharp.Enums; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +[Obsolete("The static AuthorizationService is obsolete and will be removed in a future version of ShopifySharp. Please use the ShopifyOauthUtility, ShopifyRequestValidationUtility or ShopifyDomainUtility classes instead.")] +public static class AuthorizationService { - [Obsolete("The static AuthorizationService is obsolete and will be removed in a future version of ShopifySharp. Please use the ShopifyOauthUtility, ShopifyRequestValidationUtility or ShopifyDomainUtility classes instead.")] - public static class AuthorizationService + private static readonly ShopifyDomainUtility ShopifyDomainUtility; + private static readonly ShopifyOauthUtility ShopifyOauthUtility; + private static readonly ShopifyRequestValidationUtility ShopifyRequestValidationUtility; + + static AuthorizationService() { - private static readonly ShopifyDomainUtility ShopifyDomainUtility; - private static readonly ShopifyOauthUtility ShopifyOauthUtility; - private static readonly ShopifyRequestValidationUtility ShopifyRequestValidationUtility; - - static AuthorizationService() - { - ShopifyDomainUtility = new ShopifyDomainUtility(); - ShopifyOauthUtility = new ShopifyOauthUtility(ShopifyDomainUtility); - ShopifyRequestValidationUtility = new ShopifyRequestValidationUtility(); - } - - public static bool IsAuthenticRequest(IEnumerable> querystring, string shopifySecretKey) => - ShopifyRequestValidationUtility.IsAuthenticRequest(querystring, shopifySecretKey); - - /// - /// Determines if an incoming request is authentic. - /// - /// A dictionary containing the keys and values from the request's querystring. - /// Your app's secret key. - /// A boolean indicating whether the request is authentic or not. - public static bool IsAuthenticRequest(IDictionary querystring, string shopifySecretKey) => - ShopifyRequestValidationUtility.IsAuthenticRequest(querystring, shopifySecretKey); - - /// - /// Determines if an incoming request is authentic. - /// - /// The request's raw querystring. - /// Your app's secret key. - /// A boolean indicating whether the request is authentic or not. - public static bool IsAuthenticRequest(string querystring, string shopifySecretKey) => - ShopifyRequestValidationUtility.IsAuthenticRequest(querystring, shopifySecretKey); - - /// - /// Determines if an incoming proxy page request is authentic. - /// - /// The collection of querystring parameters from the request. Hint: use Request.QueryString if you're calling this from an ASP.NET MVC controller. - /// Your app's secret key. - /// A boolean indicating whether the request is authentic or not. - public static bool IsAuthenticProxyRequest(IEnumerable> querystring, string shopifySecretKey) => - ShopifyRequestValidationUtility.IsAuthenticProxyRequest(querystring, shopifySecretKey); - - /// - /// Determines if an incoming proxy page request is authentic. - /// - /// A dictionary containing the keys and values from the request's querystring. - /// Your app's secret key. - /// A boolean indicating whether the request is authentic or not. - public static bool IsAuthenticProxyRequest(IDictionary querystring, string shopifySecretKey) => - ShopifyRequestValidationUtility.IsAuthenticProxyRequest(querystring, shopifySecretKey); - - /// - /// Determines if an incoming proxy page request is authentic. - /// - /// The request's raw querystring. - /// Your app's secret key. - /// A boolean indicating whether the request is authentic or not. - public static bool IsAuthenticProxyRequest(string querystring, string shopifySecretKey) => - ShopifyRequestValidationUtility.IsAuthenticProxyRequest(querystring, shopifySecretKey); - - /// - /// Determines if an incoming webhook request is authentic. - /// - /// The request's headers. Hint: use Request.Headers if you're calling this from an ASP.NET MVC controller. - /// The request's input stream. This method does NOT dispose the stream. - /// Hint: use Request.InputStream if you're calling this from an ASP.NET MVC controller. - /// Your app's secret key. - /// A boolean indicating whether the webhook is authentic or not. - public static Task IsAuthenticWebhook(IEnumerable> requestHeaders, Stream inputStream, string shopifySecretKey) => - ShopifyRequestValidationUtility.IsAuthenticWebhookAsync(requestHeaders, inputStream, shopifySecretKey); - - /// - /// Determines if an incoming webhook request is authentic. - /// - /// The request's headers. Hint: use Request.Headers if you're calling this from an ASP.NET MVC controller. - /// The body of the request. - /// Your app's secret key. - /// A boolean indicating whether the webhook is authentic or not. - public static bool IsAuthenticWebhook(IEnumerable> requestHeaders, string requestBody, string shopifySecretKey) => - ShopifyRequestValidationUtility.IsAuthenticWebhook(requestHeaders, requestBody, shopifySecretKey); + ShopifyDomainUtility = new ShopifyDomainUtility(); + ShopifyOauthUtility = new ShopifyOauthUtility(ShopifyDomainUtility); + ShopifyRequestValidationUtility = new ShopifyRequestValidationUtility(); + } + + public static bool IsAuthenticRequest(IEnumerable> querystring, string shopifySecretKey) => + ShopifyRequestValidationUtility.IsAuthenticRequest(querystring, shopifySecretKey); + + /// + /// Determines if an incoming request is authentic. + /// + /// A dictionary containing the keys and values from the request's querystring. + /// Your app's secret key. + /// A boolean indicating whether the request is authentic or not. + public static bool IsAuthenticRequest(IDictionary querystring, string shopifySecretKey) => + ShopifyRequestValidationUtility.IsAuthenticRequest(querystring, shopifySecretKey); + + /// + /// Determines if an incoming request is authentic. + /// + /// The request's raw querystring. + /// Your app's secret key. + /// A boolean indicating whether the request is authentic or not. + public static bool IsAuthenticRequest(string querystring, string shopifySecretKey) => + ShopifyRequestValidationUtility.IsAuthenticRequest(querystring, shopifySecretKey); + + /// + /// Determines if an incoming proxy page request is authentic. + /// + /// The collection of querystring parameters from the request. Hint: use Request.QueryString if you're calling this from an ASP.NET MVC controller. + /// Your app's secret key. + /// A boolean indicating whether the request is authentic or not. + public static bool IsAuthenticProxyRequest(IEnumerable> querystring, string shopifySecretKey) => + ShopifyRequestValidationUtility.IsAuthenticProxyRequest(querystring, shopifySecretKey); + + /// + /// Determines if an incoming proxy page request is authentic. + /// + /// A dictionary containing the keys and values from the request's querystring. + /// Your app's secret key. + /// A boolean indicating whether the request is authentic or not. + public static bool IsAuthenticProxyRequest(IDictionary querystring, string shopifySecretKey) => + ShopifyRequestValidationUtility.IsAuthenticProxyRequest(querystring, shopifySecretKey); + + /// + /// Determines if an incoming proxy page request is authentic. + /// + /// The request's raw querystring. + /// Your app's secret key. + /// A boolean indicating whether the request is authentic or not. + public static bool IsAuthenticProxyRequest(string querystring, string shopifySecretKey) => + ShopifyRequestValidationUtility.IsAuthenticProxyRequest(querystring, shopifySecretKey); + + /// + /// Determines if an incoming webhook request is authentic. + /// + /// The request's headers. Hint: use Request.Headers if you're calling this from an ASP.NET MVC controller. + /// The request's input stream. This method does NOT dispose the stream. + /// Hint: use Request.InputStream if you're calling this from an ASP.NET MVC controller. + /// Your app's secret key. + /// A boolean indicating whether the webhook is authentic or not. + public static Task IsAuthenticWebhook(IEnumerable> requestHeaders, Stream inputStream, string shopifySecretKey) => + ShopifyRequestValidationUtility.IsAuthenticWebhookAsync(requestHeaders, inputStream, shopifySecretKey); + + /// + /// Determines if an incoming webhook request is authentic. + /// + /// The request's headers. Hint: use Request.Headers if you're calling this from an ASP.NET MVC controller. + /// The body of the request. + /// Your app's secret key. + /// A boolean indicating whether the webhook is authentic or not. + public static bool IsAuthenticWebhook(IEnumerable> requestHeaders, string requestBody, string shopifySecretKey) => + ShopifyRequestValidationUtility.IsAuthenticWebhook(requestHeaders, requestBody, shopifySecretKey); #if NET6_0_OR_GREATER - public static bool IsAuthenticWebhook( - IEnumerable> requestHeaders, - ReadOnlyMemory requestBody, - ReadOnlyMemory shopifySecretKey - ) => ShopifyRequestValidationUtility.IsAuthenticWebhook(requestHeaders, requestBody, shopifySecretKey); + public static bool IsAuthenticWebhook( + IEnumerable> requestHeaders, + ReadOnlyMemory requestBody, + ReadOnlyMemory shopifySecretKey + ) => ShopifyRequestValidationUtility.IsAuthenticWebhook(requestHeaders, requestBody, shopifySecretKey); #endif - /// - /// Determines if an incoming webhook request is authentic. - /// - /// The request's headers. - /// The body of the request. - /// Your app's secret key. - /// A boolean indicating whether the webhook is authentic or not. - public static bool IsAuthenticWebhook(HttpRequestHeaders requestHeaders, string requestBody, string shopifySecretKey) => - ShopifyRequestValidationUtility.IsAuthenticWebhook(requestHeaders, requestBody, shopifySecretKey); - - /// - /// A convenience function that tries to ensure that a given URL is a valid Shopify domain. It does this by making a HEAD request to the given domain, and returns true if the response contains an X-ShopId header. - /// - /// **Warning**: a domain could fake the response header, which would cause this method to return true. - /// - /// **Warning**: this method of validation is not officially supported by Shopify and could break at any time. - /// - /// The URL of the shop to check. - /// A boolean indicating whether the URL is valid. - public static Task IsValidShopDomainAsync(string shopDomain) => - ShopifyDomainUtility.IsValidShopDomainAsync(shopDomain); - - /// - /// Builds an authorization URL for Shopify OAuth integration. - /// - /// An array of — the permissions that your app needs to run. - /// The shop's *.myshopify.com URL. - /// Your app's public Client ID, also known as its public API key. - /// URL to redirect the user to after integration. - /// An optional, random string value provided by your application which is unique for each authorization request. During the OAuth callback phase, your application should check that this value matches the one you provided to this method. - /// Requested grant types, which will change the type of access token granted upon OAuth completion. - public static Uri BuildAuthorizationUrl( - IEnumerable scopes, - string shopDomain, - string clientId, - string redirectUrl, - string state = null, - IEnumerable grants = null - ) => ShopifyOauthUtility.BuildAuthorizationUrl(scopes, shopDomain, clientId, redirectUrl, state, grants); - - /// - /// Builds an authorization URL for Shopify OAuth integration. - /// - /// An array of Shopify permission strings, e.g. 'read_orders' or 'write_script_tags'. These are the permissions that your app needs to run. - /// The shop's *.myshopify.com URL. - /// Your app's public Client ID, also known as its public API key. - /// URL to redirect the user to after integration. - /// An optional, random string value provided by your application which is unique for each authorization request. During the OAuth callback phase, your application should check that this value matches the one you provided to this method. - /// Requested grant types, which will change the type of access token granted upon OAuth completion. - public static Uri BuildAuthorizationUrl( - IEnumerable scopes, - string shopDomain, - string clientId, - string redirectUrl, - string state = null, - IEnumerable grants = null - ) => ShopifyOauthUtility.BuildAuthorizationUrl(scopes, shopDomain, clientId, redirectUrl, state, grants); - - /// - /// Authorizes an application installation, generating an access token for the given shop. - /// - /// The authorization code generated by Shopify, which should be a parameter named 'code' on the request querystring. - /// The store's *.myshopify.com URL, which should be a parameter named 'shop' on the request querystring. - /// Your app's secret API key. - /// Your app's secret key. - /// The shop access token. - public static async Task Authorize(string code, string myShopifyUrl, string shopifyApiKey, string shopifySecretKey) - { - var result = await ShopifyOauthUtility.AuthorizeAsync(code, myShopifyUrl, shopifyApiKey, shopifySecretKey); - return result.AccessToken; - } - - /// - /// Authorizes an application installation, generating an access token for the given shop. - /// - /// The authorization code generated by Shopify, which should be a parameter named 'code' on the request querystring. - /// The store's *.myshopify.com URL, which should be a parameter named 'shop' on the request querystring. - /// Your app's public API key. - /// Your app's secret key. - /// The authorization result. - public static Task AuthorizeWithResult(string code, string myShopifyUrl, string shopifyApiKey, string shopifySecretKey) => - ShopifyOauthUtility.AuthorizeAsync(code, myShopifyUrl, shopifyApiKey, shopifySecretKey); - - /// - /// Refreshes an existing store access token using the app's client secret and a refresh token - /// For more info on rotating tokens, see https://shopify.dev/apps/auth/oauth/rotate-revoke-client-credentials - /// - /// The store's *.myshopify.com url - /// The app's client ID, also known as API key - /// The app's secret key - /// The app's refresh token - /// The existing store access token - /// - public static Task RefreshAccessToken(string myShopifyUrl, string clientId, string clientSecret, string refreshToken, string existingStoreAccessToken) => - ShopifyOauthUtility.RefreshAccessTokenAsync(myShopifyUrl, clientId, clientSecret, refreshToken, existingStoreAccessToken); + /// + /// Determines if an incoming webhook request is authentic. + /// + /// The request's headers. + /// The body of the request. + /// Your app's secret key. + /// A boolean indicating whether the webhook is authentic or not. + public static bool IsAuthenticWebhook(HttpRequestHeaders requestHeaders, string requestBody, string shopifySecretKey) => + ShopifyRequestValidationUtility.IsAuthenticWebhook(requestHeaders, requestBody, shopifySecretKey); + + /// + /// A convenience function that tries to ensure that a given URL is a valid Shopify domain. It does this by making a HEAD request to the given domain, and returns true if the response contains an X-ShopId header. + /// + /// **Warning**: a domain could fake the response header, which would cause this method to return true. + /// + /// **Warning**: this method of validation is not officially supported by Shopify and could break at any time. + /// + /// The URL of the shop to check. + /// A boolean indicating whether the URL is valid. + public static Task IsValidShopDomainAsync(string shopDomain) => + ShopifyDomainUtility.IsValidShopDomainAsync(shopDomain); + + /// + /// Builds an authorization URL for Shopify OAuth integration. + /// + /// An array of — the permissions that your app needs to run. + /// The shop's *.myshopify.com URL. + /// Your app's public Client ID, also known as its public API key. + /// URL to redirect the user to after integration. + /// An optional, random string value provided by your application which is unique for each authorization request. During the OAuth callback phase, your application should check that this value matches the one you provided to this method. + /// Requested grant types, which will change the type of access token granted upon OAuth completion. + public static Uri BuildAuthorizationUrl( + IEnumerable scopes, + string shopDomain, + string clientId, + string redirectUrl, + string state = null, + IEnumerable grants = null + ) => ShopifyOauthUtility.BuildAuthorizationUrl(scopes, shopDomain, clientId, redirectUrl, state, grants); + + /// + /// Builds an authorization URL for Shopify OAuth integration. + /// + /// An array of Shopify permission strings, e.g. 'read_orders' or 'write_script_tags'. These are the permissions that your app needs to run. + /// The shop's *.myshopify.com URL. + /// Your app's public Client ID, also known as its public API key. + /// URL to redirect the user to after integration. + /// An optional, random string value provided by your application which is unique for each authorization request. During the OAuth callback phase, your application should check that this value matches the one you provided to this method. + /// Requested grant types, which will change the type of access token granted upon OAuth completion. + public static Uri BuildAuthorizationUrl( + IEnumerable scopes, + string shopDomain, + string clientId, + string redirectUrl, + string state = null, + IEnumerable grants = null + ) => ShopifyOauthUtility.BuildAuthorizationUrl(scopes, shopDomain, clientId, redirectUrl, state, grants); + + /// + /// Authorizes an application installation, generating an access token for the given shop. + /// + /// The authorization code generated by Shopify, which should be a parameter named 'code' on the request querystring. + /// The store's *.myshopify.com URL, which should be a parameter named 'shop' on the request querystring. + /// Your app's secret API key. + /// Your app's secret key. + /// The shop access token. + public static async Task Authorize(string code, string myShopifyUrl, string shopifyApiKey, string shopifySecretKey) + { + var result = await ShopifyOauthUtility.AuthorizeAsync(code, myShopifyUrl, shopifyApiKey, shopifySecretKey); + return result.AccessToken; } -} + + /// + /// Authorizes an application installation, generating an access token for the given shop. + /// + /// The authorization code generated by Shopify, which should be a parameter named 'code' on the request querystring. + /// The store's *.myshopify.com URL, which should be a parameter named 'shop' on the request querystring. + /// Your app's public API key. + /// Your app's secret key. + /// The authorization result. + public static Task AuthorizeWithResult(string code, string myShopifyUrl, string shopifyApiKey, string shopifySecretKey) => + ShopifyOauthUtility.AuthorizeAsync(code, myShopifyUrl, shopifyApiKey, shopifySecretKey); + + /// + /// Refreshes an existing store access token using the app's client secret and a refresh token + /// For more info on rotating tokens, see https://shopify.dev/apps/auth/oauth/rotate-revoke-client-credentials + /// + /// The store's *.myshopify.com url + /// The app's client ID, also known as API key + /// The app's secret key + /// The app's refresh token + /// The existing store access token + /// + public static Task RefreshAccessToken(string myShopifyUrl, string clientId, string clientSecret, string refreshToken, string existingStoreAccessToken) => + ShopifyOauthUtility.RefreshAccessTokenAsync(myShopifyUrl, clientId, clientSecret, refreshToken, existingStoreAccessToken); +} \ No newline at end of file diff --git a/ShopifySharp/Services/Blog/BlogService.cs b/ShopifySharp/Services/Blog/BlogService.cs index e24648aa..084c4a56 100644 --- a/ShopifySharp/Services/Blog/BlogService.cs +++ b/ShopifySharp/Services/Blog/BlogService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Collections.Generic; @@ -8,88 +8,87 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for interacting with a store's blogs (not blog posts). +/// +public class BlogService : ShopifyService, IBlogService { /// - /// A service for interacting with a store's blogs (not blog posts). + /// Creates a new instance of . /// - public class BlogService : ShopifyService, IBlogService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public BlogService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal BlogService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public BlogService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal BlogService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("blogs.json", "blogs", filter, cancellationToken); - - /// - public virtual async Task> ListAsync(BlogListFilter filter, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("blogs.json", "blogs", filter, cancellationToken); - /// - public virtual async Task CountAsync(CancellationToken cancellationToken = default) => - await ExecuteGetAsync("blogs/count.json", "count", cancellationToken: cancellationToken); - - /// - public virtual async Task CreateAsync(Blog blog, IEnumerable metafields = null, CancellationToken cancellationToken = default) - { - var request = BuildRequestUri("blogs.json"); - var body = blog.ToDictionary(); + /// + public virtual async Task> ListAsync(BlogListFilter filter, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); - if (metafields != null && metafields.Any()) - { - body.Add("metafields", metafields); - } + /// + public virtual async Task CountAsync(CancellationToken cancellationToken = default) => + await ExecuteGetAsync("blogs/count.json", "count", cancellationToken: cancellationToken); - var content = new JsonContent(new - { - blog = body - }); + /// + public virtual async Task CreateAsync(Blog blog, IEnumerable metafields = null, CancellationToken cancellationToken = default) + { + var request = BuildRequestUri("blogs.json"); + var body = blog.ToDictionary(); - var response = await ExecuteRequestAsync(request, HttpMethod.Post, cancellationToken, content, "blog"); - return response.Result; + if (metafields != null && metafields.Any()) + { + body.Add("metafields", metafields); } - /// - public virtual async Task UpdateAsync(long blogId, Blog blog, IEnumerable metafields = null, CancellationToken cancellationToken = default) + var content = new JsonContent(new { - var request = BuildRequestUri($"blogs/{blogId}.json"); - var body = blog.ToDictionary(); + blog = body + }); - if (metafields != null && metafields.Count() >= 1) - { - body.Add("metafields", metafields); - } + var response = await ExecuteRequestAsync(request, HttpMethod.Post, cancellationToken, content, "blog"); + return response.Result; + } - var content = new JsonContent(new - { - blog = body - }); + /// + public virtual async Task UpdateAsync(long blogId, Blog blog, IEnumerable metafields = null, CancellationToken cancellationToken = default) + { + var request = BuildRequestUri($"blogs/{blogId}.json"); + var body = blog.ToDictionary(); - var response = await ExecuteRequestAsync(request, HttpMethod.Put, cancellationToken, content, "blog"); - return response.Result; + if (metafields != null && metafields.Count() >= 1) + { + body.Add("metafields", metafields); } - /// - public virtual async Task GetAsync(long id, CancellationToken cancellationToken = default) + var content = new JsonContent(new { - var request = BuildRequestUri($"blogs/{id}.json"); + blog = body + }); - var response = await ExecuteRequestAsync(request, HttpMethod.Get, cancellationToken, rootElement: "blog"); - return response.Result; - } + var response = await ExecuteRequestAsync(request, HttpMethod.Put, cancellationToken, content, "blog"); + return response.Result; + } - /// - public virtual async Task DeleteAsync(long id, CancellationToken cancellationToken = default) - { - var request = BuildRequestUri($"blogs/{id}.json"); + /// + public virtual async Task GetAsync(long id, CancellationToken cancellationToken = default) + { + var request = BuildRequestUri($"blogs/{id}.json"); - await ExecuteRequestAsync(request, HttpMethod.Delete, cancellationToken); - } + var response = await ExecuteRequestAsync(request, HttpMethod.Get, cancellationToken, rootElement: "blog"); + return response.Result; + } + + /// + public virtual async Task DeleteAsync(long id, CancellationToken cancellationToken = default) + { + var request = BuildRequestUri($"blogs/{id}.json"); + + await ExecuteRequestAsync(request, HttpMethod.Delete, cancellationToken); } } \ No newline at end of file diff --git a/ShopifySharp/Services/Blog/IBlogService.cs b/ShopifySharp/Services/Blog/IBlogService.cs index 0dddb76d..fabfb147 100644 --- a/ShopifySharp/Services/Blog/IBlogService.cs +++ b/ShopifySharp/Services/Blog/IBlogService.cs @@ -4,54 +4,53 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IBlogService : IShopifyService { - public interface IBlogService : IShopifyService - { - /// - /// Gets a list of up to 250 blogs belonging to the store. - /// - Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default); - - /// - /// Gets a list of up to 250 blogs belonging to the store. - /// - Task> ListAsync(BlogListFilter filter, CancellationToken cancellationToken = default); - - /// - /// Gets a count of all blogs. - /// - Task CountAsync(CancellationToken cancellationToken = default); - - /// - /// Creates a new blog. - /// - /// The blog being created. Id should be null. - /// Optional metafield data that can be returned by the . - /// Cancellation Token - Task CreateAsync(Blog blog, IEnumerable metafields = null, CancellationToken cancellationToken = default); - - /// - /// Updates a blog. - /// - /// Id of the object being updated. - /// The updated blog. - /// Optional metafield data that can be returned by the . - /// Cancellation Token - Task UpdateAsync(long blogId, Blog blog, IEnumerable metafields = null, CancellationToken cancellationToken = default); - - /// - /// Gets a blog with the given id. - /// - /// The id of the blog you want to retrieve. - /// Cancellation Token - Task GetAsync(long id, CancellationToken cancellationToken = default); - - /// - /// Deletes a blog with the given id. - /// - /// The id of the blog you want to delete. - /// Cancellation Token - Task DeleteAsync(long id, CancellationToken cancellationToken = default); - } + /// + /// Gets a list of up to 250 blogs belonging to the store. + /// + Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default); + + /// + /// Gets a list of up to 250 blogs belonging to the store. + /// + Task> ListAsync(BlogListFilter filter, CancellationToken cancellationToken = default); + + /// + /// Gets a count of all blogs. + /// + Task CountAsync(CancellationToken cancellationToken = default); + + /// + /// Creates a new blog. + /// + /// The blog being created. Id should be null. + /// Optional metafield data that can be returned by the . + /// Cancellation Token + Task CreateAsync(Blog blog, IEnumerable metafields = null, CancellationToken cancellationToken = default); + + /// + /// Updates a blog. + /// + /// Id of the object being updated. + /// The updated blog. + /// Optional metafield data that can be returned by the . + /// Cancellation Token + Task UpdateAsync(long blogId, Blog blog, IEnumerable metafields = null, CancellationToken cancellationToken = default); + + /// + /// Gets a blog with the given id. + /// + /// The id of the blog you want to retrieve. + /// Cancellation Token + Task GetAsync(long id, CancellationToken cancellationToken = default); + + /// + /// Deletes a blog with the given id. + /// + /// The id of the blog you want to delete. + /// Cancellation Token + Task DeleteAsync(long id, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/CancellationRequest/CancellationRequestService.cs b/ShopifySharp/Services/CancellationRequest/CancellationRequestService.cs index 26d7f7bf..0ff971c3 100644 --- a/ShopifySharp/Services/CancellationRequest/CancellationRequestService.cs +++ b/ShopifySharp/Services/CancellationRequest/CancellationRequestService.cs @@ -1,70 +1,69 @@ -using ShopifySharp.Infrastructure; +using ShopifySharp.Infrastructure; using System.Net.Http; using System.Threading.Tasks; using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// The CancellationRequest resource represents a cancellation request made by the merchant or an order management app to a fulfillment service for a fulfillment order. +/// +public class CancellationRequestService : ShopifyService, ICancellationRequestService { /// - /// The CancellationRequest resource represents a cancellation request made by the merchant or an order management app to a fulfillment service for a fulfillment order. + /// Creates a new instance of . /// - public class CancellationRequestService : ShopifyService, ICancellationRequestService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public CancellationRequestService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal CancellationRequestService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public CancellationRequestService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal CancellationRequestService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CreateAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($@"fulfillment_orders/{fulfillmentOrderId}/cancellation_request.json"); + var cancellationRequest = new CancellationRequest { Message = message }; + var body = cancellationRequest.ToDictionary(); + + var content = new JsonContent(new { - var req = BuildRequestUri($@"fulfillment_orders/{fulfillmentOrderId}/cancellation_request.json"); - var cancellationRequest = new CancellationRequest { Message = message }; - var body = cancellationRequest.ToDictionary(); + cancellation_request = body + }); - var content = new JsonContent(new - { - cancellation_request = body - }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment_order"); + return response.Result; + } - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment_order"); - return response.Result; - } + /// + public virtual async Task AcceptAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/cancellation_request/accept.json"); + var cancellationRequest = new CancellationRequest { Message = message }; + var body = cancellationRequest.ToDictionary(); - /// - public virtual async Task AcceptAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default) + var content = new JsonContent(new { - var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/cancellation_request/accept.json"); - var cancellationRequest = new CancellationRequest { Message = message }; - var body = cancellationRequest.ToDictionary(); + cancellation_request = body + }); - var content = new JsonContent(new - { - cancellation_request = body - }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment_order"); + return response.Result; + } - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment_order"); - return response.Result; - } + /// + public virtual async Task RejectAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($@"fulfillment_orders/{fulfillmentOrderId}/cancellation_request/reject.json"); + var cancellationRequest = new CancellationRequest { Message = message }; + var body = cancellationRequest.ToDictionary(); - /// - public virtual async Task RejectAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default) + var content = new JsonContent(new { - var req = BuildRequestUri($@"fulfillment_orders/{fulfillmentOrderId}/cancellation_request/reject.json"); - var cancellationRequest = new CancellationRequest { Message = message }; - var body = cancellationRequest.ToDictionary(); - - var content = new JsonContent(new - { - cancellation_request = body - }); + cancellation_request = body + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment_order"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment_order"); + return response.Result; } -} +} \ No newline at end of file diff --git a/ShopifySharp/Services/CancellationRequest/ICancellationRequestService.cs b/ShopifySharp/Services/CancellationRequest/ICancellationRequestService.cs index 5d6efffe..290fcb4b 100644 --- a/ShopifySharp/Services/CancellationRequest/ICancellationRequestService.cs +++ b/ShopifySharp/Services/CancellationRequest/ICancellationRequestService.cs @@ -1,42 +1,41 @@ -using System.Threading; +using System.Threading; using System.Threading.Tasks; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// The CancellationRequest resource represents a cancellation request made by the merchant or an order management app to a fulfillment service for a fulfillment order. +/// API Reference +/// +public interface ICancellationRequestService : IShopifyService { /// - /// The CancellationRequest resource represents a cancellation request made by the merchant or an order management app to a fulfillment service for a fulfillment order. - /// API Reference + /// Sends a cancellation request to the fulfillment service of a fulfillment order. + /// API Reference /// - public interface ICancellationRequestService : IShopifyService - { - /// - /// Sends a cancellation request to the fulfillment service of a fulfillment order. - /// API Reference - /// - /// - /// An optional reason for the cancellation request - /// Cancellation Token - /// - Task CreateAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default); + /// + /// An optional reason for the cancellation request + /// Cancellation Token + /// + Task CreateAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default); - /// - /// Accepts a cancellation request sent to a fulfillment service for a fulfillment order. - /// API Reference - /// - /// - /// An optional reason for accepting the cancellation request - /// Cancellation Token - /// - Task AcceptAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default); + /// + /// Accepts a cancellation request sent to a fulfillment service for a fulfillment order. + /// API Reference + /// + /// + /// An optional reason for accepting the cancellation request + /// Cancellation Token + /// + Task AcceptAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default); - /// - /// Rejects a cancellation request sent to a fulfillment service for a fulfillment order. - /// API Reference - /// - /// - /// An optional reason for rejecting the cancellation request - /// Cancellation Token - /// - Task RejectAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default); - } + /// + /// Rejects a cancellation request sent to a fulfillment service for a fulfillment order. + /// API Reference + /// + /// + /// An optional reason for rejecting the cancellation request + /// Cancellation Token + /// + Task RejectAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Carrier/CarrierService.cs b/ShopifySharp/Services/Carrier/CarrierService.cs index ae3a6450..ae296c90 100644 --- a/ShopifySharp/Services/Carrier/CarrierService.cs +++ b/ShopifySharp/Services/Carrier/CarrierService.cs @@ -5,66 +5,65 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for working with shipping carriers. +/// +public class CarrierService : ShopifyService, ICarrierService { /// - /// A service for working with shipping carriers. + /// Creates a new instance of . /// - public class CarrierService : ShopifyService, ICarrierService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public CarrierService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal CarrierService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public CarrierService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal CarrierService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(CancellationToken cancellationToken = default) => - await ExecuteGetAsync< IEnumerable < Carrier >>("carrier_services.json", "carrier_services", cancellationToken: cancellationToken); + /// + public virtual async Task> ListAsync(CancellationToken cancellationToken = default) => + await ExecuteGetAsync< IEnumerable < Carrier >>("carrier_services.json", "carrier_services", cancellationToken: cancellationToken); - /// - public virtual async Task CreateAsync(Carrier carrier, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(Carrier carrier, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("carrier_services.json"); + var content = new JsonContent(new { - var req = BuildRequestUri("carrier_services.json"); - var content = new JsonContent(new - { - carrier_service = carrier - }); + carrier_service = carrier + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "carrier_service"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "carrier_service"); + return response.Result; + } - /// - public virtual async Task GetAsync(long carrierId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"carrier_services/{carrierId}.json"); + /// + public virtual async Task GetAsync(long carrierId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"carrier_services/{carrierId}.json"); - var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "carrier_service"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "carrier_service"); + return response.Result; + } - /// - public virtual async Task DeleteAsync(long carrierId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"carrier_services/{carrierId}.json"); + /// + public virtual async Task DeleteAsync(long carrierId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"carrier_services/{carrierId}.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); + } - /// - public virtual async Task UpdateAsync(long carrierId, Carrier carrier, CancellationToken cancellationToken = default) + /// + public virtual async Task UpdateAsync(long carrierId, Carrier carrier, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"carrier_services/{carrierId}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"carrier_services/{carrierId}.json"); - var content = new JsonContent(new - { - carrier_service = carrier - }); + carrier_service = carrier + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "carrier_service"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "carrier_service"); + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/Carrier/ICarrierService.cs b/ShopifySharp/Services/Carrier/ICarrierService.cs index 99a41e52..28f38257 100644 --- a/ShopifySharp/Services/Carrier/ICarrierService.cs +++ b/ShopifySharp/Services/Carrier/ICarrierService.cs @@ -2,45 +2,44 @@ using System.Threading; using System.Threading.Tasks; -namespace ShopifySharp +namespace ShopifySharp; + +public interface ICarrierService : IShopifyService { - public interface ICarrierService : IShopifyService - { - /// - /// Retrieve a list of all carrier services that are associated with the store. - /// - Task> ListAsync(CancellationToken cancellationToken = default); + /// + /// Retrieve a list of all carrier services that are associated with the store. + /// + Task> ListAsync(CancellationToken cancellationToken = default); - /// - /// Creates a new Carrier - /// - /// A new . Id should be set to null. - /// Cancellation Token - /// The new . - Task CreateAsync(Carrier carrier, CancellationToken cancellationToken = default); + /// + /// Creates a new Carrier + /// + /// A new . Id should be set to null. + /// Cancellation Token + /// The new . + Task CreateAsync(Carrier carrier, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the Carrier to retrieve. - /// Cancellation Token - /// The . - Task GetAsync(long carrierId, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the Carrier to retrieve. + /// Cancellation Token + /// The . + Task GetAsync(long carrierId, CancellationToken cancellationToken = default); - /// - /// Deletes a Carruer with the given Id. - /// - /// The Carrier's Id. - /// Cancellation Token - Task DeleteAsync(long carrierId, CancellationToken cancellationToken = default); + /// + /// Deletes a Carruer with the given Id. + /// + /// The Carrier's Id. + /// Cancellation Token + Task DeleteAsync(long carrierId, CancellationToken cancellationToken = default); - /// - /// Updates the given . - /// - /// Id of the Carrier being updated. - /// The to update. - /// Cancellation Token - /// The updated . - Task UpdateAsync(long carrierId, Carrier carrier, CancellationToken cancellationToken = default); - } + /// + /// Updates the given . + /// + /// Id of the Carrier being updated. + /// The to update. + /// Cancellation Token + /// The updated . + Task UpdateAsync(long carrierId, Carrier carrier, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Charge/ChargeService.cs b/ShopifySharp/Services/Charge/ChargeService.cs index 85d177d4..41187095 100644 --- a/ShopifySharp/Services/Charge/ChargeService.cs +++ b/ShopifySharp/Services/Charge/ChargeService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using System.Collections.Generic; using System.Net.Http; @@ -6,47 +6,46 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify's ApplicationCharge API. +/// +public class ChargeService : ShopifyService, IChargeService { /// - /// A service for manipulating Shopify's ApplicationCharge API. + /// Creates a new instance of . /// - public class ChargeService : ShopifyService, IChargeService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public ChargeService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal ChargeService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public ChargeService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal ChargeService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CreateAsync(Charge charge, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri("application_charges.json"); - var content = new JsonContent(new { application_charge = charge }); - - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "application_charge"); - return response.Result; - } + /// + public virtual async Task CreateAsync(Charge charge, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("application_charges.json"); + var content = new JsonContent(new { application_charge = charge }); - /// - public virtual async Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"application_charges/{id}.json"); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "application_charge"); + return response.Result; + } - if (!string.IsNullOrEmpty(fields)) - { - req.QueryParams.Add("fields", fields); - } + /// + public virtual async Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"application_charges/{id}.json"); - var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "application_charge"); - return response.Result; + if (!string.IsNullOrEmpty(fields)) + { + req.QueryParams.Add("fields", fields); } - /// - public virtual async Task> ListAsync(ChargeListFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync< IEnumerable < Charge >>("application_charges.json", "application_charges", filter, cancellationToken); + var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "application_charge"); + return response.Result; } -} + + /// + public virtual async Task> ListAsync(ChargeListFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync< IEnumerable < Charge >>("application_charges.json", "application_charges", filter, cancellationToken); +} \ No newline at end of file diff --git a/ShopifySharp/Services/Charge/IChargeService.cs b/ShopifySharp/Services/Charge/IChargeService.cs index fae88abf..210ede56 100644 --- a/ShopifySharp/Services/Charge/IChargeService.cs +++ b/ShopifySharp/Services/Charge/IChargeService.cs @@ -3,32 +3,31 @@ using System.Threading.Tasks; using ShopifySharp.Filters; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IChargeService : IShopifyService { - public interface IChargeService : IShopifyService - { - /// - /// Creates a . - /// - /// The to create. - /// Cancellation Token - /// The new . - Task CreateAsync(Charge charge, CancellationToken cancellationToken = default); + /// + /// Creates a . + /// + /// The to create. + /// Cancellation Token + /// The new . + Task CreateAsync(Charge charge, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the charge to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the charge to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default); - /// - /// Retrieves a list of all past and present objects. - /// - /// Options for filtering the list. - /// Cancellation Token - Task> ListAsync(ChargeListFilter filter = null, CancellationToken cancellationToken = default); - } + /// + /// Retrieves a list of all past and present objects. + /// + /// Options for filtering the list. + /// Cancellation Token + Task> ListAsync(ChargeListFilter filter = null, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Checkout/CheckoutService.cs b/ShopifySharp/Services/Checkout/CheckoutService.cs index e0d4b684..99af158d 100644 --- a/ShopifySharp/Services/Checkout/CheckoutService.cs +++ b/ShopifySharp/Services/Checkout/CheckoutService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Collections.Generic; @@ -8,75 +8,74 @@ using ShopifySharp.Utilities; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for working with abandoned checkouts. +/// +[Obsolete("https://shopify.dev/changelog/deprecation-of-checkout-apis")] +public class CheckoutService : ShopifyService, ICheckoutService { - /// - /// A service for working with abandoned checkouts. - /// - [Obsolete("https://shopify.dev/changelog/deprecation-of-checkout-apis")] - public class CheckoutService : ShopifyService, ICheckoutService - { - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public CheckoutService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal CheckoutService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public CheckoutService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal CheckoutService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CountAsync(CheckoutCountFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync("checkouts/count.json", "count", filter, cancellationToken); + /// + public virtual async Task CountAsync(CheckoutCountFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync("checkouts/count.json", "count", filter, cancellationToken); - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("checkouts.json", "checkouts", filter, cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("checkouts.json", "checkouts", filter, cancellationToken); - /// - public virtual async Task> ListAsync(CheckoutListFilter filter = null, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListAsync(CheckoutListFilter filter = null, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task CreateAsync(Checkout checkout, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri("checkouts.json"); - var body = checkout.ToDictionary(); + /// + public virtual async Task CreateAsync(Checkout checkout, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("checkouts.json"); + var body = checkout.ToDictionary(); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, new JsonContent(new { checkout }), "checkout"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, new JsonContent(new { checkout }), "checkout"); + return response.Result; + } - /// - public virtual async Task CompleteAsync(string token, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"checkouts/{token}/complete.json"); + /// + public virtual async Task CompleteAsync(string token, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"checkouts/{token}/complete.json"); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "checkout"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "checkout"); + return response.Result; + } - /// - public virtual async Task GetAsync(string token, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"checkouts/{token}.json"); + /// + public virtual async Task GetAsync(string token, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"checkouts/{token}.json"); - var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "checkout"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "checkout"); + return response.Result; + } - /// - public virtual async Task UpdateAsync(string token, Checkout updatedCheckout, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"checkouts/{token}.json"); + /// + public virtual async Task UpdateAsync(string token, Checkout updatedCheckout, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"checkouts/{token}.json"); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, new JsonContent(new { checkout = updatedCheckout }), "checkout"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, new JsonContent(new { checkout = updatedCheckout }), "checkout"); + return response.Result; + } - /// - public virtual async Task> ListShippingRatesAsync(string token, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"checkouts/{token}/shipping_rates.json"); + /// + public virtual async Task> ListShippingRatesAsync(string token, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"checkouts/{token}/shipping_rates.json"); - var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "shipping_rates"); - return response.Result; - } + var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "shipping_rates"); + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/Checkout/ICheckoutService.cs b/ShopifySharp/Services/Checkout/ICheckoutService.cs index a2c59f48..258b2b16 100644 --- a/ShopifySharp/Services/Checkout/ICheckoutService.cs +++ b/ShopifySharp/Services/Checkout/ICheckoutService.cs @@ -4,57 +4,56 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface ICheckoutService : IShopifyService { - public interface ICheckoutService : IShopifyService - { - /// - /// Gets a count of all of the shop's orders. - /// - /// Options for filtering the count. - /// Cancellation Token - /// The count of all orders for the shop. - Task CountAsync(CheckoutCountFilter filter = null, CancellationToken cancellationToken = default); - - /// - /// Gets a list of up to 250 of the shop's abandoned checkouts. - /// - /// Options for filtering the result. - /// Cancellation Token - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - - /// - /// Gets a list of up to 250 of the shop's abandoned checkouts. - /// - /// Options for filtering the result. - /// Cancellation Token - Task> ListAsync(CheckoutListFilter filter = null, CancellationToken cancellationToken = default); - - /// - /// Creates a new Checkout. - /// - Task CreateAsync(Checkout checkout, CancellationToken cancellationToken = default); - - /// - /// Completes a checkout without requiring payment. - /// - Task CompleteAsync(string token, CancellationToken cancellationToken = default); - - /// - /// Gets an existing, processing or completed checkout. - /// - Task GetAsync(string token, CancellationToken cancellationToken = default); - - /// - /// Updates an existing checkout based on the token id. - /// - Task UpdateAsync(string token, Checkout updatedCheckout, CancellationToken cancellationToken = default); - - /// - /// Retrieves a list of available shipping rates for the specified checkout. Implementers need to poll this endpoint until rates become available. Each shipping rate contains the checkout's - /// new subtotal price, total tax, and total price in the event that this shipping rate is selected. This can be used to update the UI without performing further API requests. To apply a - /// shipping rate, update the checkout's shipping line with the handle of the selected rate. - /// - Task> ListShippingRatesAsync(string token, CancellationToken cancellationToken = default); - } + /// + /// Gets a count of all of the shop's orders. + /// + /// Options for filtering the count. + /// Cancellation Token + /// The count of all orders for the shop. + Task CountAsync(CheckoutCountFilter filter = null, CancellationToken cancellationToken = default); + + /// + /// Gets a list of up to 250 of the shop's abandoned checkouts. + /// + /// Options for filtering the result. + /// Cancellation Token + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + + /// + /// Gets a list of up to 250 of the shop's abandoned checkouts. + /// + /// Options for filtering the result. + /// Cancellation Token + Task> ListAsync(CheckoutListFilter filter = null, CancellationToken cancellationToken = default); + + /// + /// Creates a new Checkout. + /// + Task CreateAsync(Checkout checkout, CancellationToken cancellationToken = default); + + /// + /// Completes a checkout without requiring payment. + /// + Task CompleteAsync(string token, CancellationToken cancellationToken = default); + + /// + /// Gets an existing, processing or completed checkout. + /// + Task GetAsync(string token, CancellationToken cancellationToken = default); + + /// + /// Updates an existing checkout based on the token id. + /// + Task UpdateAsync(string token, Checkout updatedCheckout, CancellationToken cancellationToken = default); + + /// + /// Retrieves a list of available shipping rates for the specified checkout. Implementers need to poll this endpoint until rates become available. Each shipping rate contains the checkout's + /// new subtotal price, total tax, and total price in the event that this shipping rate is selected. This can be used to update the UI without performing further API requests. To apply a + /// shipping rate, update the checkout's shipping line with the handle of the selected rate. + /// + Task> ListShippingRatesAsync(string token, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/CheckoutSalesChannel/CheckoutSalesChannelService.cs b/ShopifySharp/Services/CheckoutSalesChannel/CheckoutSalesChannelService.cs index 68555088..f7f792da 100644 --- a/ShopifySharp/Services/CheckoutSalesChannel/CheckoutSalesChannelService.cs +++ b/ShopifySharp/Services/CheckoutSalesChannel/CheckoutSalesChannelService.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using System.Net.Http; using System.Threading; @@ -7,85 +7,84 @@ using ShopifySharp.Infrastructure; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service use the Checkout API to let customers purchase products from Shopify stores that have installed your sales channel. +/// +public class CheckoutSalesChannelService: ShopifyService, ICheckoutSalesChannelService { - /// - /// A service use the Checkout API to let customers purchase products from Shopify stores that have installed your sales channel. - /// - public class CheckoutSalesChannelService: ShopifyService, ICheckoutSalesChannelService - { - public CheckoutSalesChannelService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal CheckoutSalesChannelService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + public CheckoutSalesChannelService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal CheckoutSalesChannelService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task GetAsync(string token, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"checkouts/{token}.json"); - - var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "checkout"); - return response.Result; - } - - /// - public virtual async Task CreateAsync(CheckoutSalesChannel checkout, - CancellationToken cancellationToken = default) - { - var req = BuildRequestUri("checkouts.json"); - - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, - new JsonContent(new {checkout}), "checkout"); - return response.Result; - } - - /// - public virtual async Task CompleteAsync(string token, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"checkouts/{token}/complete.json"); - - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "checkout"); - return response.Result; - } - - /// - public virtual async Task UpdateAsync(string token, CheckoutSalesChannel checkout, - CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"checkouts/{token}.json"); - - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, - new JsonContent(new { checkout }), "checkout"); - return response.Result; - } - - /// - public virtual async Task> ListShippingRatesAsync(string token, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"checkouts/{token}/shipping_rates.json"); - - var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "shipping_rates"); - return response.Result; - } - - /// - public virtual async Task CreatePaymentAsync(string token, CreatePayment createPayment, - CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"checkouts/{token}/payments.json"); - - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, - new JsonContent(new {payment = createPayment}), "payment"); - return response.Result; - } - - /// - public virtual async Task StoreCreditCard(CreditCard creditCard, CancellationToken cancellationToken = default) - { - var req = new RequestUri(new Uri("https://elb.deposit.shopifycs.com/sessions")); - - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, - new JsonContent(new { credit_card = creditCard })); - - return response.Result; - } + /// + public virtual async Task GetAsync(string token, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"checkouts/{token}.json"); + + var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "checkout"); + return response.Result; + } + + /// + public virtual async Task CreateAsync(CheckoutSalesChannel checkout, + CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("checkouts.json"); + + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, + new JsonContent(new {checkout}), "checkout"); + return response.Result; + } + + /// + public virtual async Task CompleteAsync(string token, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"checkouts/{token}/complete.json"); + + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "checkout"); + return response.Result; + } + + /// + public virtual async Task UpdateAsync(string token, CheckoutSalesChannel checkout, + CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"checkouts/{token}.json"); + + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, + new JsonContent(new { checkout }), "checkout"); + return response.Result; + } + + /// + public virtual async Task> ListShippingRatesAsync(string token, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"checkouts/{token}/shipping_rates.json"); + + var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "shipping_rates"); + return response.Result; + } + + /// + public virtual async Task CreatePaymentAsync(string token, CreatePayment createPayment, + CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"checkouts/{token}/payments.json"); + + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, + new JsonContent(new {payment = createPayment}), "payment"); + return response.Result; + } + + /// + public virtual async Task StoreCreditCard(CreditCard creditCard, CancellationToken cancellationToken = default) + { + var req = new RequestUri(new Uri("https://elb.deposit.shopifycs.com/sessions")); + + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, + new JsonContent(new { credit_card = creditCard })); + + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/CheckoutSalesChannel/ICheckoutSalesChannelService.cs b/ShopifySharp/Services/CheckoutSalesChannel/ICheckoutSalesChannelService.cs index 764e6edf..052df8a3 100644 --- a/ShopifySharp/Services/CheckoutSalesChannel/ICheckoutSalesChannelService.cs +++ b/ShopifySharp/Services/CheckoutSalesChannel/ICheckoutSalesChannelService.cs @@ -3,54 +3,53 @@ using System.Threading.Tasks; using ShopifySharp.Entities.SalesChannel; -namespace ShopifySharp +namespace ShopifySharp; + +public interface ICheckoutSalesChannelService : IShopifyService { - public interface ICheckoutSalesChannelService : IShopifyService - { - /// - /// Gets an existing, processing or completed checkout. - /// - Task GetAsync(string token, CancellationToken cancellationToken = default); - - /// - /// Creates a new Checkout. - /// - Task CreateAsync(CheckoutSalesChannel checkout, - CancellationToken cancellationToken = default); - - /// - /// Completes a checkout without requiring payment. - /// - Task CompleteAsync(string token, CancellationToken cancellationToken = default); - - /// - /// Updates an existing checkout based on the token id. - /// - Task UpdateAsync(string token, CheckoutSalesChannel checkout, - CancellationToken cancellationToken = default); - - /// - /// Retrieves a list of available shipping rates for the specified checkout. Implementers need to poll this endpoint until rates become available. Each shipping rate contains the checkout's - /// new subtotal price, total tax, and total price in the event that this shipping rate is selected. This can be used to update the UI without performing further API requests. To apply a - /// shipping rate, update the checkout's shipping line with the handle of the selected rate. - /// - Task> ListShippingRatesAsync(string token, CancellationToken cancellationToken = default); - - /// - /// Creates a payment on a checkout using the session ID returned by the card vault - /// - Task CreatePaymentAsync(string token, CreatePayment createPayment, - CancellationToken cancellationToken = default); - - /// - /// Stores a credit card in the card vault. Credit cards cannot be sent to the Checkout API directly. - /// They must be sent to the card vault, which in response will return a session ID. - /// This session ID can then be used when calling the POST #{token}/payments.json endpoint . - /// A session ID is valid only for a single call to the endpoint. - /// The card vault has a static URL and is located at https://elb.deposit.shopifycs.com/sessions. - /// It is also provided via the payment_url property on the Checkout resource. - /// - /// - Task StoreCreditCard(CreditCard creditCard, CancellationToken cancellationToken = default); - } + /// + /// Gets an existing, processing or completed checkout. + /// + Task GetAsync(string token, CancellationToken cancellationToken = default); + + /// + /// Creates a new Checkout. + /// + Task CreateAsync(CheckoutSalesChannel checkout, + CancellationToken cancellationToken = default); + + /// + /// Completes a checkout without requiring payment. + /// + Task CompleteAsync(string token, CancellationToken cancellationToken = default); + + /// + /// Updates an existing checkout based on the token id. + /// + Task UpdateAsync(string token, CheckoutSalesChannel checkout, + CancellationToken cancellationToken = default); + + /// + /// Retrieves a list of available shipping rates for the specified checkout. Implementers need to poll this endpoint until rates become available. Each shipping rate contains the checkout's + /// new subtotal price, total tax, and total price in the event that this shipping rate is selected. This can be used to update the UI without performing further API requests. To apply a + /// shipping rate, update the checkout's shipping line with the handle of the selected rate. + /// + Task> ListShippingRatesAsync(string token, CancellationToken cancellationToken = default); + + /// + /// Creates a payment on a checkout using the session ID returned by the card vault + /// + Task CreatePaymentAsync(string token, CreatePayment createPayment, + CancellationToken cancellationToken = default); + + /// + /// Stores a credit card in the card vault. Credit cards cannot be sent to the Checkout API directly. + /// They must be sent to the card vault, which in response will return a session ID. + /// This session ID can then be used when calling the POST #{token}/payments.json endpoint . + /// A session ID is valid only for a single call to the endpoint. + /// The card vault has a static URL and is located at https://elb.deposit.shopifycs.com/sessions. + /// It is also provided via the payment_url property on the Checkout resource. + /// + /// + Task StoreCreditCard(CreditCard creditCard, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Collect/CollectService.cs b/ShopifySharp/Services/Collect/CollectService.cs index 410c33bc..a994b5c5 100644 --- a/ShopifySharp/Services/Collect/CollectService.cs +++ b/ShopifySharp/Services/Collect/CollectService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Net.Http; @@ -6,56 +6,55 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating mapping between Shopify products and collections. +/// +public class CollectService : ShopifyService, ICollectService { /// - /// A service for manipulating mapping between Shopify products and collections. + /// Creates a new instance of . /// - public class CollectService : ShopifyService, ICollectService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public CollectService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal CollectService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public CollectService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal CollectService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CountAsync(CollectCountFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync("collects/count.json", "count", filter, cancellationToken); + /// + public virtual async Task CountAsync(CollectCountFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync("collects/count.json", "count", filter, cancellationToken); - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("collects.json", "collects", filter, cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("collects.json", "collects", filter, cancellationToken); - /// - public virtual async Task> ListAsync(CollectListFilter filter = null, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListAsync(CollectListFilter filter = null, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task GetAsync(long collectId, string fields = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"collects/{collectId}.json", "collect", fields, cancellationToken); + /// + public virtual async Task GetAsync(long collectId, string fields = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"collects/{collectId}.json", "collect", fields, cancellationToken); - /// - public virtual async Task CreateAsync(Collect collect, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri("collects.json"); - var content = new JsonContent(new - { - collect = collect - }); - - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "collect"); - return response.Result; - } - - /// - public virtual async Task DeleteAsync(long collectId, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(Collect collect, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("collects.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"collects/{collectId}.json"); + collect = collect + }); + + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "collect"); + return response.Result; + } + + /// + public virtual async Task DeleteAsync(long collectId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"collects/{collectId}.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); } } \ No newline at end of file diff --git a/ShopifySharp/Services/Collect/ICollectService.cs b/ShopifySharp/Services/Collect/ICollectService.cs index 80f9426a..4fda17b0 100644 --- a/ShopifySharp/Services/Collect/ICollectService.cs +++ b/ShopifySharp/Services/Collect/ICollectService.cs @@ -3,44 +3,43 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface ICollectService : IShopifyService { - public interface ICollectService : IShopifyService - { - Task CountAsync(CollectCountFilter filter = null, CancellationToken cancellationToken = default); + Task CountAsync(CollectCountFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the shop's collects. - /// - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's collects. + /// + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the shop's collects. - /// - Task> ListAsync(CollectListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's collects. + /// + Task> ListAsync(CollectListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the collect to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long collectId, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the collect to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long collectId, string fields = null, CancellationToken cancellationToken = default); - /// - /// Creates a new on the store. Map product to collection - /// - /// A new . Id should be set to null. - /// Cancellation Token - /// The new . - Task CreateAsync(Collect collect, CancellationToken cancellationToken = default); + /// + /// Creates a new on the store. Map product to collection + /// + /// A new . Id should be set to null. + /// Cancellation Token + /// The new . + Task CreateAsync(Collect collect, CancellationToken cancellationToken = default); - /// - /// Deletes a collect with the given Id. - /// - /// The product object's Id. - /// Cancellation Token - Task DeleteAsync(long collectId, CancellationToken cancellationToken = default); - } + /// + /// Deletes a collect with the given Id. + /// + /// The product object's Id. + /// Cancellation Token + Task DeleteAsync(long collectId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Collection/CollectionService.cs b/ShopifySharp/Services/Collection/CollectionService.cs index 691bc17e..3643d9b8 100644 --- a/ShopifySharp/Services/Collection/CollectionService.cs +++ b/ShopifySharp/Services/Collection/CollectionService.cs @@ -4,31 +4,30 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for interacting with Shopify Collections. +/// +public class CollectionService : ShopifyService, ICollectionService { /// - /// A service for interacting with Shopify Collections. + /// Creates a new instance of the service. /// - public class CollectionService : ShopifyService, ICollectionService - { - /// - /// Creates a new instance of the service. - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public CollectionService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal CollectionService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public CollectionService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal CollectionService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListProductsAsync(long collectionId, ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync($"collections/{collectionId}/products.json", "products", filter, cancellationToken); + /// + public virtual async Task> ListProductsAsync(long collectionId, ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync($"collections/{collectionId}/products.json", "products", filter, cancellationToken); - /// - public virtual async Task> ListProductsAsync(long collectionId, CollectionProductsListFilter filter = null, CancellationToken cancellationToken = default) => - await ListProductsAsync(collectionId, filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListProductsAsync(long collectionId, CollectionProductsListFilter filter = null, CancellationToken cancellationToken = default) => + await ListProductsAsync(collectionId, filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task GetAsync(long collectionId, string fields = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"collections/{collectionId}.json", "collection", fields, cancellationToken); - } + /// + public virtual async Task GetAsync(long collectionId, string fields = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"collections/{collectionId}.json", "collection", fields, cancellationToken); } \ No newline at end of file diff --git a/ShopifySharp/Services/Collection/ICollectionService.cs b/ShopifySharp/Services/Collection/ICollectionService.cs index 1a02805f..706cbb1f 100644 --- a/ShopifySharp/Services/Collection/ICollectionService.cs +++ b/ShopifySharp/Services/Collection/ICollectionService.cs @@ -3,32 +3,31 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface ICollectionService : IShopifyService { - public interface ICollectionService : IShopifyService - { - /// - /// Gets a list of the products belonging to the collection. - /// - /// Id of the collection for which to retrieve products. - /// Options for filtering the result. - /// Cancellation Token - Task> ListProductsAsync(long collectionId, ListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of the products belonging to the collection. + /// + /// Id of the collection for which to retrieve products. + /// Options for filtering the result. + /// Cancellation Token + Task> ListProductsAsync(long collectionId, ListFilter filter, CancellationToken cancellationToken = default); - /// - /// Gets a list of the products belonging to the collection. - /// - /// Id of the collection for which to retrieve products. - /// Options for filtering the result. - /// Cancellation Token - Task> ListProductsAsync(long collectionId, CollectionProductsListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of the products belonging to the collection. + /// + /// Id of the collection for which to retrieve products. + /// Options for filtering the result. + /// Cancellation Token + Task> ListProductsAsync(long collectionId, CollectionProductsListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Retrieves the object with the given id. - /// - /// The id of the object to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - Task GetAsync(long collectionId, string fields = null, CancellationToken cancellationToken = default); - } + /// + /// Retrieves the object with the given id. + /// + /// The id of the object to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + Task GetAsync(long collectionId, string fields = null, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/CollectionListing/CollectionListingService.cs b/ShopifySharp/Services/CollectionListing/CollectionListingService.cs index 4ca8ba0c..aecbb913 100644 --- a/ShopifySharp/Services/CollectionListing/CollectionListingService.cs +++ b/ShopifySharp/Services/CollectionListing/CollectionListingService.cs @@ -1,31 +1,30 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Lists; using System.Threading.Tasks; using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for interacting with Shopify product collection that a merchant has made available to your sales channel +/// +public class CollectionListingService: ShopifyService, ICollectionListingService { /// - /// A service for interacting with Shopify product collection that a merchant has made available to your sales channel + /// Creates a new instance of . /// - public class CollectionListingService: ShopifyService, ICollectionListingService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public CollectionListingService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal CollectionListingService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public CollectionListingService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal CollectionListingService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - public virtual async Task> ListAsync(ListFilter filter = default, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("collection_listings.json", "collection_listings", filter, cancellationToken); + public virtual async Task> ListAsync(ListFilter filter = default, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("collection_listings.json", "collection_listings", filter, cancellationToken); - public virtual async Task GetAsync(long collectionId, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"collection_listings/{collectionId}.json", "collection_listing", cancellationToken: cancellationToken); + public virtual async Task GetAsync(long collectionId, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"collection_listings/{collectionId}.json", "collection_listing", cancellationToken: cancellationToken); - public virtual async Task> ListIdsAsync(long collectionId, ListFilter filter = default, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync($"collection_listings/{collectionId}/product_ids.json", "product_ids", filter, cancellationToken); - } + public virtual async Task> ListIdsAsync(long collectionId, ListFilter filter = default, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync($"collection_listings/{collectionId}/product_ids.json", "product_ids", filter, cancellationToken); } \ No newline at end of file diff --git a/ShopifySharp/Services/CollectionListing/ICollectionListingService.cs b/ShopifySharp/Services/CollectionListing/ICollectionListingService.cs index 0742f291..e7694ff0 100644 --- a/ShopifySharp/Services/CollectionListing/ICollectionListingService.cs +++ b/ShopifySharp/Services/CollectionListing/ICollectionListingService.cs @@ -3,27 +3,26 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface ICollectionListingService : IShopifyService { - public interface ICollectionListingService : IShopifyService - { - /// - /// Retrieve collection listings that are published to your app. - /// - Task> ListAsync(ListFilter filter = default, CancellationToken cancellationToken = default); + /// + /// Retrieve collection listings that are published to your app. + /// + Task> ListAsync(ListFilter filter = default, CancellationToken cancellationToken = default); - /// - /// Retrieves the specific that is published to your app - /// - /// The id of the collection to retrieve. - /// Cancellation Token - /// The . - Task GetAsync(long collectionId, - CancellationToken cancellationToken = default); + /// + /// Retrieves the specific that is published to your app + /// + /// The id of the collection to retrieve. + /// Cancellation Token + /// The . + Task GetAsync(long collectionId, + CancellationToken cancellationToken = default); - /// - /// Retrieve product_ids that are published to a collection_id. Maximum 1,000 results per page - /// - Task> ListIdsAsync(long collectionId, ListFilter filter = default, CancellationToken cancellationToken = default); - } + /// + /// Retrieve product_ids that are published to a collection_id. Maximum 1,000 results per page + /// + Task> ListIdsAsync(long collectionId, ListFilter filter = default, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Country/CountryService.cs b/ShopifySharp/Services/Country/CountryService.cs index 1c4d9fc9..f10e2a75 100644 --- a/ShopifySharp/Services/Country/CountryService.cs +++ b/ShopifySharp/Services/Country/CountryService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Net.Http; @@ -6,69 +6,68 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify countries. +/// +public class CountryService : ShopifyService, ICountryService { /// - /// A service for manipulating Shopify countries. + /// Creates a new instance of . /// - public class CountryService : ShopifyService, ICountryService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public CountryService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal CountryService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public CountryService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal CountryService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CountAsync(CountryCountFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync("countries/count.json", "count", filter, cancellationToken); + /// + public virtual async Task CountAsync(CountryCountFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync("countries/count.json", "count", filter, cancellationToken); - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("countries.json", "countries", filter, cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("countries.json", "countries", filter, cancellationToken); - /// - public virtual async Task> ListAsync(CountryListFilter filter = null, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListAsync(CountryListFilter filter = null, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task GetAsync(long countryId, string fields = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"countries/{countryId}.json", "country", fields, cancellationToken); + /// + public virtual async Task GetAsync(long countryId, string fields = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"countries/{countryId}.json", "country", fields, cancellationToken); - /// - public virtual async Task CreateAsync(Country country, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(Country country, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("countries.json"); + var content = new JsonContent(new { - var req = BuildRequestUri("countries.json"); - var content = new JsonContent(new - { - country = country - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "country"); + country = country + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "country"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task UpdateAsync(long countryId, Country country, CancellationToken cancellationToken = default) + /// + public virtual async Task UpdateAsync(long countryId, Country country, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"countries/{countryId}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"countries/{countryId}.json"); - var content = new JsonContent(new - { - country = country - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "country"); + country = country + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "country"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task DeleteAsync(long countryId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"countries/{countryId}.json"); + /// + public virtual async Task DeleteAsync(long countryId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"countries/{countryId}.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); } } \ No newline at end of file diff --git a/ShopifySharp/Services/Country/ICountryService.cs b/ShopifySharp/Services/Country/ICountryService.cs index 168cf329..b03b5780 100644 --- a/ShopifySharp/Services/Country/ICountryService.cs +++ b/ShopifySharp/Services/Country/ICountryService.cs @@ -3,57 +3,56 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface ICountryService : IShopifyService { - public interface ICountryService : IShopifyService - { - /// - /// Gets a count of all of the shop's countries. - /// - /// The count of all countries for the shop. - Task CountAsync(CountryCountFilter filter = null, CancellationToken cancellationToken = default); - - /// - /// Gets a list of the shop's countries. - /// - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - - /// - /// Gets a list of the shop's countries. - /// - Task> ListAsync(CountryListFilter filter = null, CancellationToken cancellationToken = default); - - /// - /// Retrieves the with the given id. - /// - /// The id of the country to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long countryId, string fields = null, CancellationToken cancellationToken = default); - - /// - /// Creates a new on the store. - /// - /// A new . Id should be set to null. - /// Cancellation Token - /// The new . - Task CreateAsync(Country country, CancellationToken cancellationToken = default); - - /// - /// Updates the given . - /// - /// Id of the object being updated. - /// The to update. - /// Cancellation Token - /// The updated . - Task UpdateAsync(long countryId, Country country, CancellationToken cancellationToken = default); - - /// - /// Deletes a country with the given Id. - /// - /// The country object's Id. - /// Cancellation Token - Task DeleteAsync(long countryId, CancellationToken cancellationToken = default); - } + /// + /// Gets a count of all of the shop's countries. + /// + /// The count of all countries for the shop. + Task CountAsync(CountryCountFilter filter = null, CancellationToken cancellationToken = default); + + /// + /// Gets a list of the shop's countries. + /// + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + + /// + /// Gets a list of the shop's countries. + /// + Task> ListAsync(CountryListFilter filter = null, CancellationToken cancellationToken = default); + + /// + /// Retrieves the with the given id. + /// + /// The id of the country to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long countryId, string fields = null, CancellationToken cancellationToken = default); + + /// + /// Creates a new on the store. + /// + /// A new . Id should be set to null. + /// Cancellation Token + /// The new . + Task CreateAsync(Country country, CancellationToken cancellationToken = default); + + /// + /// Updates the given . + /// + /// Id of the object being updated. + /// The to update. + /// Cancellation Token + /// The updated . + Task UpdateAsync(long countryId, Country country, CancellationToken cancellationToken = default); + + /// + /// Deletes a country with the given Id. + /// + /// The country object's Id. + /// Cancellation Token + Task DeleteAsync(long countryId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/CustomCollection/CustomCollectionService.cs b/ShopifySharp/Services/CustomCollection/CustomCollectionService.cs index a39b9cc7..87e6db0a 100644 --- a/ShopifySharp/Services/CustomCollection/CustomCollectionService.cs +++ b/ShopifySharp/Services/CustomCollection/CustomCollectionService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Net.Http; @@ -6,69 +6,68 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating mapping between custom collections and collections +/// +public class CustomCollectionService : ShopifyService, ICustomCollectionService { - /// - /// A service for manipulating mapping between custom collections and collections - /// - public class CustomCollectionService : ShopifyService, ICustomCollectionService - { - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public CustomCollectionService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal CustomCollectionService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public CustomCollectionService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal CustomCollectionService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default) => await ExecuteGetListAsync("custom_collections.json", "custom_collections", filter, cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default) => await ExecuteGetListAsync("custom_collections.json", "custom_collections", filter, cancellationToken); - /// - public virtual async Task> ListAsync(CustomCollectionListFilter filter, CancellationToken cancellationToken = default) => await ListAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListAsync(CustomCollectionListFilter filter, CancellationToken cancellationToken = default) => await ListAsync(filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task CreateAsync(CustomCollection customCollection, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(CustomCollection customCollection, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("custom_collections.json"); + var content = new JsonContent(new { - var req = BuildRequestUri("custom_collections.json"); - var content = new JsonContent(new - { - custom_collection = customCollection - }); + custom_collection = customCollection + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "custom_collection"); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "custom_collection"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task CountAsync(CustomCollectionCountFilter filter = null, CancellationToken cancellationToken = default) - { - return await ExecuteGetAsync("custom_collections/count.json", "count", filter, cancellationToken); - } + /// + public virtual async Task CountAsync(CustomCollectionCountFilter filter = null, CancellationToken cancellationToken = default) + { + return await ExecuteGetAsync("custom_collections/count.json", "count", filter, cancellationToken); + } - /// - public virtual async Task GetAsync(long customCollectionId, string fields = null, CancellationToken cancellationToken = default) - { - return await ExecuteGetAsync($"custom_collections/{customCollectionId}.json", "custom_collection", fields, cancellationToken); - } + /// + public virtual async Task GetAsync(long customCollectionId, string fields = null, CancellationToken cancellationToken = default) + { + return await ExecuteGetAsync($"custom_collections/{customCollectionId}.json", "custom_collection", fields, cancellationToken); + } - /// - public virtual async Task DeleteAsync(long customCollectionId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"custom_collections/{customCollectionId}.json"); + /// + public virtual async Task DeleteAsync(long customCollectionId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"custom_collections/{customCollectionId}.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); + } - /// - public virtual async Task UpdateAsync(long customCollectionId, CustomCollection customCollection, CancellationToken cancellationToken = default) + /// + public virtual async Task UpdateAsync(long customCollectionId, CustomCollection customCollection, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"custom_collections/{customCollectionId}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"custom_collections/{customCollectionId}.json"); - var content = new JsonContent(new - { - custom_collection = customCollection - }); + custom_collection = customCollection + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "custom_collection"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "custom_collection"); + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/CustomCollection/ICustomCollectionService.cs b/ShopifySharp/Services/CustomCollection/ICustomCollectionService.cs index 80989f72..98068751 100644 --- a/ShopifySharp/Services/CustomCollection/ICustomCollectionService.cs +++ b/ShopifySharp/Services/CustomCollection/ICustomCollectionService.cs @@ -3,53 +3,52 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface ICustomCollectionService : IShopifyService { - public interface ICustomCollectionService : IShopifyService - { - /// - /// Gets a list of up to 250 custom collections. - /// - Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default); - - /// - /// Gets a list of up to 250 custom collections. - /// - Task> ListAsync(CustomCollectionListFilter filter, CancellationToken cancellationToken = default); - - /// - /// Creates a new Custom Collection - /// - /// A new . Id should be set to null. - /// Cancellation Token - /// The new . - Task CreateAsync(CustomCollection customCollection, CancellationToken cancellationToken = default); - - Task CountAsync(CustomCollectionCountFilter filter = null, CancellationToken cancellationToken = default); - - /// - /// Retrieves the with the given id. - /// - /// The id of the custom collection to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long customCollectionId, string fields = null, CancellationToken cancellationToken = default); - - /// - /// Deletes a custom collection with the given Id. - /// - /// The custom collection's Id. - /// Cancellation Token - Task DeleteAsync(long customCollectionId, CancellationToken cancellationToken = default); - - /// - /// Updates the given . - /// - /// Id of the object being updated. - /// The to update. - /// Cancellation Token - /// The updated . - Task UpdateAsync(long customCollectionId, CustomCollection customCollection, CancellationToken cancellationToken = default); - } + /// + /// Gets a list of up to 250 custom collections. + /// + Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default); + + /// + /// Gets a list of up to 250 custom collections. + /// + Task> ListAsync(CustomCollectionListFilter filter, CancellationToken cancellationToken = default); + + /// + /// Creates a new Custom Collection + /// + /// A new . Id should be set to null. + /// Cancellation Token + /// The new . + Task CreateAsync(CustomCollection customCollection, CancellationToken cancellationToken = default); + + Task CountAsync(CustomCollectionCountFilter filter = null, CancellationToken cancellationToken = default); + + /// + /// Retrieves the with the given id. + /// + /// The id of the custom collection to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long customCollectionId, string fields = null, CancellationToken cancellationToken = default); + + /// + /// Deletes a custom collection with the given Id. + /// + /// The custom collection's Id. + /// Cancellation Token + Task DeleteAsync(long customCollectionId, CancellationToken cancellationToken = default); + + /// + /// Updates the given . + /// + /// Id of the object being updated. + /// The to update. + /// Cancellation Token + /// The updated . + Task UpdateAsync(long customCollectionId, CustomCollection customCollection, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Customer/CustomerCreateOptions.cs b/ShopifySharp/Services/Customer/CustomerCreateOptions.cs index dca3d5f2..82618b35 100644 --- a/ShopifySharp/Services/Customer/CustomerCreateOptions.cs +++ b/ShopifySharp/Services/Customer/CustomerCreateOptions.cs @@ -1,22 +1,21 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// Options for creating a . +/// +public class CustomerCreateOptions : CustomerUpdateOptions { /// - /// Options for creating a . + /// Whether an email invite should be sent to the new customer. Default is null. /// - public class CustomerCreateOptions : CustomerUpdateOptions - { - /// - /// Whether an email invite should be sent to the new customer. Default is null. - /// - [JsonProperty("send_email_invite")] - public bool? SendEmailInvite { get; set; } + [JsonProperty("send_email_invite")] + public bool? SendEmailInvite { get; set; } - /// - /// Whether a welcome email should be sent to the new customer. Default is null. - /// - [JsonProperty("send_email_welcome")] - public bool? SendWelcomeEmail { get; set; } - } -} + /// + /// Whether a welcome email should be sent to the new customer. Default is null. + /// + [JsonProperty("send_email_welcome")] + public bool? SendWelcomeEmail { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Services/Customer/CustomerService.cs b/ShopifySharp/Services/Customer/CustomerService.cs index f9865f69..fe4acbe0 100644 --- a/ShopifySharp/Services/Customer/CustomerService.cs +++ b/ShopifySharp/Services/Customer/CustomerService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Collections.Generic; @@ -7,123 +7,122 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify customers. +/// +public class CustomerService : ShopifyService, ICustomerService { - /// - /// A service for manipulating Shopify customers. - /// - public class CustomerService : ShopifyService, ICustomerService - { - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public CustomerService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal CustomerService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public CustomerService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal CustomerService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CountAsync(CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"customers/count.json", "count", cancellationToken: cancellationToken); + /// + public virtual async Task CountAsync(CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"customers/count.json", "count", cancellationToken: cancellationToken); - /// - public virtual async Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("customers.json", "customers", filter, cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("customers.json", "customers", filter, cancellationToken); - /// - public virtual async Task> ListAsync(CustomerListFilter filter, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListAsync(CustomerListFilter filter, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task GetAsync(long customerId, string fields = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"customers/{customerId}.json", "customer", fields, cancellationToken); + /// + public virtual async Task GetAsync(long customerId, string fields = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"customers/{customerId}.json", "customer", fields, cancellationToken); - /// - public virtual async Task> SearchAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("customers/search.json", "customers", filter, cancellationToken); + /// + public virtual async Task> SearchAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("customers/search.json", "customers", filter, cancellationToken); - /// - public virtual async Task> SearchAsync(CustomerSearchListFilter filter, CancellationToken cancellationToken = default) => - await SearchAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> SearchAsync(CustomerSearchListFilter filter, CancellationToken cancellationToken = default) => + await SearchAsync(filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task CreateAsync(Customer customer, CustomerCreateOptions options = null, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri("customers.json"); - var body = customer.ToDictionary(); + /// + public virtual async Task CreateAsync(Customer customer, CustomerCreateOptions options = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("customers.json"); + var body = customer.ToDictionary(); - if (options != null) + if (options != null) + { + foreach (var keyValuePair in options.ToDictionary()) { - foreach (var keyValuePair in options.ToDictionary()) - { - body.Add(keyValuePair); - } + body.Add(keyValuePair); } - - var content = new JsonContent(new - { - customer = body - }); - - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "customer"); - return response.Result; } - /// - public virtual async Task UpdateAsync(long customerId, Customer customer, CustomerUpdateOptions options = null, CancellationToken cancellationToken = default) + var content = new JsonContent(new { - var req = BuildRequestUri($"customers/{customerId}.json"); - var body = customer.ToDictionary(); + customer = body + }); - if (options != null) - { - foreach (var keyValuePair in options.ToDictionary()) - { - body.Add(keyValuePair); - } - } + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "customer"); + return response.Result; + } - var content = new JsonContent(new - { - customer = body - }); + /// + public virtual async Task UpdateAsync(long customerId, Customer customer, CustomerUpdateOptions options = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"customers/{customerId}.json"); + var body = customer.ToDictionary(); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "customer"); - return response.Result; + if (options != null) + { + foreach (var keyValuePair in options.ToDictionary()) + { + body.Add(keyValuePair); + } } - /// - public virtual async Task DeleteAsync(long customerId, CancellationToken cancellationToken = default) + var content = new JsonContent(new { - var req = BuildRequestUri($"customers/{customerId}.json"); + customer = body + }); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken: cancellationToken); - } + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "customer"); + return response.Result; + } - /// - public virtual async Task SendInviteAsync(long customerId, CustomerInvite invite = null, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"customers/{customerId}/send_invite.json"); + /// + public virtual async Task DeleteAsync(long customerId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"customers/{customerId}.json"); - var content = new JsonContent(new - { - customer_invite = invite - }); + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken: cancellationToken); + } - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "customer_invite"); - return response.Result; - } + /// + public virtual async Task SendInviteAsync(long customerId, CustomerInvite invite = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"customers/{customerId}/send_invite.json"); - /// - public virtual async Task GetAccountActivationUrl(long customerid, CancellationToken cancellationToken = default) + var content = new JsonContent(new { - var req = BuildRequestUri($"customers/{customerid}/account_activation_url.json"); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken); + customer_invite = invite + }); - return response.Result.SelectToken("account_activation_url").ToString(); - } + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "customer_invite"); + return response.Result; + } - /// - public virtual async Task> ListOrdersForCustomerAsync(long customerId, CustomerOrderListFilter filter = null, CancellationToken cancellationToken = default) - { - return await ExecuteGetAsync>($"customers/{customerId}/orders.json", "orders", filter, cancellationToken); - } + /// + public virtual async Task GetAccountActivationUrl(long customerid, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"customers/{customerid}/account_activation_url.json"); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken); + + return response.Result.SelectToken("account_activation_url").ToString(); + } + + /// + public virtual async Task> ListOrdersForCustomerAsync(long customerId, CustomerOrderListFilter filter = null, CancellationToken cancellationToken = default) + { + return await ExecuteGetAsync>($"customers/{customerId}/orders.json", "orders", filter, cancellationToken); } } \ No newline at end of file diff --git a/ShopifySharp/Services/Customer/CustomerUpdateOptions.cs b/ShopifySharp/Services/Customer/CustomerUpdateOptions.cs index a3a3e0a3..2b9f3f2b 100644 --- a/ShopifySharp/Services/Customer/CustomerUpdateOptions.cs +++ b/ShopifySharp/Services/Customer/CustomerUpdateOptions.cs @@ -1,22 +1,21 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// Options for updating a . +/// +public class CustomerUpdateOptions : Parameterizable { /// - /// Options for updating a . + /// An optional password for the user. Default is null. /// - public class CustomerUpdateOptions : Parameterizable - { - /// - /// An optional password for the user. Default is null. - /// - [JsonProperty("password")] - public string Password { get; set; } + [JsonProperty("password")] + public string Password { get; set; } - /// - /// Should be set and match . Default is null. - /// - [JsonProperty("password_confirmation")] - public string PasswordConfirmation { get; set; } - } -} + /// + /// Should be set and match . Default is null. + /// + [JsonProperty("password_confirmation")] + public string PasswordConfirmation { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Services/Customer/ICustomerService.cs b/ShopifySharp/Services/Customer/ICustomerService.cs index 5cfa8400..c1ae670c 100644 --- a/ShopifySharp/Services/Customer/ICustomerService.cs +++ b/ShopifySharp/Services/Customer/ICustomerService.cs @@ -4,109 +4,108 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface ICustomerService : IShopifyService { - public interface ICustomerService : IShopifyService - { - /// - /// Gets a count of all of the shop's customers. - /// - /// - /// According to Shopify's documentation, the count endpoint does not support any parameters. - /// - Task CountAsync(CancellationToken cancellationToken = default); + /// + /// Gets a count of all of the shop's customers. + /// + /// + /// According to Shopify's documentation, the count endpoint does not support any parameters. + /// + Task CountAsync(CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the shop's customers. - /// - Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's customers. + /// + Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the shop's customers. - /// - Task> ListAsync(CustomerListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's customers. + /// + Task> ListAsync(CustomerListFilter filter, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the customer to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long customerId, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the customer to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long customerId, string fields = null, CancellationToken cancellationToken = default); - /// - /// Searches through a shop's customers for the given search query. NOTE: Assumes the and strings are not encoded. - /// - /// Options for filtering the result. - /// Cancellation Token - Task> SearchAsync(ListFilter filter, CancellationToken cancellationToken = default); + /// + /// Searches through a shop's customers for the given search query. NOTE: Assumes the and strings are not encoded. + /// + /// Options for filtering the result. + /// Cancellation Token + Task> SearchAsync(ListFilter filter, CancellationToken cancellationToken = default); - /// - /// Searches through a shop's customers for the given search query. NOTE: Assumes the and strings are not encoded. - /// - /// Options for filtering the result. - /// Cancellation Token - Task> SearchAsync(CustomerSearchListFilter filter, CancellationToken cancellationToken = default); + /// + /// Searches through a shop's customers for the given search query. NOTE: Assumes the and strings are not encoded. + /// + /// Options for filtering the result. + /// Cancellation Token + Task> SearchAsync(CustomerSearchListFilter filter, CancellationToken cancellationToken = default); - /// - /// Creates a new on the store. - /// - /// A new . Id should be set to null. - /// Options for creating the customer. - /// Cancellation Token - /// The new . - Task CreateAsync(Customer customer, CustomerCreateOptions options = null, CancellationToken cancellationToken = default); + /// + /// Creates a new on the store. + /// + /// A new . Id should be set to null. + /// Options for creating the customer. + /// Cancellation Token + /// The new . + Task CreateAsync(Customer customer, CustomerCreateOptions options = null, CancellationToken cancellationToken = default); - /// - /// Updates the given . - /// - /// Id of the object being updated. - /// The to update. - /// Options for updating the customer. - /// Cancellation Token - /// The updated . - Task UpdateAsync(long customerId, Customer customer, CustomerUpdateOptions options = null, CancellationToken cancellationToken = default); + /// + /// Updates the given . + /// + /// Id of the object being updated. + /// The to update. + /// Options for updating the customer. + /// Cancellation Token + /// The updated . + Task UpdateAsync(long customerId, Customer customer, CustomerUpdateOptions options = null, CancellationToken cancellationToken = default); - /// - /// Deletes a customer with the given Id. - /// - /// The customer object's Id. - /// Cancellation Token - Task DeleteAsync(long customerId, CancellationToken cancellationToken = default); + /// + /// Deletes a customer with the given Id. + /// + /// The customer object's Id. + /// Cancellation Token + Task DeleteAsync(long customerId, CancellationToken cancellationToken = default); - /// - /// Send an invite by email to activate a customers account. - /// - /// The customer object's Id. - /// Options for the invite email request - /// Cancellation Token - /// - Task SendInviteAsync(long customerId, CustomerInvite invite = null, CancellationToken cancellationToken = default); + /// + /// Send an invite by email to activate a customers account. + /// + /// The customer object's Id. + /// Options for the invite email request + /// Cancellation Token + /// + Task SendInviteAsync(long customerId, CustomerInvite invite = null, CancellationToken cancellationToken = default); - /// - /// Generate and retrieve an account activation URL for a customer who is not yet enabled. - /// This is useful if you've imported a large number of customers and want to send them activation emails all at once (using this approach, you'll need to generate and send the activation emails yourself). - /// The account activation URL generated by this endpoint is one time use and will expire after 7 days. - /// If you make a new POST request to this endpoint, a new URL will be generated which will be again valid for 7 days, but the previous URL will no longer be valid. - /// - /// The customer object's Id. - /// Cancellation Token - /// - Task GetAccountActivationUrl(long customerid, CancellationToken cancellationToken = default); + /// + /// Generate and retrieve an account activation URL for a customer who is not yet enabled. + /// This is useful if you've imported a large number of customers and want to send them activation emails all at once (using this approach, you'll need to generate and send the activation emails yourself). + /// The account activation URL generated by this endpoint is one time use and will expire after 7 days. + /// If you make a new POST request to this endpoint, a new URL will be generated which will be again valid for 7 days, but the previous URL will no longer be valid. + /// + /// The customer object's Id. + /// Cancellation Token + /// + Task GetAccountActivationUrl(long customerid, CancellationToken cancellationToken = default); - /// - /// Gets a list of the customer's orders. - /// - /// The id of the customer to list orders for. - /// Options for filtering the result. - /// Cancellation Token - /// - /// Previously this was part of the OrderService, and was documented under the Orders API in Shopify. - /// Shopify appears to have moved it to the Customers API. - /// https://shopify.dev/docs/admin-api/rest/reference/customers/customer#orders-2020-01 - /// This list does not appear to be paginated. - /// - Task> ListOrdersForCustomerAsync(long customerId, CustomerOrderListFilter filter = null, CancellationToken cancellationToken = default); - } + /// + /// Gets a list of the customer's orders. + /// + /// The id of the customer to list orders for. + /// Options for filtering the result. + /// Cancellation Token + /// + /// Previously this was part of the OrderService, and was documented under the Orders API in Shopify. + /// Shopify appears to have moved it to the Customers API. + /// https://shopify.dev/docs/admin-api/rest/reference/customers/customer#orders-2020-01 + /// This list does not appear to be paginated. + /// + Task> ListOrdersForCustomerAsync(long customerId, CustomerOrderListFilter filter = null, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/CustomerAddress/CustomerAddressService.cs b/ShopifySharp/Services/CustomerAddress/CustomerAddressService.cs index 760daf6b..d8bfc612 100644 --- a/ShopifySharp/Services/CustomerAddress/CustomerAddressService.cs +++ b/ShopifySharp/Services/CustomerAddress/CustomerAddressService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Net.Http; @@ -6,80 +6,79 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify customers addresses. +/// +public class CustomerAddressService : ShopifyService, ICustomerAddressService { - /// - /// A service for manipulating Shopify customers addresses. - /// - public class CustomerAddressService : ShopifyService, ICustomerAddressService - { - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public CustomerAddressService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal CustomerAddressService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public CustomerAddressService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal CustomerAddressService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(long customerId, ListFilter
filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync($"customers/{customerId}/addresses.json", "addresses", filter, cancellationToken); - - /// - public virtual async Task
GetAsync(long customerId, long addressId, string fields = null, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"customers/{customerId}/addresses/{addressId}.json"); - - if (string.IsNullOrEmpty(fields) == false) - { - req.QueryParams.Add("fields", fields); - } + /// + public virtual async Task> ListAsync(long customerId, ListFilter
filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync($"customers/{customerId}/addresses.json", "addresses", filter, cancellationToken); - var response = await ExecuteRequestAsync
(req, HttpMethod.Get, cancellationToken, rootElement: "customer_address"); - return response.Result; - } + /// + public virtual async Task
GetAsync(long customerId, long addressId, string fields = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"customers/{customerId}/addresses/{addressId}.json"); - /// - public virtual async Task
CreateAsync(long customerId, Address address, CancellationToken cancellationToken = default) + if (string.IsNullOrEmpty(fields) == false) { - var req = BuildRequestUri($"customers/{customerId}/addresses.json"); - var addressBody = address.ToDictionary(); - var content = new JsonContent(new - { - address = addressBody - }); - - var response = await ExecuteRequestAsync
(req, HttpMethod.Post, cancellationToken, content, "customer_address"); - return response.Result; + req.QueryParams.Add("fields", fields); } - /// - public virtual async Task
UpdateAsync(long customerId, long addressId, Address address, CancellationToken cancellationToken = default) + var response = await ExecuteRequestAsync
(req, HttpMethod.Get, cancellationToken, rootElement: "customer_address"); + return response.Result; + } + + /// + public virtual async Task
CreateAsync(long customerId, Address address, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"customers/{customerId}/addresses.json"); + var addressBody = address.ToDictionary(); + var content = new JsonContent(new { - var req = BuildRequestUri($"customers/{customerId}/addresses/{addressId}.json"); - var addressBody = address.ToDictionary(); + address = addressBody + }); - var content = new JsonContent(new - { - address = addressBody - }); + var response = await ExecuteRequestAsync
(req, HttpMethod.Post, cancellationToken, content, "customer_address"); + return response.Result; + } - var response = await ExecuteRequestAsync
(req, HttpMethod.Put, cancellationToken, content, "customer_address"); - return response.Result; - } + /// + public virtual async Task
UpdateAsync(long customerId, long addressId, Address address, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"customers/{customerId}/addresses/{addressId}.json"); + var addressBody = address.ToDictionary(); - /// - public virtual async Task DeleteAsync(long customerId, long addressId, CancellationToken cancellationToken = default) + var content = new JsonContent(new { - var req = BuildRequestUri($"customers/{customerId}/addresses/{addressId}.json"); + address = addressBody + }); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + var response = await ExecuteRequestAsync
(req, HttpMethod.Put, cancellationToken, content, "customer_address"); + return response.Result; + } - /// - public virtual async Task
SetDefault(long customerId, long addressId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"customers/{customerId}/addresses/{addressId}/default.json"); + /// + public virtual async Task DeleteAsync(long customerId, long addressId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"customers/{customerId}/addresses/{addressId}.json"); - var response = await ExecuteRequestAsync
(req, HttpMethod.Put, cancellationToken, rootElement: "customer_address"); - return response.Result; - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); + } + + /// + public virtual async Task
SetDefault(long customerId, long addressId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"customers/{customerId}/addresses/{addressId}/default.json"); + + var response = await ExecuteRequestAsync
(req, HttpMethod.Put, cancellationToken, rootElement: "customer_address"); + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/CustomerAddress/ICustomerAddressService.cs b/ShopifySharp/Services/CustomerAddress/ICustomerAddressService.cs index 3ce84f7f..580f4f30 100644 --- a/ShopifySharp/Services/CustomerAddress/ICustomerAddressService.cs +++ b/ShopifySharp/Services/CustomerAddress/ICustomerAddressService.cs @@ -3,61 +3,60 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface ICustomerAddressService : IShopifyService { - public interface ICustomerAddressService : IShopifyService - { - /// - /// Gets a list of up to 250 of the shop customer's addresses. - /// - /// The id of the customer to retrieve. - /// Cancellation Token - Task> ListAsync(long customerId, ListFilter
filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop customer's addresses. + /// + /// The id of the customer to retrieve. + /// Cancellation Token + Task> ListAsync(long customerId, ListFilter
filter = null, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the customer to retrieve. - /// The id of the customer address to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task
GetAsync(long customerId, long addressId, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the customer to retrieve. + /// The id of the customer address to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task
GetAsync(long customerId, long addressId, string fields = null, CancellationToken cancellationToken = default); - /// - /// Creates a new on the store. - /// - /// The id of the customer to create address for. - /// A new . Id should be set to null. - /// Cancellation Token - /// The new . - Task
CreateAsync(long customerId, Address address, CancellationToken cancellationToken = default); + /// + /// Creates a new on the store. + /// + /// The id of the customer to create address for. + /// A new . Id should be set to null. + /// Cancellation Token + /// The new . + Task
CreateAsync(long customerId, Address address, CancellationToken cancellationToken = default); - /// - /// Updates the given . - /// - /// Id of the customer object being updated. - /// Id of the address object being updated. - /// The to update. - /// Cancellation Token - /// The updated . - Task
UpdateAsync(long customerId, long addressId, Address address, CancellationToken cancellationToken = default); + /// + /// Updates the given . + /// + /// Id of the customer object being updated. + /// Id of the address object being updated. + /// The to update. + /// Cancellation Token + /// The updated . + Task
UpdateAsync(long customerId, long addressId, Address address, CancellationToken cancellationToken = default); - /// - /// Deletes a address with the given Id from a customer. - /// - /// The customer object's Id. - /// The address object's Id. - /// Cancellation Token - Task DeleteAsync(long customerId, long addressId, CancellationToken cancellationToken = default); + /// + /// Deletes a address with the given Id from a customer. + /// + /// The customer object's Id. + /// The address object's Id. + /// Cancellation Token + Task DeleteAsync(long customerId, long addressId, CancellationToken cancellationToken = default); - /// - /// Sets the specified address as the default for a customer - /// - /// The customer object's Id. - /// The address object's Id. - /// Cancellation Token - /// - Task
SetDefault(long customerId, long addressId, CancellationToken cancellationToken = default); - } + /// + /// Sets the specified address as the default for a customer + /// + /// The customer object's Id. + /// The address object's Id. + /// Cancellation Token + /// + Task
SetDefault(long customerId, long addressId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/DiscountCode/DiscountCodeService.cs b/ShopifySharp/Services/DiscountCode/DiscountCodeService.cs index 09822b80..cf942b06 100644 --- a/ShopifySharp/Services/DiscountCode/DiscountCodeService.cs +++ b/ShopifySharp/Services/DiscountCode/DiscountCodeService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Net.Http; @@ -6,79 +6,78 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify discount codes. +/// +public class DiscountCodeService : ShopifyService, IDiscountCodeService { - /// - /// A service for manipulating Shopify discount codes. - /// - public class DiscountCodeService : ShopifyService, IDiscountCodeService - { - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public DiscountCodeService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal DiscountCodeService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public DiscountCodeService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal DiscountCodeService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(long priceRuleId, ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync($"price_rules/{priceRuleId}/discount_codes.json", "discount_codes", filter, cancellationToken); + /// + public virtual async Task> ListAsync(long priceRuleId, ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync($"price_rules/{priceRuleId}/discount_codes.json", "discount_codes", filter, cancellationToken); - /// - public virtual async Task> ListAsync(long priceRuleId, PriceRuleDiscountCodeListFilter filter = null, CancellationToken cancellationToken = default) => - await ListAsync(priceRuleId, filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListAsync(long priceRuleId, PriceRuleDiscountCodeListFilter filter = null, CancellationToken cancellationToken = default) => + await ListAsync(priceRuleId, filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task GetAsync(long priceRuleId, long discountId, string fields = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"price_rules/{priceRuleId}/discount_codes/{discountId}.json", "discount_code", fields, cancellationToken); + /// + public virtual async Task GetAsync(long priceRuleId, long discountId, string fields = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"price_rules/{priceRuleId}/discount_codes/{discountId}.json", "discount_code", fields, cancellationToken); - /// - public virtual async Task GetAsync(PriceRuleDiscountCodeFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"discount_codes/lookup.json", "discount_code", queryParams: filter, cancellationToken); + /// + public virtual async Task GetAsync(PriceRuleDiscountCodeFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"discount_codes/lookup.json", "discount_code", queryParams: filter, cancellationToken); - /// - public virtual async Task GetAsync(string code, CancellationToken cancellationToken = default) + /// + public virtual async Task GetAsync(string code, CancellationToken cancellationToken = default) + { + var filter = new PriceRuleDiscountCodeFilter { - var filter = new PriceRuleDiscountCodeFilter - { - Code = code - }; + Code = code + }; - return await GetAsync(filter, cancellationToken); - } + return await GetAsync(filter, cancellationToken); + } - /// - public virtual async Task CreateAsync(long priceRuleId, PriceRuleDiscountCode code, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"price_rules/{priceRuleId}/discount_codes.json"); - var body = code.ToDictionary(); + /// + public virtual async Task CreateAsync(long priceRuleId, PriceRuleDiscountCode code, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"price_rules/{priceRuleId}/discount_codes.json"); + var body = code.ToDictionary(); - var content = new JsonContent(new - { - discount_code = body - }); + var content = new JsonContent(new + { + discount_code = body + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "discount_code"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "discount_code"); + return response.Result; + } - /// - public virtual async Task UpdateAsync(long priceRuleId, PriceRuleDiscountCode code, CancellationToken cancellationToken = default) + /// + public virtual async Task UpdateAsync(long priceRuleId, PriceRuleDiscountCode code, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"price_rules/{priceRuleId}/discount_codes/{code.Id.Value}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"price_rules/{priceRuleId}/discount_codes/{code.Id.Value}.json"); - var content = new JsonContent(new - { - discount_code = code - }); + discount_code = code + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "discount_code"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "discount_code"); + return response.Result; + } - /// - public virtual async Task DeleteAsync(long priceRuleId, long discountCodeId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"price_rules/{priceRuleId}/discount_codes/{discountCodeId}.json"); + /// + public virtual async Task DeleteAsync(long priceRuleId, long discountCodeId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"price_rules/{priceRuleId}/discount_codes/{discountCodeId}.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); } } \ No newline at end of file diff --git a/ShopifySharp/Services/DiscountCode/IDiscountCodeService.cs b/ShopifySharp/Services/DiscountCode/IDiscountCodeService.cs index ccf8313c..0a1dcbe2 100644 --- a/ShopifySharp/Services/DiscountCode/IDiscountCodeService.cs +++ b/ShopifySharp/Services/DiscountCode/IDiscountCodeService.cs @@ -3,67 +3,66 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IDiscountCodeService : IShopifyService { - public interface IDiscountCodeService : IShopifyService - { - /// - /// Gets a list of up to 250 of the discount codes belonging to the price rule. - /// - Task> ListAsync(long priceRuleId, ListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the discount codes belonging to the price rule. + /// + Task> ListAsync(long priceRuleId, ListFilter filter, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the discount codes belonging to the price rule. - /// - Task> ListAsync(long priceRuleId, PriceRuleDiscountCodeListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the discount codes belonging to the price rule. + /// + Task> ListAsync(long priceRuleId, PriceRuleDiscountCodeListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the associated price rule. - /// The id of the discount to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long priceRuleId, long discountId, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the associated price rule. + /// The id of the discount to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long priceRuleId, long discountId, string fields = null, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given code. - /// - /// A filter with the code of the associated price rule. - /// Cancellation Token - /// The . - Task GetAsync(PriceRuleDiscountCodeFilter filter, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given code. + /// + /// A filter with the code of the associated price rule. + /// Cancellation Token + /// The . + Task GetAsync(PriceRuleDiscountCodeFilter filter, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given code. - /// - /// The code of the associated price rule. - /// Cancellation Token - /// The . - Task GetAsync(string code, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given code. + /// + /// The code of the associated price rule. + /// Cancellation Token + /// The . + Task GetAsync(string code, CancellationToken cancellationToken = default); - /// - /// Creates a new discount code. - /// - /// Id of an existing price rule. - /// Cancellation Token - Task CreateAsync(long priceRuleId, PriceRuleDiscountCode code, CancellationToken cancellationToken = default); + /// + /// Creates a new discount code. + /// + /// Id of an existing price rule. + /// Cancellation Token + Task CreateAsync(long priceRuleId, PriceRuleDiscountCode code, CancellationToken cancellationToken = default); - /// - /// Updates the given object. - /// - /// The Id of the Price Rule being updated. - /// The code being updated. - /// Cancellation Token - Task UpdateAsync(long priceRuleId, PriceRuleDiscountCode code, CancellationToken cancellationToken = default); + /// + /// Updates the given object. + /// + /// The Id of the Price Rule being updated. + /// The code being updated. + /// Cancellation Token + Task UpdateAsync(long priceRuleId, PriceRuleDiscountCode code, CancellationToken cancellationToken = default); - /// - /// Removes the discount with the specified Id. - /// - /// /// The price rule object's Id. - /// The discount object's Id. - /// Cancellation Token - Task DeleteAsync(long priceRuleId, long discountCodeId, CancellationToken cancellationToken = default); - } + /// + /// Removes the discount with the specified Id. + /// + /// /// The price rule object's Id. + /// The discount object's Id. + /// Cancellation Token + Task DeleteAsync(long priceRuleId, long discountCodeId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/DraftOrder/DraftOrderService.cs b/ShopifySharp/Services/DraftOrder/DraftOrderService.cs index b1d89fc8..d4420df4 100644 --- a/ShopifySharp/Services/DraftOrder/DraftOrderService.cs +++ b/ShopifySharp/Services/DraftOrder/DraftOrderService.cs @@ -7,108 +7,107 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify draft orders. +/// +public class DraftOrderService : ShopifyService, IDraftOrderService { - /// - /// A service for manipulating Shopify draft orders. - /// - public class DraftOrderService : ShopifyService, IDraftOrderService - { - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public DraftOrderService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal DraftOrderService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public DraftOrderService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal DraftOrderService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CountAsync(DraftOrderCountFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync("draft_orders/count.json", "count", filter, cancellationToken); + /// + public virtual async Task CountAsync(DraftOrderCountFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync("draft_orders/count.json", "count", filter, cancellationToken); - /// - public virtual async Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("draft_orders.json", "draft_orders", filter, cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("draft_orders.json", "draft_orders", filter, cancellationToken); - /// - public virtual async Task> ListAsync(DraftOrderListFilter filter, CancellationToken cancellationToken = default) => - await ListAsync((ListFilter)filter, cancellationToken); + /// + public virtual async Task> ListAsync(DraftOrderListFilter filter, CancellationToken cancellationToken = default) => + await ListAsync((ListFilter)filter, cancellationToken); - /// - public virtual async Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"draft_orders/{id}.json", "draft_order", fields, cancellationToken); + /// + public virtual async Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"draft_orders/{id}.json", "draft_order", fields, cancellationToken); - /// - public virtual async Task CreateAsync(DraftOrder order, bool useCustomerDefaultAddress, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri("draft_orders.json"); - var body = order.ToDictionary(); + /// + public virtual async Task CreateAsync(DraftOrder order, bool useCustomerDefaultAddress, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("draft_orders.json"); + var body = order.ToDictionary(); - body.Add("use_customer_default_address", useCustomerDefaultAddress); + body.Add("use_customer_default_address", useCustomerDefaultAddress); - var content = new JsonContent(new - { - draft_order = body - }); + var content = new JsonContent(new + { + draft_order = body + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "draft_order"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "draft_order"); + return response.Result; + } - /// - public virtual async Task CreateAsync(DraftOrder order, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri("draft_orders.json"); - var content = new JsonContent(new - { - draft_order = order.ToDictionary() - }); - - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "draft_order"); - return response.Result; - } - - /// - public virtual async Task UpdateAsync(long id, DraftOrder order, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"draft_orders/{id}.json"); - var content = new JsonContent(new - { - draft_order = order.ToDictionary() - }); - - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "draft_order"); - return response.Result; - } - - /// - public virtual async Task DeleteAsync(long id, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(DraftOrder order, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("draft_orders.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"draft_orders/{id}.json"); + draft_order = order.ToDictionary() + }); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "draft_order"); + return response.Result; + } - /// - public virtual async Task CompleteAsync(long id, bool paymentPending = false, CancellationToken cancellationToken = default) + /// + public virtual async Task UpdateAsync(long id, DraftOrder order, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"draft_orders/{id}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"draft_orders/{id}/complete.json"); - req.QueryParams.Add("payment_pending", paymentPending); + draft_order = order.ToDictionary() + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, rootElement: "draft_order"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "draft_order"); + return response.Result; + } + + /// + public virtual async Task DeleteAsync(long id, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"draft_orders/{id}.json"); - /// - public virtual async Task SendInvoiceAsync(long id, DraftOrderInvoice customInvoice = null, CancellationToken cancellationToken = default) + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); + } + + /// + public virtual async Task CompleteAsync(long id, bool paymentPending = false, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"draft_orders/{id}/complete.json"); + req.QueryParams.Add("payment_pending", paymentPending); + + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, rootElement: "draft_order"); + return response.Result; + } + + /// + public virtual async Task SendInvoiceAsync(long id, DraftOrderInvoice customInvoice = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"draft_orders/{id}/send_invoice.json"); + // If the custom invoice is not null, use that as the body. Else use an empty dictionary object which will send the default invoice + var body = customInvoice?.ToDictionary() ?? new Dictionary(); + var content = new JsonContent(new { - var req = BuildRequestUri($"draft_orders/{id}/send_invoice.json"); - // If the custom invoice is not null, use that as the body. Else use an empty dictionary object which will send the default invoice - var body = customInvoice?.ToDictionary() ?? new Dictionary(); - var content = new JsonContent(new - { - draft_order_invoice = body - }); - - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "draft_order_invoice"); - return response.Result; - } + draft_order_invoice = body + }); + + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "draft_order_invoice"); + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/DraftOrder/IDraftOrderService.cs b/ShopifySharp/Services/DraftOrder/IDraftOrderService.cs index 4d2013dd..8182a2ad 100644 --- a/ShopifySharp/Services/DraftOrder/IDraftOrderService.cs +++ b/ShopifySharp/Services/DraftOrder/IDraftOrderService.cs @@ -3,78 +3,77 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IDraftOrderService : IShopifyService { - public interface IDraftOrderService : IShopifyService - { - /// - /// Retrieves a count of the shop's draft orders. - /// - /// Options for filtering the count. - /// Cancellation Token - Task CountAsync(DraftOrderCountFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Retrieves a count of the shop's draft orders. + /// + /// Options for filtering the count. + /// Cancellation Token + Task CountAsync(DraftOrderCountFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the shop's draft orders. - /// - Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's draft orders. + /// + Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the shop's draft orders. - /// - Task> ListAsync(DraftOrderListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's draft orders. + /// + Task> ListAsync(DraftOrderListFilter filter, CancellationToken cancellationToken = default); - /// - /// Retrieves the object with the given id. - /// - /// The id of the object to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the object with the given id. + /// + /// The id of the object to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default); - /// - /// Creates a new draft order. - /// - /// A new DraftOrder. Id should be set to null. - /// Optional boolean that you can send as part of a draft order object to load customer shipping information. - /// Cancellation Token - Task CreateAsync(DraftOrder order, bool useCustomerDefaultAddress, CancellationToken cancellationToken = default); + /// + /// Creates a new draft order. + /// + /// A new DraftOrder. Id should be set to null. + /// Optional boolean that you can send as part of a draft order object to load customer shipping information. + /// Cancellation Token + Task CreateAsync(DraftOrder order, bool useCustomerDefaultAddress, CancellationToken cancellationToken = default); - /// - /// Creates a new draft order. - /// - /// A new DraftOrder. Id should be set to null. - /// Cancellation Token - Task CreateAsync(DraftOrder order, CancellationToken cancellationToken = default); + /// + /// Creates a new draft order. + /// + /// A new DraftOrder. Id should be set to null. + /// Cancellation Token + Task CreateAsync(DraftOrder order, CancellationToken cancellationToken = default); - /// - /// Updates the draft order with the given id. - /// - /// The id of the item being updated. - /// The updated draft order. - /// Cancellation Token - Task UpdateAsync(long id, DraftOrder order, CancellationToken cancellationToken = default); + /// + /// Updates the draft order with the given id. + /// + /// The id of the item being updated. + /// The updated draft order. + /// Cancellation Token + Task UpdateAsync(long id, DraftOrder order, CancellationToken cancellationToken = default); - /// - /// Deletes the draft order with the given id. - /// - /// The id of the item being deleted. - /// Cancellation Token - Task DeleteAsync(long id, CancellationToken cancellationToken = default); + /// + /// Deletes the draft order with the given id. + /// + /// The id of the item being deleted. + /// Cancellation Token + Task DeleteAsync(long id, CancellationToken cancellationToken = default); - /// - /// Completes the draft order, transitioning it to a full order. - /// - /// The id of the item being completed. - /// A bool indicating whether payment is pending or not. True if payment is pending, false if payment is not pending and order has been paid. Defaults to false (payment not pending). - /// Cancellation Token - Task CompleteAsync(long id, bool paymentPending = false, CancellationToken cancellationToken = default); + /// + /// Completes the draft order, transitioning it to a full order. + /// + /// The id of the item being completed. + /// A bool indicating whether payment is pending or not. True if payment is pending, false if payment is not pending and order has been paid. Defaults to false (payment not pending). + /// Cancellation Token + Task CompleteAsync(long id, bool paymentPending = false, CancellationToken cancellationToken = default); - /// - /// Send an invoice for the draft order. - /// - /// The id of the item with the invoice. - /// Cancellation Token - Task SendInvoiceAsync(long id, DraftOrderInvoice customInvoice = null, CancellationToken cancellationToken = default); - } + /// + /// Send an invoice for the draft order. + /// + /// The id of the item with the invoice. + /// Cancellation Token + Task SendInvoiceAsync(long id, DraftOrderInvoice customInvoice = null, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Event/EventService.cs b/ShopifySharp/Services/Event/EventService.cs index ccc3d38f..a6bb6a0a 100644 --- a/ShopifySharp/Services/Event/EventService.cs +++ b/ShopifySharp/Services/Event/EventService.cs @@ -1,56 +1,55 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Lists; using System.Threading.Tasks; using System.Threading; using System; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for getting Shopify Events +/// Reference: https://help.shopify.com/api/reference/event +/// +public class EventService : ShopifyService, IEventService { /// - /// A service for getting Shopify Events - /// Reference: https://help.shopify.com/api/reference/event + /// Creates a new instance of . /// - public class EventService : ShopifyService, IEventService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public EventService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal EventService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public EventService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal EventService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CountAsync(EventCountFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync("events/count.json", "count", filter, cancellationToken: cancellationToken); + /// + public virtual async Task CountAsync(EventCountFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync("events/count.json", "count", filter, cancellationToken: cancellationToken); - /// - public virtual async Task GetAsync(long eventId, string fields = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"events/{eventId}.json", "event", fields, cancellationToken: cancellationToken); + /// + public virtual async Task GetAsync(long eventId, string fields = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"events/{eventId}.json", "event", fields, cancellationToken: cancellationToken); - /// - public virtual async Task> ListAsync(long subjectId, string subjectType, ListFilter filter = null, CancellationToken cancellationToken = default) + /// + public virtual async Task> ListAsync(long subjectId, string subjectType, ListFilter filter = null, CancellationToken cancellationToken = default) + { + // Ensure the subject type is plural + if (!subjectType.Substring(subjectType.Length - 1).Equals("s", StringComparison.OrdinalIgnoreCase)) { - // Ensure the subject type is plural - if (!subjectType.Substring(subjectType.Length - 1).Equals("s", StringComparison.OrdinalIgnoreCase)) - { - subjectType = subjectType + "s"; - } - - return await ExecuteGetListAsync($"{subjectType?.ToLower()}/{subjectId}/events.json", "events", filter, cancellationToken: cancellationToken); + subjectType = subjectType + "s"; } + + return await ExecuteGetListAsync($"{subjectType?.ToLower()}/{subjectId}/events.json", "events", filter, cancellationToken: cancellationToken); + } - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync($"events.json", "events", filter, cancellationToken: cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync($"events.json", "events", filter, cancellationToken: cancellationToken); - /// - public virtual async Task> ListAsync(long subjectId, string subjectType, EventListFilter filter, CancellationToken cancellationToken = default) => - await ListAsync(subjectId, subjectType, (ListFilter) filter, cancellationToken); + /// + public virtual async Task> ListAsync(long subjectId, string subjectType, EventListFilter filter, CancellationToken cancellationToken = default) => + await ListAsync(subjectId, subjectType, (ListFilter) filter, cancellationToken); - /// - public virtual async Task> ListAsync(EventListFilter filter = null, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); - } + /// + public virtual async Task> ListAsync(EventListFilter filter = null, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); } \ No newline at end of file diff --git a/ShopifySharp/Services/Event/IEventService.cs b/ShopifySharp/Services/Event/IEventService.cs index 4ced0e98..c6470652 100644 --- a/ShopifySharp/Services/Event/IEventService.cs +++ b/ShopifySharp/Services/Event/IEventService.cs @@ -3,50 +3,49 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IEventService : IShopifyService { - public interface IEventService : IShopifyService - { - /// - /// Gets a count of all site events. - /// - /// Options for filtering the result. - /// Cancellation Token - Task CountAsync(EventCountFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a count of all site events. + /// + /// Options for filtering the result. + /// Cancellation Token + Task CountAsync(EventCountFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the event to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long eventId, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the event to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long eventId, string fields = null, CancellationToken cancellationToken = default); - /// - /// Returns a list of events for the given subject and subject type. A full list of supported subject types can be found at https://help.shopify.com/api/reference/event - /// - /// Restricts results to just one subject item, e.g. all changes on a product. - /// The subject's type, e.g. 'Order' or 'Product'. Known subject types are 'Articles', 'Blogs', 'Custom_Collections', 'Comments', 'Orders', 'Pages', 'Products' and 'Smart_Collections'. A current list of subject types can be found at https://help.shopify.com/api/reference/event - /// Cancellation Token - Task> ListAsync(long subjectId, string subjectType, ListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Returns a list of events for the given subject and subject type. A full list of supported subject types can be found at https://help.shopify.com/api/reference/event + /// + /// Restricts results to just one subject item, e.g. all changes on a product. + /// The subject's type, e.g. 'Order' or 'Product'. Known subject types are 'Articles', 'Blogs', 'Custom_Collections', 'Comments', 'Orders', 'Pages', 'Products' and 'Smart_Collections'. A current list of subject types can be found at https://help.shopify.com/api/reference/event + /// Cancellation Token + Task> ListAsync(long subjectId, string subjectType, ListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Returns a list of events. - /// - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + /// + /// Returns a list of events. + /// + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - /// - /// Returns a list of events for the given subject and subject type. A full list of supported subject types can be found at https://help.shopify.com/api/reference/event - /// - /// Restricts results to just one subject item, e.g. all changes on a product. - /// The subject's type, e.g. 'Order' or 'Product'. Known subject types are 'Articles', 'Blogs', 'Custom_Collections', 'Comments', 'Orders', 'Pages', 'Products' and 'Smart_Collections'. A current list of subject types can be found at https://help.shopify.com/api/reference/event - /// Cancellation Token - Task> ListAsync(long subjectId, string subjectType, EventListFilter filter, CancellationToken cancellationToken = default); + /// + /// Returns a list of events for the given subject and subject type. A full list of supported subject types can be found at https://help.shopify.com/api/reference/event + /// + /// Restricts results to just one subject item, e.g. all changes on a product. + /// The subject's type, e.g. 'Order' or 'Product'. Known subject types are 'Articles', 'Blogs', 'Custom_Collections', 'Comments', 'Orders', 'Pages', 'Products' and 'Smart_Collections'. A current list of subject types can be found at https://help.shopify.com/api/reference/event + /// Cancellation Token + Task> ListAsync(long subjectId, string subjectType, EventListFilter filter, CancellationToken cancellationToken = default); - /// - /// Returns a list of events. - /// - Task> ListAsync(EventListFilter filter = null, CancellationToken cancellationToken = default); - } + /// + /// Returns a list of events. + /// + Task> ListAsync(EventListFilter filter = null, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Fulfillment/FulfillmentService.cs b/ShopifySharp/Services/Fulfillment/FulfillmentService.cs index 202e59f6..1bc16c16 100644 --- a/ShopifySharp/Services/Fulfillment/FulfillmentService.cs +++ b/ShopifySharp/Services/Fulfillment/FulfillmentService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Net.Http; @@ -6,77 +6,76 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify fulfillments. +/// +public class FulfillmentService : ShopifyService, IFulfillmentService { /// - /// A service for manipulating Shopify fulfillments. + /// Creates a new instance of . /// - public class FulfillmentService : ShopifyService, IFulfillmentService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public FulfillmentService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal FulfillmentService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public FulfillmentService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal FulfillmentService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CountAsync(long orderId, FulfillmentCountFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"orders/{orderId}/fulfillments/count.json", "count", filter, cancellationToken); + /// + public virtual async Task CountAsync(long orderId, FulfillmentCountFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"orders/{orderId}/fulfillments/count.json", "count", filter, cancellationToken); - /// - public virtual async Task> ListAsync(long orderId, ListFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync($"orders/{orderId}/fulfillments.json", "fulfillments", filter, cancellationToken); + /// + public virtual async Task> ListAsync(long orderId, ListFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync($"orders/{orderId}/fulfillments.json", "fulfillments", filter, cancellationToken); - /// - public virtual async Task> ListAsync(long orderId, FulfillmentListFilter filter, CancellationToken cancellationToken = default) => - await ListAsync(orderId, filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListAsync(long orderId, FulfillmentListFilter filter, CancellationToken cancellationToken = default) => + await ListAsync(orderId, filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task> ListForFulfillmentOrderAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync($"fulfillment_orders/{fulfillmentOrderId}/fulfillments.json", "fulfillments", ListFilter.Empty, cancellationToken); + /// + public virtual async Task> ListForFulfillmentOrderAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync($"fulfillment_orders/{fulfillmentOrderId}/fulfillments.json", "fulfillments", ListFilter.Empty, cancellationToken); - /// - public virtual async Task GetAsync(long orderId, long fulfillmentId, string fields = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"orders/{orderId}/fulfillments/{fulfillmentId}.json", "fulfillment", fields, cancellationToken); + /// + public virtual async Task GetAsync(long orderId, long fulfillmentId, string fields = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"orders/{orderId}/fulfillments/{fulfillmentId}.json", "fulfillment", fields, cancellationToken); - /// - public virtual async Task CreateAsync(FulfillmentShipping fulfillment, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"fulfillments.json"); - var body = fulfillment.ToDictionary(); + /// + public virtual async Task CreateAsync(FulfillmentShipping fulfillment, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"fulfillments.json"); + var body = fulfillment.ToDictionary(); - var content = new JsonContent(new - { - fulfillment = body - }); + var content = new JsonContent(new + { + fulfillment = body + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment"); + return response.Result; + } - /// - public virtual async Task UpdateTrackingAsync(long fulfillmentId, FulfillmentShipping fulfillment, CancellationToken cancellationToken = default) + /// + public virtual async Task UpdateTrackingAsync(long fulfillmentId, FulfillmentShipping fulfillment, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"fulfillments/{fulfillmentId}/update_tracking.json"); + var body = fulfillment.ToDictionary(); + var content = new JsonContent(new { - var req = BuildRequestUri($"fulfillments/{fulfillmentId}/update_tracking.json"); - var body = fulfillment.ToDictionary(); - var content = new JsonContent(new - { - fulfillment = body - }); + fulfillment = body + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment"); + return response.Result; + } - /// - public virtual async Task CancelAsync(long fulfillmentId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"fulfillments/{fulfillmentId}/cancel.json"); + /// + public virtual async Task CancelAsync(long fulfillmentId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"fulfillments/{fulfillmentId}/cancel.json"); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "fulfillment"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "fulfillment"); + return response.Result; } -} +} \ No newline at end of file diff --git a/ShopifySharp/Services/Fulfillment/IFulfillmentService.cs b/ShopifySharp/Services/Fulfillment/IFulfillmentService.cs index bf12aee8..a8d6c760 100644 --- a/ShopifySharp/Services/Fulfillment/IFulfillmentService.cs +++ b/ShopifySharp/Services/Fulfillment/IFulfillmentService.cs @@ -3,74 +3,73 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IFulfillmentService : IShopifyService { - public interface IFulfillmentService : IShopifyService - { - /// - /// Gets a count of all of the order's fulfillments. - /// - /// The order id to which the fulfillments belong. - /// Options for filtering the count. - /// Cancellation Token - /// The count of all fulfillments for the shop. - Task CountAsync(long orderId, FulfillmentCountFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a count of all of the order's fulfillments. + /// + /// The order id to which the fulfillments belong. + /// Options for filtering the count. + /// Cancellation Token + /// The count of all fulfillments for the shop. + Task CountAsync(long orderId, FulfillmentCountFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the order's fulfillments. - /// - /// The order id to which the fulfillments belong. - /// Options for filtering the list. - /// Cancellation Token - Task> ListAsync(long orderId, ListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the order's fulfillments. + /// + /// The order id to which the fulfillments belong. + /// Options for filtering the list. + /// Cancellation Token + Task> ListAsync(long orderId, ListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the order's fulfillments. - /// - /// The order id to which the fulfillments belong. - /// Options for filtering the list. - /// Cancellation Token - Task> ListAsync(long orderId, FulfillmentListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the order's fulfillments. + /// + /// The order id to which the fulfillments belong. + /// Options for filtering the list. + /// Cancellation Token + Task> ListAsync(long orderId, FulfillmentListFilter filter, CancellationToken cancellationToken = default); - /// - /// Gets a list of the fulfillment order's fulfillments. - /// - /// The fulfillment order id to which the fulfillments belong. - /// Cancellation Token - Task> ListForFulfillmentOrderAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default); + /// + /// Gets a list of the fulfillment order's fulfillments. + /// + /// The fulfillment order id to which the fulfillments belong. + /// Cancellation Token + Task> ListForFulfillmentOrderAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The order id to which the fulfillments belong. - /// The id of the Fulfillment to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long orderId, long fulfillmentId, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The order id to which the fulfillments belong. + /// The id of the Fulfillment to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long orderId, long fulfillmentId, string fields = null, CancellationToken cancellationToken = default); - /// - /// Creates a fulfillment for one or many fulfillment orders. - /// - /// An object containing fulfillment order and tracking data. - /// Cancellation Token - /// The new . - Task CreateAsync(FulfillmentShipping fulfillment, CancellationToken cancellationToken = default); + /// + /// Creates a fulfillment for one or many fulfillment orders. + /// + /// An object containing fulfillment order and tracking data. + /// Cancellation Token + /// The new . + Task CreateAsync(FulfillmentShipping fulfillment, CancellationToken cancellationToken = default); - /// - /// Updates tracking for the given . - /// - /// Id of the object being updated. - /// The to update. - /// Cancellation Token - /// The updated . - Task UpdateTrackingAsync(long fulfillmentId, FulfillmentShipping fulfillment, CancellationToken cancellationToken = default); + /// + /// Updates tracking for the given . + /// + /// Id of the object being updated. + /// The to update. + /// Cancellation Token + /// The updated . + Task UpdateTrackingAsync(long fulfillmentId, FulfillmentShipping fulfillment, CancellationToken cancellationToken = default); - /// - /// Cancels a pending fulfillment with the given id. - /// - /// The fulfillment's id. - /// Cancellation Token - Task CancelAsync(long fulfillmentId, CancellationToken cancellationToken = default); - } + /// + /// Cancels a pending fulfillment with the given id. + /// + /// The fulfillment's id. + /// Cancellation Token + Task CancelAsync(long fulfillmentId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/FulfillmentEvent/FulfillmentEventService.cs b/ShopifySharp/Services/FulfillmentEvent/FulfillmentEventService.cs index d7a0a282..7b478727 100644 --- a/ShopifySharp/Services/FulfillmentEvent/FulfillmentEventService.cs +++ b/ShopifySharp/Services/FulfillmentEvent/FulfillmentEventService.cs @@ -1,53 +1,52 @@ -using ShopifySharp.Infrastructure; +using ShopifySharp.Infrastructure; using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify fulfillment events. +/// +public class FulfillmentEventService : ShopifyService, IFulfillmentEventService { /// - /// A service for manipulating Shopify fulfillment events. + /// Creates a new instance of . /// - public class FulfillmentEventService : ShopifyService, IFulfillmentEventService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public FulfillmentEventService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal FulfillmentEventService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public FulfillmentEventService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal FulfillmentEventService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(long orderId, long fulfillmentId, CancellationToken cancellationToken = default) => - await ExecuteGetAsync>($"orders/{orderId}/fulfillments/{fulfillmentId}/events.json", "fulfillment_events", cancellationToken: cancellationToken); + /// + public virtual async Task> ListAsync(long orderId, long fulfillmentId, CancellationToken cancellationToken = default) => + await ExecuteGetAsync>($"orders/{orderId}/fulfillments/{fulfillmentId}/events.json", "fulfillment_events", cancellationToken: cancellationToken); - /// - public virtual async Task GetAsync(long orderId, long fulfillmentId, long fulfillmentEventId, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"orders/{orderId}/fulfillments/{fulfillmentId}/events/{fulfillmentEventId}.json", "fulfillment_event", cancellationToken: cancellationToken); + /// + public virtual async Task GetAsync(long orderId, long fulfillmentId, long fulfillmentEventId, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"orders/{orderId}/fulfillments/{fulfillmentId}/events/{fulfillmentEventId}.json", "fulfillment_event", cancellationToken: cancellationToken); - /// - public virtual async Task CreateAsync(long orderId, long fulfillmentId, FulfillmentEvent @event, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"orders/{orderId}/fulfillments/{fulfillmentId}/events.json"); + /// + public virtual async Task CreateAsync(long orderId, long fulfillmentId, FulfillmentEvent @event, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"orders/{orderId}/fulfillments/{fulfillmentId}/events.json"); - var content = new JsonContent(new - { - @event - }); + var content = new JsonContent(new + { + @event + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment_event"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment_event"); + return response.Result; + } - /// - public virtual async Task DeleteAsync(long orderId, long fulfillmentId, long fulfillmentEventId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"orders/{orderId}/fulfillments/{fulfillmentId}/events/{fulfillmentEventId}.json"); + /// + public virtual async Task DeleteAsync(long orderId, long fulfillmentId, long fulfillmentEventId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"orders/{orderId}/fulfillments/{fulfillmentId}/events/{fulfillmentEventId}.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); } } \ No newline at end of file diff --git a/ShopifySharp/Services/FulfillmentEvent/IFulfillmentEventService.cs b/ShopifySharp/Services/FulfillmentEvent/IFulfillmentEventService.cs index 359ca12b..177eff4a 100644 --- a/ShopifySharp/Services/FulfillmentEvent/IFulfillmentEventService.cs +++ b/ShopifySharp/Services/FulfillmentEvent/IFulfillmentEventService.cs @@ -2,46 +2,45 @@ using System.Threading; using System.Threading.Tasks; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IFulfillmentEventService : IShopifyService { - public interface IFulfillmentEventService : IShopifyService - { - /// - /// Get a list of all fulfillment events for a fulfillment - /// - /// The order id to which the fulfillment belongs to. - /// The fulfillment id to which the fulfillment events belong to. - /// Cancellation Token - /// The list of fulfillment events for the given fulfillment. - Task> ListAsync(long orderId, long fulfillmentId, CancellationToken cancellationToken = default); + /// + /// Get a list of all fulfillment events for a fulfillment + /// + /// The order id to which the fulfillment belongs to. + /// The fulfillment id to which the fulfillment events belong to. + /// Cancellation Token + /// The list of fulfillment events for the given fulfillment. + Task> ListAsync(long orderId, long fulfillmentId, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The order id to which the fulfillment belongs to. - /// The id of the fulfillment to which the event belongs to. - /// The id of the fulfillment event to retrieve. - /// Cancellation Token - /// The . - Task GetAsync(long orderId, long fulfillmentId, long fulfillmentEventId, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The order id to which the fulfillment belongs to. + /// The id of the fulfillment to which the event belongs to. + /// The id of the fulfillment event to retrieve. + /// Cancellation Token + /// The . + Task GetAsync(long orderId, long fulfillmentId, long fulfillmentEventId, CancellationToken cancellationToken = default); - /// - /// Creates a new on the fulfillment. - /// - /// The order id to which the fulfillment belongs to. - /// The id of the fulfillment to which the event belongs to. - /// A new . Id should be set to null. - /// Cancellation Token - /// The new . - Task CreateAsync(long orderId, long fulfillmentId, FulfillmentEvent @event, CancellationToken cancellationToken = default); + /// + /// Creates a new on the fulfillment. + /// + /// The order id to which the fulfillment belongs to. + /// The id of the fulfillment to which the event belongs to. + /// A new . Id should be set to null. + /// Cancellation Token + /// The new . + Task CreateAsync(long orderId, long fulfillmentId, FulfillmentEvent @event, CancellationToken cancellationToken = default); - /// - /// Deletes the with the given Id. - /// - /// The order id to which the fulfillment belongs to. - /// The id of the fulfillment to which the event belongs to. - /// The id of the fulfillment event to retrieve. - /// Cancellation Token - Task DeleteAsync(long orderId, long fulfillmentId, long fulfillmentEventId, CancellationToken cancellationToken = default); - } + /// + /// Deletes the with the given Id. + /// + /// The order id to which the fulfillment belongs to. + /// The id of the fulfillment to which the event belongs to. + /// The id of the fulfillment event to retrieve. + /// Cancellation Token + Task DeleteAsync(long orderId, long fulfillmentId, long fulfillmentEventId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/FulfillmentOrders/FulfillmentOrderService.cs b/ShopifySharp/Services/FulfillmentOrders/FulfillmentOrderService.cs index 338ddfcc..2cee4f09 100644 --- a/ShopifySharp/Services/FulfillmentOrders/FulfillmentOrderService.cs +++ b/ShopifySharp/Services/FulfillmentOrders/FulfillmentOrderService.cs @@ -6,135 +6,134 @@ using System; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify fulfillment orders. +/// +public class FulfillmentOrderService : ShopifyService, IFulfillmentOrderService { /// - /// A service for manipulating Shopify fulfillment orders. + /// Creates a new instance of . /// - public class FulfillmentOrderService : ShopifyService, IFulfillmentOrderService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public FulfillmentOrderService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal FulfillmentOrderService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public FulfillmentOrderService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal FulfillmentOrderService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CancelAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/cancel.json"); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "fulfillment_order"); + /// + public virtual async Task CancelAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/cancel.json"); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "fulfillment_order"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task CloseAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default) + /// + public virtual async Task CloseAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default) + { + var body = new { - var body = new - { - message = message, - }.ToDictionary(); - var content = new JsonContent(new - { - fulfillment_order = body, - }); - - var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/close.json"); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, rootElement: "fulfillment_order"); - - return response.Result; - } - - /// - public virtual async Task HoldAsync(long fulfillmentOrderId, FulfillmentHold fulfillmentHold, CancellationToken cancellationToken = default) + message = message, + }.ToDictionary(); + var content = new JsonContent(new { - var body = fulfillmentHold.ToDictionary(); - var content = new JsonContent(new - { - fulfillment_hold = body, - }); + fulfillment_order = body, + }); - var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/hold.json"); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, rootElement: "fulfillment_order"); + var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/close.json"); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, rootElement: "fulfillment_order"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task MoveAsync(long fulfillmentOrderId, long newLocationId, CancellationToken cancellationToken = default) + /// + public virtual async Task HoldAsync(long fulfillmentOrderId, FulfillmentHold fulfillmentHold, CancellationToken cancellationToken = default) + { + var body = fulfillmentHold.ToDictionary(); + var content = new JsonContent(new { - var body = new - { - new_location_id = newLocationId, - }.ToDictionary(); - var content = new JsonContent(new - { - fulfillment_order = body, - }); + fulfillment_hold = body, + }); - var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/move.json"); + var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/hold.json"); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, rootElement: "fulfillment_order"); - //needs to be original_fulfillment_order - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content); - - return response.Result; - } + return response.Result; + } - /// - public virtual async Task OpenAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default) + /// + public virtual async Task MoveAsync(long fulfillmentOrderId, long newLocationId, CancellationToken cancellationToken = default) + { + var body = new + { + new_location_id = newLocationId, + }.ToDictionary(); + var content = new JsonContent(new { - var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/open.json"); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "fulfillment_order"); + fulfillment_order = body, + }); - return response.Result; - } + var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/move.json"); - /// - public virtual async Task ReleaseHoldAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/release_hold.json"); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "fulfillment_order"); + //needs to be original_fulfillment_order + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content); + + return response.Result; + } - return response.Result; - } + /// + public virtual async Task OpenAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/open.json"); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "fulfillment_order"); - /// - public virtual async Task RescheduleAsync(long fulfillmentOrderId, DateTimeOffset newFulfillAt, CancellationToken cancellationToken = default) + return response.Result; + } + + /// + public virtual async Task ReleaseHoldAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/release_hold.json"); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "fulfillment_order"); + + return response.Result; + } + + /// + public virtual async Task RescheduleAsync(long fulfillmentOrderId, DateTimeOffset newFulfillAt, CancellationToken cancellationToken = default) + { + var body = new { - var body = new - { - new_fulfill_at = newFulfillAt, - }.ToDictionary(); - var content = new JsonContent(new - { - fulfillment_order = body, - }); - - var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/reschedule.json"); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, rootElement: "fulfillment_order"); - - return response.Result; - } - - /// - public virtual async Task GetAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default) + new_fulfill_at = newFulfillAt, + }.ToDictionary(); + var content = new JsonContent(new { - var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}.json"); - var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "fulfillment_order"); + fulfillment_order = body, + }); - return response.Result; - } + var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/reschedule.json"); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, rootElement: "fulfillment_order"); - /// - public virtual async Task> ListAsync(long orderId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"orders/{orderId}/fulfillment_orders.json"); - var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "fulfillment_orders"); + return response.Result; + } + + /// + public virtual async Task GetAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}.json"); + var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "fulfillment_order"); + + return response.Result; + } + + /// + public virtual async Task> ListAsync(long orderId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"orders/{orderId}/fulfillment_orders.json"); + var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "fulfillment_orders"); - return response.Result; - } + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/FulfillmentOrders/IFulfillmentOrderService.cs b/ShopifySharp/Services/FulfillmentOrders/IFulfillmentOrderService.cs index 9ce483d1..c1291784 100644 --- a/ShopifySharp/Services/FulfillmentOrders/IFulfillmentOrderService.cs +++ b/ShopifySharp/Services/FulfillmentOrders/IFulfillmentOrderService.cs @@ -3,75 +3,74 @@ using System.Threading; using System.Threading.Tasks; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IFulfillmentOrderService : IShopifyService { - public interface IFulfillmentOrderService : IShopifyService - { - /// - /// Cancel a fulfillment order with the given id. - /// - /// The fulfillment order to which the fulfillment orders belong. - /// Cancellation Token - Task CancelAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default); + /// + /// Cancel a fulfillment order with the given id. + /// + /// The fulfillment order to which the fulfillment orders belong. + /// Cancellation Token + Task CancelAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default); - /// - /// Marks an in progress fulfillment order as incomplete, indicating the fulfillment service is unable to ship any remaining items and intends to close the fulfillment order. - /// - /// The fulfillment order id. - /// Close reason. - /// Cancellation Token - Task CloseAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default); + /// + /// Marks an in progress fulfillment order as incomplete, indicating the fulfillment service is unable to ship any remaining items and intends to close the fulfillment order. + /// + /// The fulfillment order id. + /// Close reason. + /// Cancellation Token + Task CloseAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default); - /// - /// Halts all fulfillment work on a fulfillment order with status OPEN and changes the status of the fulfillment order to ON_HOLD. - /// - /// The fulfillment order id. - /// The fulfillment hold. - /// Cancellation Token - Task HoldAsync(long fulfillmentOrderId, FulfillmentHold fulfillmentHold, CancellationToken cancellationToken = default); + /// + /// Halts all fulfillment work on a fulfillment order with status OPEN and changes the status of the fulfillment order to ON_HOLD. + /// + /// The fulfillment order id. + /// The fulfillment hold. + /// Cancellation Token + Task HoldAsync(long fulfillmentOrderId, FulfillmentHold fulfillmentHold, CancellationToken cancellationToken = default); - /// - /// Moves a fulfillment order from one merchant managed location to another merchant managed location. - /// - /// The fulfillment order id. - /// The new fulfillment order location. - /// Cancellation Token - Task MoveAsync(long fulfillmentOrderId, long newLocationId, CancellationToken cancellationToken = default); + /// + /// Moves a fulfillment order from one merchant managed location to another merchant managed location. + /// + /// The fulfillment order id. + /// The new fulfillment order location. + /// Cancellation Token + Task MoveAsync(long fulfillmentOrderId, long newLocationId, CancellationToken cancellationToken = default); - /// - /// Marks a scheduled fulfillment order as ready for fulfillment. - /// - /// The fulfillment order to which the fulfillment orders belong. - /// Cancellation Token - Task OpenAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default); + /// + /// Marks a scheduled fulfillment order as ready for fulfillment. + /// + /// The fulfillment order to which the fulfillment orders belong. + /// Cancellation Token + Task OpenAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default); - /// - /// Release the fulfillment hold on a fulfillment order and changes the status of the fulfillment order to OPEN or SCHEDULED - /// - /// The fulfillment order to which the fulfillment orders belong. - /// Cancellation Token - Task ReleaseHoldAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default); + /// + /// Release the fulfillment hold on a fulfillment order and changes the status of the fulfillment order to OPEN or SCHEDULED + /// + /// The fulfillment order to which the fulfillment orders belong. + /// Cancellation Token + Task ReleaseHoldAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default); - /// - /// Updates the fulfill_at time of a scheduled fulfillment order. This endpoint is used to manage the time a scheduled fulfillment order will be marked as ready for fulfillment. - /// - /// The fulfillment order id. - /// The new fulfill date. - /// Cancellation Token - Task RescheduleAsync(long fulfillmentOrderId, DateTimeOffset newFulfillAt, CancellationToken cancellationToken = default); + /// + /// Updates the fulfill_at time of a scheduled fulfillment order. This endpoint is used to manage the time a scheduled fulfillment order will be marked as ready for fulfillment. + /// + /// The fulfillment order id. + /// The new fulfill date. + /// Cancellation Token + Task RescheduleAsync(long fulfillmentOrderId, DateTimeOffset newFulfillAt, CancellationToken cancellationToken = default); - /// - /// Gets a fulfillment order with the given id. - /// - /// The fulfillment order to which the fulfillment orders belong. - /// Cancellation Token - Task GetAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default); + /// + /// Gets a fulfillment order with the given id. + /// + /// The fulfillment order to which the fulfillment orders belong. + /// Cancellation Token + Task GetAsync(long fulfillmentOrderId, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the order's fulfillment orders. - /// - /// The order id to which the fulfillment orders belong. - /// Cancellation Token - Task> ListAsync(long orderId, CancellationToken cancellationToken = default); - } + /// + /// Gets a list of up to 250 of the order's fulfillment orders. + /// + /// The order id to which the fulfillment orders belong. + /// Cancellation Token + Task> ListAsync(long orderId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/FulfillmentRequest/FulfillmentRequestService.cs b/ShopifySharp/Services/FulfillmentRequest/FulfillmentRequestService.cs index 514454de..5611005d 100644 --- a/ShopifySharp/Services/FulfillmentRequest/FulfillmentRequestService.cs +++ b/ShopifySharp/Services/FulfillmentRequest/FulfillmentRequestService.cs @@ -1,69 +1,68 @@ -using ShopifySharp.Infrastructure; +using ShopifySharp.Infrastructure; using System.Net.Http; using System.Threading.Tasks; using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// The FulfillmentRequest resource represents a fulfillment request made by the merchant to a fulfillment service for a fulfillment order. +/// +public class FulfillmentRequestService : ShopifyService, IFulfillmentRequestService { /// - /// The FulfillmentRequest resource represents a fulfillment request made by the merchant to a fulfillment service for a fulfillment order. + /// Creates a new instance of . /// - public class FulfillmentRequestService : ShopifyService, IFulfillmentRequestService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public FulfillmentRequestService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal FulfillmentRequestService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public FulfillmentRequestService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal FulfillmentRequestService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CreateAsync(long fulfillmentOrderId, FulfillmentRequest fulfillmentRequest, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(long fulfillmentOrderId, FulfillmentRequest fulfillmentRequest, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($@"fulfillment_orders/{fulfillmentOrderId}/fulfillment_request.json"); + var body = fulfillmentRequest.ToDictionary(); + + var content = new JsonContent(new { - var req = BuildRequestUri($@"fulfillment_orders/{fulfillmentOrderId}/fulfillment_request.json"); - var body = fulfillmentRequest.ToDictionary(); + fulfillment_request = body + }); - var content = new JsonContent(new - { - fulfillment_request = body - }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "original_fulfillment_order"); + return response.Result; + } - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "original_fulfillment_order"); - return response.Result; - } + /// + public virtual async Task AcceptAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/fulfillment_request/accept.json"); + var fulfillmentRequest = new FulfillmentRequest { Message = message }; + var body = fulfillmentRequest.ToDictionary(); - /// - public virtual async Task AcceptAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default) + var content = new JsonContent(new { - var req = BuildRequestUri($"fulfillment_orders/{fulfillmentOrderId}/fulfillment_request/accept.json"); - var fulfillmentRequest = new FulfillmentRequest { Message = message }; - var body = fulfillmentRequest.ToDictionary(); + fulfillment_request = body + }); - var content = new JsonContent(new - { - fulfillment_request = body - }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment_order"); + return response.Result; + } - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment_order"); - return response.Result; - } + /// + public virtual async Task RejectAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($@"fulfillment_orders/{fulfillmentOrderId}/fulfillment_request/reject.json"); + var fulfillmentRequest = new FulfillmentRequest { Message = message }; + var body = fulfillmentRequest.ToDictionary(); - /// - public virtual async Task RejectAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default) + var content = new JsonContent(new { - var req = BuildRequestUri($@"fulfillment_orders/{fulfillmentOrderId}/fulfillment_request/reject.json"); - var fulfillmentRequest = new FulfillmentRequest { Message = message }; - var body = fulfillmentRequest.ToDictionary(); - - var content = new JsonContent(new - { - fulfillment_request = body - }); + fulfillment_request = body + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment_order"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment_order"); + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/FulfillmentRequest/IFulfillmentRequestService.cs b/ShopifySharp/Services/FulfillmentRequest/IFulfillmentRequestService.cs index bb34d1fa..10799df9 100644 --- a/ShopifySharp/Services/FulfillmentRequest/IFulfillmentRequestService.cs +++ b/ShopifySharp/Services/FulfillmentRequest/IFulfillmentRequestService.cs @@ -1,42 +1,41 @@ -using System.Threading; +using System.Threading; using System.Threading.Tasks; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// The FulfillmentRequest resource represents a fulfillment request made by the merchant to a fulfillment service for a fulfillment order. +/// API Reference +/// +public interface IFulfillmentRequestService : IShopifyService { /// - /// The FulfillmentRequest resource represents a fulfillment request made by the merchant to a fulfillment service for a fulfillment order. - /// API Reference + /// Accepts a fulfillment request sent to a fulfillment service for a fulfillment order. + /// API Reference /// - public interface IFulfillmentRequestService : IShopifyService - { - /// - /// Accepts a fulfillment request sent to a fulfillment service for a fulfillment order. - /// API Reference - /// - /// - /// An optional reason for accepting the fulfillment request - /// Cancellation Token - /// - Task AcceptAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default); + /// + /// An optional reason for accepting the fulfillment request + /// Cancellation Token + /// + Task AcceptAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default); - /// - /// Sends a fulfillment request to the fulfillment service of a fulfillment order. - /// API Reference - /// - /// - /// A new . - /// Cancellation Token - /// - Task CreateAsync(long fulfillmentOrderId, FulfillmentRequest fulfillmentRequest, CancellationToken cancellationToken = default); + /// + /// Sends a fulfillment request to the fulfillment service of a fulfillment order. + /// API Reference + /// + /// + /// A new . + /// Cancellation Token + /// + Task CreateAsync(long fulfillmentOrderId, FulfillmentRequest fulfillmentRequest, CancellationToken cancellationToken = default); - /// - /// Rejects a fulfillment request sent to a fulfillment service for a fulfillment order. - /// API Reference - /// - /// - /// An optional reason for accepting the fulfillment request - /// Cancellation Token - /// - Task RejectAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default); - } + /// + /// Rejects a fulfillment request sent to a fulfillment service for a fulfillment order. + /// API Reference + /// + /// + /// An optional reason for accepting the fulfillment request + /// Cancellation Token + /// + Task RejectAsync(long fulfillmentOrderId, string message, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/FulfillmentService/FulfillmentServiceService.cs b/ShopifySharp/Services/FulfillmentService/FulfillmentServiceService.cs index a9b4bffe..6d7b1625 100644 --- a/ShopifySharp/Services/FulfillmentService/FulfillmentServiceService.cs +++ b/ShopifySharp/Services/FulfillmentService/FulfillmentServiceService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using System.Collections.Generic; using System.Net.Http; @@ -6,62 +6,61 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify fulfillments. +/// +public class FulfillmentServiceService : ShopifyService, IFulfillmentServiceService { - /// - /// A service for manipulating Shopify fulfillments. - /// - public class FulfillmentServiceService : ShopifyService, IFulfillmentServiceService - { - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public FulfillmentServiceService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal FulfillmentServiceService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public FulfillmentServiceService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal FulfillmentServiceService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(FulfillmentServiceListFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync>("fulfillment_services.json", "fulfillment_services", filter, cancellationToken); + /// + public virtual async Task> ListAsync(FulfillmentServiceListFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync>("fulfillment_services.json", "fulfillment_services", filter, cancellationToken); - /// - public virtual async Task GetAsync(long fulfillmentServiceId, string fields = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"fulfillment_services/{fulfillmentServiceId}.json", "fulfillment_service", fields, cancellationToken); + /// + public virtual async Task GetAsync(long fulfillmentServiceId, string fields = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"fulfillment_services/{fulfillmentServiceId}.json", "fulfillment_service", fields, cancellationToken); - /// - public virtual async Task CreateAsync(FulfillmentServiceEntity fulfillmentServiceEntity, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(FulfillmentServiceEntity fulfillmentServiceEntity, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"fulfillment_services.json"); + var body = fulfillmentServiceEntity.ToDictionary(); + + var content = new JsonContent(new { - var req = BuildRequestUri($"fulfillment_services.json"); - var body = fulfillmentServiceEntity.ToDictionary(); + fulfillment_service = body + }); - var content = new JsonContent(new - { - fulfillment_service = body - }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment_service"); + return response.Result; + } - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "fulfillment_service"); - return response.Result; - } + /// + public virtual async Task UpdateAsync(long fulfillmentServiceId, FulfillmentServiceEntity fulfillmentServiceEntity, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"fulfillment_services/{fulfillmentServiceId}.json"); + var body = fulfillmentServiceEntity.ToDictionary(); - /// - public virtual async Task UpdateAsync(long fulfillmentServiceId, FulfillmentServiceEntity fulfillmentServiceEntity, CancellationToken cancellationToken = default) + var content = new JsonContent(new { - var req = BuildRequestUri($"fulfillment_services/{fulfillmentServiceId}.json"); - var body = fulfillmentServiceEntity.ToDictionary(); - - var content = new JsonContent(new - { - fulfillment_service = body - }); + fulfillment_service = body + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "fulfillment_service"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "fulfillment_service"); + return response.Result; + } - /// - public virtual async Task DeleteAsync(long fulfillmentServiceId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"fulfillment_services/{fulfillmentServiceId}.json"); + /// + public virtual async Task DeleteAsync(long fulfillmentServiceId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"fulfillment_services/{fulfillmentServiceId}.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); } } \ No newline at end of file diff --git a/ShopifySharp/Services/FulfillmentService/IFulfillmentServiceService.cs b/ShopifySharp/Services/FulfillmentService/IFulfillmentServiceService.cs index 4ddb71d6..8cd7f77c 100644 --- a/ShopifySharp/Services/FulfillmentService/IFulfillmentServiceService.cs +++ b/ShopifySharp/Services/FulfillmentService/IFulfillmentServiceService.cs @@ -3,49 +3,48 @@ using System.Threading.Tasks; using ShopifySharp.Filters; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IFulfillmentServiceService : IShopifyService { - public interface IFulfillmentServiceService : IShopifyService - { - /// - /// Gets a list of your app's FulfillmentServices. - /// - /// Set scope to all to retrieve all of the store's fulfillment services - /// Cancellation Token - /// The list of fulfillment services matching the filter. - Task> ListAsync(FulfillmentServiceListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of your app's FulfillmentServices. + /// + /// Set scope to all to retrieve all of the store's fulfillment services + /// Cancellation Token + /// The list of fulfillment services matching the filter. + Task> ListAsync(FulfillmentServiceListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The if of the fulfillment service. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long fulfillmentServiceId, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The if of the fulfillment service. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long fulfillmentServiceId, string fields = null, CancellationToken cancellationToken = default); - /// - /// Creates a new . - /// - /// A new . Id should be set to null. - /// Cancellation Token - /// The new . - Task CreateAsync(FulfillmentServiceEntity fulfillmentServiceEntity, CancellationToken cancellationToken = default); + /// + /// Creates a new . + /// + /// A new . Id should be set to null. + /// Cancellation Token + /// The new . + Task CreateAsync(FulfillmentServiceEntity fulfillmentServiceEntity, CancellationToken cancellationToken = default); - /// - /// Updates the given . - /// - /// Id of the fulfillment service being updated. - /// The to update. - /// Cancellation Token - /// The updated . - Task UpdateAsync(long fulfillmentServiceId, FulfillmentServiceEntity fulfillmentServiceEntity, CancellationToken cancellationToken = default); + /// + /// Updates the given . + /// + /// Id of the fulfillment service being updated. + /// The to update. + /// Cancellation Token + /// The updated . + Task UpdateAsync(long fulfillmentServiceId, FulfillmentServiceEntity fulfillmentServiceEntity, CancellationToken cancellationToken = default); - /// - /// Deletes a fulfillment service with the given Id. - /// - /// The fulfillment service object's Id. - /// Cancellation Token - Task DeleteAsync(long fulfillmentServiceId, CancellationToken cancellationToken = default); - } + /// + /// Deletes a fulfillment service with the given Id. + /// + /// The fulfillment service object's Id. + /// Cancellation Token + Task DeleteAsync(long fulfillmentServiceId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/GiftCard/GiftCardService.cs b/ShopifySharp/Services/GiftCard/GiftCardService.cs index 0d7fab41..3fb667fe 100644 --- a/ShopifySharp/Services/GiftCard/GiftCardService.cs +++ b/ShopifySharp/Services/GiftCard/GiftCardService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Net.Http; @@ -6,76 +6,75 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify gift cards. +/// +public class GiftCardService : ShopifyService, IGiftCardService { /// - /// A service for manipulating Shopify gift cards. + /// Creates a new instance of . /// - public class GiftCardService : ShopifyService, IGiftCardService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public GiftCardService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal GiftCardService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public GiftCardService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal GiftCardService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CountAsync(GiftCardCountFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"gift_cards/count.json", "count", filter, cancellationToken); + /// + public virtual async Task CountAsync(GiftCardCountFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"gift_cards/count.json", "count", filter, cancellationToken); - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("gift_cards.json", "gift_cards", filter, cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("gift_cards.json", "gift_cards", filter, cancellationToken); - /// - public virtual async Task> ListAsync(GiftCardListFilter filter = null, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListAsync(GiftCardListFilter filter = null, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); - public virtual async Task> SearchAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("gift_cards/search.json", "gift_cards", filter, cancellationToken); + public virtual async Task> SearchAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("gift_cards/search.json", "gift_cards", filter, cancellationToken); - public virtual async Task> SearchAsync(GiftCardSearchFilter filter, CancellationToken cancellationToken = default) => - await SearchAsync(filter.AsListFilter(), cancellationToken); + public virtual async Task> SearchAsync(GiftCardSearchFilter filter, CancellationToken cancellationToken = default) => + await SearchAsync(filter.AsListFilter(), cancellationToken); - /// - public virtual async Task GetAsync(long giftCardId, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"gift_cards/{giftCardId}.json", "gift_card", cancellationToken: cancellationToken); + /// + public virtual async Task GetAsync(long giftCardId, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"gift_cards/{giftCardId}.json", "gift_card", cancellationToken: cancellationToken); - /// - public virtual async Task CreateAsync(GiftCard giftCard, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri("gift_cards.json"); - var body = giftCard.ToDictionary(); + /// + public virtual async Task CreateAsync(GiftCard giftCard, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("gift_cards.json"); + var body = giftCard.ToDictionary(); - var content = new JsonContent(new - { - gift_card = body - }); + var content = new JsonContent(new + { + gift_card = body + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "gift_card"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "gift_card"); + return response.Result; + } - /// - public virtual async Task UpdateAsync(long giftCardId, GiftCard giftCard, CancellationToken cancellationToken = default) + /// + public virtual async Task UpdateAsync(long giftCardId, GiftCard giftCard, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"gift_cards/{giftCardId}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"gift_cards/{giftCardId}.json"); - var content = new JsonContent(new - { - gift_card = giftCard - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "gift_card"); - return response.Result; - } + gift_card = giftCard + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "gift_card"); + return response.Result; + } - /// - public virtual async Task DisableAsync(long giftCardId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"gift_cards/{giftCardId}/disable.json"); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "gift_card"); - return response.Result; - } + /// + public virtual async Task DisableAsync(long giftCardId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"gift_cards/{giftCardId}/disable.json"); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "gift_card"); + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/GiftCard/IGiftCardService.cs b/ShopifySharp/Services/GiftCard/IGiftCardService.cs index a1df8dca..62388d88 100644 --- a/ShopifySharp/Services/GiftCard/IGiftCardService.cs +++ b/ShopifySharp/Services/GiftCard/IGiftCardService.cs @@ -3,69 +3,68 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IGiftCardService : IShopifyService { - public interface IGiftCardService : IShopifyService - { - /// - /// Gets a count of all of the gift cards on the shop. - /// - /// Options for filtering the count. - /// Cancellation Token - Task CountAsync(GiftCardCountFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a count of all of the gift cards on the shop. + /// + /// Options for filtering the count. + /// Cancellation Token + Task CountAsync(GiftCardCountFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the gift cards. - /// - /// Options for filtering the list. - /// Cancellation Token - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the gift cards. + /// + /// Options for filtering the list. + /// Cancellation Token + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the gift cards. - /// - /// Options for filtering the list. - /// Cancellation Token - Task> ListAsync(GiftCardListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the gift cards. + /// + /// Options for filtering the list. + /// Cancellation Token + Task> ListAsync(GiftCardListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the GiftCard to retrieve. - /// Cancellation Token - /// The . - Task GetAsync(long giftCardId, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the GiftCard to retrieve. + /// Cancellation Token + /// The . + Task GetAsync(long giftCardId, CancellationToken cancellationToken = default); - /// - /// Creates a new . - /// - /// A new . Id should be set to null. - /// Cancellation Token - /// The new . - Task CreateAsync(GiftCard giftCard, CancellationToken cancellationToken = default); + /// + /// Creates a new . + /// + /// A new . Id should be set to null. + /// Cancellation Token + /// The new . + Task CreateAsync(GiftCard giftCard, CancellationToken cancellationToken = default); - /// - /// Updates the given . - /// - /// Id of the object being updated. - /// The to update. - /// Cancellation Token - /// The updated . - Task UpdateAsync(long giftCardId, GiftCard giftCard, CancellationToken cancellationToken = default); + /// + /// Updates the given . + /// + /// Id of the object being updated. + /// The to update. + /// Cancellation Token + /// The updated . + Task UpdateAsync(long giftCardId, GiftCard giftCard, CancellationToken cancellationToken = default); - /// - /// Disables the with the given id. - /// - /// The id of the GiftCard to disable. - /// Cancellation Token - /// The . - Task DisableAsync(long giftCardId, CancellationToken cancellationToken = default); + /// + /// Disables the with the given id. + /// + /// The id of the GiftCard to disable. + /// Cancellation Token + /// The . + Task DisableAsync(long giftCardId, CancellationToken cancellationToken = default); - /// - /// Search for gift cards matching supplied query - /// - /// Options for searching and filtering the results. - /// Cancellation Token - Task> SearchAsync(GiftCardSearchFilter filter, CancellationToken cancellationToken = default); - } + /// + /// Search for gift cards matching supplied query + /// + /// Options for searching and filtering the results. + /// Cancellation Token + Task> SearchAsync(GiftCardSearchFilter filter, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/GiftCardAdjustment/GiftCardAdjustmentService.cs b/ShopifySharp/Services/GiftCardAdjustment/GiftCardAdjustmentService.cs index da716bc5..6d1d9879 100644 --- a/ShopifySharp/Services/GiftCardAdjustment/GiftCardAdjustmentService.cs +++ b/ShopifySharp/Services/GiftCardAdjustment/GiftCardAdjustmentService.cs @@ -1,41 +1,40 @@ -using ShopifySharp.Infrastructure; +using ShopifySharp.Infrastructure; using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for adjusting existing Shopify gift cards. +/// +public class GiftCardAdjustmentService : ShopifyService, IGiftCardAdjustmentService { /// - /// A service for adjusting existing Shopify gift cards. + /// Creates a new instance of . /// - public class GiftCardAdjustmentService : ShopifyService, IGiftCardAdjustmentService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public GiftCardAdjustmentService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal GiftCardAdjustmentService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public GiftCardAdjustmentService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal GiftCardAdjustmentService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - public virtual async Task> ListAsync(long giftCardId, CancellationToken cancellationToken = default) => - await ExecuteGetAsync>($"gift_cards/{giftCardId}/adjustments.json", "adjustments", cancellationToken: cancellationToken); + public virtual async Task> ListAsync(long giftCardId, CancellationToken cancellationToken = default) => + await ExecuteGetAsync>($"gift_cards/{giftCardId}/adjustments.json", "adjustments", cancellationToken: cancellationToken); - public virtual async Task GetAsync(long giftCardId, long adjustmentId, CancellationToken cancellationToken = default) => - await ExecuteGetAsync< GiftCardAdjustment>($"gift_cards/{giftCardId}/adjustments/{adjustmentId}.json", "adjustment", cancellationToken: cancellationToken); + public virtual async Task GetAsync(long giftCardId, long adjustmentId, CancellationToken cancellationToken = default) => + await ExecuteGetAsync< GiftCardAdjustment>($"gift_cards/{giftCardId}/adjustments/{adjustmentId}.json", "adjustment", cancellationToken: cancellationToken); - public virtual async Task CreateAsync(long giftCardId, GiftCardAdjustment adjustment, CancellationToken cancellationToken = default) + public virtual async Task CreateAsync(long giftCardId, GiftCardAdjustment adjustment, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"gift_cards/{giftCardId}/adjustments.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"gift_cards/{giftCardId}/adjustments.json"); - var content = new JsonContent(new - { - adjustment = adjustment - }); + adjustment = adjustment + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "adjustment"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "adjustment"); + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/GiftCardAdjustment/IGiftCardAdjustmentService.cs b/ShopifySharp/Services/GiftCardAdjustment/IGiftCardAdjustmentService.cs index d7e3c389..d4786d0a 100644 --- a/ShopifySharp/Services/GiftCardAdjustment/IGiftCardAdjustmentService.cs +++ b/ShopifySharp/Services/GiftCardAdjustment/IGiftCardAdjustmentService.cs @@ -2,33 +2,32 @@ using System.Threading; using System.Threading.Tasks; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IGiftCardAdjustmentService : IShopifyService { - public interface IGiftCardAdjustmentService : IShopifyService - { - /// - /// Gets a list of gift card adjustments belonging to the given gift card. - /// - /// The gift card that the adjustment was applied to. - /// Cancellation Token - Task> ListAsync(long giftCardId, CancellationToken cancellationToken = default); + /// + /// Gets a list of gift card adjustments belonging to the given gift card. + /// + /// The gift card that the adjustment was applied to. + /// Cancellation Token + Task> ListAsync(long giftCardId, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The gift card that the adjustment was applied to. - /// The id of the adjustment to retrieve. - /// Cancellation Token - /// - Task GetAsync(long giftCardId, long adjustmentId, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The gift card that the adjustment was applied to. + /// The id of the adjustment to retrieve. + /// Cancellation Token + /// + Task GetAsync(long giftCardId, long adjustmentId, CancellationToken cancellationToken = default); - /// - /// Apply an adjustment to an existing gift card - /// - /// The gift card that the adjustment was applied to. - /// A new . Signed amount and note should be the only properties set. - /// Cancellation Token - /// - Task CreateAsync(long giftCardId, GiftCardAdjustment adjustment, CancellationToken cancellationToken = default); - } + /// + /// Apply an adjustment to an existing gift card + /// + /// The gift card that the adjustment was applied to. + /// A new . Signed amount and note should be the only properties set. + /// Cancellation Token + /// + Task CreateAsync(long giftCardId, GiftCardAdjustment adjustment, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Graph/GraphRequest.cs b/ShopifySharp/Services/Graph/GraphRequest.cs index e3511bc7..35ad9903 100644 --- a/ShopifySharp/Services/Graph/GraphRequest.cs +++ b/ShopifySharp/Services/Graph/GraphRequest.cs @@ -1,9 +1,8 @@ -namespace ShopifySharp +namespace ShopifySharp; + +public class GraphRequest { - public class GraphRequest - { - public string query { get; set; } + public string query { get; set; } - public object variables { get; set; } - } -} + public object variables { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Services/Graph/GraphService.cs b/ShopifySharp/Services/Graph/GraphService.cs index ff745437..2d485f0c 100644 --- a/ShopifySharp/Services/Graph/GraphService.cs +++ b/ShopifySharp/Services/Graph/GraphService.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Linq; using Newtonsoft.Json; using ShopifySharp.Infrastructure; using System.Collections.Generic; @@ -12,133 +12,132 @@ using System.Text.Json; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for using or manipulating Shopify's Graph API. +/// +public class GraphService : ShopifyService, IGraphService { + private readonly string _apiVersion; + + public override string APIVersion => _apiVersion ?? base.APIVersion; + /// - /// A service for using or manipulating Shopify's Graph API. + /// Creates a new instance of . /// - public class GraphService : ShopifyService, IGraphService + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public GraphService(string myShopifyUrl, string shopAccessToken, string apiVersion = null) : base(myShopifyUrl, shopAccessToken) { - private readonly string _apiVersion; - - public override string APIVersion => _apiVersion ?? base.APIVersion; - - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public GraphService(string myShopifyUrl, string shopAccessToken, string apiVersion = null) : base(myShopifyUrl, shopAccessToken) - { - _apiVersion = apiVersion; - } + _apiVersion = apiVersion; + } - public GraphService(string myShopifyUrl, string shopAccessToken, IShopifyDomainUtility shopifyDomainUtility) : base(myShopifyUrl, shopAccessToken, shopifyDomainUtility) - { + public GraphService(string myShopifyUrl, string shopAccessToken, IShopifyDomainUtility shopifyDomainUtility) : base(myShopifyUrl, shopAccessToken, shopifyDomainUtility) + { - } + } - public virtual async Task PostAsync(JToken body, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) - { - var res = await PostAsync(body.ToString(Formatting.None), "application/json", graphqlQueryCost, cancellationToken); - return res["data"]; - } + public virtual async Task PostAsync(JToken body, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) + { + var res = await PostAsync(body.ToString(Formatting.None), "application/json", graphqlQueryCost, cancellationToken); + return res["data"]; + } - public virtual async Task PostAsync(string graphqlQuery, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) - { - var res = await PostAsync(graphqlQuery, "application/graphql", graphqlQueryCost, cancellationToken); - return res["data"]; - } + public virtual async Task PostAsync(string graphqlQuery, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) + { + var res = await PostAsync(graphqlQuery, "application/graphql", graphqlQueryCost, cancellationToken); + return res["data"]; + } - public virtual Task SendAsync(string graphqlQuery, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) - { - return SendAsync(new GraphRequest { query = graphqlQuery }, graphqlQueryCost, cancellationToken); - } + public virtual Task SendAsync(string graphqlQuery, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) + { + return SendAsync(new GraphRequest { query = graphqlQuery }, graphqlQueryCost, cancellationToken); + } - public virtual async Task SendAsync(GraphRequest request, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) - { - var body = System.Text.Json.JsonSerializer.Serialize(request); - var res = await PostAsync(body, "application/json", graphqlQueryCost, cancellationToken); - return res.RootElement.GetProperty("data"); - } + public virtual async Task SendAsync(GraphRequest request, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) + { + var body = System.Text.Json.JsonSerializer.Serialize(request); + var res = await PostAsync(body, "application/json", graphqlQueryCost, cancellationToken); + return res.RootElement.GetProperty("data"); + } #if NET6_0_OR_GREATER - public virtual Task SendAsync(string graphqlQuery, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) - where TResult : class - { - return SendAsync(new GraphRequest { query = graphqlQuery }, graphqlQueryCost, cancellationToken); - } + public virtual Task SendAsync(string graphqlQuery, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) + where TResult : class + { + return SendAsync(new GraphRequest { query = graphqlQuery }, graphqlQueryCost, cancellationToken); + } - /// - /// Issue a single value query and return the value as an strongly typed object. - /// Use a type from the ShopifySharp.GraphQL namespace - /// - /// Use a type from the ShopifySharp.GraphQL namespace - /// - /// - /// - public virtual async Task SendAsync(GraphRequest request, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) - where TResult : class - { - var elt = await this.SendAsync(request, graphqlQueryCost, cancellationToken); - var ptyElt = elt.EnumerateObject().Single().Value; - return GraphQL.Serializer.Deserialize(ptyElt.GetRawText()); - } + /// + /// Issue a single value query and return the value as an strongly typed object. + /// Use a type from the ShopifySharp.GraphQL namespace + /// + /// Use a type from the ShopifySharp.GraphQL namespace + /// + /// + /// + public virtual async Task SendAsync(GraphRequest request, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) + where TResult : class + { + var elt = await this.SendAsync(request, graphqlQueryCost, cancellationToken); + var ptyElt = elt.EnumerateObject().Single().Value; + return GraphQL.Serializer.Deserialize(ptyElt.GetRawText()); + } #endif - private async Task PostAsync(string body, string mediaType, int? graphqlQueryCost, CancellationToken cancellationToken) - { - var req = BuildRequestUri("graphql.json"); + private async Task PostAsync(string body, string mediaType, int? graphqlQueryCost, CancellationToken cancellationToken) + { + var req = BuildRequestUri("graphql.json"); - var content = new StringContent(body, Encoding.UTF8, mediaType); + var content = new StringContent(body, Encoding.UTF8, mediaType); - var res = await SendAsync(req, content, graphqlQueryCost, cancellationToken); + var res = await SendAsync(req, content, graphqlQueryCost, cancellationToken); - return res; - } + return res; + } - /// - /// Content agnostic way to send the request, regardless of Json or GraphQL. - /// - /// The RequestUri. - /// The HttpContent, be it GraphQL or Json. - /// An estimation of the cost of this query. - /// A JToken containing the data from the request. - protected virtual async Task SendAsync(RequestUri req, HttpContent content, int? graphqlQueryCost, CancellationToken cancellationToken = default) - { - var response = await ExecuteRequestCoreAsync(req, HttpMethod.Post, cancellationToken, content, null, null, graphqlQueryCost, DateParseHandling.None); + /// + /// Content agnostic way to send the request, regardless of Json or GraphQL. + /// + /// The RequestUri. + /// The HttpContent, be it GraphQL or Json. + /// An estimation of the cost of this query. + /// A JToken containing the data from the request. + protected virtual async Task SendAsync(RequestUri req, HttpContent content, int? graphqlQueryCost, CancellationToken cancellationToken = default) + { + var response = await ExecuteRequestCoreAsync(req, HttpMethod.Post, cancellationToken, content, null, null, graphqlQueryCost, DateParseHandling.None); - CheckForErrors(response); + CheckForErrors(response); - return response.Result; - } + return response.Result; + } - /// - /// Since Graph API Errors come back with error code 200, checking for them in a way similar to the REST API doesn't work well without potentially throwing unnecessary errors. This loses the requestId, but otherwise is capable of passing along the message. - /// - /// The response from ExecuteRequestAsync. - /// Thrown if contains an error. - protected virtual void CheckForErrors(RequestResult requestResult) + /// + /// Since Graph API Errors come back with error code 200, checking for them in a way similar to the REST API doesn't work well without potentially throwing unnecessary errors. This loses the requestId, but otherwise is capable of passing along the message. + /// + /// The response from ExecuteRequestAsync. + /// Thrown if contains an error. + protected virtual void CheckForErrors(RequestResult requestResult) + { + var res = JToken.Parse(requestResult.RawResult); + + if (res["errors"] != null) { - var res = JToken.Parse(requestResult.RawResult); + var errorList = new List(); - if (res["errors"] != null) + foreach (var error in res["errors"]) { - var errorList = new List(); - - foreach (var error in res["errors"]) + if (error["message"] is not null) { - if (error["message"] is not null) - { - errorList.Add(error["message"].ToString()); - } + errorList.Add(error["message"].ToString()); } + } - var message = errorList.FirstOrDefault() ?? "Unable to parse Shopify's error response, please inspect exception's RawBody property and report this issue to the ShopifySharp maintainers."; - var requestId = ParseRequestIdResponseHeader(requestResult.ResponseHeaders); + var message = errorList.FirstOrDefault() ?? "Unable to parse Shopify's error response, please inspect exception's RawBody property and report this issue to the ShopifySharp maintainers."; + var requestId = ParseRequestIdResponseHeader(requestResult.ResponseHeaders); - throw new ShopifyHttpException(requestResult.RequestInfo, HttpStatusCode.OK, errorList, message, requestResult.RawResult, requestId); - } + throw new ShopifyHttpException(requestResult.RequestInfo, HttpStatusCode.OK, errorList, message, requestResult.RawResult, requestId); } } -} +} \ No newline at end of file diff --git a/ShopifySharp/Services/Graph/IGraphService.cs b/ShopifySharp/Services/Graph/IGraphService.cs index 293c0df0..bc683c05 100644 --- a/ShopifySharp/Services/Graph/IGraphService.cs +++ b/ShopifySharp/Services/Graph/IGraphService.cs @@ -3,82 +3,81 @@ using System.Threading.Tasks; using Newtonsoft.Json.Linq; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IGraphService : IShopifyService { - public interface IGraphService : IShopifyService - { - /// - /// Executes a Graph API Call. - /// - /// The query you would like to execute. Please see documentation for formatting. - /// - /// The requestedQueryCost available at extensions.cost.requestedQueryCost. - /// While it is optional, it is recommended to provide it to avoid wasting resources to issue API calls that will be throttled - /// - /// Cancellation Token - /// A JToken containing the data from the request. - Task PostAsync(string body, int? graphqlQueryCost = null, CancellationToken cancellationToken = default); + /// + /// Executes a Graph API Call. + /// + /// The query you would like to execute. Please see documentation for formatting. + /// + /// The requestedQueryCost available at extensions.cost.requestedQueryCost. + /// While it is optional, it is recommended to provide it to avoid wasting resources to issue API calls that will be throttled + /// + /// Cancellation Token + /// A JToken containing the data from the request. + Task PostAsync(string body, int? graphqlQueryCost = null, CancellationToken cancellationToken = default); - /// - /// Executes a Graph API Call. - /// - /// The query you would like to execute, as a JToken. Please see documentation for formatting. - /// - /// The requestedQueryCost available at extensions.cost.requestedQueryCost. - /// While it is optional, it is recommended to provide it to avoid wasting resources to issue API calls that will be throttled - /// - /// Cancellation Token - /// A JToken containing the data from the request. - Task PostAsync(JToken body, int? graphqlQueryCost = null, CancellationToken cancellationToken = default); + /// + /// Executes a Graph API Call. + /// + /// The query you would like to execute, as a JToken. Please see documentation for formatting. + /// + /// The requestedQueryCost available at extensions.cost.requestedQueryCost. + /// While it is optional, it is recommended to provide it to avoid wasting resources to issue API calls that will be throttled + /// + /// Cancellation Token + /// A JToken containing the data from the request. + Task PostAsync(JToken body, int? graphqlQueryCost = null, CancellationToken cancellationToken = default); - /// - /// Executes a Graph API Call. - /// - /// The query you would like to execute, as a . Please see documentation for formatting. - /// - /// The requestedQueryCost available at extensions.cost.requestedQueryCost. - /// While it is optional, it is recommended to provide it to avoid wasting resources to issue API calls that will be throttled - /// - /// Cancellation Token - /// A JsonElement containing the data from the request. - Task SendAsync(GraphRequest request, int? graphqlQueryCost = null, CancellationToken cancellationToken = default); + /// + /// Executes a Graph API Call. + /// + /// The query you would like to execute, as a . Please see documentation for formatting. + /// + /// The requestedQueryCost available at extensions.cost.requestedQueryCost. + /// While it is optional, it is recommended to provide it to avoid wasting resources to issue API calls that will be throttled + /// + /// Cancellation Token + /// A JsonElement containing the data from the request. + Task SendAsync(GraphRequest request, int? graphqlQueryCost = null, CancellationToken cancellationToken = default); - /// - /// Executes a Graph API Call. - /// - /// The query you would like to execute, as a string. Please see documentation for formatting. - /// - /// The requestedQueryCost available at extensions.cost.requestedQueryCost. - /// While it is optional, it is recommended to provide it to avoid wasting resources to issue API calls that will be throttled - /// - /// Cancellation Token - /// A JsonElement containing the data from the request. - Task SendAsync(string graphqlQuery, int? graphqlQueryCost = null, CancellationToken cancellationToken = default); + /// + /// Executes a Graph API Call. + /// + /// The query you would like to execute, as a string. Please see documentation for formatting. + /// + /// The requestedQueryCost available at extensions.cost.requestedQueryCost. + /// While it is optional, it is recommended to provide it to avoid wasting resources to issue API calls that will be throttled + /// + /// Cancellation Token + /// A JsonElement containing the data from the request. + Task SendAsync(string graphqlQuery, int? graphqlQueryCost = null, CancellationToken cancellationToken = default); #if NET6_0_OR_GREATER - /// - /// Executes a Graph API Call. - /// - /// The query you would like to execute, as a . Please see documentation for formatting. - /// - /// The requestedQueryCost available at extensions.cost.requestedQueryCost. - /// While it is optional, it is recommended to provide it to avoid wasting resources to issue API calls that will be throttled - /// - /// Cancellation Token - /// A containing the data from the request. - Task SendAsync(GraphRequest request, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) where TResult : class; + /// + /// Executes a Graph API Call. + /// + /// The query you would like to execute, as a . Please see documentation for formatting. + /// + /// The requestedQueryCost available at extensions.cost.requestedQueryCost. + /// While it is optional, it is recommended to provide it to avoid wasting resources to issue API calls that will be throttled + /// + /// Cancellation Token + /// A containing the data from the request. + Task SendAsync(GraphRequest request, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) where TResult : class; - /// - /// Executes a Graph API Call. - /// - /// The query you would like to execute, as a string. Please see documentation for formatting. - /// - /// The requestedQueryCost available at extensions.cost.requestedQueryCost. - /// While it is optional, it is recommended to provide it to avoid wasting resources to issue API calls that will be throttled - /// - /// Cancellation Token - /// A containing the data from the request. - Task SendAsync(string graphqlQuery, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) where TResult : class; + /// + /// Executes a Graph API Call. + /// + /// The query you would like to execute, as a string. Please see documentation for formatting. + /// + /// The requestedQueryCost available at extensions.cost.requestedQueryCost. + /// While it is optional, it is recommended to provide it to avoid wasting resources to issue API calls that will be throttled + /// + /// Cancellation Token + /// A containing the data from the request. + Task SendAsync(string graphqlQuery, int? graphqlQueryCost = null, CancellationToken cancellationToken = default) where TResult : class; #endif - } -} +} \ No newline at end of file diff --git a/ShopifySharp/Services/IShopifyService.cs b/ShopifySharp/Services/IShopifyService.cs index 63cfb9d7..faffad17 100644 --- a/ShopifySharp/Services/IShopifyService.cs +++ b/ShopifySharp/Services/IShopifyService.cs @@ -1,17 +1,16 @@ #nullable enable // ReSharper disable InconsistentNaming -namespace ShopifySharp +namespace ShopifySharp; + +public interface IShopifyService { - public interface IShopifyService - { - string APIVersion { get; } - bool SupportsAPIVersioning { get; } + string APIVersion { get; } + bool SupportsAPIVersioning { get; } - void SetExecutionPolicy(IRequestExecutionPolicy policy); + void SetExecutionPolicy(IRequestExecutionPolicy policy); - // TODO: determine best method for DI and testing? letting devs set HttpClient, or HttpClientFactory? - //void SetHttpClient(HttpClient client); - //void SetHttpClientFactory(IHttpClientFactory factory); - } -} + // TODO: determine best method for DI and testing? letting devs set HttpClient, or HttpClientFactory? + //void SetHttpClient(HttpClient client); + //void SetHttpClientFactory(IHttpClientFactory factory); +} \ No newline at end of file diff --git a/ShopifySharp/Services/InventoryItem/IInventoryItemService.cs b/ShopifySharp/Services/InventoryItem/IInventoryItemService.cs index 4d0bb304..35d3471c 100644 --- a/ShopifySharp/Services/InventoryItem/IInventoryItemService.cs +++ b/ShopifySharp/Services/InventoryItem/IInventoryItemService.cs @@ -3,36 +3,35 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IInventoryItemService : IShopifyService { - public interface IInventoryItemService : IShopifyService - { - /// - /// Gets a list of inventory items. - /// - /// Options for filtering the result. - /// Cancellation Token - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of inventory items. + /// + /// Options for filtering the result. + /// Cancellation Token + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - /// - /// Gets a list of inventory items. - /// - /// Options for filtering the result. - /// Cancellation Token - Task> ListAsync(InventoryItemListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of inventory items. + /// + /// Options for filtering the result. + /// Cancellation Token + Task> ListAsync(InventoryItemListFilter filter, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the inventory item to retrieve. - /// Cancellation Token - Task GetAsync(long inventoryItemId, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the inventory item to retrieve. + /// Cancellation Token + Task GetAsync(long inventoryItemId, CancellationToken cancellationToken = default); - /// - /// Updates an existing . - /// - /// The id of the inventory item to retrieve. - /// Cancellation Token - Task UpdateAsync( long inventoryItemId, InventoryItem inventoryItem, CancellationToken cancellationToken = default); - } + /// + /// Updates an existing . + /// + /// The id of the inventory item to retrieve. + /// Cancellation Token + Task UpdateAsync( long inventoryItemId, InventoryItem inventoryItem, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/InventoryItem/InventoryItemService.cs b/ShopifySharp/Services/InventoryItem/InventoryItemService.cs index 56c967a5..319166ab 100644 --- a/ShopifySharp/Services/InventoryItem/InventoryItemService.cs +++ b/ShopifySharp/Services/InventoryItem/InventoryItemService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Net.Http; @@ -6,44 +6,43 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating a Shopify inventory items. +/// +public class InventoryItemService : ShopifyService, IInventoryItemService { /// - /// A service for manipulating a Shopify inventory items. + /// Creates a new instance of . /// - public class InventoryItemService : ShopifyService, IInventoryItemService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public InventoryItemService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal InventoryItemService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public InventoryItemService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal InventoryItemService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync($"inventory_items.json", "inventory_items", filter, cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync($"inventory_items.json", "inventory_items", filter, cancellationToken); - /// - public virtual async Task> ListAsync(InventoryItemListFilter filter, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListAsync(InventoryItemListFilter filter, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task GetAsync(long inventoryItemId, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"inventory_items/{inventoryItemId}.json", "inventory_item", cancellationToken: cancellationToken); + /// + public virtual async Task GetAsync(long inventoryItemId, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"inventory_items/{inventoryItemId}.json", "inventory_item", cancellationToken: cancellationToken); - /// - public virtual async Task UpdateAsync( long inventoryItemId, InventoryItem inventoryItem, CancellationToken cancellationToken = default) + /// + public virtual async Task UpdateAsync( long inventoryItemId, InventoryItem inventoryItem, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri( $"inventory_items/{inventoryItemId}.json" ); + var content = new JsonContent( new { - var req = BuildRequestUri( $"inventory_items/{inventoryItemId}.json" ); - var content = new JsonContent( new - { - inventory_item = inventoryItem - } ); + inventory_item = inventoryItem + } ); - var response = await ExecuteRequestAsync( req, HttpMethod.Put, cancellationToken, content, "inventory_item"); - return response.Result; - } + var response = await ExecuteRequestAsync( req, HttpMethod.Put, cancellationToken, content, "inventory_item"); + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/InventoryLevel/IInventoryLevelService.cs b/ShopifySharp/Services/InventoryLevel/IInventoryLevelService.cs index 65975e8b..54df5578 100644 --- a/ShopifySharp/Services/InventoryLevel/IInventoryLevelService.cs +++ b/ShopifySharp/Services/InventoryLevel/IInventoryLevelService.cs @@ -3,53 +3,52 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IInventoryLevelService : IShopifyService { - public interface IInventoryLevelService : IShopifyService - { - /// - /// Gets a list of inventory items. - /// - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of inventory items. + /// + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - /// - /// Gets a list of inventory items - /// - Task> ListAsync(InventoryLevelListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of inventory items + /// + Task> ListAsync(InventoryLevelListFilter filter, CancellationToken cancellationToken = default); - /// - /// Deletes inventory for an item at specified location. All items must keep inventory at at least one location. - /// - /// The ID of the inventory item. - /// The ID of the location that the inventory level belongs to. - /// Cancellation Token - Task DeleteAsync(long inventoryItemId, long locationId, CancellationToken cancellationToken = default); + /// + /// Deletes inventory for an item at specified location. All items must keep inventory at at least one location. + /// + /// The ID of the inventory item. + /// The ID of the location that the inventory level belongs to. + /// Cancellation Token + Task DeleteAsync(long inventoryItemId, long locationId, CancellationToken cancellationToken = default); - /// - /// Updates the given . - /// - /// The updated - /// Whether inventory for any previously connected locations will be set to 0 and the locations disconnected. This property is ignored when no fulfillment service is involved. - /// Cancellation Token - /// The updated - Task SetAsync(InventoryLevel updatedInventoryLevel, bool disconnectIfNecessary = false, CancellationToken cancellationToken = default); + /// + /// Updates the given . + /// + /// The updated + /// Whether inventory for any previously connected locations will be set to 0 and the locations disconnected. This property is ignored when no fulfillment service is involved. + /// Cancellation Token + /// The updated + Task SetAsync(InventoryLevel updatedInventoryLevel, bool disconnectIfNecessary = false, CancellationToken cancellationToken = default); - /// - /// Adjusts the given . - /// - /// The updated - /// Cancellation Token - /// The updated - Task AdjustAsync(InventoryLevelAdjust updatedInventoryLevel, CancellationToken cancellationToken = default); + /// + /// Adjusts the given . + /// + /// The updated + /// Cancellation Token + /// The updated + Task AdjustAsync(InventoryLevelAdjust updatedInventoryLevel, CancellationToken cancellationToken = default); - /// - /// Connect an inventory item to a location - /// - /// The ID of the inventory item - /// The ID of the location that the inventory level belongs to - /// Whether inventory for any previously connected locations will be relocated. This property is ignored when no fulfillment service location is involved - /// Cancellation Token - /// The new . - Task ConnectAsync(long inventoryItemId, long locationId, bool relocateIfNecessary = false, CancellationToken cancellationToken = default); - } + /// + /// Connect an inventory item to a location + /// + /// The ID of the inventory item + /// The ID of the location that the inventory level belongs to + /// Whether inventory for any previously connected locations will be relocated. This property is ignored when no fulfillment service location is involved + /// Cancellation Token + /// The new . + Task ConnectAsync(long inventoryItemId, long locationId, bool relocateIfNecessary = false, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/InventoryLevel/InventoryLevelService.cs b/ShopifySharp/Services/InventoryLevel/InventoryLevelService.cs index df6b40b9..2ecb6711 100644 --- a/ShopifySharp/Services/InventoryLevel/InventoryLevelService.cs +++ b/ShopifySharp/Services/InventoryLevel/InventoryLevelService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Net.Http; @@ -6,74 +6,73 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating a Shopify inventory items. +/// +public class InventoryLevelService : ShopifyService, IInventoryLevelService { /// - /// A service for manipulating a Shopify inventory items. + /// Creates a new instance of . /// - public class InventoryLevelService : ShopifyService, IInventoryLevelService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public InventoryLevelService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal InventoryLevelService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public InventoryLevelService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal InventoryLevelService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync($"inventory_levels.json", "inventory_levels", filter, cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync($"inventory_levels.json", "inventory_levels", filter, cancellationToken); - /// - public virtual async Task> ListAsync(InventoryLevelListFilter filter, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListAsync(InventoryLevelListFilter filter, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task DeleteAsync(long inventoryItemId, long locationId, CancellationToken cancellationToken = default) - { - var requestUri = BuildRequestUri($"inventory_levels.json?inventory_item_id={inventoryItemId}&location_id={locationId}"); - await ExecuteRequestAsync(requestUri, HttpMethod.Delete, cancellationToken); - } + /// + public virtual async Task DeleteAsync(long inventoryItemId, long locationId, CancellationToken cancellationToken = default) + { + var requestUri = BuildRequestUri($"inventory_levels.json?inventory_item_id={inventoryItemId}&location_id={locationId}"); + await ExecuteRequestAsync(requestUri, HttpMethod.Delete, cancellationToken); + } - /// - public virtual async Task SetAsync(InventoryLevel updatedInventoryLevel, bool disconnectIfNecessary = false, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"inventory_levels/set.json"); - var body = updatedInventoryLevel.ToDictionary(); + /// + public virtual async Task SetAsync(InventoryLevel updatedInventoryLevel, bool disconnectIfNecessary = false, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"inventory_levels/set.json"); + var body = updatedInventoryLevel.ToDictionary(); - body.Add("disconnect_if_necessary", disconnectIfNecessary); + body.Add("disconnect_if_necessary", disconnectIfNecessary); - var content = new JsonContent(body); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "inventory_level"); + var content = new JsonContent(body); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "inventory_level"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task AdjustAsync(InventoryLevelAdjust updatedInventoryLevel, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"inventory_levels/adjust.json"); - var body = updatedInventoryLevel.ToDictionary(); - var content = new JsonContent(body); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "inventory_level"); + /// + public virtual async Task AdjustAsync(InventoryLevelAdjust updatedInventoryLevel, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"inventory_levels/adjust.json"); + var body = updatedInventoryLevel.ToDictionary(); + var content = new JsonContent(body); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "inventory_level"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task ConnectAsync(long inventoryItemId, long locationId, bool relocateIfNecessary = false, CancellationToken cancellationToken = default) + /// + public virtual async Task ConnectAsync(long inventoryItemId, long locationId, bool relocateIfNecessary = false, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"inventory_levels/connect.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"inventory_levels/connect.json"); - var content = new JsonContent(new - { - location_id = locationId, - inventory_item_id = inventoryItemId, - relocate_if_necessary = relocateIfNecessary - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "inventory_level"); + location_id = locationId, + inventory_item_id = inventoryItemId, + relocate_if_necessary = relocateIfNecessary + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "inventory_level"); - return response.Result; - } + return response.Result; } -} +} \ No newline at end of file diff --git a/ShopifySharp/Services/Location/ILocationService.cs b/ShopifySharp/Services/Location/ILocationService.cs index d327e42b..55b0fe42 100644 --- a/ShopifySharp/Services/Location/ILocationService.cs +++ b/ShopifySharp/Services/Location/ILocationService.cs @@ -3,26 +3,25 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface ILocationService : IShopifyService { - public interface ILocationService : IShopifyService - { - /// - /// Retrieves the with the given id. - /// - /// The id of the charge to retrieve. - /// Cancellation Token - /// The . - Task GetAsync(long id, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the charge to retrieve. + /// Cancellation Token + /// The . + Task GetAsync(long id, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the locations. - /// - Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the locations. + /// + Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the locations. - /// - Task> ListAsync(LocationListFilter filter, CancellationToken cancellationToken = default); - } + /// + /// Gets a list of up to 250 of the locations. + /// + Task> ListAsync(LocationListFilter filter, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Location/LocationService.cs b/ShopifySharp/Services/Location/LocationService.cs index 768ee28c..7a119eb7 100644 --- a/ShopifySharp/Services/Location/LocationService.cs +++ b/ShopifySharp/Services/Location/LocationService.cs @@ -1,31 +1,30 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Lists; using System.Threading.Tasks; using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify's Location API. +/// +public class LocationService : ShopifyService, ILocationService { /// - /// A service for manipulating Shopify's Location API. + /// Creates a new instance of . /// - public class LocationService : ShopifyService, ILocationService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public LocationService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal LocationService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public LocationService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal LocationService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - public virtual async Task GetAsync(long id, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"locations/{id}.json", "location", cancellationToken: cancellationToken); + public virtual async Task GetAsync(long id, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"locations/{id}.json", "location", cancellationToken: cancellationToken); - public virtual async Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("locations.json", "locations", filter, cancellationToken); + public virtual async Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("locations.json", "locations", filter, cancellationToken); - public virtual async Task> ListAsync(LocationListFilter filter, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); - } + public virtual async Task> ListAsync(LocationListFilter filter, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); } \ No newline at end of file diff --git a/ShopifySharp/Services/MetaField/IMetaFieldService.cs b/ShopifySharp/Services/MetaField/IMetaFieldService.cs index 6d4cfd7d..7ac29501 100644 --- a/ShopifySharp/Services/MetaField/IMetaFieldService.cs +++ b/ShopifySharp/Services/MetaField/IMetaFieldService.cs @@ -3,144 +3,143 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IMetaFieldService : IShopifyService { - public interface IMetaFieldService : IShopifyService - { - /// - /// Gets a count of the metafields on the shop itself. - /// - /// - /// According to Shopify's documentation, this endpoint does not currently support any additional filter parameters for counting. - /// - Task CountAsync(CancellationToken cancellationToken = default); - - /// - /// Gets a count of the metafields for the given entity type and filter options. - /// - /// The type of shopify resource to obtain metafields for. This could be variants, products, orders, customers, custom_collections. - /// The Id for the resource type. - /// Cancellation Token - /// - /// According to Shopify's documentation, this endpoint does not currently support any additional filter parameters for counting. - /// - Task CountAsync(long resourceId, string resourceType, CancellationToken cancellationToken = default); - - /// - /// Gets a count of the metafields for the given entity type and filter options. - /// - /// The type of shopify resource to obtain metafields for. This could be variants, products, orders, customers, custom_collections. - /// The Id for the resource type. - /// The type of shopify parent resource to obtain metafields for. This could be blogs, products. - /// The Id for the resource type. - /// Cancellation Token - /// - /// According to Shopify's documentation, this endpoint does not currently support any additional filter parameters for counting. - /// - Task CountAsync(long resourceId, string resourceType, long parentResourceId, string parentResourceType, CancellationToken cancellationToken = default); - - /// - /// Gets a list of the metafields for the shop itself. - /// - /// Options to filter the results. - /// Cancellation Token - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - - /// - /// Gets a list of the metafields for the given entity type and filter options. - /// - /// The type of shopify resource to obtain metafields for. This could be variants, products, orders, customers, custom_collections. - /// The Id for the resource type. - /// Options to filter the results. - /// Cancellation Token - Task> ListAsync(long resourceId, string resourceType, ListFilter filter, CancellationToken cancellationToken = default); - - /// - /// Gets a list of the metafields for the given entity type and filter options. - /// - /// The type of shopify parentresource to obtain metafields for. This could be blogs, products. - /// The Id for the parent resource type. - /// The type of shopify resource to obtain metafields for. This could be variants, products, orders, customers, custom_collections. - /// The Id for the resource type. - /// Options to filter the results. - /// Cancellation Token - Task> ListAsync(long resourceId, string resourceType, long parentResourceId, string parentResourceType, ListFilter filter, CancellationToken cancellationToken = default); - - /// - /// Gets a list of the metafields for the shop itself. - /// - /// Options to filter the results. - /// Cancellation Token - Task> ListAsync(MetaFieldFilter filter = null, CancellationToken cancellationToken = default); - - /// - /// Gets a list of the metafields for the given entity type and filter options. - /// - /// The type of shopify resource to obtain metafields for. This could be variants, products, orders, customers, custom_collections. - /// The Id for the resource type. - /// Options to filter the results. - /// Cancellation Token - Task> ListAsync(long resourceId, string resourceType, MetaFieldFilter filter = null, CancellationToken cancellationToken = default); - - /// - /// Gets a list of the metafields for the given entity type and filter options. - /// - /// The type of shopify parentresource to obtain metafields for. This could be blogs, products. - /// The Id for the parent resource type. - /// The type of shopify resource to obtain metafields for. This could be variants, products, orders, customers, custom_collections. - /// The Id for the resource type. - /// Options to filter the results. - /// Cancellation Token - Task> ListAsync(long resourceId, string resourceType, long parentResourceId, string parentResourceType, MetaFieldFilter filter = null, CancellationToken cancellationToken = default); - - /// - /// Retrieves the metafield with the given id. - /// - /// The id of the metafield to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - Task GetAsync(long metafieldId, string fields = null, CancellationToken cancellationToken = default); - - /// - /// Creates a new metafield on the shop itself. - /// - /// A new metafield. Id should be set to null. - /// Cancellation Token - Task CreateAsync(MetaField metafield, CancellationToken cancellationToken = default); - - /// - /// Creates a new metafield on the given entity. - /// - /// A new metafield. Id should be set to null. - /// The Id of the resource the metafield will be associated with. This can be variants, products, orders, customers, custom_collections, etc. - /// The resource type the metaifeld will be associated with. This can be variants, products, orders, customers, custom_collections, etc. - /// The Id of the parent resource the metafield will be associated with. This can be blogs, products. - /// The resource type the metaifeld will be associated with. This can be articles, variants. - /// Cancellation Token - Task CreateAsync(MetaField metafield, long resourceId, string resourceType, long parentResourceId, string parentResourceType, CancellationToken cancellationToken = default); - - /// - /// Creates a new metafield on the given entity. - /// - /// A new metafield. Id should be set to null. - /// The Id of the resource the metafield will be associated with. This can be variants, products, orders, customers, custom_collections, etc. - /// The resource type the metaifeld will be associated with. This can be variants, products, orders, customers, custom_collections, etc. - /// Cancellation Token - Task CreateAsync(MetaField metafield, long resourceId, string resourceType, CancellationToken cancellationToken = default); - - /// - /// Updates the given metafield. - /// - /// Id of the object being updated. - /// The metafield to update. - /// Cancellation Token - Task UpdateAsync(long metafieldId, MetaField metafield, CancellationToken cancellationToken = default); - - /// - /// Deletes a metafield with the given Id. - /// - /// The metafield object's Id. - /// Cancellation Token - Task DeleteAsync(long metafieldId, CancellationToken cancellationToken = default); - } + /// + /// Gets a count of the metafields on the shop itself. + /// + /// + /// According to Shopify's documentation, this endpoint does not currently support any additional filter parameters for counting. + /// + Task CountAsync(CancellationToken cancellationToken = default); + + /// + /// Gets a count of the metafields for the given entity type and filter options. + /// + /// The type of shopify resource to obtain metafields for. This could be variants, products, orders, customers, custom_collections. + /// The Id for the resource type. + /// Cancellation Token + /// + /// According to Shopify's documentation, this endpoint does not currently support any additional filter parameters for counting. + /// + Task CountAsync(long resourceId, string resourceType, CancellationToken cancellationToken = default); + + /// + /// Gets a count of the metafields for the given entity type and filter options. + /// + /// The type of shopify resource to obtain metafields for. This could be variants, products, orders, customers, custom_collections. + /// The Id for the resource type. + /// The type of shopify parent resource to obtain metafields for. This could be blogs, products. + /// The Id for the resource type. + /// Cancellation Token + /// + /// According to Shopify's documentation, this endpoint does not currently support any additional filter parameters for counting. + /// + Task CountAsync(long resourceId, string resourceType, long parentResourceId, string parentResourceType, CancellationToken cancellationToken = default); + + /// + /// Gets a list of the metafields for the shop itself. + /// + /// Options to filter the results. + /// Cancellation Token + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + + /// + /// Gets a list of the metafields for the given entity type and filter options. + /// + /// The type of shopify resource to obtain metafields for. This could be variants, products, orders, customers, custom_collections. + /// The Id for the resource type. + /// Options to filter the results. + /// Cancellation Token + Task> ListAsync(long resourceId, string resourceType, ListFilter filter, CancellationToken cancellationToken = default); + + /// + /// Gets a list of the metafields for the given entity type and filter options. + /// + /// The type of shopify parentresource to obtain metafields for. This could be blogs, products. + /// The Id for the parent resource type. + /// The type of shopify resource to obtain metafields for. This could be variants, products, orders, customers, custom_collections. + /// The Id for the resource type. + /// Options to filter the results. + /// Cancellation Token + Task> ListAsync(long resourceId, string resourceType, long parentResourceId, string parentResourceType, ListFilter filter, CancellationToken cancellationToken = default); + + /// + /// Gets a list of the metafields for the shop itself. + /// + /// Options to filter the results. + /// Cancellation Token + Task> ListAsync(MetaFieldFilter filter = null, CancellationToken cancellationToken = default); + + /// + /// Gets a list of the metafields for the given entity type and filter options. + /// + /// The type of shopify resource to obtain metafields for. This could be variants, products, orders, customers, custom_collections. + /// The Id for the resource type. + /// Options to filter the results. + /// Cancellation Token + Task> ListAsync(long resourceId, string resourceType, MetaFieldFilter filter = null, CancellationToken cancellationToken = default); + + /// + /// Gets a list of the metafields for the given entity type and filter options. + /// + /// The type of shopify parentresource to obtain metafields for. This could be blogs, products. + /// The Id for the parent resource type. + /// The type of shopify resource to obtain metafields for. This could be variants, products, orders, customers, custom_collections. + /// The Id for the resource type. + /// Options to filter the results. + /// Cancellation Token + Task> ListAsync(long resourceId, string resourceType, long parentResourceId, string parentResourceType, MetaFieldFilter filter = null, CancellationToken cancellationToken = default); + + /// + /// Retrieves the metafield with the given id. + /// + /// The id of the metafield to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + Task GetAsync(long metafieldId, string fields = null, CancellationToken cancellationToken = default); + + /// + /// Creates a new metafield on the shop itself. + /// + /// A new metafield. Id should be set to null. + /// Cancellation Token + Task CreateAsync(MetaField metafield, CancellationToken cancellationToken = default); + + /// + /// Creates a new metafield on the given entity. + /// + /// A new metafield. Id should be set to null. + /// The Id of the resource the metafield will be associated with. This can be variants, products, orders, customers, custom_collections, etc. + /// The resource type the metaifeld will be associated with. This can be variants, products, orders, customers, custom_collections, etc. + /// The Id of the parent resource the metafield will be associated with. This can be blogs, products. + /// The resource type the metaifeld will be associated with. This can be articles, variants. + /// Cancellation Token + Task CreateAsync(MetaField metafield, long resourceId, string resourceType, long parentResourceId, string parentResourceType, CancellationToken cancellationToken = default); + + /// + /// Creates a new metafield on the given entity. + /// + /// A new metafield. Id should be set to null. + /// The Id of the resource the metafield will be associated with. This can be variants, products, orders, customers, custom_collections, etc. + /// The resource type the metaifeld will be associated with. This can be variants, products, orders, customers, custom_collections, etc. + /// Cancellation Token + Task CreateAsync(MetaField metafield, long resourceId, string resourceType, CancellationToken cancellationToken = default); + + /// + /// Updates the given metafield. + /// + /// Id of the object being updated. + /// The metafield to update. + /// Cancellation Token + Task UpdateAsync(long metafieldId, MetaField metafield, CancellationToken cancellationToken = default); + + /// + /// Deletes a metafield with the given Id. + /// + /// The metafield object's Id. + /// Cancellation Token + Task DeleteAsync(long metafieldId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/MetaField/MetaFieldService.cs b/ShopifySharp/Services/MetaField/MetaFieldService.cs index ce149126..5e11788a 100644 --- a/ShopifySharp/Services/MetaField/MetaFieldService.cs +++ b/ShopifySharp/Services/MetaField/MetaFieldService.cs @@ -6,125 +6,124 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify metafields. +/// +public class MetaFieldService : ShopifyService, IMetaFieldService { /// - /// A service for manipulating Shopify metafields. + /// Creates a new instance of . /// - public class MetaFieldService : ShopifyService, IMetaFieldService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public MetaFieldService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal MetaFieldService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public MetaFieldService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal MetaFieldService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CountAsync(CancellationToken cancellationToken = default) => - await _CountAsync("metafields/count.json", cancellationToken); + /// + public virtual async Task CountAsync(CancellationToken cancellationToken = default) => + await _CountAsync("metafields/count.json", cancellationToken); - /// - public virtual async Task CountAsync(long resourceId, string resourceType, CancellationToken cancellationToken = default) => - await _CountAsync($"{resourceType.ToLower()}/{resourceId}/metafields/count.json", cancellationToken); + /// + public virtual async Task CountAsync(long resourceId, string resourceType, CancellationToken cancellationToken = default) => + await _CountAsync($"{resourceType.ToLower()}/{resourceId}/metafields/count.json", cancellationToken); - /// - public virtual async Task CountAsync(long resourceId, string resourceType, long parentResourceId, string parentResourceType, CancellationToken cancellationToken = default) => - await _CountAsync($"{parentResourceType.ToLower()}/{parentResourceId}/{resourceType.ToLower()}/{resourceId}/metafields/count.json", cancellationToken); + /// + public virtual async Task CountAsync(long resourceId, string resourceType, long parentResourceId, string parentResourceType, CancellationToken cancellationToken = default) => + await _CountAsync($"{parentResourceType.ToLower()}/{parentResourceId}/{resourceType.ToLower()}/{resourceId}/metafields/count.json", cancellationToken); - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await _ListAsync("metafields.json", filter, cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await _ListAsync("metafields.json", filter, cancellationToken); - /// - public virtual async Task> ListAsync(long resourceId, string resourceType, ListFilter filter, CancellationToken cancellationToken = default) => - await _ListAsync($"{resourceType.ToLower()}/{resourceId}/metafields.json", filter, cancellationToken); + /// + public virtual async Task> ListAsync(long resourceId, string resourceType, ListFilter filter, CancellationToken cancellationToken = default) => + await _ListAsync($"{resourceType.ToLower()}/{resourceId}/metafields.json", filter, cancellationToken); - /// - public virtual async Task> ListAsync(long resourceId, string resourceType, long parentResourceId, string parentResourceType, ListFilter filter, CancellationToken cancellationToken = default) => - await _ListAsync($"{parentResourceType.ToLower()}/{parentResourceId}/{resourceType.ToLower()}/{resourceId}/metafields.json", filter, cancellationToken); + /// + public virtual async Task> ListAsync(long resourceId, string resourceType, long parentResourceId, string parentResourceType, ListFilter filter, CancellationToken cancellationToken = default) => + await _ListAsync($"{parentResourceType.ToLower()}/{parentResourceId}/{resourceType.ToLower()}/{resourceId}/metafields.json", filter, cancellationToken); - /// - public virtual async Task> ListAsync(MetaFieldFilter filter = null, CancellationToken cancellationToken = default) => - await _ListAsync("metafields.json", filter, cancellationToken); + /// + public virtual async Task> ListAsync(MetaFieldFilter filter = null, CancellationToken cancellationToken = default) => + await _ListAsync("metafields.json", filter, cancellationToken); - /// - public virtual async Task> ListAsync(long resourceId, string resourceType, MetaFieldFilter filter = null, CancellationToken cancellationToken = default) => - await _ListAsync($"{resourceType.ToLower()}/{resourceId}/metafields.json", filter, cancellationToken); + /// + public virtual async Task> ListAsync(long resourceId, string resourceType, MetaFieldFilter filter = null, CancellationToken cancellationToken = default) => + await _ListAsync($"{resourceType.ToLower()}/{resourceId}/metafields.json", filter, cancellationToken); - /// - public virtual async Task> ListAsync(long resourceId, string resourceType, long parentResourceId, string parentResourceType, MetaFieldFilter filter = null, CancellationToken cancellationToken = default) => - await _ListAsync($"{parentResourceType.ToLower()}/{parentResourceId}/{resourceType.ToLower()}/{resourceId}/metafields.json", filter, cancellationToken); + /// + public virtual async Task> ListAsync(long resourceId, string resourceType, long parentResourceId, string parentResourceType, MetaFieldFilter filter = null, CancellationToken cancellationToken = default) => + await _ListAsync($"{parentResourceType.ToLower()}/{parentResourceId}/{resourceType.ToLower()}/{resourceId}/metafields.json", filter, cancellationToken); - /// - public virtual async Task GetAsync(long metafieldId, string fields = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"metafields/{metafieldId}.json", "metafield", fields, cancellationToken); + /// + public virtual async Task GetAsync(long metafieldId, string fields = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"metafields/{metafieldId}.json", "metafield", fields, cancellationToken); - /// - public virtual async Task CreateAsync(MetaField metafield, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(MetaField metafield, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("metafields.json"); + var content = new JsonContent(new { - var req = BuildRequestUri("metafields.json"); - var content = new JsonContent(new - { - metafield = metafield - }); - - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "metafield"); - return response.Result; - } - - /// - public virtual async Task CreateAsync(MetaField metafield, long resourceId, string resourceType, long parentResourceId, string parentResourceType, CancellationToken cancellationToken = default) + metafield = metafield + }); + + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "metafield"); + return response.Result; + } + + /// + public virtual async Task CreateAsync(MetaField metafield, long resourceId, string resourceType, long parentResourceId, string parentResourceType, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"{parentResourceType.ToLower()}/{parentResourceId}/{resourceType.ToLower()}/{resourceId}/metafields.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"{parentResourceType.ToLower()}/{parentResourceId}/{resourceType.ToLower()}/{resourceId}/metafields.json"); - var content = new JsonContent(new - { - metafield = metafield - }); - - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "metafield"); - return response.Result; - } - - /// - public virtual async Task CreateAsync(MetaField metafield, long resourceId, string resourceType, CancellationToken cancellationToken = default) + metafield = metafield + }); + + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "metafield"); + return response.Result; + } + + /// + public virtual async Task CreateAsync(MetaField metafield, long resourceId, string resourceType, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"{resourceType.ToLower()}/{resourceId}/metafields.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"{resourceType.ToLower()}/{resourceId}/metafields.json"); - var content = new JsonContent(new - { - metafield = metafield - }); - - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "metafield"); - return response.Result; - } - - /// - public virtual async Task UpdateAsync(long metafieldId, MetaField metafield, CancellationToken cancellationToken = default) + metafield = metafield + }); + + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "metafield"); + return response.Result; + } + + /// + public virtual async Task UpdateAsync(long metafieldId, MetaField metafield, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"metafields/{metafieldId}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"metafields/{metafieldId}.json"); - var content = new JsonContent(new - { - metafield = metafield - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "metafield"); + metafield = metafield + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "metafield"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task DeleteAsync(long metafieldId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"metafields/{metafieldId}.json"); + /// + public virtual async Task DeleteAsync(long metafieldId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"metafields/{metafieldId}.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); + } - private async Task _CountAsync(string path, CancellationToken cancellationToken) => - await ExecuteGetAsync(path, "count", cancellationToken: cancellationToken); + private async Task _CountAsync(string path, CancellationToken cancellationToken) => + await ExecuteGetAsync(path, "count", cancellationToken: cancellationToken); - private async Task> _ListAsync(string path, ListFilter filter, CancellationToken cancellationToken) => - await ExecuteGetListAsync(path, "metafields", filter, cancellationToken); - } + private async Task> _ListAsync(string path, ListFilter filter, CancellationToken cancellationToken) => + await ExecuteGetListAsync(path, "metafields", filter, cancellationToken); } \ No newline at end of file diff --git a/ShopifySharp/Services/Multipass/MultipassService.cs b/ShopifySharp/Services/Multipass/MultipassService.cs index f961b609..fc213a34 100644 --- a/ShopifySharp/Services/Multipass/MultipassService.cs +++ b/ShopifySharp/Services/Multipass/MultipassService.cs @@ -1,105 +1,104 @@ -using System; +using System; using System.IO; using System.Linq; using System.Security.Cryptography; using System.Text; using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public static class MultipassService { - public static class MultipassService + private const int FixedKeySize = 16; + + public static string GetMultipassUrl( + Customer userData, + string shopifyUrl, + string multipassSecret + ) { - private const int FixedKeySize = 16; + string validatedShopifyUrl = ValidateShopifyUrl(shopifyUrl); - public static string GetMultipassUrl( - Customer userData, - string shopifyUrl, - string multipassSecret - ) + if (userData == null) { - string validatedShopifyUrl = ValidateShopifyUrl(shopifyUrl); + throw new ShopifyException($"The given {nameof(userData)} is empty."); + } - if (userData == null) - { - throw new ShopifyException($"The given {nameof(userData)} is empty."); - } + if (string.IsNullOrEmpty(multipassSecret)) + { + throw new ShopifyException($"The given {nameof(multipassSecret)} is empty."); + } - if (string.IsNullOrEmpty(multipassSecret)) + string token = Encrypt( + JsonConvert.SerializeObject(userData, new JsonSerializerSettings() { - throw new ShopifyException($"The given {nameof(multipassSecret)} is empty."); - } - - string token = Encrypt( - JsonConvert.SerializeObject(userData, new JsonSerializerSettings() - { - NullValueHandling = NullValueHandling.Ignore - }), - multipassSecret - ); + NullValueHandling = NullValueHandling.Ignore + }), + multipassSecret + ); - return $"{validatedShopifyUrl}/account/login/multipass/{token}"; - } + return $"{validatedShopifyUrl}/account/login/multipass/{token}"; + } - private static string ValidateShopifyUrl(string shopifyUrl) + private static string ValidateShopifyUrl(string shopifyUrl) + { + // TODO: refactor this to use the domain utility + if (Uri.IsWellFormedUriString(shopifyUrl, UriKind.Absolute) == false) { - // TODO: refactor this to use the domain utility - if (Uri.IsWellFormedUriString(shopifyUrl, UriKind.Absolute) == false) + //Shopify typically returns the shop URL without a scheme. If the user is storing that as-is, the uri will not be well formed. + //Try to fix that by adding a scheme and checking again. + if (Uri.IsWellFormedUriString("https://" + shopifyUrl, UriKind.Absolute) == false) { - //Shopify typically returns the shop URL without a scheme. If the user is storing that as-is, the uri will not be well formed. - //Try to fix that by adding a scheme and checking again. - if (Uri.IsWellFormedUriString("https://" + shopifyUrl, UriKind.Absolute) == false) - { - throw new ShopifyException($"The given {nameof(shopifyUrl)} cannot be converted into a well-formed URI."); - } - - return "https://" + shopifyUrl; + throw new ShopifyException($"The given {nameof(shopifyUrl)} cannot be converted into a well-formed URI."); } - return shopifyUrl; + return "https://" + shopifyUrl; } - private static string Encrypt(string json, string multipassSecret) - { - byte[] hash = SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(multipassSecret)); - byte[] encryptionKey = new ArraySegment(hash, 0, FixedKeySize).ToArray(); - byte[] signatureKey = new ArraySegment(hash, FixedKeySize, FixedKeySize).ToArray(); + return shopifyUrl; + } - byte[] initVector = new byte[FixedKeySize]; - //change to more proper with .net standard 2.0 - //RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); - RandomNumberGenerator rng = RandomNumberGenerator.Create(); - rng.GetBytes(initVector); + private static string Encrypt(string json, string multipassSecret) + { + byte[] hash = SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(multipassSecret)); + byte[] encryptionKey = new ArraySegment(hash, 0, FixedKeySize).ToArray(); + byte[] signatureKey = new ArraySegment(hash, FixedKeySize, FixedKeySize).ToArray(); + + byte[] initVector = new byte[FixedKeySize]; + //change to more proper with .net standard 2.0 + //RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider(); + RandomNumberGenerator rng = RandomNumberGenerator.Create(); + rng.GetBytes(initVector); - byte[] cipherData = new Func((iv, key) => + byte[] cipherData = new Func((iv, key) => + { + byte[] encrypted; + using (Aes aes = Aes.Create()) { - byte[] encrypted; - using (Aes aes = Aes.Create()) - { - aes.Key = encryptionKey; - aes.IV = iv; - aes.Mode = CipherMode.CBC; + aes.Key = encryptionKey; + aes.IV = iv; + aes.Mode = CipherMode.CBC; - ICryptoTransform encryptor = aes.CreateEncryptor(aes.Key, aes.IV); - using (MemoryStream ms = new MemoryStream()) + ICryptoTransform encryptor = aes.CreateEncryptor(aes.Key, aes.IV); + using (MemoryStream ms = new MemoryStream()) + { + using (CryptoStream cs = new CryptoStream(ms, encryptor, CryptoStreamMode.Write)) { - using (CryptoStream cs = new CryptoStream(ms, encryptor, CryptoStreamMode.Write)) + using (StreamWriter sw = new StreamWriter(cs)) { - using (StreamWriter sw = new StreamWriter(cs)) - { - sw.Write(json); - } - - encrypted = ms.ToArray(); + sw.Write(json); } + + encrypted = ms.ToArray(); } } - return encrypted; - })(initVector, encryptionKey); - byte[] cipher = initVector.Concat(cipherData).ToArray(); - byte[] signature = new HMACSHA256(signatureKey).ComputeHash(cipher); - return Convert.ToBase64String(cipher.Concat(signature).ToArray()) - .Replace("+", "-") - .Replace("/", "_"); - } + } + return encrypted; + })(initVector, encryptionKey); + byte[] cipher = initVector.Concat(cipherData).ToArray(); + byte[] signature = new HMACSHA256(signatureKey).ComputeHash(cipher); + return Convert.ToBase64String(cipher.Concat(signature).ToArray()) + .Replace("+", "-") + .Replace("/", "_"); } -} +} \ No newline at end of file diff --git a/ShopifySharp/Services/Order/IOrderService.cs b/ShopifySharp/Services/Order/IOrderService.cs index d5274fe9..100a50cd 100644 --- a/ShopifySharp/Services/Order/IOrderService.cs +++ b/ShopifySharp/Services/Order/IOrderService.cs @@ -4,96 +4,95 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IOrderService : IShopifyService { - public interface IOrderService : IShopifyService - { - /// - /// Gets a count of all of the shop's orders. - /// - /// Options for filtering the count. - /// Cancellation Token - /// The count of all orders for the shop. - Task CountAsync(OrderCountFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a count of all of the shop's orders. + /// + /// Options for filtering the count. + /// Cancellation Token + /// The count of all orders for the shop. + Task CountAsync(OrderCountFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the shop's orders. - /// - /// Options for filtering the list. - /// Cancellation Token - /// The list of orders matching the filter. - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's orders. + /// + /// Options for filtering the list. + /// Cancellation Token + /// The list of orders matching the filter. + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the shop's orders. - /// - /// Options for filtering the list. - /// Cancellation Token - /// The list of orders matching the filter. - Task> ListAsync(OrderListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's orders. + /// + /// Options for filtering the list. + /// Cancellation Token + /// The list of orders matching the filter. + Task> ListAsync(OrderListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the order to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long orderId, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the order to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long orderId, string fields = null, CancellationToken cancellationToken = default); - /// - /// Closes an order. - /// - /// The order's id. - /// Cancellation Token - Task CloseAsync(long id, CancellationToken cancellationToken = default); + /// + /// Closes an order. + /// + /// The order's id. + /// Cancellation Token + Task CloseAsync(long id, CancellationToken cancellationToken = default); - /// - /// Opens a closed order. - /// - /// The order's id. - /// Cancellation Token - Task OpenAsync(long id, CancellationToken cancellationToken = default); + /// + /// Opens a closed order. + /// + /// The order's id. + /// Cancellation Token + Task OpenAsync(long id, CancellationToken cancellationToken = default); - /// - /// Creates a new on the store. - /// - /// A new . Id should be set to null. - /// Options for creating the order. - /// Cancellation Token - /// The new . - Task CreateAsync(Order order, OrderCreateOptions options = null, CancellationToken cancellationToken = default); + /// + /// Creates a new on the store. + /// + /// A new . Id should be set to null. + /// Options for creating the order. + /// Cancellation Token + /// The new . + Task CreateAsync(Order order, OrderCreateOptions options = null, CancellationToken cancellationToken = default); - /// - /// Updates the given . - /// - /// Id of the object being updated. - /// The to update. - /// Cancellation Token - /// The updated . - Task UpdateAsync(long orderId, Order order, CancellationToken cancellationToken = default); + /// + /// Updates the given . + /// + /// Id of the object being updated. + /// The to update. + /// Cancellation Token + /// The updated . + Task UpdateAsync(long orderId, Order order, CancellationToken cancellationToken = default); - /// - /// Deletes an order with the given Id. - /// - /// The order object's Id. - /// Cancellation Token - Task DeleteAsync(long orderId, CancellationToken cancellationToken = default); + /// + /// Deletes an order with the given Id. + /// + /// The order object's Id. + /// Cancellation Token + Task DeleteAsync(long orderId, CancellationToken cancellationToken = default); - /// - /// Cancels an order. - /// - /// The order's id. - /// Cancellation Token - /// The cancelled . - Task CancelAsync(long orderId, OrderCancelOptions options = null, CancellationToken cancellationToken = default); + /// + /// Cancels an order. + /// + /// The order's id. + /// Cancellation Token + /// The cancelled . + Task CancelAsync(long orderId, OrderCancelOptions options = null, CancellationToken cancellationToken = default); - /// - /// Get MetaField's for an order. - /// - /// The order's id. - /// Cancellation Token - /// The set of for the order. - Task> GetMetaFieldsAsync(long orderId, CancellationToken cancellationToken = default); - } + /// + /// Get MetaField's for an order. + /// + /// The order's id. + /// Cancellation Token + /// The set of for the order. + Task> GetMetaFieldsAsync(long orderId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Order/OrderCancelOptions.cs b/ShopifySharp/Services/Order/OrderCancelOptions.cs index 5a4600d1..25869e2e 100644 --- a/ShopifySharp/Services/Order/OrderCancelOptions.cs +++ b/ShopifySharp/Services/Order/OrderCancelOptions.cs @@ -1,41 +1,40 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class OrderCancelOptions { - public class OrderCancelOptions - { - /// - /// Amount to refund (decimal ex: 21.20). - /// If set, Shopify will attempt to void/refund the payment depending on the status. - /// - [JsonProperty("amount")] - public decimal? RefundAmount { get; set; } + /// + /// Amount to refund (decimal ex: 21.20). + /// If set, Shopify will attempt to void/refund the payment depending on the status. + /// + [JsonProperty("amount")] + public decimal? RefundAmount { get; set; } - /// - /// The three letter code (ISO 4217) for the currency used for the refund. - /// The currency of the refund that's issued when the order is canceled. - /// Required for multi-currency orders whenever the `amount` property is provided. - /// - [JsonProperty("currency")] - public string Currency { get; set; } + /// + /// The three letter code (ISO 4217) for the currency used for the refund. + /// The currency of the refund that's issued when the order is canceled. + /// Required for multi-currency orders whenever the `amount` property is provided. + /// + [JsonProperty("currency")] + public string Currency { get; set; } - /// - /// Restock the items for this order back to your store. - /// - [JsonProperty("restock")] - public bool? Restock { get; set; } + /// + /// Restock the items for this order back to your store. + /// + [JsonProperty("restock")] + public bool? Restock { get; set; } - /// - /// The reason for the order cancellation - /// Must be: customer, inventory, fraud or other. - /// - [JsonProperty("reason")] - public string Reason { get; set; } + /// + /// The reason for the order cancellation + /// Must be: customer, inventory, fraud or other. + /// + [JsonProperty("reason")] + public string Reason { get; set; } - /// - /// Send an email to the customer notifying them of the cancellation. - /// - [JsonProperty("email")] - public bool? SendCancellationReceipt { get; set; } - } -} + /// + /// Send an email to the customer notifying them of the cancellation. + /// + [JsonProperty("email")] + public bool? SendCancellationReceipt { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Services/Order/OrderCreateOptions.cs b/ShopifySharp/Services/Order/OrderCreateOptions.cs index 49ca3410..93f61cbf 100644 --- a/ShopifySharp/Services/Order/OrderCreateOptions.cs +++ b/ShopifySharp/Services/Order/OrderCreateOptions.cs @@ -1,22 +1,21 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class OrderCreateOptions : Parameterizable { - public class OrderCreateOptions : Parameterizable - { - [JsonProperty("send_webhooks")] - public bool? SendWebhooks { get; set; } + [JsonProperty("send_webhooks")] + public bool? SendWebhooks { get; set; } - [JsonProperty("send_receipt")] - public bool? SendReceipt { get; set; } + [JsonProperty("send_receipt")] + public bool? SendReceipt { get; set; } - [JsonProperty("send_fulfillment_receipt")] - public bool? SendFulfillmentReceipt { get; set; } + [JsonProperty("send_fulfillment_receipt")] + public bool? SendFulfillmentReceipt { get; set; } - /// - /// The inventory behavior for the order. Known values are 'bypass', 'decrement_ignoring_policy' and 'decrement_obeying_policy'. - /// - [JsonProperty("inventory_behaviour")] - public string InventoryBehavior { get; set; } - } -} + /// + /// The inventory behavior for the order. Known values are 'bypass', 'decrement_ignoring_policy' and 'decrement_obeying_policy'. + /// + [JsonProperty("inventory_behaviour")] + public string InventoryBehavior { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Services/Order/OrderService.cs b/ShopifySharp/Services/Order/OrderService.cs index a5ee16bc..c86f589f 100644 --- a/ShopifySharp/Services/Order/OrderService.cs +++ b/ShopifySharp/Services/Order/OrderService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Collections.Generic; @@ -7,116 +7,115 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify orders. +/// +public class OrderService : ShopifyService, IOrderService { /// - /// A service for manipulating Shopify orders. + /// Creates a new instance of . /// - public class OrderService : ShopifyService, IOrderService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public OrderService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public OrderService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal OrderService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + internal OrderService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CountAsync(OrderCountFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync("orders/count.json", "count", filter, cancellationToken); + /// + public virtual async Task CountAsync(OrderCountFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync("orders/count.json", "count", filter, cancellationToken); - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("orders.json", "orders", filter, cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("orders.json", "orders", filter, cancellationToken); - /// - public virtual async Task> ListAsync(OrderListFilter filter = null, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListAsync(OrderListFilter filter = null, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task GetAsync(long orderId, string fields = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"orders/{orderId}.json", "order", fields, cancellationToken); + /// + public virtual async Task GetAsync(long orderId, string fields = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"orders/{orderId}.json", "order", fields, cancellationToken); - /// - public virtual async Task CloseAsync(long id, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"orders/{id}/close.json"); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "order"); + /// + public virtual async Task CloseAsync(long id, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"orders/{id}/close.json"); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "order"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task OpenAsync(long id, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"orders/{id}/open.json"); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "order"); + /// + public virtual async Task OpenAsync(long id, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"orders/{id}/open.json"); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, rootElement: "order"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task CreateAsync(Order order, OrderCreateOptions options = null, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri("orders.json"); - var body = order.ToDictionary(); + /// + public virtual async Task CreateAsync(Order order, OrderCreateOptions options = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("orders.json"); + var body = order.ToDictionary(); - if (options != null) + if (options != null) + { + foreach (var option in options.ToDictionary()) { - foreach (var option in options.ToDictionary()) - { - body.Add(option); - } + body.Add(option); } - - var content = new JsonContent(new - { - order = body - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "order"); - - return response.Result; } - /// - public virtual async Task UpdateAsync(long orderId, Order order, CancellationToken cancellationToken = default) + var content = new JsonContent(new { - var req = BuildRequestUri($"orders/{orderId}.json"); - var content = new JsonContent(new - { - order = order - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "order"); + order = body + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "order"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task DeleteAsync(long orderId, CancellationToken cancellationToken = default) + /// + public virtual async Task UpdateAsync(long orderId, Order order, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"orders/{orderId}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"orders/{orderId}.json"); + order = order + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "order"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + return response.Result; + } - /// - public virtual async Task CancelAsync(long orderId, OrderCancelOptions options = null, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"orders/{orderId}/cancel.json"); - var content = new JsonContent(options ?? new OrderCancelOptions()); + /// + public virtual async Task DeleteAsync(long orderId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"orders/{orderId}.json"); - await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); + } - /// - public virtual async Task> GetMetaFieldsAsync(long orderId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"orders/{orderId}/metafields.json"); - var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "metafields"); + /// + public virtual async Task CancelAsync(long orderId, OrderCancelOptions options = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"orders/{orderId}/cancel.json"); + var content = new JsonContent(options ?? new OrderCancelOptions()); - return response.Result; - } + await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content); + } + + /// + public virtual async Task> GetMetaFieldsAsync(long orderId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"orders/{orderId}/metafields.json"); + var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "metafields"); + + return response.Result; } -} +} \ No newline at end of file diff --git a/ShopifySharp/Services/OrderRisk/IOrderRiskService.cs b/ShopifySharp/Services/OrderRisk/IOrderRiskService.cs index 503ace51..b8c60570 100644 --- a/ShopifySharp/Services/OrderRisk/IOrderRiskService.cs +++ b/ShopifySharp/Services/OrderRisk/IOrderRiskService.cs @@ -3,49 +3,48 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IOrderRiskService : IShopifyService { - public interface IOrderRiskService : IShopifyService - { - /// - /// Gets a list of all order risks for an order. - /// - /// The order the risks belong to. - /// Options for filtering the request. - /// Cancellation Token - Task> ListAsync(long orderId, ListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of all order risks for an order. + /// + /// The order the risks belong to. + /// Options for filtering the request. + /// Cancellation Token + Task> ListAsync(long orderId, ListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The order the risk belongs to. - /// The id of the risk to retrieve. - /// Cancellation Token - Task GetAsync(long orderId, long riskId, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The order the risk belongs to. + /// The id of the risk to retrieve. + /// Cancellation Token + Task GetAsync(long orderId, long riskId, CancellationToken cancellationToken = default); - /// - /// Creates a new on the order. - /// - /// The order the risk belongs to. - /// A new . Id should be set to null. - /// Cancellation Token - Task CreateAsync(long orderId, OrderRisk risk, CancellationToken cancellationToken = default); + /// + /// Creates a new on the order. + /// + /// The order the risk belongs to. + /// A new . Id should be set to null. + /// Cancellation Token + Task CreateAsync(long orderId, OrderRisk risk, CancellationToken cancellationToken = default); - /// - /// Updates the given . - /// - /// Id of the object being updated. - /// The order the risk belongs to. - /// The risk to update. - /// Cancellation Token - Task UpdateAsync(long orderId, long orderRiskId, OrderRisk risk, CancellationToken cancellationToken = default); + /// + /// Updates the given . + /// + /// Id of the object being updated. + /// The order the risk belongs to. + /// The risk to update. + /// Cancellation Token + Task UpdateAsync(long orderId, long orderRiskId, OrderRisk risk, CancellationToken cancellationToken = default); - /// - /// Deletes an order with the given Id. - /// - /// The order the risk belongs to. - /// The risk's id. - /// Cancellation Token - Task DeleteAsync(long orderId, long riskId, CancellationToken cancellationToken = default); - } + /// + /// Deletes an order with the given Id. + /// + /// The order the risk belongs to. + /// The risk's id. + /// Cancellation Token + Task DeleteAsync(long orderId, long riskId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/OrderRisk/OrderRiskService.cs b/ShopifySharp/Services/OrderRisk/OrderRiskService.cs index 17d61298..90625c76 100644 --- a/ShopifySharp/Services/OrderRisk/OrderRiskService.cs +++ b/ShopifySharp/Services/OrderRisk/OrderRiskService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Net.Http; @@ -7,61 +7,60 @@ using ShopifySharp.Utilities; using System; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify order risks. +/// +[Obsolete("https://shopify.dev/docs/api/release-notes/2024-04#AccordionItem85")] +public class OrderRiskService : ShopifyService, IOrderRiskService { /// - /// A service for manipulating Shopify order risks. + /// Creates a new instance of . /// - [Obsolete("https://shopify.dev/docs/api/release-notes/2024-04#AccordionItem85")] - public class OrderRiskService : ShopifyService, IOrderRiskService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public OrderRiskService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public OrderRiskService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal OrderRiskService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + internal OrderRiskService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(long orderId, ListFilter filter = null, CancellationToken cancellationToken = default) => await ExecuteGetListAsync($"orders/{orderId}/risks.json", "risks", filter, cancellationToken); + /// + public virtual async Task> ListAsync(long orderId, ListFilter filter = null, CancellationToken cancellationToken = default) => await ExecuteGetListAsync($"orders/{orderId}/risks.json", "risks", filter, cancellationToken); - /// - public virtual async Task GetAsync(long orderId, long riskId, CancellationToken cancellationToken = default) => await ExecuteGetAsync($"orders/{orderId}/risks/{riskId}.json", "risk", cancellationToken: cancellationToken); + /// + public virtual async Task GetAsync(long orderId, long riskId, CancellationToken cancellationToken = default) => await ExecuteGetAsync($"orders/{orderId}/risks/{riskId}.json", "risk", cancellationToken: cancellationToken); - /// - public virtual async Task CreateAsync(long orderId, OrderRisk risk, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(long orderId, OrderRisk risk, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"orders/{orderId}/risks.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"orders/{orderId}/risks.json"); - var content = new JsonContent(new - { - risk = risk - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "risk"); + risk = risk + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "risk"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task UpdateAsync(long orderId, long orderRiskId, OrderRisk risk, CancellationToken cancellationToken = default) + /// + public virtual async Task UpdateAsync(long orderId, long orderRiskId, OrderRisk risk, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"orders/{orderId}/risks/{orderRiskId}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"orders/{orderId}/risks/{orderRiskId}.json"); - var content = new JsonContent(new - { - risk = risk - }); + risk = risk + }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "risk"); - return response.Result; - } + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "risk"); + return response.Result; + } - /// - public virtual async Task DeleteAsync(long orderId, long riskId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"orders/{orderId}/risks/{riskId}.json"); + /// + public virtual async Task DeleteAsync(long orderId, long riskId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"orders/{orderId}/risks/{riskId}.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); } -} +} \ No newline at end of file diff --git a/ShopifySharp/Services/Page/IPageService.cs b/ShopifySharp/Services/Page/IPageService.cs index ea4515b5..9e55dc4c 100644 --- a/ShopifySharp/Services/Page/IPageService.cs +++ b/ShopifySharp/Services/Page/IPageService.cs @@ -3,57 +3,56 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IPageService : IShopifyService { - public interface IPageService : IShopifyService - { - /// - /// Gets a count of all of the shop's pages. - /// - Task CountAsync(PageCountFilter filter = null, CancellationToken cancellationToken = default); - - /// - /// Gets a list of up to 250 of the shop's pages. - /// - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - - /// - /// Gets a list of up to 250 of the shop's pages. - /// - Task> ListAsync(PageListFilter filter = null, CancellationToken cancellationToken = default); - - /// - /// Retrieves the with the given id. - /// - /// The id of the page to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long pageId, string fields = null, CancellationToken cancellationToken = default); - - /// - /// Creates a new on the store. - /// - /// A new . Id should be set to null. - /// Options for creating the page. - /// Cancellation Token - /// The new . - Task CreateAsync(Page page, PageCreateOptions options = null, CancellationToken cancellationToken = default); - - /// - /// Updates the given . - /// - /// Id of the object being updated. - /// The to update. - /// Cancellation Token - /// The updated . - Task UpdateAsync(long pageId, Page page, CancellationToken cancellationToken = default); - - /// - /// Deletes a page with the given Id. - /// - /// The page object's Id. - /// Cancellation Token - Task DeleteAsync(long pageId, CancellationToken cancellationToken = default); - } + /// + /// Gets a count of all of the shop's pages. + /// + Task CountAsync(PageCountFilter filter = null, CancellationToken cancellationToken = default); + + /// + /// Gets a list of up to 250 of the shop's pages. + /// + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + + /// + /// Gets a list of up to 250 of the shop's pages. + /// + Task> ListAsync(PageListFilter filter = null, CancellationToken cancellationToken = default); + + /// + /// Retrieves the with the given id. + /// + /// The id of the page to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long pageId, string fields = null, CancellationToken cancellationToken = default); + + /// + /// Creates a new on the store. + /// + /// A new . Id should be set to null. + /// Options for creating the page. + /// Cancellation Token + /// The new . + Task CreateAsync(Page page, PageCreateOptions options = null, CancellationToken cancellationToken = default); + + /// + /// Updates the given . + /// + /// Id of the object being updated. + /// The to update. + /// Cancellation Token + /// The updated . + Task UpdateAsync(long pageId, Page page, CancellationToken cancellationToken = default); + + /// + /// Deletes a page with the given Id. + /// + /// The page object's Id. + /// Cancellation Token + Task DeleteAsync(long pageId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Page/PageCreateOptions.cs b/ShopifySharp/Services/Page/PageCreateOptions.cs index 1ba77a0c..a8c2fdba 100644 --- a/ShopifySharp/Services/Page/PageCreateOptions.cs +++ b/ShopifySharp/Services/Page/PageCreateOptions.cs @@ -1,10 +1,9 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class PageCreateOptions : Parameterizable { - public class PageCreateOptions : Parameterizable - { - [JsonProperty("published")] - public bool? Published { get; set; } - } -} + [JsonProperty("published")] + public bool? Published { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Services/Page/PageService.cs b/ShopifySharp/Services/Page/PageService.cs index efe826fd..77c328cd 100644 --- a/ShopifySharp/Services/Page/PageService.cs +++ b/ShopifySharp/Services/Page/PageService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Net.Http; @@ -6,90 +6,89 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify pages. +/// +public class PageService : ShopifyService, IPageService { /// - /// A service for manipulating Shopify pages. + /// Creates a new instance of . /// - public class PageService : ShopifyService, IPageService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public PageService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal PageService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public PageService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal PageService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CountAsync(PageCountFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync("pages/count.json", "count", filter, cancellationToken); + /// + public virtual async Task CountAsync(PageCountFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync("pages/count.json", "count", filter, cancellationToken); + + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("pages.json", "pages", filter, cancellationToken); - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("pages.json", "pages", filter, cancellationToken); + /// + public virtual async Task> ListAsync(PageListFilter filter = null, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task> ListAsync(PageListFilter filter = null, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task GetAsync(long pageId, string fields = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"pages/{pageId}.json"); - /// - public virtual async Task GetAsync(long pageId, string fields = null, CancellationToken cancellationToken = default) + if (!string.IsNullOrEmpty(fields)) { - var req = BuildRequestUri($"pages/{pageId}.json"); + req.QueryParams.Add("fields", fields); + } - if (!string.IsNullOrEmpty(fields)) - { - req.QueryParams.Add("fields", fields); - } + var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "page"); - var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "page"); + return response.Result; + } - return response.Result; - } + /// + public virtual async Task CreateAsync(Page page, PageCreateOptions options = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("pages.json"); + var body = page.ToDictionary(); - /// - public virtual async Task CreateAsync(Page page, PageCreateOptions options = null, CancellationToken cancellationToken = default) + if (options != null) { - var req = BuildRequestUri("pages.json"); - var body = page.ToDictionary(); - - if (options != null) + foreach (var option in options.ToDictionary()) { - foreach (var option in options.ToDictionary()) - { - body.Add(option); - } + body.Add(option); } - - var content = new JsonContent(new - { - page = body - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "page"); - - return response.Result; } - /// - public virtual async Task UpdateAsync(long pageId, Page page, CancellationToken cancellationToken = default) + var content = new JsonContent(new { - var req = BuildRequestUri($"pages/{pageId}.json"); - var content = new JsonContent(new - { - page = page - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "page"); + page = body + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "page"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task DeleteAsync(long pageId, CancellationToken cancellationToken = default) + /// + public virtual async Task UpdateAsync(long pageId, Page page, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"pages/{pageId}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"pages/{pageId}.json"); + page = page + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "page"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + return response.Result; + } + + /// + public virtual async Task DeleteAsync(long pageId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"pages/{pageId}.json"); + + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); } } \ No newline at end of file diff --git a/ShopifySharp/Services/Partner/IPartnerService.cs b/ShopifySharp/Services/Partner/IPartnerService.cs index 0b736338..1a00f3e7 100644 --- a/ShopifySharp/Services/Partner/IPartnerService.cs +++ b/ShopifySharp/Services/Partner/IPartnerService.cs @@ -2,16 +2,15 @@ using System.Threading.Tasks; using Newtonsoft.Json.Linq; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IPartnerService : IShopifyService { - public interface IPartnerService : IShopifyService - { - /// - /// Executes a Graph API Call. - /// - /// The query you would like to execute. Please see documentation for formatting. - /// Cancellation Token - /// A JToken containing the data from the request. - Task PostAsync(string body, CancellationToken cancellationToken = default); - } + /// + /// Executes a Graph API Call. + /// + /// The query you would like to execute. Please see documentation for formatting. + /// Cancellation Token + /// A JToken containing the data from the request. + Task PostAsync(string body, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Partner/PartnerService.cs b/ShopifySharp/Services/Partner/PartnerService.cs index f74ea196..909ade99 100644 --- a/ShopifySharp/Services/Partner/PartnerService.cs +++ b/ShopifySharp/Services/Partner/PartnerService.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json.Linq; +using Newtonsoft.Json.Linq; using ShopifySharp.Infrastructure; using System.Collections.Generic; using System.Linq; @@ -10,70 +10,69 @@ using System; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service to query the GraphQL Partner API +/// See https://shopify.dev/api/partner +/// +public class PartnerService : ShopifyService, IPartnerService { - /// - /// A service to query the GraphQL Partner API - /// See https://shopify.dev/api/partner - /// - public class PartnerService : ShopifyService, IPartnerService + private readonly long _organizationId; + private readonly string _apiVersion; + + public override string APIVersion => _apiVersion ?? base.APIVersion; + + public PartnerService(long organizationId, string accessToken, string apiVersion = null) : base("partners.shopify.com", accessToken) { - private readonly long _organizationId; - private readonly string _apiVersion; + _organizationId = organizationId; + _apiVersion = apiVersion; + } - public override string APIVersion => _apiVersion ?? base.APIVersion; + public PartnerService(long organizationId, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base("partners.shopify.com", accessToken, shopifyDomainUtility) + { + _organizationId = organizationId; + } - public PartnerService(long organizationId, string accessToken, string apiVersion = null) : base("partners.shopify.com", accessToken) - { - _organizationId = organizationId; - _apiVersion = apiVersion; - } + /// + public virtual async Task PostAsync(string body, CancellationToken cancellationToken = default) + { + var req = new RequestUri(new Uri($"https://partners.shopify.com/{_organizationId}/api/{APIVersion}/graphql.json")); + var content = new StringContent(body, Encoding.UTF8, "application/graphql"); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content); + CheckForErrors(response); + return response.Result["data"]; + } - public PartnerService(long organizationId, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base("partners.shopify.com", accessToken, shopifyDomainUtility) + /// + /// Since Graph API Errors come back with error code 200, checking for them in a way similar to the REST API + /// doesn't work well without potentially throwing unnecessary errors. This loses the requestId, but otherwise + /// is capable of passing along the message. + /// + /// The RequestResult{JToken} response from ExecuteRequestAsync. + /// Thrown if contains an error. + private static void CheckForErrors(RequestResult requestResult) + { + if (requestResult.Result["errors"] is null) { - _organizationId = organizationId; + return; } - /// - public virtual async Task PostAsync(string body, CancellationToken cancellationToken = default) - { - var req = new RequestUri(new Uri($"https://partners.shopify.com/{_organizationId}/api/{APIVersion}/graphql.json")); - var content = new StringContent(body, Encoding.UTF8, "application/graphql"); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content); - CheckForErrors(response); - return response.Result["data"]; - } + var requestId = ParseRequestIdResponseHeader(requestResult.ResponseHeaders); + var errorList = new List(); - /// - /// Since Graph API Errors come back with error code 200, checking for them in a way similar to the REST API - /// doesn't work well without potentially throwing unnecessary errors. This loses the requestId, but otherwise - /// is capable of passing along the message. - /// - /// The RequestResult{JToken} response from ExecuteRequestAsync. - /// Thrown if contains an error. - private static void CheckForErrors(RequestResult requestResult) + foreach (var error in requestResult.Result["errors"]) { - if (requestResult.Result["errors"] is null) - { - return; - } - - var requestId = ParseRequestIdResponseHeader(requestResult.ResponseHeaders); - var errorList = new List(); + var errorMessage = error["message"]; - foreach (var error in requestResult.Result["errors"]) + if (errorMessage is not null) { - var errorMessage = error["message"]; - - if (errorMessage is not null) - { - errorList.Add(errorMessage.ToString()); - } + errorList.Add(errorMessage.ToString()); } + } - var message = errorList.FirstOrDefault() ?? "Unable to parse Shopify's error response, please inspect exception's RawBody property and report this issue to the ShopifySharp maintainers."; + var message = errorList.FirstOrDefault() ?? "Unable to parse Shopify's error response, please inspect exception's RawBody property and report this issue to the ShopifySharp maintainers."; - throw new ShopifyHttpException(requestResult.RequestInfo, HttpStatusCode.OK, errorList, message, requestResult.RawResult, requestId); - } + throw new ShopifyHttpException(requestResult.RequestInfo, HttpStatusCode.OK, errorList, message, requestResult.RawResult, requestId); } -} +} \ No newline at end of file diff --git a/ShopifySharp/Services/Policy/IPolicyService.cs b/ShopifySharp/Services/Policy/IPolicyService.cs index d99e305e..82da0a59 100644 --- a/ShopifySharp/Services/Policy/IPolicyService.cs +++ b/ShopifySharp/Services/Policy/IPolicyService.cs @@ -2,13 +2,12 @@ using System.Threading; using System.Threading.Tasks; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IPolicyService : IShopifyService { - public interface IPolicyService : IShopifyService - { - /// - /// Get the policies and their contents for a shop - /// - Task> ListAsync(CancellationToken cancellationToken = default); - } + /// + /// Get the policies and their contents for a shop + /// + Task> ListAsync(CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Policy/PolicyService.cs b/ShopifySharp/Services/Policy/PolicyService.cs index 72dce461..1d616160 100644 --- a/ShopifySharp/Services/Policy/PolicyService.cs +++ b/ShopifySharp/Services/Policy/PolicyService.cs @@ -1,28 +1,27 @@ -using System.Collections.Generic; +using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +public class PolicyService : ShopifyService, IPolicyService { - public class PolicyService : ShopifyService, IPolicyService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public PolicyService(string myShopifyUrl, string shopAccessToken): base(myShopifyUrl, shopAccessToken) { } - internal PolicyService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// + /// Creates a new instance of . + /// + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public PolicyService(string myShopifyUrl, string shopAccessToken): base(myShopifyUrl, shopAccessToken) { } + internal PolicyService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(CancellationToken cancellationToken = default) - { - var request = BuildRequestUri("policies.json"); - var response = await ExecuteRequestAsync>(request, HttpMethod.Get, cancellationToken, rootElement: "policies"); + /// + public virtual async Task> ListAsync(CancellationToken cancellationToken = default) + { + var request = BuildRequestUri("policies.json"); + var response = await ExecuteRequestAsync>(request, HttpMethod.Get, cancellationToken, rootElement: "policies"); - return response.Result; - } + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/PriceRule/IPriceRuleService.cs b/ShopifySharp/Services/PriceRule/IPriceRuleService.cs index 65ebff30..3049412d 100644 --- a/ShopifySharp/Services/PriceRule/IPriceRuleService.cs +++ b/ShopifySharp/Services/PriceRule/IPriceRuleService.cs @@ -3,48 +3,47 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IPriceRuleService : IShopifyService { - public interface IPriceRuleService : IShopifyService - { - /// - /// Gets a list of up to 250 of the shop's price rules. - /// - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's price rules. + /// + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the shop's price rules. - /// - Task> ListAsync(PriceRuleListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's price rules. + /// + Task> ListAsync(PriceRuleListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Retrieves the object with the given id. - /// - /// The id of the object to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the object with the given id. + /// + /// The id of the object to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default); - /// - /// Creates a new price rule. - /// - /// A new price rule. Id should be set to null. - /// Cancellation Token - Task CreateAsync(PriceRule rule, CancellationToken cancellationToken = default); + /// + /// Creates a new price rule. + /// + /// A new price rule. Id should be set to null. + /// Cancellation Token + Task CreateAsync(PriceRule rule, CancellationToken cancellationToken = default); - /// - /// Updates the given object. - /// - /// Id of the object being updated. - /// The updated rule. - /// Cancellation Token - Task UpdateAsync(long id, PriceRule rule, CancellationToken cancellationToken = default); + /// + /// Updates the given object. + /// + /// Id of the object being updated. + /// The updated rule. + /// Cancellation Token + Task UpdateAsync(long id, PriceRule rule, CancellationToken cancellationToken = default); - /// - /// Deletes the object with the given Id. - /// - /// The object's Id. - /// Cancellation Token - Task DeleteAsync(long id, CancellationToken cancellationToken = default); - } + /// + /// Deletes the object with the given Id. + /// + /// The object's Id. + /// Cancellation Token + Task DeleteAsync(long id, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/PriceRule/PriceRuleService.cs b/ShopifySharp/Services/PriceRule/PriceRuleService.cs index 4b7962cf..9e4d272a 100644 --- a/ShopifySharp/Services/PriceRule/PriceRuleService.cs +++ b/ShopifySharp/Services/PriceRule/PriceRuleService.cs @@ -6,78 +6,77 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify price rules. +/// +public class PriceRuleService : ShopifyService, IPriceRuleService { - /// - /// A service for manipulating Shopify price rules. - /// - public class PriceRuleService : ShopifyService, IPriceRuleService - { - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public PriceRuleService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal PriceRuleService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public PriceRuleService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal PriceRuleService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) - { - return await ExecuteGetListAsync("price_rules.json", "price_rules", filter, cancellationToken); - } + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) + { + return await ExecuteGetListAsync("price_rules.json", "price_rules", filter, cancellationToken); + } - /// - public virtual async Task> ListAsync(PriceRuleListFilter filter = null, CancellationToken cancellationToken = default) - { - return await ListAsync(filter?.AsListFilter(), cancellationToken); - } + /// + public virtual async Task> ListAsync(PriceRuleListFilter filter = null, CancellationToken cancellationToken = default) + { + return await ListAsync(filter?.AsListFilter(), cancellationToken); + } - /// - public virtual async Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"price_rules/{id}.json"); + /// + public virtual async Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"price_rules/{id}.json"); - if (!string.IsNullOrEmpty(fields)) - { - req.QueryParams.Add("fields", fields); - } + if (!string.IsNullOrEmpty(fields)) + { + req.QueryParams.Add("fields", fields); + } - var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "price_rule"); + var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "price_rule"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task CreateAsync(PriceRule rule, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(PriceRule rule, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("price_rules.json"); + var body = rule.ToDictionary(); + var content = new JsonContent(new { - var req = BuildRequestUri("price_rules.json"); - var body = rule.ToDictionary(); - var content = new JsonContent(new - { - price_rule = body - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "price_rule"); + price_rule = body + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "price_rule"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task UpdateAsync(long id, PriceRule rule, CancellationToken cancellationToken = default) + /// + public virtual async Task UpdateAsync(long id, PriceRule rule, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"price_rules/{id}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"price_rules/{id}.json"); - var content = new JsonContent(new - { - price_rule = rule - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "price_rule"); + price_rule = rule + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "price_rule"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task DeleteAsync(long id, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"price_rules/{id}.json"); + /// + public virtual async Task DeleteAsync(long id, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"price_rules/{id}.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); } } \ No newline at end of file diff --git a/ShopifySharp/Services/Product/IProductService.cs b/ShopifySharp/Services/Product/IProductService.cs index 339558cb..bf5d2042 100644 --- a/ShopifySharp/Services/Product/IProductService.cs +++ b/ShopifySharp/Services/Product/IProductService.cs @@ -3,74 +3,73 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IProductService : IShopifyService { - public interface IProductService : IShopifyService - { - /// - /// Gets a count of all of the shop's products. - /// - /// The count of all products for the shop. - Task CountAsync(ProductCountFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a count of all of the shop's products. + /// + /// The count of all products for the shop. + Task CountAsync(ProductCountFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the shop's products. - /// - Task> ListAsync(ListFilter filter, bool includePresentmentPrices = false, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's products. + /// + Task> ListAsync(ListFilter filter, bool includePresentmentPrices = false, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the shop's products. - /// - Task> ListAsync(ProductListFilter filter = null, bool includePresentmentPrices = false, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's products. + /// + Task> ListAsync(ProductListFilter filter = null, bool includePresentmentPrices = false, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the product to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long productId, string fields = null, bool includePresentmentPrices = false, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the product to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long productId, string fields = null, bool includePresentmentPrices = false, CancellationToken cancellationToken = default); - /// - /// Creates a new on the store. - /// - /// A new . Id should be set to null. - /// Options for creating the product. - /// Cancellation Token - /// The new . - Task CreateAsync(Product product, ProductCreateOptions options = null, CancellationToken cancellationToken = default); + /// + /// Creates a new on the store. + /// + /// A new . Id should be set to null. + /// Options for creating the product. + /// Cancellation Token + /// The new . + Task CreateAsync(Product product, ProductCreateOptions options = null, CancellationToken cancellationToken = default); - /// - /// Updates the given . - /// - /// Id of the object being updated. - /// The to update. - /// Cancellation Token - /// The updated . - Task UpdateAsync(long productId, Product product, CancellationToken cancellationToken = default); + /// + /// Updates the given . + /// + /// Id of the object being updated. + /// The to update. + /// Cancellation Token + /// The updated . + Task UpdateAsync(long productId, Product product, CancellationToken cancellationToken = default); - /// - /// Deletes a product with the given Id. - /// - /// The product object's Id. - /// Cancellation Token - Task DeleteAsync(long productId, CancellationToken cancellationToken = default); + /// + /// Deletes a product with the given Id. + /// + /// The product object's Id. + /// Cancellation Token + Task DeleteAsync(long productId, CancellationToken cancellationToken = default); - /// - /// Publishes an unpublished . - /// - /// The product's id. - /// Cancellation Token - /// The published - Task PublishAsync(long id, CancellationToken cancellationToken = default); + /// + /// Publishes an unpublished . + /// + /// The product's id. + /// Cancellation Token + /// The published + Task PublishAsync(long id, CancellationToken cancellationToken = default); - /// - /// Unpublishes an published . - /// - /// The product's id. - /// Cancellation Token - /// The unpublished - Task UnpublishAsync(long id, CancellationToken cancellationToken = default); - } + /// + /// Unpublishes an published . + /// + /// The product's id. + /// Cancellation Token + /// The unpublished + Task UnpublishAsync(long id, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Product/ProductCreateOptions.cs b/ShopifySharp/Services/Product/ProductCreateOptions.cs index 4d8560e1..2e2c790c 100644 --- a/ShopifySharp/Services/Product/ProductCreateOptions.cs +++ b/ShopifySharp/Services/Product/ProductCreateOptions.cs @@ -1,10 +1,9 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; -namespace ShopifySharp +namespace ShopifySharp; + +public class ProductCreateOptions : Parameterizable { - public class ProductCreateOptions : Parameterizable - { - [JsonProperty("published")] - public bool? Published { get; set; } - } -} + [JsonProperty("published")] + public bool? Published { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/Services/Product/ProductService.cs b/ShopifySharp/Services/Product/ProductService.cs index 763de5c9..bfeeb698 100644 --- a/ShopifySharp/Services/Product/ProductService.cs +++ b/ShopifySharp/Services/Product/ProductService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Collections.Generic; @@ -7,115 +7,114 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify products. +/// +public class ProductService : ShopifyService, IProductService { /// - /// A service for manipulating Shopify products. + /// Creates a new instance of . /// - public class ProductService : ShopifyService, IProductService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public ProductService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal ProductService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public ProductService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal ProductService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - public virtual async Task CountAsync(ProductCountFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync("products/count.json", "count", filter, cancellationToken); + public virtual async Task CountAsync(ProductCountFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync("products/count.json", "count", filter, cancellationToken); - public virtual async Task> ListAsync(ListFilter filter, bool includePresentmentPrices = false, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("products.json", "products", filter, cancellationToken, GetHeaders(includePresentmentPrices)); + public virtual async Task> ListAsync(ListFilter filter, bool includePresentmentPrices = false, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("products.json", "products", filter, cancellationToken, GetHeaders(includePresentmentPrices)); - public virtual async Task> ListAsync(ProductListFilter filter = null, bool includePresentmentPrices = false, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), includePresentmentPrices, cancellationToken); + public virtual async Task> ListAsync(ProductListFilter filter = null, bool includePresentmentPrices = false, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), includePresentmentPrices, cancellationToken); - public virtual async Task GetAsync(long productId, string fields = null, bool includePresentmentPrices = false, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"products/{productId}.json", "product", fields, cancellationToken, GetHeaders(includePresentmentPrices)); + public virtual async Task GetAsync(long productId, string fields = null, bool includePresentmentPrices = false, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"products/{productId}.json", "product", fields, cancellationToken, GetHeaders(includePresentmentPrices)); - public virtual async Task CreateAsync(Product product, ProductCreateOptions options = null, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri("products.json"); - var body = product.ToDictionary(); + public virtual async Task CreateAsync(Product product, ProductCreateOptions options = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("products.json"); + var body = product.ToDictionary(); - if (options != null) + if (options != null) + { + foreach (var option in options.ToDictionary()) { - foreach (var option in options.ToDictionary()) - { - body.Add(option); - } + body.Add(option); } - - var content = new JsonContent(new - { - product = body - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "product"); - - return response.Result; } - public virtual async Task UpdateAsync(long productId, Product product, CancellationToken cancellationToken = default) + var content = new JsonContent(new { - var req = BuildRequestUri($"products/{productId}.json"); - var content = new JsonContent(new - { - product = product - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "product"); + product = body + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "product"); - return response.Result; - } + return response.Result; + } - public virtual async Task DeleteAsync(long productId, CancellationToken cancellationToken = default) + public virtual async Task UpdateAsync(long productId, Product product, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"products/{productId}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"products/{productId}.json"); + product = product + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "product"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + return response.Result; + } + + public virtual async Task DeleteAsync(long productId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"products/{productId}.json"); - public virtual async Task PublishAsync(long id, CancellationToken cancellationToken = default) + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); + } + + public virtual async Task PublishAsync(long id, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"products/{id}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"products/{id}.json"); - var content = new JsonContent(new + product = new { - product = new - { - id = id, - published = true - } - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "product"); - - return response.Result; - } + id = id, + published = true + } + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "product"); - public virtual async Task UnpublishAsync(long id, CancellationToken cancellationToken = default) + return response.Result; + } + + public virtual async Task UnpublishAsync(long id, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"products/{id}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"products/{id}.json"); - var content = new JsonContent(new + product = new { - product = new - { - id = id, - published = false - } - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "product"); - - return response.Result; - } + id = id, + published = false + } + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "product"); - protected virtual Dictionary GetHeaders(bool includePresentmentPrices) - { - if (!includePresentmentPrices) - return null; + return response.Result; + } - return new Dictionary - { - { "X-Shopify-Api-Features", "include-presentment-prices" } - }; - } + protected virtual Dictionary GetHeaders(bool includePresentmentPrices) + { + if (!includePresentmentPrices) + return null; + + return new Dictionary + { + { "X-Shopify-Api-Features", "include-presentment-prices" } + }; } } \ No newline at end of file diff --git a/ShopifySharp/Services/ProductImage/IProductImageService.cs b/ShopifySharp/Services/ProductImage/IProductImageService.cs index 2abfb12d..dfd73bd5 100644 --- a/ShopifySharp/Services/ProductImage/IProductImageService.cs +++ b/ShopifySharp/Services/ProductImage/IProductImageService.cs @@ -3,60 +3,59 @@ using System.Threading.Tasks; using System.Threading; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IProductImageService : IShopifyService { - public interface IProductImageService : IShopifyService - { - /// - /// Gets a count of all of the shop's ProductImages. - /// - /// The id of the product that counted images belong to. - /// Options for filtering the result. - /// Cancellation Token - Task CountAsync(long productId, ProductImageCountFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a count of all of the shop's ProductImages. + /// + /// The id of the product that counted images belong to. + /// Options for filtering the result. + /// Cancellation Token + Task CountAsync(long productId, ProductImageCountFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the shop's ProductImages. - /// - /// The id of the product that counted images belong to. - /// Cancellation Token - Task> ListAsync(long productId, ListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's ProductImages. + /// + /// The id of the product that counted images belong to. + /// Cancellation Token + Task> ListAsync(long productId, ListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the product that counted images belong to. - /// The id of the ProductImage to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long productId, long imageId, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the product that counted images belong to. + /// The id of the ProductImage to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long productId, long imageId, string fields = null, CancellationToken cancellationToken = default); - /// - /// Creates a new . If the new image has an string, it will be converted to the . - /// - /// The id of the product that counted images belong to. - /// The new . - /// Cancellation Token - /// The new . - Task CreateAsync(long productId, ProductImage image, CancellationToken cancellationToken = default); + /// + /// Creates a new . If the new image has an string, it will be converted to the . + /// + /// The id of the product that counted images belong to. + /// The new . + /// Cancellation Token + /// The new . + Task CreateAsync(long productId, ProductImage image, CancellationToken cancellationToken = default); - /// - /// Updates the given . - /// - /// The id of the product that counted images belong to. - /// Id of the object being updated. - /// The to update. - /// Cancellation Token - /// The updated . - Task UpdateAsync(long productId, long productImageId, ProductImage image, CancellationToken cancellationToken = default); + /// + /// Updates the given . + /// + /// The id of the product that counted images belong to. + /// Id of the object being updated. + /// The to update. + /// Cancellation Token + /// The updated . + Task UpdateAsync(long productId, long productImageId, ProductImage image, CancellationToken cancellationToken = default); - /// - /// Deletes a ProductImage with the given Id. - /// - /// The id of the product that counted images belong to. - /// The ProductImage object's Id. - /// Cancellation Token - Task DeleteAsync(long productId, long imageId, CancellationToken cancellationToken = default); - } + /// + /// Deletes a ProductImage with the given Id. + /// + /// The id of the product that counted images belong to. + /// The ProductImage object's Id. + /// Cancellation Token + Task DeleteAsync(long productId, long imageId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/ProductImage/ProductImageService.cs b/ShopifySharp/Services/ProductImage/ProductImageService.cs index 1a811bd4..c44fc7aa 100644 --- a/ShopifySharp/Services/ProductImage/ProductImageService.cs +++ b/ShopifySharp/Services/ProductImage/ProductImageService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Net.Http; @@ -6,71 +6,70 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify ProductImages. +/// +public class ProductImageService : ShopifyService, IProductImageService { /// - /// A service for manipulating Shopify ProductImages. + /// Creates a new instance of . /// - public class ProductImageService : ShopifyService, IProductImageService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public ProductImageService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal ProductImageService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public ProductImageService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal ProductImageService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CountAsync(long productId, ProductImageCountFilter filter = null, CancellationToken cancellationToken = default) - { - return await ExecuteGetAsync($"products/{productId}/images/count.json", "count", filter, cancellationToken); - } + /// + public virtual async Task CountAsync(long productId, ProductImageCountFilter filter = null, CancellationToken cancellationToken = default) + { + return await ExecuteGetAsync($"products/{productId}/images/count.json", "count", filter, cancellationToken); + } - /// - public virtual async Task> ListAsync(long productId, ListFilter filter = null, CancellationToken cancellationToken = default) - { - return await ExecuteGetListAsync($"products/{productId}/images.json", "images", filter, cancellationToken); - } + /// + public virtual async Task> ListAsync(long productId, ListFilter filter = null, CancellationToken cancellationToken = default) + { + return await ExecuteGetListAsync($"products/{productId}/images.json", "images", filter, cancellationToken); + } - /// - public virtual async Task GetAsync(long productId, long imageId, string fields = null, CancellationToken cancellationToken = default) - { - return await ExecuteGetAsync($"products/{productId}/images/{imageId}.json", "image", fields, cancellationToken); - } + /// + public virtual async Task GetAsync(long productId, long imageId, string fields = null, CancellationToken cancellationToken = default) + { + return await ExecuteGetAsync($"products/{productId}/images/{imageId}.json", "image", fields, cancellationToken); + } - /// - public virtual async Task CreateAsync(long productId, ProductImage image, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(long productId, ProductImage image, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"products/{productId}/images.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"products/{productId}/images.json"); - var content = new JsonContent(new - { - image = image - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "image"); + image = image + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "image"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task UpdateAsync(long productId, long productImageId, ProductImage image, CancellationToken cancellationToken = default) + /// + public virtual async Task UpdateAsync(long productId, long productImageId, ProductImage image, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"products/{productId}/images/{productImageId}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"products/{productId}/images/{productImageId}.json"); - var content = new JsonContent(new - { - image = image - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "image"); + image = image + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "image"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task DeleteAsync(long productId, long imageId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"products/{productId}/images/{imageId}.json"); + /// + public virtual async Task DeleteAsync(long productId, long imageId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"products/{productId}/images/{imageId}.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); } } \ No newline at end of file diff --git a/ShopifySharp/Services/ProductListing/IProductListingService.cs b/ShopifySharp/Services/ProductListing/IProductListingService.cs index 2568f958..3d02eb37 100644 --- a/ShopifySharp/Services/ProductListing/IProductListingService.cs +++ b/ShopifySharp/Services/ProductListing/IProductListingService.cs @@ -3,53 +3,52 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IProductListingService : IShopifyService { - public interface IProductListingService : IShopifyService - { - /// - /// Gets a list of up to 1000 default 50 of the shop's product listings. - /// - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - - /// - /// Gets a list of up to 1000 default 50 of the shop's product listings. - /// - Task> ListAsync(ProductListingListFilter filter = null, CancellationToken cancellationToken = default); - - /// - /// Retrieves the specific that is published to your app - /// - /// The id of the product to retrieve. - /// Cancellation Token - /// The . - Task GetAsync(long productId, - CancellationToken cancellationToken = default); - - /// - /// Retrieve a count of products that are published to your app - /// - /// The count of all products for the shop. - Task CountAsync(CancellationToken cancellationToken = default); - - /// - /// Retrieve product_ids that are published to your app. Maximum 1,000 results per page - /// - Task> ListIdsAsync(CancellationToken cancellationToken = default); - - /// - /// Create a product listing to publish a product to your app . - /// - /// Id of listing product - /// Cancellation Token - /// The updated . - Task CreateAsync(long productId, CancellationToken cancellationToken = default); - - /// - /// Delete a product listing to unpublish a product from your app - /// - /// The product object's Id. - /// Cancellation Token - Task DeleteAsync(long productId, CancellationToken cancellationToken = default); - } + /// + /// Gets a list of up to 1000 default 50 of the shop's product listings. + /// + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + + /// + /// Gets a list of up to 1000 default 50 of the shop's product listings. + /// + Task> ListAsync(ProductListingListFilter filter = null, CancellationToken cancellationToken = default); + + /// + /// Retrieves the specific that is published to your app + /// + /// The id of the product to retrieve. + /// Cancellation Token + /// The . + Task GetAsync(long productId, + CancellationToken cancellationToken = default); + + /// + /// Retrieve a count of products that are published to your app + /// + /// The count of all products for the shop. + Task CountAsync(CancellationToken cancellationToken = default); + + /// + /// Retrieve product_ids that are published to your app. Maximum 1,000 results per page + /// + Task> ListIdsAsync(CancellationToken cancellationToken = default); + + /// + /// Create a product listing to publish a product to your app . + /// + /// Id of listing product + /// Cancellation Token + /// The updated . + Task CreateAsync(long productId, CancellationToken cancellationToken = default); + + /// + /// Delete a product listing to unpublish a product from your app + /// + /// The product object's Id. + /// Cancellation Token + Task DeleteAsync(long productId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/ProductListing/ProductListingService.cs b/ShopifySharp/Services/ProductListing/ProductListingService.cs index c5363821..913c7772 100644 --- a/ShopifySharp/Services/ProductListing/ProductListingService.cs +++ b/ShopifySharp/Services/ProductListing/ProductListingService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Net.Http; @@ -6,60 +6,59 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify Product which is available to your sales channel +/// +public class ProductListingService: ShopifyService, IProductListingService { /// - /// A service for manipulating Shopify Product which is available to your sales channel + /// Creates a new instance of . /// - public class ProductListingService: ShopifyService, IProductListingService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public ProductListingService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal ProductListingService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public ProductListingService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal ProductListingService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("product_listings.json", "product_listings", filter, cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("product_listings.json", "product_listings", filter, cancellationToken); - /// - public virtual async Task> ListAsync(ProductListingListFilter filter = null, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListAsync(ProductListingListFilter filter = null, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task GetAsync(long productId, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"product_listings/{productId}.json", "product_listing", cancellationToken: cancellationToken); + /// + public virtual async Task GetAsync(long productId, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"product_listings/{productId}.json", "product_listing", cancellationToken: cancellationToken); - /// - public virtual async Task CountAsync(CancellationToken cancellationToken = default) => - await ExecuteGetAsync("product_listings/count.json", "count", cancellationToken: cancellationToken); + /// + public virtual async Task CountAsync(CancellationToken cancellationToken = default) => + await ExecuteGetAsync("product_listings/count.json", "count", cancellationToken: cancellationToken); - /// - public virtual async Task> ListIdsAsync(CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("product_listings/product_ids.json", "product_ids", ListFilter.Empty, cancellationToken); + /// + public virtual async Task> ListIdsAsync(CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("product_listings/product_ids.json", "product_ids", ListFilter.Empty, cancellationToken); - /// - public virtual async Task CreateAsync(long productId, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(long productId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"product_listings/{productId}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"product_listings/{productId}.json"); - var content = new JsonContent(new - { - product_listing = new { product_id = productId } - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "product_listing"); + product_listing = new { product_id = productId } + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "product_listing"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task DeleteAsync(long productId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"product_listings/{productId}.json"); + /// + public virtual async Task DeleteAsync(long productId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"product_listings/{productId}.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); } } \ No newline at end of file diff --git a/ShopifySharp/Services/ProductVariant/IProductVariantService.cs b/ShopifySharp/Services/ProductVariant/IProductVariantService.cs index b6d8a03c..cf03b8bd 100644 --- a/ShopifySharp/Services/ProductVariant/IProductVariantService.cs +++ b/ShopifySharp/Services/ProductVariant/IProductVariantService.cs @@ -3,63 +3,62 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IProductVariantService : IShopifyService { - public interface IProductVariantService : IShopifyService - { - /// - /// Gets a count of all variants belonging to the given product. - /// - /// The product that the variants belong to. - /// Options for filtering the result. - /// - /// According to Shopify's documentation, this endpoint does not currently support any additional filter parameters for counting. - /// - Task CountAsync(long productId, CancellationToken cancellationToken = default); + /// + /// Gets a count of all variants belonging to the given product. + /// + /// The product that the variants belong to. + /// Options for filtering the result. + /// + /// According to Shopify's documentation, this endpoint does not currently support any additional filter parameters for counting. + /// + Task CountAsync(long productId, CancellationToken cancellationToken = default); - /// - /// Gets a list of variants belonging to the given product. - /// - /// The product that the variants belong to. - /// Cancellation Token - Task> ListAsync(long productId, ListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of variants belonging to the given product. + /// + /// The product that the variants belong to. + /// Cancellation Token + Task> ListAsync(long productId, ListFilter filter, CancellationToken cancellationToken = default); - /// - /// Gets a list of variants belonging to the given product. - /// - /// The product that the variants belong to. - /// Cancellation Token - Task> ListAsync(long productId, ProductVariantListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of variants belonging to the given product. + /// + /// The product that the variants belong to. + /// Cancellation Token + Task> ListAsync(long productId, ProductVariantListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the product variant to retrieve. - /// Cancellation Token - Task GetAsync(long variantId, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the product variant to retrieve. + /// Cancellation Token + Task GetAsync(long variantId, CancellationToken cancellationToken = default); - /// - /// Creates a new . - /// - /// The product that the new variant will belong to. - /// A new . Id should be set to null. - /// Cancellation Token - Task CreateAsync(long productId, ProductVariant variant, CancellationToken cancellationToken = default); + /// + /// Creates a new . + /// + /// The product that the new variant will belong to. + /// A new . Id should be set to null. + /// Cancellation Token + Task CreateAsync(long productId, ProductVariant variant, CancellationToken cancellationToken = default); - /// - /// Updates the given . - /// - /// Id of the object being updated. - /// The variant to update. - /// Cancellation Token - Task UpdateAsync(long productVariantId, ProductVariant variant, CancellationToken cancellationToken = default); + /// + /// Updates the given . + /// + /// Id of the object being updated. + /// The variant to update. + /// Cancellation Token + Task UpdateAsync(long productVariantId, ProductVariant variant, CancellationToken cancellationToken = default); - /// - /// Deletes a product variant with the given Id. - /// - /// The product that the variant belongs to. - /// The product variant's id. - /// Cancellation Token - Task DeleteAsync(long productId, long variantId, CancellationToken cancellationToken = default); - } + /// + /// Deletes a product variant with the given Id. + /// + /// The product that the variant belongs to. + /// The product variant's id. + /// Cancellation Token + Task DeleteAsync(long productId, long variantId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/ProductVariant/ProductVariantService.cs b/ShopifySharp/Services/ProductVariant/ProductVariantService.cs index f3b15ee9..8ef5fdc3 100644 --- a/ShopifySharp/Services/ProductVariant/ProductVariantService.cs +++ b/ShopifySharp/Services/ProductVariant/ProductVariantService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Net.Http; @@ -6,77 +6,76 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating a Shopify product's variants. +/// +public class ProductVariantService : ShopifyService, IProductVariantService { /// - /// A service for manipulating a Shopify product's variants. + /// Creates a new instance of . /// - public class ProductVariantService : ShopifyService, IProductVariantService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public ProductVariantService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal ProductVariantService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public ProductVariantService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal ProductVariantService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CountAsync(long productId, CancellationToken cancellationToken = default) - { - return await ExecuteGetAsync($"products/{productId}/variants/count.json", "count", cancellationToken: cancellationToken); - } + /// + public virtual async Task CountAsync(long productId, CancellationToken cancellationToken = default) + { + return await ExecuteGetAsync($"products/{productId}/variants/count.json", "count", cancellationToken: cancellationToken); + } - /// - public virtual async Task> ListAsync(long productId, ListFilter filter, CancellationToken cancellationToken = default) - { - return await ExecuteGetListAsync($"products/{productId}/variants.json", "variants", filter, cancellationToken); - } + /// + public virtual async Task> ListAsync(long productId, ListFilter filter, CancellationToken cancellationToken = default) + { + return await ExecuteGetListAsync($"products/{productId}/variants.json", "variants", filter, cancellationToken); + } - /// - public virtual async Task> ListAsync(long productId, ProductVariantListFilter filter = null, CancellationToken cancellationToken = default) - { - return await ListAsync(productId, filter?.AsListFilter(), cancellationToken); - } + /// + public virtual async Task> ListAsync(long productId, ProductVariantListFilter filter = null, CancellationToken cancellationToken = default) + { + return await ListAsync(productId, filter?.AsListFilter(), cancellationToken); + } - /// - public virtual async Task GetAsync(long variantId, CancellationToken cancellationToken = default) - { - return await ExecuteGetAsync($"variants/{variantId}.json", "variant", cancellationToken: cancellationToken); - } + /// + public virtual async Task GetAsync(long variantId, CancellationToken cancellationToken = default) + { + return await ExecuteGetAsync($"variants/{variantId}.json", "variant", cancellationToken: cancellationToken); + } - /// - public virtual async Task CreateAsync(long productId, ProductVariant variant, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(long productId, ProductVariant variant, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"products/{productId}/variants.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"products/{productId}/variants.json"); - var content = new JsonContent(new - { - variant = variant - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "variant"); + variant = variant + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "variant"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task UpdateAsync(long productVariantId, ProductVariant variant, CancellationToken cancellationToken = default) + /// + public virtual async Task UpdateAsync(long productVariantId, ProductVariant variant, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"variants/{productVariantId}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"variants/{productVariantId}.json"); - var content = new JsonContent(new - { - variant = variant - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "variant"); + variant = variant + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "variant"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task DeleteAsync(long productId, long variantId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"products/{productId}/variants/{variantId}.json"); + /// + public virtual async Task DeleteAsync(long productId, long variantId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"products/{productId}/variants/{variantId}.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); } } \ No newline at end of file diff --git a/ShopifySharp/Services/RecurringCharge/IRecurringChargeService.cs b/ShopifySharp/Services/RecurringCharge/IRecurringChargeService.cs index e3d09c51..cddccc53 100644 --- a/ShopifySharp/Services/RecurringCharge/IRecurringChargeService.cs +++ b/ShopifySharp/Services/RecurringCharge/IRecurringChargeService.cs @@ -3,37 +3,36 @@ using System.Threading.Tasks; using ShopifySharp.Filters; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IRecurringChargeService : IShopifyService { - public interface IRecurringChargeService : IShopifyService - { - /// - /// Creates a . - /// - /// The to create. - /// Cancellation Token - /// The new . - Task CreateAsync(RecurringCharge charge, CancellationToken cancellationToken = default); + /// + /// Creates a . + /// + /// The to create. + /// Cancellation Token + /// The new . + Task CreateAsync(RecurringCharge charge, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the charge to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the charge to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default); - /// - /// Retrieves a list of all past and present objects. - /// - Task> ListAsync(RecurringChargeListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Retrieves a list of all past and present objects. + /// + Task> ListAsync(RecurringChargeListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Deletes a . - /// - /// The id of the charge to delete. - /// Cancellation Token - Task DeleteAsync(long id, CancellationToken cancellationToken = default); - } + /// + /// Deletes a . + /// + /// The id of the charge to delete. + /// Cancellation Token + Task DeleteAsync(long id, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/RecurringCharge/RecurringChargeService.cs b/ShopifySharp/Services/RecurringCharge/RecurringChargeService.cs index 2144272e..b343f25b 100644 --- a/ShopifySharp/Services/RecurringCharge/RecurringChargeService.cs +++ b/ShopifySharp/Services/RecurringCharge/RecurringChargeService.cs @@ -1,38 +1,37 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using System.Collections.Generic; using System.Threading.Tasks; using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify's RecurringApplicationCharge API. +/// +public class RecurringChargeService : ShopifyService, IRecurringChargeService { /// - /// A service for manipulating Shopify's RecurringApplicationCharge API. + /// Creates a new instance of . /// - public class RecurringChargeService : ShopifyService, IRecurringChargeService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public RecurringChargeService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal RecurringChargeService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public RecurringChargeService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal RecurringChargeService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CreateAsync(RecurringCharge charge, CancellationToken cancellationToken = default) => - await ExecutePostAsync("recurring_application_charges.json", "recurring_application_charge", cancellationToken, new { recurring_application_charge = charge }); + /// + public virtual async Task CreateAsync(RecurringCharge charge, CancellationToken cancellationToken = default) => + await ExecutePostAsync("recurring_application_charges.json", "recurring_application_charge", cancellationToken, new { recurring_application_charge = charge }); - /// - public virtual async Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"recurring_application_charges/{id}.json", "recurring_application_charge", fields, cancellationToken); + /// + public virtual async Task GetAsync(long id, string fields = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"recurring_application_charges/{id}.json", "recurring_application_charge", fields, cancellationToken); - /// - public virtual async Task> ListAsync(RecurringChargeListFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync>("recurring_application_charges.json", "recurring_application_charges", filter, cancellationToken); + /// + public virtual async Task> ListAsync(RecurringChargeListFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync>("recurring_application_charges.json", "recurring_application_charges", filter, cancellationToken); - /// - public virtual async Task DeleteAsync(long id, CancellationToken cancellationToken = default) => - await ExecuteDeleteAsync($"recurring_application_charges/{id}.json", cancellationToken); - } + /// + public virtual async Task DeleteAsync(long id, CancellationToken cancellationToken = default) => + await ExecuteDeleteAsync($"recurring_application_charges/{id}.json", cancellationToken); } \ No newline at end of file diff --git a/ShopifySharp/Services/Redirect/IRedirectService.cs b/ShopifySharp/Services/Redirect/IRedirectService.cs index 6542946c..b04d6a10 100644 --- a/ShopifySharp/Services/Redirect/IRedirectService.cs +++ b/ShopifySharp/Services/Redirect/IRedirectService.cs @@ -3,60 +3,59 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IRedirectService : IShopifyService { - public interface IRedirectService : IShopifyService - { - /// - /// Gets a count of all of the shop's redirects. - /// - /// Options for filtering the result. - /// Cancellation Token - Task CountAsync(RedirectCountFilter filter = null, CancellationToken cancellationToken = default); - - /// - /// Gets a list of up to 250 of the shop's redirects. - /// - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - - /// - /// Gets a list of up to 250 of the shop's redirects. - /// - Task> ListAsync(RedirectListFilter filter = null, CancellationToken cancellationToken = default); - - /// - /// Retrieves the with the given id. - /// - /// The id of the redirect to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long redirectId, string fields = null, CancellationToken cancellationToken = default); - - /// - /// Creates a new on the store. The redirect always starts out with a role of - /// "unpublished." If the redirect has a different role, it will be assigned that only after all of its - /// files have been extracted and stored by Shopify (which might take a couple of minutes). - /// - /// The new . - /// Cancellation Token - /// The new . - Task CreateAsync(Redirect redirect, CancellationToken cancellationToken = default); - - /// - /// Updates the given . - /// - /// Id of the object being updated. - /// The to update. - /// Cancellation Token - /// The updated . - Task UpdateAsync(long redirectId, Redirect redirect, CancellationToken cancellationToken = default); - - /// - /// Deletes a redirect with the given Id. - /// - /// The redirect object's Id. - /// Cancellation Token - Task DeleteAsync(long redirectId, CancellationToken cancellationToken = default); - } + /// + /// Gets a count of all of the shop's redirects. + /// + /// Options for filtering the result. + /// Cancellation Token + Task CountAsync(RedirectCountFilter filter = null, CancellationToken cancellationToken = default); + + /// + /// Gets a list of up to 250 of the shop's redirects. + /// + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + + /// + /// Gets a list of up to 250 of the shop's redirects. + /// + Task> ListAsync(RedirectListFilter filter = null, CancellationToken cancellationToken = default); + + /// + /// Retrieves the with the given id. + /// + /// The id of the redirect to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long redirectId, string fields = null, CancellationToken cancellationToken = default); + + /// + /// Creates a new on the store. The redirect always starts out with a role of + /// "unpublished." If the redirect has a different role, it will be assigned that only after all of its + /// files have been extracted and stored by Shopify (which might take a couple of minutes). + /// + /// The new . + /// Cancellation Token + /// The new . + Task CreateAsync(Redirect redirect, CancellationToken cancellationToken = default); + + /// + /// Updates the given . + /// + /// Id of the object being updated. + /// The to update. + /// Cancellation Token + /// The updated . + Task UpdateAsync(long redirectId, Redirect redirect, CancellationToken cancellationToken = default); + + /// + /// Deletes a redirect with the given Id. + /// + /// The redirect object's Id. + /// Cancellation Token + Task DeleteAsync(long redirectId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Redirect/RedirectService.cs b/ShopifySharp/Services/Redirect/RedirectService.cs index e5703432..af2fcb60 100644 --- a/ShopifySharp/Services/Redirect/RedirectService.cs +++ b/ShopifySharp/Services/Redirect/RedirectService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Net.Http; @@ -6,80 +6,79 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify redirects. +/// +public class RedirectService : ShopifyService, IRedirectService { /// - /// A service for manipulating Shopify redirects. + /// Creates a new instance of . /// - public class RedirectService : ShopifyService, IRedirectService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public RedirectService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal RedirectService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public RedirectService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal RedirectService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CountAsync(RedirectCountFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync("redirects/count.json", "count", filter, cancellationToken); + /// + public virtual async Task CountAsync(RedirectCountFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync("redirects/count.json", "count", filter, cancellationToken); - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("redirects.json", "redirects", filter, cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("redirects.json", "redirects", filter, cancellationToken); - /// - public virtual async Task> ListAsync(RedirectListFilter filter = null, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListAsync(RedirectListFilter filter = null, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task GetAsync(long redirectId, string fields = null, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"redirects/{redirectId}.json"); + /// + public virtual async Task GetAsync(long redirectId, string fields = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"redirects/{redirectId}.json"); - if (!string.IsNullOrEmpty(fields)) - { - req.QueryParams.Add("fields", fields); - } + if (!string.IsNullOrEmpty(fields)) + { + req.QueryParams.Add("fields", fields); + } - var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "redirect"); + var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "redirect"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task CreateAsync(Redirect redirect, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(Redirect redirect, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("redirects.json"); + var content = new JsonContent(new { - var req = BuildRequestUri("redirects.json"); - var content = new JsonContent(new - { - redirect = redirect - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "redirect"); + redirect = redirect + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "redirect"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task UpdateAsync(long redirectId, Redirect redirect, CancellationToken cancellationToken = default) + /// + public virtual async Task UpdateAsync(long redirectId, Redirect redirect, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"redirects/{redirectId}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"redirects/{redirectId}.json"); - var content = new JsonContent(new - { - redirect = redirect - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "redirect"); + redirect = redirect + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "redirect"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task DeleteAsync(long redirectId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"redirects/{redirectId}.json"); + /// + public virtual async Task DeleteAsync(long redirectId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"redirects/{redirectId}.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); } } \ No newline at end of file diff --git a/ShopifySharp/Services/Refund/IRefundService.cs b/ShopifySharp/Services/Refund/IRefundService.cs index ed1cee39..91d25112 100644 --- a/ShopifySharp/Services/Refund/IRefundService.cs +++ b/ShopifySharp/Services/Refund/IRefundService.cs @@ -3,46 +3,45 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IRefundService : IShopifyService { - public interface IRefundService : IShopifyService - { - /// - /// Retrieves a list of refunds for an order. - /// - /// The id of the order to list orders for. - /// Cancellation Token - Task> ListForOrderAsync(long orderId, ListFilter filter, CancellationToken cancellationToken = default); + /// + /// Retrieves a list of refunds for an order. + /// + /// The id of the order to list orders for. + /// Cancellation Token + Task> ListForOrderAsync(long orderId, ListFilter filter, CancellationToken cancellationToken = default); - /// - /// Retrieves a list of refunds for an order. - /// - /// The id of the order to list orders for. - /// Cancellation Token - Task> ListForOrderAsync(long orderId, RefundListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Retrieves a list of refunds for an order. + /// + /// The id of the order to list orders for. + /// Cancellation Token + Task> ListForOrderAsync(long orderId, RefundListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Retrieves a specific refund. - /// - /// - /// - /// Cancellation Token - /// - Task GetAsync(long orderId, long refundId, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves a specific refund. + /// + /// + /// + /// Cancellation Token + /// + Task GetAsync(long orderId, long refundId, string fields = null, CancellationToken cancellationToken = default); - /// - /// Calculates transactions based on line items and shipping. - /// When you want to create a refund, you should first use the calculate endpoint to generate accurate refund transactions. - /// Specify the line items that are being refunded, their quantity and restock instructions, and whether you intend to refund shipping costs. - /// If the restock instructions can't be met—for example, because you try to return more items than have been fulfilled—then the endpoint returns modified restock instructions. - /// You can then use the response in the body of the request to create the actual refund. - /// The response includes a transactions object with "kind": "suggested_refund", which must to be changed to "kind" : "refund" for the refund to be accepted. - /// - Task CalculateAsync(long orderId, Refund options, CancellationToken cancellationToken = default); + /// + /// Calculates transactions based on line items and shipping. + /// When you want to create a refund, you should first use the calculate endpoint to generate accurate refund transactions. + /// Specify the line items that are being refunded, their quantity and restock instructions, and whether you intend to refund shipping costs. + /// If the restock instructions can't be met—for example, because you try to return more items than have been fulfilled—then the endpoint returns modified restock instructions. + /// You can then use the response in the body of the request to create the actual refund. + /// The response includes a transactions object with "kind": "suggested_refund", which must to be changed to "kind" : "refund" for the refund to be accepted. + /// + Task CalculateAsync(long orderId, Refund options, CancellationToken cancellationToken = default); - /// - /// Creates a . Use the calculate endpoint to produce the transactions to submit. - /// - Task RefundAsync(long orderId, Refund options, CancellationToken cancellationToken = default); - } + /// + /// Creates a . Use the calculate endpoint to produce the transactions to submit. + /// + Task RefundAsync(long orderId, Refund options, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Refund/RefundService.cs b/ShopifySharp/Services/Refund/RefundService.cs index 6207ccfb..bfebda80 100644 --- a/ShopifySharp/Services/Refund/RefundService.cs +++ b/ShopifySharp/Services/Refund/RefundService.cs @@ -6,51 +6,50 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for creating Shopify Refunds. +/// +public class RefundService : ShopifyService, IRefundService { /// - /// A service for creating Shopify Refunds. + /// Creates a new instance of . /// - public class RefundService : ShopifyService, IRefundService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public RefundService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal RefundService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public RefundService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal RefundService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListForOrderAsync(long orderId, ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync($"orders/{orderId}/refunds.json", "refunds", filter, cancellationToken); - - /// - public virtual async Task> ListForOrderAsync(long orderId, RefundListFilter filter = null, CancellationToken cancellationToken = default) => - await ListForOrderAsync(orderId, filter?.AsListFilter(), cancellationToken); - - /// - public virtual async Task GetAsync(long orderId, long refundId, string fields = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"orders/{orderId}/refunds/{refundId}.json", "refund", fields, cancellationToken); - - /// - public virtual async Task CalculateAsync(long orderId, Refund options, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"orders/{orderId}/refunds/calculate.json"); - var content = new JsonContent(new { refund = options }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "refund"); - - return response.Result; - } - - /// - public virtual async Task RefundAsync(long orderId, Refund options, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"orders/{orderId}/refunds.json"); - var content = new JsonContent(new { refund = options }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "refund"); - - return response.Result; - } + /// + public virtual async Task> ListForOrderAsync(long orderId, ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync($"orders/{orderId}/refunds.json", "refunds", filter, cancellationToken); + + /// + public virtual async Task> ListForOrderAsync(long orderId, RefundListFilter filter = null, CancellationToken cancellationToken = default) => + await ListForOrderAsync(orderId, filter?.AsListFilter(), cancellationToken); + + /// + public virtual async Task GetAsync(long orderId, long refundId, string fields = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"orders/{orderId}/refunds/{refundId}.json", "refund", fields, cancellationToken); + + /// + public virtual async Task CalculateAsync(long orderId, Refund options, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"orders/{orderId}/refunds/calculate.json"); + var content = new JsonContent(new { refund = options }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "refund"); + + return response.Result; + } + + /// + public virtual async Task RefundAsync(long orderId, Refund options, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"orders/{orderId}/refunds.json"); + var content = new JsonContent(new { refund = options }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "refund"); + + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/ScriptTag/IScriptTagService.cs b/ShopifySharp/Services/ScriptTag/IScriptTagService.cs index 615af1ec..ad274ff7 100644 --- a/ShopifySharp/Services/ScriptTag/IScriptTagService.cs +++ b/ShopifySharp/Services/ScriptTag/IScriptTagService.cs @@ -3,58 +3,57 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IScriptTagService : IShopifyService { - public interface IScriptTagService : IShopifyService - { - /// - /// Gets a count of all of the shop's s. - /// - /// Options for filtering the result. - /// Cancellation Token - Task CountAsync(ScriptTagCountFilter filter = null, CancellationToken cancellationToken = default); - - /// - /// Gets a list of up to 250 of the shop's script tags. - /// - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - - /// - /// Gets a list of up to 250 of the shop's script tags. - /// - Task> ListAsync(ScriptTagListFilter filter = null, CancellationToken cancellationToken = default); - - /// - /// Retrieves the with the given id. - /// - /// The id of the to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long tagId, string fields = null, CancellationToken cancellationToken = default); - - /// - /// Creates a new on the store. - /// - /// A new . Id should be set to null. - /// Cancellation Token - /// The new . - Task CreateAsync(ScriptTag tag, CancellationToken cancellationToken = default); - - /// - /// Updates the given . - /// - /// Id of the object being updated. - /// The to update. - /// Cancellation Token - /// The updated . - Task UpdateAsync(long scriptTagId, ScriptTag tag, CancellationToken cancellationToken = default); - - /// - /// Deletes the with the given Id. - /// - /// The tag's Id. - /// Cancellation Token - Task DeleteAsync(long tagId, CancellationToken cancellationToken = default); - } + /// + /// Gets a count of all of the shop's s. + /// + /// Options for filtering the result. + /// Cancellation Token + Task CountAsync(ScriptTagCountFilter filter = null, CancellationToken cancellationToken = default); + + /// + /// Gets a list of up to 250 of the shop's script tags. + /// + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + + /// + /// Gets a list of up to 250 of the shop's script tags. + /// + Task> ListAsync(ScriptTagListFilter filter = null, CancellationToken cancellationToken = default); + + /// + /// Retrieves the with the given id. + /// + /// The id of the to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long tagId, string fields = null, CancellationToken cancellationToken = default); + + /// + /// Creates a new on the store. + /// + /// A new . Id should be set to null. + /// Cancellation Token + /// The new . + Task CreateAsync(ScriptTag tag, CancellationToken cancellationToken = default); + + /// + /// Updates the given . + /// + /// Id of the object being updated. + /// The to update. + /// Cancellation Token + /// The updated . + Task UpdateAsync(long scriptTagId, ScriptTag tag, CancellationToken cancellationToken = default); + + /// + /// Deletes the with the given Id. + /// + /// The tag's Id. + /// Cancellation Token + Task DeleteAsync(long tagId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/ScriptTag/ScriptTagService.cs b/ShopifySharp/Services/ScriptTag/ScriptTagService.cs index a3fcccad..5bf51115 100644 --- a/ShopifySharp/Services/ScriptTag/ScriptTagService.cs +++ b/ShopifySharp/Services/ScriptTag/ScriptTagService.cs @@ -1,4 +1,4 @@ -using System.Net.Http; +using System.Net.Http; using ShopifySharp.Filters; using System.Threading; using System.Threading.Tasks; @@ -6,86 +6,85 @@ using ShopifySharp.Lists; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify's ScriptTag API. +/// +public class ScriptTagService : ShopifyService, IScriptTagService { /// - /// A service for manipulating Shopify's ScriptTag API. + /// Creates a new instance of . /// - public class ScriptTagService : ShopifyService, IScriptTagService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public ScriptTagService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal ScriptTagService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public ScriptTagService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal ScriptTagService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CountAsync(ScriptTagCountFilter filter = null, CancellationToken cancellationToken = default) - { - return await ExecuteGetAsync("script_tags/count.json", "count", filter, cancellationToken); - } + /// + public virtual async Task CountAsync(ScriptTagCountFilter filter = null, CancellationToken cancellationToken = default) + { + return await ExecuteGetAsync("script_tags/count.json", "count", filter, cancellationToken); + } - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) - { - return await ExecuteGetListAsync("script_tags.json", "script_tags", filter, cancellationToken); - } + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) + { + return await ExecuteGetListAsync("script_tags.json", "script_tags", filter, cancellationToken); + } - /// - public virtual async Task> ListAsync(ScriptTagListFilter filter = null, CancellationToken cancellationToken = default) - { - return await ListAsync(filter?.AsListFilter(), cancellationToken); - } + /// + public virtual async Task> ListAsync(ScriptTagListFilter filter = null, CancellationToken cancellationToken = default) + { + return await ListAsync(filter?.AsListFilter(), cancellationToken); + } - /// - public virtual async Task GetAsync(long tagId, string fields = null, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"script_tags/{tagId}.json"); + /// + public virtual async Task GetAsync(long tagId, string fields = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"script_tags/{tagId}.json"); - if (!string.IsNullOrEmpty(fields)) - { - req.QueryParams.Add("fields", fields); - } + if (!string.IsNullOrEmpty(fields)) + { + req.QueryParams.Add("fields", fields); + } - var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "script_tag"); + var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "script_tag"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task CreateAsync(ScriptTag tag, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(ScriptTag tag, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("script_tags.json"); + var content = new JsonContent(new { - var req = BuildRequestUri("script_tags.json"); - var content = new JsonContent(new - { - script_tag = tag - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "script_tag"); + script_tag = tag + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "script_tag"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task UpdateAsync(long scriptTagId, ScriptTag tag, CancellationToken cancellationToken = default) + /// + public virtual async Task UpdateAsync(long scriptTagId, ScriptTag tag, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"script_tags/{scriptTagId}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"script_tags/{scriptTagId}.json"); - var content = new JsonContent(new - { - script_tag = tag - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "script_tag"); + script_tag = tag + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "script_tag"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task DeleteAsync(long tagId, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"script_tags/{tagId}.json"); + /// + public virtual async Task DeleteAsync(long tagId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"script_tags/{tagId}.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); } } \ No newline at end of file diff --git a/ShopifySharp/Services/ShippingZone/IShippingZoneService.cs b/ShopifySharp/Services/ShippingZone/IShippingZoneService.cs index 0362e7ef..af0d6167 100644 --- a/ShopifySharp/Services/ShippingZone/IShippingZoneService.cs +++ b/ShopifySharp/Services/ShippingZone/IShippingZoneService.cs @@ -3,13 +3,12 @@ using System.Threading.Tasks; using ShopifySharp.Filters; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IShippingZoneService : IShopifyService { - public interface IShippingZoneService : IShopifyService - { - /// - /// Retrieves a list of all shipping zones. - /// - Task> ListAsync(ShippingZoneListFilter filter = null, CancellationToken cancellationToken = default); - } + /// + /// Retrieves a list of all shipping zones. + /// + Task> ListAsync(ShippingZoneListFilter filter = null, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/ShippingZone/ShippingZoneService.cs b/ShopifySharp/Services/ShippingZone/ShippingZoneService.cs index 0900730d..b2d09506 100644 --- a/ShopifySharp/Services/ShippingZone/ShippingZoneService.cs +++ b/ShopifySharp/Services/ShippingZone/ShippingZoneService.cs @@ -1,38 +1,37 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using System.Collections.Generic; using System.Net.Http; using System.Threading.Tasks; using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for retrieve Shopify shipping zones. +/// +public class ShippingZoneService : ShopifyService, IShippingZoneService { /// - /// A service for retrieve Shopify shipping zones. + /// Creates a new instance of . /// - public class ShippingZoneService : ShopifyService, IShippingZoneService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public ShippingZoneService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal ShippingZoneService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public ShippingZoneService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal ShippingZoneService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(ShippingZoneListFilter filter = null, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri("shipping_zones.json"); + /// + public virtual async Task> ListAsync(ShippingZoneListFilter filter = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("shipping_zones.json"); - if (filter != null) - { - req.QueryParams.AddRange(filter.ToQueryParameters()); - } + if (filter != null) + { + req.QueryParams.AddRange(filter.ToQueryParameters()); + } - var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "shipping_zones"); + var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "shipping_zones"); - return response.Result; - } + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/Shop/IShopService.cs b/ShopifySharp/Services/Shop/IShopService.cs index c440345b..0556ccf6 100644 --- a/ShopifySharp/Services/Shop/IShopService.cs +++ b/ShopifySharp/Services/Shop/IShopService.cs @@ -1,18 +1,17 @@ using System.Threading; using System.Threading.Tasks; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IShopService : IShopifyService { - public interface IShopService : IShopifyService - { - /// - /// Gets the shop's data. - /// - Task GetAsync(CancellationToken cancellationToken = default); + /// + /// Gets the shop's data. + /// + Task GetAsync(CancellationToken cancellationToken = default); - /// - /// Forces the shop to uninstall your Shopify app. Uninstalling an application is an irreversible operation. Be entirely sure that you no longer need to make API calls for the shop in which the application has been installed. - /// - Task UninstallAppAsync(CancellationToken cancellationToken = default); - } + /// + /// Forces the shop to uninstall your Shopify app. Uninstalling an application is an irreversible operation. Be entirely sure that you no longer need to make API calls for the shop in which the application has been installed. + /// + Task UninstallAppAsync(CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Shop/ShopService.cs b/ShopifySharp/Services/Shop/ShopService.cs index 5952bb19..132324db 100644 --- a/ShopifySharp/Services/Shop/ShopService.cs +++ b/ShopifySharp/Services/Shop/ShopService.cs @@ -1,30 +1,29 @@ -using System.Net.Http; +using System.Net.Http; using System.Threading; using System.Threading.Tasks; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +public class ShopService: ShopifyService, IShopService { - public class ShopService: ShopifyService, IShopService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public ShopService(string myShopifyUrl, string shopAccessToken): base(myShopifyUrl, shopAccessToken) { } - internal ShopService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// + /// Creates a new instance of . + /// + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public ShopService(string myShopifyUrl, string shopAccessToken): base(myShopifyUrl, shopAccessToken) { } + internal ShopService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task GetAsync(CancellationToken cancellationToken = default) => - await ExecuteGetAsync("shop.json", "shop", cancellationToken: cancellationToken); + /// + public virtual async Task GetAsync(CancellationToken cancellationToken = default) => + await ExecuteGetAsync("shop.json", "shop", cancellationToken: cancellationToken); - /// - public virtual async Task UninstallAppAsync(CancellationToken cancellationToken = default) - { - var request = BuildRequestUri("api_permissions/current.json"); + /// + public virtual async Task UninstallAppAsync(CancellationToken cancellationToken = default) + { + var request = BuildRequestUri("api_permissions/current.json"); - await ExecuteRequestAsync(request, HttpMethod.Delete, cancellationToken: cancellationToken); - } + await ExecuteRequestAsync(request, HttpMethod.Delete, cancellationToken: cancellationToken); } } \ No newline at end of file diff --git a/ShopifySharp/Services/ShopifyPayments/IShopifyPaymentsService.cs b/ShopifySharp/Services/ShopifyPayments/IShopifyPaymentsService.cs index 0e6497fb..920c52e8 100644 --- a/ShopifySharp/Services/ShopifyPayments/IShopifyPaymentsService.cs +++ b/ShopifySharp/Services/ShopifyPayments/IShopifyPaymentsService.cs @@ -4,65 +4,64 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IShopifyPaymentsService : IShopifyService { - public interface IShopifyPaymentsService : IShopifyService - { - /// - /// Checks whether the Shopify Payments API is enabled on this store. - /// If not enabled, all Shopify Payments API endpoints will return HTTP 404 / Not Found - /// - Task IsShopifyPaymentApiEnabledAsync(CancellationToken cancellationToken = default); + /// + /// Checks whether the Shopify Payments API is enabled on this store. + /// If not enabled, all Shopify Payments API endpoints will return HTTP 404 / Not Found + /// + Task IsShopifyPaymentApiEnabledAsync(CancellationToken cancellationToken = default); - /// - /// Gets a count of all of the shop's transactions. - /// - /// The order id to which the fulfillments belong. - /// Cancellation Token - /// The count of all fulfillments for the shop. - Task> GetBalanceAsync(CancellationToken cancellationToken = default); + /// + /// Gets a count of all of the shop's transactions. + /// + /// The order id to which the fulfillments belong. + /// Cancellation Token + /// The count of all fulfillments for the shop. + Task> GetBalanceAsync(CancellationToken cancellationToken = default); - /// - /// Retrieves a list of all payouts ordered by payout date, with the most recent being first. - /// - /// Options for filtering the result. - /// Cancellation Token - Task> ListPayoutsAsync(ListFilter filter, CancellationToken cancellationToken = default); + /// + /// Retrieves a list of all payouts ordered by payout date, with the most recent being first. + /// + /// Options for filtering the result. + /// Cancellation Token + Task> ListPayoutsAsync(ListFilter filter, CancellationToken cancellationToken = default); - /// - /// Retrieves a list of all payouts ordered by payout date, with the most recent being first. - /// - /// Options for filtering the result. - /// Cancellation Token - Task> ListPayoutsAsync(ShopifyPaymentsPayoutListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Retrieves a list of all payouts ordered by payout date, with the most recent being first. + /// + /// Options for filtering the result. + /// Cancellation Token + Task> ListPayoutsAsync(ShopifyPaymentsPayoutListFilter filter = null, CancellationToken cancellationToken = default); - Task GetPayoutAsync(long payoutId, CancellationToken cancellationToken = default); + Task GetPayoutAsync(long payoutId, CancellationToken cancellationToken = default); - Task> ListDisputesAsync(ListFilter filter, CancellationToken cancellationToken = default); + Task> ListDisputesAsync(ListFilter filter, CancellationToken cancellationToken = default); - Task> ListDisputesAsync(ShopifyPaymentsDisputeListFilter filter = null, CancellationToken cancellationToken = default); + Task> ListDisputesAsync(ShopifyPaymentsDisputeListFilter filter = null, CancellationToken cancellationToken = default); - Task GetDisputeAsync(long disputeId, CancellationToken cancellationToken = default); + Task GetDisputeAsync(long disputeId, CancellationToken cancellationToken = default); - Task> ListTransactionsAsync(ListFilter filter, CancellationToken cancellationToken = default); + Task> ListTransactionsAsync(ListFilter filter, CancellationToken cancellationToken = default); - Task> ListTransactionsAsync(ShopifyPaymentsTransactionListFilter filter = null, CancellationToken cancellationToken = default); + Task> ListTransactionsAsync(ShopifyPaymentsTransactionListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Retrieves a single dispute evidence record from the dispute Id. - /// - /// - /// - /// - Task GetDisputeEvidenceAsync(long disputeId, CancellationToken cancellationToken = default); + /// + /// Retrieves a single dispute evidence record from the dispute Id. + /// + /// + /// + /// + Task GetDisputeEvidenceAsync(long disputeId, CancellationToken cancellationToken = default); - /// - /// Updates a single dispute evidence record from the dispute Id. - /// - /// - /// - /// - /// - Task UpdateDisputeEvidenceAsync(long disputeId, ShopifyPaymentsDisputeEvidenceUpdate updateRequest, CancellationToken cancellationToken = default); - } + /// + /// Updates a single dispute evidence record from the dispute Id. + /// + /// + /// + /// + /// + Task UpdateDisputeEvidenceAsync(long disputeId, ShopifyPaymentsDisputeEvidenceUpdate updateRequest, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/ShopifyPayments/ShopifyPaymentsService.cs b/ShopifySharp/Services/ShopifyPayments/ShopifyPaymentsService.cs index 1d21bafe..0150945b 100644 --- a/ShopifySharp/Services/ShopifyPayments/ShopifyPaymentsService.cs +++ b/ShopifySharp/Services/ShopifyPayments/ShopifyPaymentsService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Lists; using System.Collections.Generic; using System.Net; @@ -7,78 +7,77 @@ using ShopifySharp.Infrastructure; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify payments. +/// +public class ShopifyPaymentsService : ShopifyService, IShopifyPaymentsService { /// - /// A service for manipulating Shopify payments. + /// Creates a new instance of . /// - public class ShopifyPaymentsService : ShopifyService, IShopifyPaymentsService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public ShopifyPaymentsService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal ShopifyPaymentsService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) { } + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public ShopifyPaymentsService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal ShopifyPaymentsService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) { } - /// - public virtual async Task IsShopifyPaymentApiEnabledAsync(CancellationToken cancellationToken = default) + /// + public virtual async Task IsShopifyPaymentApiEnabledAsync(CancellationToken cancellationToken = default) + { + try { - try - { - //calling any method endpoint would do, but choosing GetBalance because it is likely the most lightweight - await this.GetBalanceAsync(cancellationToken); - return true; - } - catch (ShopifyHttpException ex) when (ex.HttpStatusCode == HttpStatusCode.NotFound) - { - return false; - } + //calling any method endpoint would do, but choosing GetBalance because it is likely the most lightweight + await this.GetBalanceAsync(cancellationToken); + return true; } + catch (ShopifyHttpException ex) when (ex.HttpStatusCode == HttpStatusCode.NotFound) + { + return false; + } + } - /// - public virtual async Task> GetBalanceAsync(CancellationToken cancellationToken = default) => - await ExecuteGetAsync>("shopify_payments/balance.json", "balance", cancellationToken: cancellationToken); + /// + public virtual async Task> GetBalanceAsync(CancellationToken cancellationToken = default) => + await ExecuteGetAsync>("shopify_payments/balance.json", "balance", cancellationToken: cancellationToken); - /// - public virtual async Task> ListPayoutsAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("shopify_payments/payouts.json", "payouts", filter, cancellationToken: cancellationToken); + /// + public virtual async Task> ListPayoutsAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("shopify_payments/payouts.json", "payouts", filter, cancellationToken: cancellationToken); - /// - public virtual async Task> ListPayoutsAsync(ShopifyPaymentsPayoutListFilter filter = null, CancellationToken cancellationToken = default) => - await ListPayoutsAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListPayoutsAsync(ShopifyPaymentsPayoutListFilter filter = null, CancellationToken cancellationToken = default) => + await ListPayoutsAsync(filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task GetPayoutAsync(long payoutId, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"shopify_payments/payouts/{payoutId}.json", "payout", cancellationToken: cancellationToken); + /// + public virtual async Task GetPayoutAsync(long payoutId, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"shopify_payments/payouts/{payoutId}.json", "payout", cancellationToken: cancellationToken); - /// - public virtual async Task> ListDisputesAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("shopify_payments/disputes.json", "disputes", filter, cancellationToken: cancellationToken); + /// + public virtual async Task> ListDisputesAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("shopify_payments/disputes.json", "disputes", filter, cancellationToken: cancellationToken); - /// - public virtual async Task> ListDisputesAsync(ShopifyPaymentsDisputeListFilter filter = null, CancellationToken cancellationToken = default) => - await ListDisputesAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListDisputesAsync(ShopifyPaymentsDisputeListFilter filter = null, CancellationToken cancellationToken = default) => + await ListDisputesAsync(filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task GetDisputeAsync(long disputeId, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"shopify_payments/disputes/{disputeId}.json", "dispute", cancellationToken: cancellationToken); + /// + public virtual async Task GetDisputeAsync(long disputeId, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"shopify_payments/disputes/{disputeId}.json", "dispute", cancellationToken: cancellationToken); - /// - public virtual async Task> ListTransactionsAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("shopify_payments/balance/transactions.json", "transactions", filter, cancellationToken: cancellationToken); + /// + public virtual async Task> ListTransactionsAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("shopify_payments/balance/transactions.json", "transactions", filter, cancellationToken: cancellationToken); - /// - public virtual async Task> ListTransactionsAsync(ShopifyPaymentsTransactionListFilter filter = null, CancellationToken cancellationToken = default) => - await ListTransactionsAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListTransactionsAsync(ShopifyPaymentsTransactionListFilter filter = null, CancellationToken cancellationToken = default) => + await ListTransactionsAsync(filter?.AsListFilter(), cancellationToken); - /// - public async Task GetDisputeEvidenceAsync(long disputeId, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"shopify_payments/disputes/{disputeId}/dispute_evidences.json", "dispute_evidence", cancellationToken: cancellationToken); + /// + public async Task GetDisputeEvidenceAsync(long disputeId, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"shopify_payments/disputes/{disputeId}/dispute_evidences.json", "dispute_evidence", cancellationToken: cancellationToken); - /// - public async Task UpdateDisputeEvidenceAsync(long disputeId, ShopifyPaymentsDisputeEvidenceUpdate updateRequest, CancellationToken cancellationToken = default) => - await ExecutePutAsync($"shopify_payments/disputes/{disputeId}/dispute_evidences.json", "dispute_evidence", cancellationToken: cancellationToken, updateRequest); - } -} + /// + public async Task UpdateDisputeEvidenceAsync(long disputeId, ShopifyPaymentsDisputeEvidenceUpdate updateRequest, CancellationToken cancellationToken = default) => + await ExecutePutAsync($"shopify_payments/disputes/{disputeId}/dispute_evidences.json", "dispute_evidence", cancellationToken: cancellationToken, updateRequest); +} \ No newline at end of file diff --git a/ShopifySharp/Services/ShopifyService.cs b/ShopifySharp/Services/ShopifyService.cs index d1252a35..cf3a6db9 100644 --- a/ShopifySharp/Services/ShopifyService.cs +++ b/ShopifySharp/Services/ShopifyService.cs @@ -1,4 +1,4 @@ -// ReSharper disable InconsistentNaming +// ReSharper disable InconsistentNaming using System; using System.Collections.Generic; using System.Linq; @@ -14,566 +14,571 @@ using ShopifySharp.Filters; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +public abstract class ShopifyService : IShopifyService { - public abstract class ShopifyService : IShopifyService - { - public const string REQUEST_HEADER_ACCESS_TOKEN = "X-Shopify-Access-Token"; + public const string REQUEST_HEADER_ACCESS_TOKEN = "X-Shopify-Access-Token"; #nullable enable - public virtual string APIVersion => "2024-04"; - public virtual bool SupportsAPIVersioning => true; + public virtual string APIVersion => "2024-04"; + public virtual bool SupportsAPIVersioning => true; - protected Uri _ShopUri { get; set; } - protected string _AccessToken { get; set; } + protected Uri _ShopUri { get; set; } + protected string _AccessToken { get; set; } - private static IRequestExecutionPolicy _GlobalExecutionPolicy = new DefaultRequestExecutionPolicy(); - private static IHttpClientFactory _HttpClientFactory = new InternalHttpClientFactory(); - private IRequestExecutionPolicy _ExecutionPolicy; - private HttpClient _Client; + private static IRequestExecutionPolicy _GlobalExecutionPolicy = new DefaultRequestExecutionPolicy(); + private static IHttpClientFactory _HttpClientFactory = new InternalHttpClientFactory(); + private IRequestExecutionPolicy _ExecutionPolicy; + private HttpClient _Client; - protected ShopifyService(string shopDomain, string accessToken, IShopifyDomainUtility domainUtility) - { - _ShopUri = domainUtility.BuildShopDomainUri(shopDomain); - _AccessToken = accessToken; - _Client = _HttpClientFactory.CreateClient(); - _ExecutionPolicy = _GlobalExecutionPolicy; - } + protected ShopifyService(string shopDomain, string accessToken, IShopifyDomainUtility domainUtility) + { + _ShopUri = domainUtility.BuildShopDomainUri(shopDomain); + _AccessToken = accessToken; + _Client = _HttpClientFactory.CreateClient(); + _ExecutionPolicy = _GlobalExecutionPolicy; + } - /// - /// Creates a new instance of the service using a Shopify shop domain and access token. - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - protected ShopifyService(string myShopifyUrl, string shopAccessToken) - { - var domainUtility = new ShopifyDomainUtility(); - _ShopUri = domainUtility.BuildShopDomainUri(myShopifyUrl); - _AccessToken = shopAccessToken; - _Client = _HttpClientFactory.CreateClient(); - _ExecutionPolicy = _GlobalExecutionPolicy; - } + /// + /// Creates a new instance of the service using a Shopify shop domain and access token. + /// + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + protected ShopifyService(string myShopifyUrl, string shopAccessToken) + { + var domainUtility = new ShopifyDomainUtility(); + _ShopUri = domainUtility.BuildShopDomainUri(myShopifyUrl); + _AccessToken = shopAccessToken; + _Client = _HttpClientFactory.CreateClient(); + _ExecutionPolicy = _GlobalExecutionPolicy; + } - /// - /// Creates a new instance of the service using the Shopify shop domain and access token in the . - /// - protected ShopifyService(ShopifyApiCredentials credentials) - { - var domainUtility = new ShopifyDomainUtility(); - _ShopUri = domainUtility.BuildShopDomainUri(credentials.ShopDomain); - _AccessToken = credentials.AccessToken; - _Client = _HttpClientFactory.CreateClient(); - _ExecutionPolicy = _GlobalExecutionPolicy; - } + /// + /// Creates a new instance of the service using the Shopify shop domain and access token in the . + /// + protected ShopifyService(ShopifyApiCredentials credentials) + { + var domainUtility = new ShopifyDomainUtility(); + _ShopUri = domainUtility.BuildShopDomainUri(credentials.ShopDomain); + _AccessToken = credentials.AccessToken; + _Client = _HttpClientFactory.CreateClient(); + _ExecutionPolicy = _GlobalExecutionPolicy; + } + + /// + /// Attempts to build a shop API for the given shop. + /// + /// The shop's *.myshopify.com URL. + /// Whether the /admin path should be included in the resulting URI. + [Obsolete("This method is deprecated and will be removed in a future version of ShopifySharp. Please use the ShopifySharp.Utilities.ShopifyDomainUtility instead.")] + // TODO: remove this method after 6-8 weeks + public static Uri BuildShopUri(string shopDomain, bool withAdminPath) + { + var domainUtility = new ShopifyDomainUtility(); + var shopUri = domainUtility.BuildShopDomainUri(shopDomain); + + if (!withAdminPath) + return shopUri; - /// - /// Attempts to build a shop API for the given shop. - /// - /// The shop's *.myshopify.com URL. - /// Whether the /admin path should be included in the resulting URI. - [Obsolete("This method is deprecated and will be removed in a future version of ShopifySharp. Please use the ShopifySharp.Utilities.ShopifyDomainUtility instead.")] - // TODO: remove this method after 6-8 weeks - public static Uri BuildShopUri(string shopDomain, bool withAdminPath) + var uriBuilder = new UriBuilder(shopUri) { - var domainUtility = new ShopifyDomainUtility(); - var shopUri = domainUtility.BuildShopDomainUri(shopDomain); + Path = "admin" + }; - if (!withAdminPath) - return shopUri; + return uriBuilder.Uri; + } - var uriBuilder = new UriBuilder(shopUri) - { - Path = "admin" - }; +#nullable disable - return uriBuilder.Uri; - } + /// + /// Sets the execution policy for this instance only. This policy will always be used over the global execution policy. + /// This instance will revert back to the global execution policy if you pass null to this method. + /// + public void SetExecutionPolicy(IRequestExecutionPolicy executionPolicy) + { + // If the user passes null, revert to the global execution policy. + _ExecutionPolicy = executionPolicy ?? _GlobalExecutionPolicy; + } - #nullable disable + /// + /// Sets the global execution policy for all *new* instances. Current instances are unaffected, but you can call .SetExecutionPolicy on them. + /// The execution policy will revert back to the if you pass null to this method. + /// + public static void SetGlobalExecutionPolicy(IRequestExecutionPolicy globalExecutionPolicy) + { + _GlobalExecutionPolicy = globalExecutionPolicy ?? new DefaultRequestExecutionPolicy(); + } - /// - /// Sets the execution policy for this instance only. This policy will always be used over the global execution policy. - /// This instance will revert back to the global execution policy if you pass null to this method. - /// - public void SetExecutionPolicy(IRequestExecutionPolicy executionPolicy) - { - // If the user passes null, revert to the global execution policy. - _ExecutionPolicy = executionPolicy ?? _GlobalExecutionPolicy; - } + /// + /// Sets the for this instance only. This client will always be used over the one from the global . + /// This instance will revert back to the global execution policy if you pass null to this method. + /// + public void SetHttpClient(HttpClient client) + { + // If the user passes null, revert to the client factory's client. + _Client = client ?? _HttpClientFactory.CreateClient(); + } - /// - /// Sets the global execution policy for all *new* instances. Current instances are unaffected, but you can call .SetExecutionPolicy on them. - /// The execution policy will revert back to the if you pass null to this method. - /// - public static void SetGlobalExecutionPolicy(IRequestExecutionPolicy globalExecutionPolicy) - { - _GlobalExecutionPolicy = globalExecutionPolicy ?? new DefaultRequestExecutionPolicy(); - } + /// + /// Sets the global for all *new* instances. Current instances are unaffected, but you can call on them. + /// The factory will revert back to the if you pass null to this method. + /// + public static void SetGlobalHttpClientFactory(IHttpClientFactory factory) + { + _HttpClientFactory = factory ?? new InternalHttpClientFactory(); + } - /// - /// Sets the for this instance only. This client will always be used over the one from the global . - /// This instance will revert back to the global execution policy if you pass null to this method. - /// - public void SetHttpClient(HttpClient client) + /// + /// Builds a by merging the with Shopify's admin path and the parameter. + /// + /// + /// The request's path, which will be added to /admin/api or /admin/api/ if the service supports API versioning. + /// + protected virtual RequestUri BuildRequestUri(string path) + { + var ub = new UriBuilder(_ShopUri) { - // If the user passes null, revert to the client factory's client. - _Client = client ?? _HttpClientFactory.CreateClient(); - } + Scheme = Uri.UriSchemeHttps, + Port = 443, + Path = SupportsAPIVersioning ? $"admin/api/{APIVersion}/{path}" : $"admin/{path}" + }; + + return new RequestUri(ub.Uri); + } + + [Obsolete("This method is deprecated and has been replaced by BuildAdminRequestUri(string, bool).")] + protected RequestUri PrepareRequest(string path) => + BuildRequestUri(path); + + /// + /// Prepares a request to the path and appends the shop's access token header if applicable. + /// + protected CloneableRequestMessage PrepareRequestMessage(RequestUri uri, HttpMethod method, HttpContent content, IDictionary headers = null) + { + var msg = new CloneableRequestMessage(uri.ToUri(), method, content); - /// - /// Sets the global for all *new* instances. Current instances are unaffected, but you can call on them. - /// The factory will revert back to the if you pass null to this method. - /// - public static void SetGlobalHttpClientFactory(IHttpClientFactory factory) + if (!string.IsNullOrEmpty(_AccessToken)) { - _HttpClientFactory = factory ?? new InternalHttpClientFactory(); + msg.Headers.Add(REQUEST_HEADER_ACCESS_TOKEN, _AccessToken); } - /// - /// Builds a by merging the with Shopify's admin path and the parameter. - /// - /// - /// The request's path, which will be added to /admin/api or /admin/api/ if the service supports API versioning. - /// - protected virtual RequestUri BuildRequestUri(string path) + msg.Headers.Add("Accept", "application/json"); + + if (headers != null) { - var ub = new UriBuilder(_ShopUri) + foreach (var kv in headers) { - Scheme = Uri.UriSchemeHttps, - Port = 443, - Path = SupportsAPIVersioning ? $"admin/api/{APIVersion}/{path}" : $"admin/{path}" - }; - - return new RequestUri(ub.Uri); + msg.Headers.Add(kv.Key, kv.Value); + } } - [Obsolete("This method is deprecated and has been replaced by BuildAdminRequestUri(string, bool).")] - protected RequestUri PrepareRequest(string path) => - BuildRequestUri(path); + return msg; + } + + /// + /// Attempts to parse the Link header from a web response. Returns either the header value or null if it does not exist. + /// + /// + /// The Link header only exists on list requests. + /// + private string ReadLinkHeader(HttpResponseHeaders responseHeaders) + { + var linkHeaderValues = responseHeaders + .FirstOrDefault(h => h.Key.Equals("link", StringComparison.OrdinalIgnoreCase)) + .Value; + + return linkHeaderValues == null ? null : string.Join(", ", linkHeaderValues); + } - /// - /// Prepares a request to the path and appends the shop's access token header if applicable. - /// - protected CloneableRequestMessage PrepareRequestMessage(RequestUri uri, HttpMethod method, HttpContent content, IDictionary headers = null) + protected async Task> ExecuteRequestCoreAsync( + RequestUri uri, + HttpMethod method, + CancellationToken cancellationToken, + HttpContent content, + Dictionary headers, + string rootElement, + int? graphqlQueryCost, + DateParseHandling? dateParseHandlingOverride = null + ) + { + using var baseRequestMessage = PrepareRequestMessage(uri, method, content, headers); + var policyResult = await _ExecutionPolicy.Run(baseRequestMessage, async (requestMessage) => { - var msg = new CloneableRequestMessage(uri.ToUri(), method, content); + using var response = await _Client.SendAsync(requestMessage, cancellationToken); - if (!string.IsNullOrEmpty(_AccessToken)) - { - msg.Headers.Add(REQUEST_HEADER_ACCESS_TOKEN, _AccessToken); - } +#if NETSTANDARD2_0 + var rawResult = await response.Content.ReadAsStringAsync(); +#else + var rawResult = await response.Content.ReadAsStringAsync(cancellationToken); +#endif - msg.Headers.Add("Accept", "application/json"); + //Check for and throw exception when necessary. + CheckResponseExceptions(await baseRequestMessage.GetRequestInfo(), response, rawResult); - if (headers != null) - { - foreach (var kv in headers) - { - msg.Headers.Add(kv.Key, kv.Value); - } - } + var result = method == HttpMethod.Delete ? default : Serializer.Deserialize(rawResult, rootElement, dateParseHandlingOverride); - return msg; - } + return new RequestResult(await baseRequestMessage.GetRequestInfo(), + response, + response.Headers, + result, + rawResult, + ReadLinkHeader(response.Headers), + response.StatusCode); + }, cancellationToken, graphqlQueryCost); - /// - /// Attempts to parse the Link header from a web response. Returns either the header value or null if it does not exist. - /// - /// - /// The Link header only exists on list requests. - /// - private string ReadLinkHeader(HttpResponseHeaders responseHeaders) - { - var linkHeaderValues = responseHeaders - .FirstOrDefault(h => h.Key.Equals("link", StringComparison.OrdinalIgnoreCase)) - .Value; + return policyResult; + } - return linkHeaderValues == null ? null : string.Join(", ", linkHeaderValues); - } + /// + /// Executes a request and returns a JToken for querying. Throws an exception when the response is invalid. + /// Use this method when the expected response is a single line or simple object that doesn't warrant its own class. + /// + protected async Task> ExecuteRequestAsync( + RequestUri uri, + HttpMethod method, + CancellationToken cancellationToken, + HttpContent content = null, + Dictionary headers = null + ) + { + return await ExecuteRequestCoreAsync(uri, method, cancellationToken, content, headers, null, null); + } - protected async Task> ExecuteRequestCoreAsync( - RequestUri uri, - HttpMethod method, - CancellationToken cancellationToken, - HttpContent content, - Dictionary headers, - string rootElement, - int? graphqlQueryCost, - DateParseHandling? dateParseHandlingOverride = null - ) - { - using var baseRequestMessage = PrepareRequestMessage(uri, method, content, headers); - var policyResult = await _ExecutionPolicy.Run(baseRequestMessage, async (requestMessage) => - { - using var response = await _Client.SendAsync(requestMessage, cancellationToken); + /// + /// Executes a request and returns the given type. Throws an exception when the response is invalid. + /// Use this method when the expected response is a single line or simple object that doesn't warrant its own class. + /// + protected async Task> ExecuteRequestAsync( + RequestUri uri, + HttpMethod method, + CancellationToken cancellationToken, + HttpContent content = null, + string rootElement = null, + Dictionary headers = null + ) + { + return await ExecuteRequestCoreAsync(uri, method, cancellationToken, content, headers, rootElement, null); + } - #if NETSTANDARD2_0 - var rawResult = await response.Content.ReadAsStringAsync(); - #else - var rawResult = await response.Content.ReadAsStringAsync(cancellationToken); - #endif + private async Task ExecuteWithContentCoreAsync( + string path, + string resultRootElt, + HttpMethod method, + HttpContent content, + CancellationToken cancellationToken + ) + { + var requestUri = BuildRequestUri(path); + var response = await ExecuteRequestAsync(requestUri, method, cancellationToken: cancellationToken, content: content, rootElement: resultRootElt); + return response.Result; + } - //Check for and throw exception when necessary. - CheckResponseExceptions(await baseRequestMessage.GetRequestInfo(), response, rawResult); + protected async Task ExecutePostAsync( + string path, + string resultRootElt, + CancellationToken cancellationToken, + object jsonContent = null + ) + { + return await ExecuteWithContentCoreAsync(path, resultRootElt, HttpMethod.Post, jsonContent == null ? null : new JsonContent(jsonContent), cancellationToken); + } - var result = method == HttpMethod.Delete ? default : Serializer.Deserialize(rawResult, rootElement, dateParseHandlingOverride); + protected async Task ExecutePutAsync( + string path, + string resultRootElt, + CancellationToken cancellationToken, + object jsonContent = null + ) + { + return await ExecuteWithContentCoreAsync(path, resultRootElt, HttpMethod.Put, jsonContent == null ? null : new JsonContent(jsonContent), cancellationToken); + } - return new RequestResult(await baseRequestMessage.GetRequestInfo(), response, response.Headers, result, rawResult, ReadLinkHeader(response.Headers)); - }, cancellationToken, graphqlQueryCost); + protected async Task ExecuteDeleteAsync( + string path, + CancellationToken cancellationToken + ) + { + await ExecuteWithContentCoreAsync(path, null, HttpMethod.Delete, null, cancellationToken); + } - return policyResult; - } + private async Task> ExecuteGetCoreAsync( + string path, + string resultRootElt, + Parameterizable queryParams, + string fields, + Dictionary headers, + CancellationToken cancellationToken + ) + { + var requestUri = BuildRequestUri(path); - /// - /// Executes a request and returns a JToken for querying. Throws an exception when the response is invalid. - /// Use this method when the expected response is a single line or simple object that doesn't warrant its own class. - /// - protected async Task> ExecuteRequestAsync( - RequestUri uri, - HttpMethod method, - CancellationToken cancellationToken, - HttpContent content = null, - Dictionary headers = null - ) + if (queryParams != null) { - return await ExecuteRequestCoreAsync(uri, method, cancellationToken, content, headers, null, null); + requestUri.QueryParams.AddRange(queryParams.ToQueryParameters()); } - /// - /// Executes a request and returns the given type. Throws an exception when the response is invalid. - /// Use this method when the expected response is a single line or simple object that doesn't warrant its own class. - /// - protected async Task> ExecuteRequestAsync( - RequestUri uri, - HttpMethod method, - CancellationToken cancellationToken, - HttpContent content = null, - string rootElement = null, - Dictionary headers = null - ) + if (!string.IsNullOrEmpty(fields)) { - return await ExecuteRequestCoreAsync(uri, method, cancellationToken, content, headers, rootElement, null); + requestUri.QueryParams.Add("fields", fields); } - private async Task ExecuteWithContentCoreAsync( - string path, - string resultRootElt, - HttpMethod method, - HttpContent content, - CancellationToken cancellationToken - ) - { - var requestUri = BuildRequestUri(path); - var response = await ExecuteRequestAsync(requestUri, method, cancellationToken: cancellationToken, content: content, rootElement: resultRootElt); - return response.Result; - } + return await ExecuteRequestAsync(requestUri, HttpMethod.Get, cancellationToken: cancellationToken, rootElement: resultRootElt, headers: headers); + } - protected async Task ExecutePostAsync( - string path, - string resultRootElt, - CancellationToken cancellationToken, - object jsonContent = null - ) - { - return await ExecuteWithContentCoreAsync(path, resultRootElt, HttpMethod.Post, jsonContent == null ? null : new JsonContent(jsonContent), cancellationToken); - } + protected async Task ExecuteGetAsync( + string path, + string resultRootElt, + string fields, + CancellationToken cancellationToken = default, + Dictionary headers = null + ) + { + return (await ExecuteGetCoreAsync(path, resultRootElt, null, fields, headers, cancellationToken)).Result; + } - protected async Task ExecutePutAsync( - string path, - string resultRootElt, - CancellationToken cancellationToken, - object jsonContent = null - ) - { - return await ExecuteWithContentCoreAsync(path, resultRootElt, HttpMethod.Put, jsonContent == null ? null : new JsonContent(jsonContent), cancellationToken); - } + protected async Task ExecuteGetAsync( + string path, + string resultRootElt, + Parameterizable queryParams = null, + CancellationToken cancellationToken = default, + Dictionary headers = null + ) + { + return (await ExecuteGetCoreAsync(path, resultRootElt, queryParams, null, headers, cancellationToken)).Result; + } + + protected async Task> ExecuteGetListAsync( + string path, + string resultRootElt, + ListFilter filter, + CancellationToken cancellationToken = default, + Dictionary headers = null + ) + { + var result = await ExecuteGetCoreAsync>(path, resultRootElt, filter, null, headers, cancellationToken); + return ParseLinkHeaderToListResult(result); + } + + /// + /// Checks a response for exceptions or invalid status codes. Throws an exception when necessary. + /// + /// The response. + /// The response body returned by Shopify. + public static void CheckResponseExceptions(string requestInfo, HttpResponseMessage response, string rawResponse) + { + // TODO: make this method protected virtual so inheriting members can override it (e.g. the PartnerService which is doing its own custom error checking right now) - protected async Task ExecuteDeleteAsync( - string path, - CancellationToken cancellationToken - ) + var statusCode = (int)response.StatusCode; + + // No error if response was between 200 and 300. + if (statusCode is >= 200 and < 300) { - await ExecuteWithContentCoreAsync(path, null, HttpMethod.Delete, null, cancellationToken); + return; } - private async Task> ExecuteGetCoreAsync( - string path, - string resultRootElt, - Parameterizable queryParams, - string fields, - Dictionary headers, - CancellationToken cancellationToken - ) + var code = response.StatusCode; + var statusMessage = $"{(int)code} {response.ReasonPhrase}"; + var requestId = ParseRequestIdResponseHeader(response.Headers); + + // If the error was caused by reaching the API rate limit, throw a rate limit exception. + if ((int)code == 429 /* Too many requests */) { - var requestUri = BuildRequestUri(path); + string rateExceptionMessage; + IEnumerable errors; - if (queryParams != null) + if (TryParseErrorJson(rawResponse, out var rateLimitErrors)) { - requestUri.QueryParams.AddRange(queryParams.ToQueryParameters()); + rateExceptionMessage = $"({statusMessage}) {rateLimitErrors.First()}"; + errors = rateLimitErrors; } - - if (!string.IsNullOrEmpty(fields)) + else { - requestUri.QueryParams.Add("fields", fields); + const string baseMessage = "Exceeded the rate limit for api client. Reduce request rates to resume uninterrupted service."; + rateExceptionMessage = $"({statusMessage}) {baseMessage}"; + errors = new List { baseMessage }; } - return await ExecuteRequestAsync(requestUri, HttpMethod.Get, cancellationToken: cancellationToken, rootElement: resultRootElt, headers: headers); - } + var reason = response.Headers.Contains(RestBucketState.RESPONSE_HEADER_API_CALL_LIMIT) + ? ShopifyRateLimitReason.Other + : ShopifyRateLimitReason.BucketFull; + var strRetryAfter = response.Headers + .FirstOrDefault(kvp => kvp.Key == "Retry-After") + .Value + ?.FirstOrDefault(); + int? retryAfterSeconds = null; - protected async Task ExecuteGetAsync( - string path, - string resultRootElt, - string fields, - CancellationToken cancellationToken = default, - Dictionary headers = null - ) - { - return (await ExecuteGetCoreAsync(path, resultRootElt, null, fields, headers, cancellationToken)).Result; - } + if (int.TryParse(strRetryAfter, out var retryValue)) + { + retryAfterSeconds = retryValue; + } - protected async Task ExecuteGetAsync( - string path, - string resultRootElt, - Parameterizable queryParams = null, - CancellationToken cancellationToken = default, - Dictionary headers = null - ) - { - return (await ExecuteGetCoreAsync(path, resultRootElt, queryParams, null, headers, cancellationToken)).Result; + throw new ShopifyRateLimitException(requestInfo, code, errors.ToList(), rateExceptionMessage, rawResponse, requestId, reason, retryAfterSeconds); } - protected async Task> ExecuteGetListAsync( - string path, - string resultRootElt, - ListFilter filter, - CancellationToken cancellationToken = default, - Dictionary headers = null - ) - { - var result = await ExecuteGetCoreAsync>(path, resultRootElt, filter, null, headers, cancellationToken); - return ParseLinkHeaderToListResult(result); - } + var contentType = response.Content.Headers.GetValues("Content-Type").FirstOrDefault(); - /// - /// Checks a response for exceptions or invalid status codes. Throws an exception when necessary. - /// - /// The response. - /// The response body returned by Shopify. - public static void CheckResponseExceptions(string requestInfo, HttpResponseMessage response, string rawResponse) + // TODO: there's probably a better way to check if the content type is json + if (contentType.StartsWithIgnoreCase("application/json") || contentType.StartsWithIgnoreCase("text/json")) { - // TODO: make this method protected virtual so inheriting members can override it (e.g. the PartnerService which is doing its own custom error checking right now) - - var statusCode = (int)response.StatusCode; - - // No error if response was between 200 and 300. - if (statusCode is >= 200 and < 300) - { - return; - } - - var code = response.StatusCode; - var statusMessage = $"{(int)code} {response.ReasonPhrase}"; - var requestId = ParseRequestIdResponseHeader(response.Headers); + IEnumerable errors; + string exceptionMessage; - // If the error was caused by reaching the API rate limit, throw a rate limit exception. - if ((int)code == 429 /* Too many requests */) + if (TryParseErrorJson(rawResponse, out var parsedErrors)) { - string rateExceptionMessage; - IEnumerable errors; + var firstError = parsedErrors.First(); + var totalErrors = parsedErrors.Count(); + var baseErrorMessage = $"({statusMessage}) {firstError}"; - if (TryParseErrorJson(rawResponse, out var rateLimitErrors)) + switch (totalErrors) { - rateExceptionMessage = $"({statusMessage}) {rateLimitErrors.First()}"; - errors = rateLimitErrors; - } - else - { - const string baseMessage = "Exceeded the rate limit for api client. Reduce request rates to resume uninterrupted service."; - rateExceptionMessage = $"({statusMessage}) {baseMessage}"; - errors = new List { baseMessage }; - } + case 1: + exceptionMessage = baseErrorMessage; + break; - var reason = response.Headers.Contains(RestBucketState.RESPONSE_HEADER_API_CALL_LIMIT) - ? ShopifyRateLimitReason.Other - : ShopifyRateLimitReason.BucketFull; - var strRetryAfter = response.Headers - .FirstOrDefault(kvp => kvp.Key == "Retry-After") - .Value - ?.FirstOrDefault(); - int? retryAfterSeconds = null; + case 2: + exceptionMessage = $"{baseErrorMessage} (and one other error)"; + break; - if (int.TryParse(strRetryAfter, out var retryValue)) - { - retryAfterSeconds = retryValue; + default: + exceptionMessage = $"{baseErrorMessage} (and {totalErrors} other errors)"; + break; } - throw new ShopifyRateLimitException(requestInfo, code, errors.ToList(), rateExceptionMessage, rawResponse, requestId, reason, retryAfterSeconds); + errors = parsedErrors; } - - var contentType = response.Content.Headers.GetValues("Content-Type").FirstOrDefault(); - - // TODO: there's probably a better way to check if the content type is json - if (contentType.StartsWithIgnoreCase("application/json") || contentType.StartsWithIgnoreCase("text/json")) + else { - IEnumerable errors; - string exceptionMessage; - - if (TryParseErrorJson(rawResponse, out var parsedErrors)) - { - var firstError = parsedErrors.First(); - var totalErrors = parsedErrors.Count(); - var baseErrorMessage = $"({statusMessage}) {firstError}"; - - switch (totalErrors) - { - case 1: - exceptionMessage = baseErrorMessage; - break; - - case 2: - exceptionMessage = $"{baseErrorMessage} (and one other error)"; - break; + exceptionMessage = $"({statusMessage}) Shopify returned {statusMessage}, but ShopifySharp was unable to parse the response JSON."; + errors = []; + } - default: - exceptionMessage = $"{baseErrorMessage} (and {totalErrors} other errors)"; - break; - } + throw new ShopifyHttpException(requestInfo, code, errors.ToList(), exceptionMessage, rawResponse, requestId); + } - errors = parsedErrors; - } - else - { - exceptionMessage = $"({statusMessage}) Shopify returned {statusMessage}, but ShopifySharp was unable to parse the response JSON."; - errors = []; - } + var message = $"({statusMessage}) Shopify returned {statusMessage}, but there was no JSON to parse into an error message."; + var customErrors = new List + { + message + }; - throw new ShopifyHttpException(requestInfo, code, errors.ToList(), exceptionMessage, rawResponse, requestId); - } + throw new ShopifyHttpException(requestInfo, code, customErrors, message, rawResponse, requestId); + } - var message = $"({statusMessage}) Shopify returned {statusMessage}, but there was no JSON to parse into an error message."; - var customErrors = new List - { - message - }; + /// + /// Attempts to parse a JSON string for Shopify API errors. Returns false if the string cannot be parsed or contains no errors. + /// + public static bool TryParseErrorJson(string json, out List output) + { + // TODO: obsolete and replace this with a json error parsing util? + output = null; - throw new ShopifyHttpException(requestInfo, code, customErrors, message, rawResponse, requestId); + if (string.IsNullOrEmpty(json)) + { + return false; } - /// - /// Attempts to parse a JSON string for Shopify API errors. Returns false if the string cannot be parsed or contains no errors. - /// - public static bool TryParseErrorJson(string json, out List output) + var errors = new List(); + + try { - // TODO: obsolete and replace this with a json error parsing util? - output = null; + var parsed = JToken.Parse(string.IsNullOrEmpty(json) ? "{}" : json); - if (string.IsNullOrEmpty(json)) + if (parsed.Type != JTokenType.Object) { return false; } - var errors = new List(); + // Errors can be any of the following: + // 1. { "errors": "some error message"} + // 2. { "errors": { "order" : "some error message" } } + // 3. { "errors": { "order" : [ "some error message" ] } } + // 4. { "error": "invalid_request", error_description:"The authorization code was not found or was already used" } + // 5. { "error": "location_id must be specified when creating fulfillments." } - try + if (parsed.Any(p => p.Path == "error") && parsed.Any(p => p.Path == "error_description")) { - var parsed = JToken.Parse(string.IsNullOrEmpty(json) ? "{}" : json); + // Error is type #4 + var description = parsed["error_description"].Value(); + var errorType = parsed["error"].Value(); - if (parsed.Type != JTokenType.Object) - { - return false; - } - - // Errors can be any of the following: - // 1. { "errors": "some error message"} - // 2. { "errors": { "order" : "some error message" } } - // 3. { "errors": { "order" : [ "some error message" ] } } - // 4. { "error": "invalid_request", error_description:"The authorization code was not found or was already used" } - // 5. { "error": "location_id must be specified when creating fulfillments." } + errors.Add($"{errorType}: {description}"); + } + else if (parsed.Any(p => p.Path == "error")) + { + // Error is type #5 + var description = parsed["error"].Value(); - if (parsed.Any(p => p.Path == "error") && parsed.Any(p => p.Path == "error_description")) - { - // Error is type #4 - var description = parsed["error_description"].Value(); - var errorType = parsed["error"].Value(); + errors.Add(description); + } + else if (parsed.Any(x => x.Path == "errors")) + { + var parsedErrors = parsed["errors"]; - errors.Add($"{errorType}: {description}"); - } - else if (parsed.Any(p => p.Path == "error")) + // errors can be either a single string, or an array of other errors + if (parsedErrors?.Type == JTokenType.String) { - // Error is type #5 - var description = parsed["error"].Value(); + // errors is type #1 + var description = parsedErrors.Value(); errors.Add(description); } - else if (parsed.Any(x => x.Path == "errors")) + else { - var parsedErrors = parsed["errors"]; - - // errors can be either a single string, or an array of other errors - if (parsedErrors?.Type == JTokenType.String) + // errors is type #2 or #3 + foreach (var val in parsedErrors?.Values() ?? JEnumerable.Empty) { - // errors is type #1 - var description = parsedErrors.Value(); + var name = val.Path.Split('.').Last(); - errors.Add(description); - } - else - { - // errors is type #2 or #3 - foreach (var val in parsedErrors?.Values() ?? JEnumerable.Empty) + if (val.Type == JTokenType.String) { - var name = val.Path.Split('.').Last(); + var description = val.Value(); - if (val.Type == JTokenType.String) - { - var description = val.Value(); - - errors.Add($"{name}: {description}"); - } - else if (val.Type == JTokenType.Array) + errors.Add($"{name}: {description}"); + } + else if (val.Type == JTokenType.Array) + { + foreach (var msg in val.Values()) { - foreach (var msg in val.Values()) - { - errors.Add($"{name}: {msg}"); - } + errors.Add($"{name}: {msg}"); } } } } - else - { - return false; - } } - catch (JsonReaderException) + else { return false; } - - if (!errors.Any()) - { - return false; - } - - output = errors; - - return true; } - - /// - /// Parses a link header value into a . The Items property will need to be manually set. - /// - protected ListResult ParseLinkHeaderToListResult(RequestResult> requestResult) + catch (JsonReaderException) { - return new ListResult(requestResult.Result, requestResult.RawLinkHeaderValue == null ? null : LinkHeaderParser.Parse(requestResult.RawLinkHeaderValue)); + return false; } - #nullable enable - protected static string? ParseRequestIdResponseHeader(HttpResponseHeaders responseHeaders) + if (!errors.Any()) { - const string headerName = "X-Request-Id"; - return responseHeaders.TryGetValues(headerName, out var headerValues) ? headerValues.First() : null; + return false; } + + output = errors; + + return true; + } + + /// + /// Parses a link header value into a . The Items property will need to be manually set. + /// + protected ListResult ParseLinkHeaderToListResult(RequestResult> requestResult) + { + return new ListResult(requestResult.Result, requestResult.RawLinkHeaderValue == null ? null : LinkHeaderParser.Parse(requestResult.RawLinkHeaderValue)); + } + +#nullable enable + protected static string? ParseRequestIdResponseHeader(HttpResponseHeaders responseHeaders) + { + const string headerName = "X-Request-Id"; + return responseHeaders.TryGetValues(headerName, out var headerValues) ? headerValues.First() : null; } } diff --git a/ShopifySharp/Services/SmartCollection/ISmartCollectionService.cs b/ShopifySharp/Services/SmartCollection/ISmartCollectionService.cs index f038269e..192c90ce 100644 --- a/ShopifySharp/Services/SmartCollection/ISmartCollectionService.cs +++ b/ShopifySharp/Services/SmartCollection/ISmartCollectionService.cs @@ -3,85 +3,84 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface ISmartCollectionService : IShopifyService { - public interface ISmartCollectionService : IShopifyService - { - /// - /// Gets a count of all smart collections on the store. - /// - /// Options for filtering the result. - /// Cancellation Token - Task CountAsync(SmartCollectionCountFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a count of all smart collections on the store. + /// + /// Options for filtering the result. + /// Cancellation Token + Task CountAsync(SmartCollectionCountFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 smart collections. - /// - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 smart collections. + /// + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 smart collections. - /// - Task> ListAsync(SmartCollectionListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 smart collections. + /// + Task> ListAsync(SmartCollectionListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the smart collection to retrieve. - /// Cancellation Token - Task GetAsync(long collectionId, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the smart collection to retrieve. + /// Cancellation Token + Task GetAsync(long collectionId, CancellationToken cancellationToken = default); - /// - /// Creates a new . - /// - /// A new . Id should be set to null. - /// Cancellation Token - Task CreateAsync(SmartCollection collection, bool published = true, CancellationToken cancellationToken = default); + /// + /// Creates a new . + /// + /// A new . Id should be set to null. + /// Cancellation Token + Task CreateAsync(SmartCollection collection, bool published = true, CancellationToken cancellationToken = default); - /// - /// Updates the given . - /// - /// Id of the object being updated. - /// The smart collection to update. - /// Cancellation Token - Task UpdateAsync(long smartCollectionId, SmartCollection collection, CancellationToken cancellationToken = default); + /// + /// Updates the given . + /// + /// Id of the object being updated. + /// The smart collection to update. + /// Cancellation Token + Task UpdateAsync(long smartCollectionId, SmartCollection collection, CancellationToken cancellationToken = default); - /// - /// Publishes an unpublished smart collection. - /// - /// The collection's id. - /// Cancellation Token - Task PublishAsync(long smartCollectionId, CancellationToken cancellationToken = default); + /// + /// Publishes an unpublished smart collection. + /// + /// The collection's id. + /// Cancellation Token + Task PublishAsync(long smartCollectionId, CancellationToken cancellationToken = default); - /// - /// Publishes an unpublished smart collection. - /// - /// The collection's id. - /// Cancellation Token - Task UnpublishAsync(long smartCollectionId, CancellationToken cancellationToken = default); + /// + /// Publishes an unpublished smart collection. + /// + /// The collection's id. + /// Cancellation Token + Task UnpublishAsync(long smartCollectionId, CancellationToken cancellationToken = default); - /// - /// Updates the order of products when a SmartCollection's sort-by method is set to "manual". - /// - /// Id of the object being updated. - /// The order in which products in the smart collection appear. Note that specifying productIds parameter will have no effect unless the sort order is "manual" - /// An array of product ids sorted in the order you want them to appear in. - Task UpdateProductOrderAsync(long smartCollectionId, string sortOrder = null, params long[] productIds); + /// + /// Updates the order of products when a SmartCollection's sort-by method is set to "manual". + /// + /// Id of the object being updated. + /// The order in which products in the smart collection appear. Note that specifying productIds parameter will have no effect unless the sort order is "manual" + /// An array of product ids sorted in the order you want them to appear in. + Task UpdateProductOrderAsync(long smartCollectionId, string sortOrder = null, params long[] productIds); - /// - /// Updates the order of products when a SmartCollection's sort-by method is set to "manual". - /// - /// Id of the object being updated. - /// Cancellation Token - /// The order in which products in the smart collection appear. Note that specifying productIds parameter will have no effect unless the sort order is "manual" - /// An array of product ids sorted in the order you want them to appear in. - Task UpdateProductOrderAsync(long smartCollectionId, CancellationToken cancellationToken, string sortOrder = null, params long[] productIds); + /// + /// Updates the order of products when a SmartCollection's sort-by method is set to "manual". + /// + /// Id of the object being updated. + /// Cancellation Token + /// The order in which products in the smart collection appear. Note that specifying productIds parameter will have no effect unless the sort order is "manual" + /// An array of product ids sorted in the order you want them to appear in. + Task UpdateProductOrderAsync(long smartCollectionId, CancellationToken cancellationToken, string sortOrder = null, params long[] productIds); - /// - /// Deletes a smart collection with the given Id. - /// - /// The smart collection's id. - /// Cancellation Token - Task DeleteAsync(long collectionId, CancellationToken cancellationToken = default); - } + /// + /// Deletes a smart collection with the given Id. + /// + /// The smart collection's id. + /// Cancellation Token + Task DeleteAsync(long collectionId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/SmartCollection/SmartCollectionService.cs b/ShopifySharp/Services/SmartCollection/SmartCollectionService.cs index d059feee..27198e48 100644 --- a/ShopifySharp/Services/SmartCollection/SmartCollectionService.cs +++ b/ShopifySharp/Services/SmartCollection/SmartCollectionService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using ShopifySharp.Lists; using System.Collections.Generic; @@ -7,133 +7,132 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify's smart collections. +/// +public class SmartCollectionService : ShopifyService, ISmartCollectionService { /// - /// A service for manipulating Shopify's smart collections. + /// Creates a new instance of . /// - public class SmartCollectionService : ShopifyService, ISmartCollectionService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public SmartCollectionService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal SmartCollectionService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public SmartCollectionService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal SmartCollectionService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CountAsync(SmartCollectionCountFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync("smart_collections/count.json", "count", filter, cancellationToken); + /// + public virtual async Task CountAsync(SmartCollectionCountFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync("smart_collections/count.json", "count", filter, cancellationToken); + + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync($"smart_collections.json", "smart_collections", filter, cancellationToken); - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync($"smart_collections.json", "smart_collections", filter, cancellationToken); + /// + public virtual async Task> ListAsync(SmartCollectionListFilter filter = null, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task> ListAsync(SmartCollectionListFilter filter = null, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task GetAsync(long collectionId, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"smart_collections/{collectionId}.json", "smart_collection", cancellationToken: cancellationToken); - /// - public virtual async Task GetAsync(long collectionId, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"smart_collections/{collectionId}.json", "smart_collection", cancellationToken: cancellationToken); + /// + public virtual async Task CreateAsync(SmartCollection collection, bool published = true, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"smart_collections.json"); + var body = collection.ToDictionary(); + + body.Add("published", published); - /// - public virtual async Task CreateAsync(SmartCollection collection, bool published = true, CancellationToken cancellationToken = default) + var content = new JsonContent(new { - var req = BuildRequestUri($"smart_collections.json"); - var body = collection.ToDictionary(); + smart_collection = body + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "smart_collection"); - body.Add("published", published); + return response.Result; + } - var content = new JsonContent(new - { - smart_collection = body - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "smart_collection"); + /// + public virtual async Task UpdateAsync(long smartCollectionId, SmartCollection collection, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"smart_collections/{smartCollectionId}.json"); + var content = new JsonContent(new + { + smart_collection = collection + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "smart_collection"); - return response.Result; - } + return response.Result; + } - /// - public virtual async Task UpdateAsync(long smartCollectionId, SmartCollection collection, CancellationToken cancellationToken = default) + /// + public virtual async Task PublishAsync(long smartCollectionId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"smart_collections/{smartCollectionId}.json"); + var body = new Dictionary() { - var req = BuildRequestUri($"smart_collections/{smartCollectionId}.json"); - var content = new JsonContent(new - { - smart_collection = collection - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "smart_collection"); - - return response.Result; - } - - /// - public virtual async Task PublishAsync(long smartCollectionId, CancellationToken cancellationToken = default) + { "id", smartCollectionId }, + { "published", true } + }; + var content = new JsonContent(new { - var req = BuildRequestUri($"smart_collections/{smartCollectionId}.json"); - var body = new Dictionary() - { - { "id", smartCollectionId }, - { "published", true } - }; - var content = new JsonContent(new - { - smart_collection = body - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "smart_collection"); - - return response.Result; - } - - /// - public virtual async Task UnpublishAsync(long smartCollectionId, CancellationToken cancellationToken = default) + smart_collection = body + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "smart_collection"); + + return response.Result; + } + + /// + public virtual async Task UnpublishAsync(long smartCollectionId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"smart_collections/{smartCollectionId}.json"); + var body = new Dictionary() { - var req = BuildRequestUri($"smart_collections/{smartCollectionId}.json"); - var body = new Dictionary() - { - { "id", smartCollectionId }, - { "published", false } - }; - var content = new JsonContent(new - { - smart_collection = body - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "smart_collection"); - - return response.Result; - } - - /// - public virtual async Task UpdateProductOrderAsync(long smartCollectionId, string sortOrder = null, params long[] productIds) + { "id", smartCollectionId }, + { "published", false } + }; + var content = new JsonContent(new { - var req = BuildRequestUri($"smart_collections/{smartCollectionId}/order.json"); - var content = new JsonContent(new - { - sort_order = sortOrder, - products = productIds - }); - await ExecuteRequestAsync(req, HttpMethod.Put, CancellationToken.None, content); - } - - /// - public virtual async Task UpdateProductOrderAsync(long smartCollectionId, CancellationToken cancellationToken, string sortOrder = null, params long[] productIds) + smart_collection = body + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "smart_collection"); + + return response.Result; + } + + /// + public virtual async Task UpdateProductOrderAsync(long smartCollectionId, string sortOrder = null, params long[] productIds) + { + var req = BuildRequestUri($"smart_collections/{smartCollectionId}/order.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"smart_collections/{smartCollectionId}/order.json"); - var content = new JsonContent(new - { - sort_order = sortOrder, - products = productIds - }); - await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content); - } - - /// - public virtual async Task DeleteAsync(long collectionId, CancellationToken cancellationToken = default) + sort_order = sortOrder, + products = productIds + }); + await ExecuteRequestAsync(req, HttpMethod.Put, CancellationToken.None, content); + } + + /// + public virtual async Task UpdateProductOrderAsync(long smartCollectionId, CancellationToken cancellationToken, string sortOrder = null, params long[] productIds) + { + var req = BuildRequestUri($"smart_collections/{smartCollectionId}/order.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"smart_collections/{collectionId}.json"); + sort_order = sortOrder, + products = productIds + }); + await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content); + } + + /// + public virtual async Task DeleteAsync(long collectionId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"smart_collections/{collectionId}.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); } } \ No newline at end of file diff --git a/ShopifySharp/Services/StorefrontAccessToken/IStorefrontAccessTokenService.cs b/ShopifySharp/Services/StorefrontAccessToken/IStorefrontAccessTokenService.cs index c2cf7ee7..eb01e6f0 100644 --- a/ShopifySharp/Services/StorefrontAccessToken/IStorefrontAccessTokenService.cs +++ b/ShopifySharp/Services/StorefrontAccessToken/IStorefrontAccessTokenService.cs @@ -2,24 +2,23 @@ using System.Threading; using System.Threading.Tasks; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IStorefrontAccessTokenService : IShopifyService { - public interface IStorefrontAccessTokenService : IShopifyService - { - /// - /// Creates a new with the given . A store can only have a - /// maximum of 100 storefront access tokens. - /// - Task CreateAsync(string title, CancellationToken cancellationToken = default); + /// + /// Creates a new with the given . A store can only have a + /// maximum of 100 storefront access tokens. + /// + Task CreateAsync(string title, CancellationToken cancellationToken = default); - /// - /// Deletes the storefront access token with the given . - /// - Task DeleteAsync(long id, CancellationToken cancellationToken = default); + /// + /// Deletes the storefront access token with the given . + /// + Task DeleteAsync(long id, CancellationToken cancellationToken = default); - /// - /// Gets a list of storefront access tokens. A store can only have a maximum of 100 access tokens. - /// - Task> ListAsync(CancellationToken cancellationToken = default); - } + /// + /// Gets a list of storefront access tokens. A store can only have a maximum of 100 access tokens. + /// + Task> ListAsync(CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/StorefrontAccessToken/StorefrontAccessTokenService.cs b/ShopifySharp/Services/StorefrontAccessToken/StorefrontAccessTokenService.cs index a47b2d90..45f4caa2 100644 --- a/ShopifySharp/Services/StorefrontAccessToken/StorefrontAccessTokenService.cs +++ b/ShopifySharp/Services/StorefrontAccessToken/StorefrontAccessTokenService.cs @@ -5,47 +5,46 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for working with Shopify's StorefrontAccessTokens API. +/// +public class StorefrontAccessTokenService : ShopifyService, IStorefrontAccessTokenService { - /// - /// A service for working with Shopify's StorefrontAccessTokens API. - /// - public class StorefrontAccessTokenService : ShopifyService, IStorefrontAccessTokenService - { - public StorefrontAccessTokenService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal StorefrontAccessTokenService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + public StorefrontAccessTokenService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal StorefrontAccessTokenService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public async Task CreateAsync(string title, CancellationToken cancellationToken = default) + /// + public async Task CreateAsync(string title, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("storefront_access_tokens.json"); + var content = new JsonContent(new { - var req = BuildRequestUri("storefront_access_tokens.json"); - var content = new JsonContent(new + storefront_access_token = new { - storefront_access_token = new - { - title = title - } - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "storefront_access_token"); + title = title + } + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "storefront_access_token"); - return response.Result; - } + return response.Result; + } - /// - public async Task DeleteAsync(long id, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"storefront_access_tokens/{id}.json"); + /// + public async Task DeleteAsync(long id, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"storefront_access_tokens/{id}.json"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); + } - /// - public async Task> ListAsync(CancellationToken cancellationToken = default) - { - var req = BuildRequestUri("storefront_access_tokens.json"); - var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "storefront_access_tokens"); + /// + public async Task> ListAsync(CancellationToken cancellationToken = default) + { + var req = BuildRequestUri("storefront_access_tokens.json"); + var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "storefront_access_tokens"); - return response.Result; - } + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/TenderTransaction/ITenderTransactionService.cs b/ShopifySharp/Services/TenderTransaction/ITenderTransactionService.cs index 7596849d..0efb2a3f 100644 --- a/ShopifySharp/Services/TenderTransaction/ITenderTransactionService.cs +++ b/ShopifySharp/Services/TenderTransaction/ITenderTransactionService.cs @@ -3,22 +3,21 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface ITenderTransactionService : IShopifyService { - public interface ITenderTransactionService : IShopifyService - { - /// - /// Gets a list of up to 250 of the shop's tender transactions. - /// - /// Options for filtering the list. - /// Cancellation Token - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's tender transactions. + /// + /// Options for filtering the list. + /// Cancellation Token + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the shop's tender transactions. - /// - /// Options for filtering the list. - /// Cancellation Token - Task> ListAsync(TenderTransactionListFilter filter = null, CancellationToken cancellationToken = default); - } + /// + /// Gets a list of up to 250 of the shop's tender transactions. + /// + /// Options for filtering the list. + /// Cancellation Token + Task> ListAsync(TenderTransactionListFilter filter = null, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/TenderTransaction/TenderTransactionService.cs b/ShopifySharp/Services/TenderTransaction/TenderTransactionService.cs index 700cc9f9..98778bbf 100644 --- a/ShopifySharp/Services/TenderTransaction/TenderTransactionService.cs +++ b/ShopifySharp/Services/TenderTransaction/TenderTransactionService.cs @@ -1,30 +1,29 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Lists; using System.Threading.Tasks; using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for listing Shopify tender transactions. +/// +public class TenderTransactionService : ShopifyService, ITenderTransactionService { /// - /// A service for listing Shopify tender transactions. + /// Creates a new instance of . /// - public class TenderTransactionService : ShopifyService, ITenderTransactionService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public TenderTransactionService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal TenderTransactionService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public TenderTransactionService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal TenderTransactionService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("tender_transactions.json", "tender_transactions", filter, cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("tender_transactions.json", "tender_transactions", filter, cancellationToken); - /// - public virtual async Task> ListAsync(TenderTransactionListFilter filter = null, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); - } + /// + public virtual async Task> ListAsync(TenderTransactionListFilter filter = null, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); } \ No newline at end of file diff --git a/ShopifySharp/Services/Theme/IThemeService.cs b/ShopifySharp/Services/Theme/IThemeService.cs index af449d71..6c0f6b04 100644 --- a/ShopifySharp/Services/Theme/IThemeService.cs +++ b/ShopifySharp/Services/Theme/IThemeService.cs @@ -3,57 +3,56 @@ using System.Threading.Tasks; using ShopifySharp.Filters; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IThemeService : IShopifyService { - public interface IThemeService : IShopifyService - { - /// - /// Gets a list of up to 250 of the shop's themes. - /// - Task> ListAsync(ThemeListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's themes. + /// + Task> ListAsync(ThemeListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the theme to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long themeId, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the theme to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long themeId, string fields = null, CancellationToken cancellationToken = default); - /// - /// Creates a new theme on the store. The theme always starts out with a role of - /// "unpublished." If the theme has a different role, it will be assigned that only after all of its - /// files have been extracted and stored by Shopify (which might take a couple of minutes). - /// - /// The new theme. - /// Cancellation Token - Task CreateAsync(Theme theme, CancellationToken cancellationToken = default); + /// + /// Creates a new theme on the store. The theme always starts out with a role of + /// "unpublished." If the theme has a different role, it will be assigned that only after all of its + /// files have been extracted and stored by Shopify (which might take a couple of minutes). + /// + /// The new theme. + /// Cancellation Token + Task CreateAsync(Theme theme, CancellationToken cancellationToken = default); - /// - /// Creates a new theme on the store. The theme always starts out with a role of - /// "unpublished." If the theme has a different role, it will be assigned that only after all of its - /// files have been extracted and stored by Shopify (which might take a couple of minutes). - /// - /// The new theme. - /// A URL that points to the .zip file containing the theme's source files. - /// Cancellation Token - Task CreateAsync(Theme theme, string sourceUrl, CancellationToken cancellationToken = default); + /// + /// Creates a new theme on the store. The theme always starts out with a role of + /// "unpublished." If the theme has a different role, it will be assigned that only after all of its + /// files have been extracted and stored by Shopify (which might take a couple of minutes). + /// + /// The new theme. + /// A URL that points to the .zip file containing the theme's source files. + /// Cancellation Token + Task CreateAsync(Theme theme, string sourceUrl, CancellationToken cancellationToken = default); - /// - /// Updates the given . - /// - /// Id of the object being updated. - /// The to update. - /// Cancellation Token - /// The updated . - Task UpdateAsync(long themeId, Theme theme, CancellationToken cancellationToken = default); + /// + /// Updates the given . + /// + /// Id of the object being updated. + /// The to update. + /// Cancellation Token + /// The updated . + Task UpdateAsync(long themeId, Theme theme, CancellationToken cancellationToken = default); - /// - /// Deletes a Theme with the given Id. - /// - /// The Theme object's Id. - /// Cancellation Token - Task DeleteAsync(long themeId, CancellationToken cancellationToken = default); - } + /// + /// Deletes a Theme with the given Id. + /// + /// The Theme object's Id. + /// Cancellation Token + Task DeleteAsync(long themeId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Theme/ThemeService.cs b/ShopifySharp/Services/Theme/ThemeService.cs index 58d96cee..b28c3a92 100644 --- a/ShopifySharp/Services/Theme/ThemeService.cs +++ b/ShopifySharp/Services/Theme/ThemeService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using System.Collections.Generic; using System.Net.Http; @@ -6,86 +6,85 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify themes. +/// +public class ThemeService : ShopifyService, IThemeService { /// - /// A service for manipulating Shopify themes. + /// Creates a new instance of . /// - public class ThemeService : ShopifyService, IThemeService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public ThemeService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal ThemeService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public ThemeService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal ThemeService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(ThemeListFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync>("themes.json", "themes", filter, cancellationToken); - - /// - public virtual async Task GetAsync(long themeId, string fields = null, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"themes/{themeId}.json"); - - if (!string.IsNullOrEmpty(fields)) - { - req.QueryParams.Add("fields", fields); - } + /// + public virtual async Task> ListAsync(ThemeListFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync>("themes.json", "themes", filter, cancellationToken); - var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "theme"); + /// + public virtual async Task GetAsync(long themeId, string fields = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"themes/{themeId}.json"); - return response.Result; + if (!string.IsNullOrEmpty(fields)) + { + req.QueryParams.Add("fields", fields); } - /// - public virtual async Task CreateAsync(Theme theme, CancellationToken cancellationToken = default) => - await _CreateAsync(theme, cancellationToken); + var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "theme"); - /// - public virtual async Task CreateAsync(Theme theme, string sourceUrl, CancellationToken cancellationToken = default) => - await _CreateAsync(theme, cancellationToken, sourceUrl); + return response.Result; + } - /// - public virtual async Task UpdateAsync(long themeId, Theme theme, CancellationToken cancellationToken = default) - { - var req = BuildRequestUri($"themes/{themeId}.json"); - var content = new JsonContent(new - { - theme = theme - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "theme"); - - return response.Result; - } + /// + public virtual async Task CreateAsync(Theme theme, CancellationToken cancellationToken = default) => + await _CreateAsync(theme, cancellationToken); + + /// + public virtual async Task CreateAsync(Theme theme, string sourceUrl, CancellationToken cancellationToken = default) => + await _CreateAsync(theme, cancellationToken, sourceUrl); - /// - public virtual async Task DeleteAsync(long themeId, CancellationToken cancellationToken = default) + /// + public virtual async Task UpdateAsync(long themeId, Theme theme, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"themes/{themeId}.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"themes/{themeId}.json"); + theme = theme + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Put, cancellationToken, content, "theme"); - await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); - } + return response.Result; + } - private async Task _CreateAsync(Theme theme, CancellationToken cancellationToken, string sourceUrl = null) - { - var req = BuildRequestUri("themes.json"); - var body = theme.ToDictionary(); + /// + public virtual async Task DeleteAsync(long themeId, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"themes/{themeId}.json"); - if (!string.IsNullOrEmpty(sourceUrl)) - { - body.Add("src", sourceUrl); - } + await ExecuteRequestAsync(req, HttpMethod.Delete, cancellationToken); + } - var content = new JsonContent(new - { - theme = body - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "theme"); + private async Task _CreateAsync(Theme theme, CancellationToken cancellationToken, string sourceUrl = null) + { + var req = BuildRequestUri("themes.json"); + var body = theme.ToDictionary(); - return response.Result; + if (!string.IsNullOrEmpty(sourceUrl)) + { + body.Add("src", sourceUrl); } + + var content = new JsonContent(new + { + theme = body + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "theme"); + + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/Transaction/ITransactionService.cs b/ShopifySharp/Services/Transaction/ITransactionService.cs index 215cab35..3b7ce450 100644 --- a/ShopifySharp/Services/Transaction/ITransactionService.cs +++ b/ShopifySharp/Services/Transaction/ITransactionService.cs @@ -3,46 +3,45 @@ using System.Threading.Tasks; using ShopifySharp.Filters; -namespace ShopifySharp +namespace ShopifySharp; + +public interface ITransactionService : IShopifyService { - public interface ITransactionService : IShopifyService - { - /// - /// Gets a count of all of the shop's transactions. - /// - /// The order id to which the fulfillments belong. - /// Task cancellation token. - /// - /// According to Shopify's documentation, this endpoint does not currently support any additional filter parameters for counting. - /// - Task CountAsync(long orderId, CancellationToken cancellationToken = default); + /// + /// Gets a count of all of the shop's transactions. + /// + /// The order id to which the fulfillments belong. + /// Task cancellation token. + /// + /// According to Shopify's documentation, this endpoint does not currently support any additional filter parameters for counting. + /// + Task CountAsync(long orderId, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the shop's transactions. - /// - /// The order id to which the fulfillments belong. - /// Options for filtering the list. - /// Whether currency exchange adjustments should be included. - /// Task cancellation token - Task> ListAsync(long orderId, TransactionListFilter filter = null, bool includeCurrencyExchangeAdjustments = false, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's transactions. + /// + /// The order id to which the fulfillments belong. + /// Options for filtering the list. + /// Whether currency exchange adjustments should be included. + /// Task cancellation token + Task> ListAsync(long orderId, TransactionListFilter filter = null, bool includeCurrencyExchangeAdjustments = false, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The order id to which the fulfillments belong. - /// The id of the Transaction to retrieve. - /// Options for filtering the result. - /// Whether currency exchange adjustments should be included. - /// Task cancellation token - Task GetAsync(long orderId, long transactionId, TransactionGetFilter filter = null, bool includeCurrencyExchangeAdjustments = false, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The order id to which the fulfillments belong. + /// The id of the Transaction to retrieve. + /// Options for filtering the result. + /// Whether currency exchange adjustments should be included. + /// Task cancellation token + Task GetAsync(long orderId, long transactionId, TransactionGetFilter filter = null, bool includeCurrencyExchangeAdjustments = false, CancellationToken cancellationToken = default); - /// - /// Creates a new of the given kind. - /// - /// The order id to which the fulfillments belong. - /// The transaction. - /// Cancellation Token - /// The new . - Task CreateAsync(long orderId, Transaction transaction, CancellationToken cancellationToken = default); - } + /// + /// Creates a new of the given kind. + /// + /// The order id to which the fulfillments belong. + /// The transaction. + /// Cancellation Token + /// The new . + Task CreateAsync(long orderId, Transaction transaction, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Transaction/TransactionService.cs b/ShopifySharp/Services/Transaction/TransactionService.cs index 11ff9431..b9c84840 100644 --- a/ShopifySharp/Services/Transaction/TransactionService.cs +++ b/ShopifySharp/Services/Transaction/TransactionService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using System.Collections.Generic; using System.Net.Http; @@ -6,55 +6,54 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify transactions. +/// +public class TransactionService : ShopifyService, ITransactionService { /// - /// A service for manipulating Shopify transactions. + /// Creates a new instance of . /// - public class TransactionService : ShopifyService, ITransactionService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public TransactionService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal TransactionService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public TransactionService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal TransactionService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - public virtual async Task CountAsync(long orderId, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"orders/{orderId}/transactions/count.json", "count", cancellationToken: cancellationToken); + public virtual async Task CountAsync(long orderId, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"orders/{orderId}/transactions/count.json", "count", cancellationToken: cancellationToken); - public virtual async Task> ListAsync(long orderId, TransactionListFilter filter = null, bool includeCurrencyExchangeAdjustments = false, CancellationToken cancellationToken = default) => - await ExecuteGetAsync>($"orders/{orderId}/transactions.json", "transactions", filter, cancellationToken, GetHeaders(includeCurrencyExchangeAdjustments)); + public virtual async Task> ListAsync(long orderId, TransactionListFilter filter = null, bool includeCurrencyExchangeAdjustments = false, CancellationToken cancellationToken = default) => + await ExecuteGetAsync>($"orders/{orderId}/transactions.json", "transactions", filter, cancellationToken, GetHeaders(includeCurrencyExchangeAdjustments)); - public virtual async Task GetAsync(long orderId, long transactionId, TransactionGetFilter filter = null, bool includeCurrencyExchangeAdjustments = false, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"orders/{orderId}/transactions/{transactionId}.json", "transaction", filter, cancellationToken, GetHeaders(includeCurrencyExchangeAdjustments)); + public virtual async Task GetAsync(long orderId, long transactionId, TransactionGetFilter filter = null, bool includeCurrencyExchangeAdjustments = false, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"orders/{orderId}/transactions/{transactionId}.json", "transaction", filter, cancellationToken, GetHeaders(includeCurrencyExchangeAdjustments)); - public virtual async Task CreateAsync(long orderId, Transaction transaction, CancellationToken cancellationToken = default) + public virtual async Task CreateAsync(long orderId, Transaction transaction, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"orders/{orderId}/transactions.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"orders/{orderId}/transactions.json"); - var content = new JsonContent(new - { - transaction = transaction - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "transaction"); - - return response.Result; - } - - /// - /// Creates a dictionary containing the currency exchange adjustments headers depending on whether - /// is true or false. - /// - private Dictionary GetHeaders(bool includeCurrencyExchangeAdjustments) + transaction = transaction + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "transaction"); + + return response.Result; + } + + /// + /// Creates a dictionary containing the currency exchange adjustments headers depending on whether + /// is true or false. + /// + private Dictionary GetHeaders(bool includeCurrencyExchangeAdjustments) + { + if (!includeCurrencyExchangeAdjustments) + return null; + + return new Dictionary { - if (!includeCurrencyExchangeAdjustments) - return null; - - return new Dictionary - { - { "X-Shopify-Api-Features", "include-currency-exchange-adjustments" } - }; - } + { "X-Shopify-Api-Features", "include-currency-exchange-adjustments" } + }; } } \ No newline at end of file diff --git a/ShopifySharp/Services/UsageCharge/IUsageChargeService.cs b/ShopifySharp/Services/UsageCharge/IUsageChargeService.cs index d8d0e924..bf0bb6cd 100644 --- a/ShopifySharp/Services/UsageCharge/IUsageChargeService.cs +++ b/ShopifySharp/Services/UsageCharge/IUsageChargeService.cs @@ -3,36 +3,35 @@ using System.Threading.Tasks; using ShopifySharp.Filters; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IUsageChargeService : IShopifyService { - public interface IUsageChargeService : IShopifyService - { - /// - /// Creates a . - /// - /// The id of the that this usage charge belongs to. - /// The name or description of the usage charge. - /// The price of the usage charge. - /// Cancellation Token - /// The new . - Task CreateAsync(long recurringChargeId, string description, decimal price, CancellationToken cancellationToken = default); + /// + /// Creates a . + /// + /// The id of the that this usage charge belongs to. + /// The name or description of the usage charge. + /// The price of the usage charge. + /// Cancellation Token + /// The new . + Task CreateAsync(long recurringChargeId, string description, decimal price, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the recurring charge that this usage charge belongs to. - /// The id of the charge to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long recurringChargeId, long id, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the recurring charge that this usage charge belongs to. + /// The id of the charge to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long recurringChargeId, long id, string fields = null, CancellationToken cancellationToken = default); - /// - /// Retrieves a list of all past and present objects. - /// - /// The id of the recurring charge that these usage charges belong to. - /// Options for filtering the list. - /// Cancellation Token - Task> ListAsync(long recurringChargeId, UsageChargeListFilter filter = null, CancellationToken cancellationToken = default); - } + /// + /// Retrieves a list of all past and present objects. + /// + /// The id of the recurring charge that these usage charges belong to. + /// Options for filtering the list. + /// Cancellation Token + Task> ListAsync(long recurringChargeId, UsageChargeListFilter filter = null, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/UsageCharge/UsageChargeService.cs b/ShopifySharp/Services/UsageCharge/UsageChargeService.cs index 3a329d76..2508c8b5 100644 --- a/ShopifySharp/Services/UsageCharge/UsageChargeService.cs +++ b/ShopifySharp/Services/UsageCharge/UsageChargeService.cs @@ -1,4 +1,4 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Infrastructure; using System.Collections.Generic; using System.Net.Http; @@ -6,66 +6,65 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify's UsageCharge API. +/// +public class UsageChargeService : ShopifyService, IUsageChargeService { /// - /// A service for manipulating Shopify's UsageCharge API. + /// Creates a new instance of . /// - public class UsageChargeService : ShopifyService, IUsageChargeService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public UsageChargeService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal UsageChargeService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public UsageChargeService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal UsageChargeService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CreateAsync(long recurringChargeId, string description, decimal price, CancellationToken cancellationToken = default) + /// + public virtual async Task CreateAsync(long recurringChargeId, string description, decimal price, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"recurring_application_charges/{recurringChargeId}/usage_charges.json"); + var content = new JsonContent(new { - var req = BuildRequestUri($"recurring_application_charges/{recurringChargeId}/usage_charges.json"); - var content = new JsonContent(new + usage_charge = new { - usage_charge = new - { - description = description, - price = price - } - }); - var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "usage_charge"); + description = description, + price = price + } + }); + var response = await ExecuteRequestAsync(req, HttpMethod.Post, cancellationToken, content, "usage_charge"); - return response.Result; - } + return response.Result; + } + + /// + public virtual async Task GetAsync(long recurringChargeId, long id, string fields = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"recurring_application_charges/{recurringChargeId}/usage_charges/{id}.json"); - /// - public virtual async Task GetAsync(long recurringChargeId, long id, string fields = null, CancellationToken cancellationToken = default) + if (!string.IsNullOrEmpty(fields)) { - var req = BuildRequestUri($"recurring_application_charges/{recurringChargeId}/usage_charges/{id}.json"); + req.QueryParams.Add("fields", fields); + } - if (!string.IsNullOrEmpty(fields)) - { - req.QueryParams.Add("fields", fields); - } + var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "usage_charge"); - var response = await ExecuteRequestAsync(req, HttpMethod.Get, cancellationToken, rootElement: "usage_charge"); + return response.Result; + } - return response.Result; - } + /// + public virtual async Task> ListAsync(long recurringChargeId, UsageChargeListFilter filter = null, CancellationToken cancellationToken = default) + { + var req = BuildRequestUri($"recurring_application_charges/{recurringChargeId}/usage_charges.json"); - /// - public virtual async Task> ListAsync(long recurringChargeId, UsageChargeListFilter filter = null, CancellationToken cancellationToken = default) + if (filter != null) { - var req = BuildRequestUri($"recurring_application_charges/{recurringChargeId}/usage_charges.json"); - - if (filter != null) - { - req.QueryParams.AddRange(filter.ToQueryParameters()); - } + req.QueryParams.AddRange(filter.ToQueryParameters()); + } - var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "usage_charges"); + var response = await ExecuteRequestAsync>(req, HttpMethod.Get, cancellationToken, rootElement: "usage_charges"); - return response.Result; - } + return response.Result; } } \ No newline at end of file diff --git a/ShopifySharp/Services/User/IUserService.cs b/ShopifySharp/Services/User/IUserService.cs index 33530af4..55d8c2ee 100644 --- a/ShopifySharp/Services/User/IUserService.cs +++ b/ShopifySharp/Services/User/IUserService.cs @@ -3,32 +3,31 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IUserService : IShopifyService { - public interface IUserService : IShopifyService - { - /// - /// Gets a list of up to 250 of the users. - /// - Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the users. + /// + Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the users. - /// - Task> ListAsync(UserListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the users. + /// + Task> ListAsync(UserListFilter filter, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the User to retrieve. - /// Cancellation Token - /// The . - Task GetAsync(long userId, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the User to retrieve. + /// Cancellation Token + /// The . + Task GetAsync(long userId, CancellationToken cancellationToken = default); - /// - /// Retrieves the current logged-in (useful only when the access token was created for a specific user of the shop). - /// - /// The . - Task GetCurrentAsync(CancellationToken cancellationToken = default); - } + /// + /// Retrieves the current logged-in (useful only when the access token was created for a specific user of the shop). + /// + /// The . + Task GetCurrentAsync(CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/User/UserService.cs b/ShopifySharp/Services/User/UserService.cs index d9365396..8651ca4d 100644 --- a/ShopifySharp/Services/User/UserService.cs +++ b/ShopifySharp/Services/User/UserService.cs @@ -4,35 +4,34 @@ using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify users. +/// +public class UserService : ShopifyService, IUserService { /// - /// A service for manipulating Shopify users. + /// Creates a new instance of . /// - public class UserService : ShopifyService, IUserService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public UserService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal UserService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public UserService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal UserService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("users.json", "users", filter, cancellationToken); + /// + public virtual async Task> ListAsync(ListFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("users.json", "users", filter, cancellationToken); - /// - public virtual async Task> ListAsync(UserListFilter filter, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); + /// + public virtual async Task> ListAsync(UserListFilter filter, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); - /// - public virtual async Task GetAsync(long userId, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"users/{userId}.json", "user", cancellationToken: cancellationToken); + /// + public virtual async Task GetAsync(long userId, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"users/{userId}.json", "user", cancellationToken: cancellationToken); - /// - public virtual async Task GetCurrentAsync(CancellationToken cancellationToken = default) => - await ExecuteGetAsync("users/current.json", "user", cancellationToken: cancellationToken); - } -} + /// + public virtual async Task GetCurrentAsync(CancellationToken cancellationToken = default) => + await ExecuteGetAsync("users/current.json", "user", cancellationToken: cancellationToken); +} \ No newline at end of file diff --git a/ShopifySharp/Services/Webhook/IWebhookService.cs b/ShopifySharp/Services/Webhook/IWebhookService.cs index 331afd78..5faac663 100644 --- a/ShopifySharp/Services/Webhook/IWebhookService.cs +++ b/ShopifySharp/Services/Webhook/IWebhookService.cs @@ -3,63 +3,62 @@ using ShopifySharp.Filters; using ShopifySharp.Lists; -namespace ShopifySharp +namespace ShopifySharp; + +public interface IWebhookService : IShopifyService { - public interface IWebhookService : IShopifyService - { - /// - /// Gets a count of all of the shop's webhooks. - /// - /// Options for filtering the result. - /// Cancellation Token - /// The count of all webhooks for the shop. - Task CountAsync(WebhookCountFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a count of all of the shop's webhooks. + /// + /// Options for filtering the result. + /// Cancellation Token + /// The count of all webhooks for the shop. + Task CountAsync(WebhookCountFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the shop's webhooks. - /// - /// Options for filtering the list. - /// Cancellation Token - Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's webhooks. + /// + /// Options for filtering the list. + /// Cancellation Token + Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default); - /// - /// Gets a list of up to 250 of the shop's webhooks. - /// - /// Options for filtering the list. - /// Cancellation Token - Task> ListAsync(WebhookListFilter filter = null, CancellationToken cancellationToken = default); + /// + /// Gets a list of up to 250 of the shop's webhooks. + /// + /// Options for filtering the list. + /// Cancellation Token + Task> ListAsync(WebhookListFilter filter = null, CancellationToken cancellationToken = default); - /// - /// Retrieves the with the given id. - /// - /// The id of the webhook to retrieve. - /// A comma-separated list of fields to return. - /// Cancellation Token - /// The . - Task GetAsync(long webhookId, string fields = null, CancellationToken cancellationToken = default); + /// + /// Retrieves the with the given id. + /// + /// The id of the webhook to retrieve. + /// A comma-separated list of fields to return. + /// Cancellation Token + /// The . + Task GetAsync(long webhookId, string fields = null, CancellationToken cancellationToken = default); - /// - /// Creates a new on the store. - /// - /// A new . Id should be set to null. - /// Cancellation Token - /// The new . - Task CreateAsync(Webhook webhook, CancellationToken cancellationToken = default); + /// + /// Creates a new on the store. + /// + /// A new . Id should be set to null. + /// Cancellation Token + /// The new . + Task CreateAsync(Webhook webhook, CancellationToken cancellationToken = default); - /// - /// Updates the given . - /// - /// Id of the object being updated. - /// The to update. - /// Cancellation Token - /// The updated . - Task UpdateAsync(long webhookId, Webhook webhook, CancellationToken cancellationToken = default); + /// + /// Updates the given . + /// + /// Id of the object being updated. + /// The to update. + /// Cancellation Token + /// The updated . + Task UpdateAsync(long webhookId, Webhook webhook, CancellationToken cancellationToken = default); - /// - /// Deletes the webhook with the given Id. - /// - /// The order object's Id. - /// Cancellation Token - Task DeleteAsync(long webhookId, CancellationToken cancellationToken = default); - } + /// + /// Deletes the webhook with the given Id. + /// + /// The order object's Id. + /// Cancellation Token + Task DeleteAsync(long webhookId, CancellationToken cancellationToken = default); } \ No newline at end of file diff --git a/ShopifySharp/Services/Webhook/WebhookService.cs b/ShopifySharp/Services/Webhook/WebhookService.cs index 077fd27c..ce22f033 100644 --- a/ShopifySharp/Services/Webhook/WebhookService.cs +++ b/ShopifySharp/Services/Webhook/WebhookService.cs @@ -1,50 +1,49 @@ -using ShopifySharp.Filters; +using ShopifySharp.Filters; using ShopifySharp.Lists; using System.Threading.Tasks; using System.Threading; using ShopifySharp.Utilities; -namespace ShopifySharp +namespace ShopifySharp; + +/// +/// A service for manipulating Shopify webhooks. +/// +public class WebhookService : ShopifyService, IWebhookService { /// - /// A service for manipulating Shopify webhooks. + /// Creates a new instance of . /// - public class WebhookService : ShopifyService, IWebhookService - { - /// - /// Creates a new instance of . - /// - /// The shop's *.myshopify.com URL. - /// An API access token for the shop. - public WebhookService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } - internal WebhookService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} + /// The shop's *.myshopify.com URL. + /// An API access token for the shop. + public WebhookService(string myShopifyUrl, string shopAccessToken) : base(myShopifyUrl, shopAccessToken) { } + internal WebhookService(string shopDomain, string accessToken, IShopifyDomainUtility shopifyDomainUtility) : base(shopDomain, accessToken, shopifyDomainUtility) {} - /// - public virtual async Task CountAsync(WebhookCountFilter filter = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync("webhooks/count.json", "count", filter, cancellationToken); - - /// - public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => - await ExecuteGetListAsync("webhooks.json", "webhooks", filter, cancellationToken); - - /// - public virtual async Task> ListAsync(WebhookListFilter filter = null, CancellationToken cancellationToken = default) => - await ListAsync(filter?.AsListFilter(), cancellationToken); - - /// - public virtual async Task GetAsync(long webhookId, string fields = null, CancellationToken cancellationToken = default) => - await ExecuteGetAsync($"webhooks/{webhookId}.json", "webhook", fields, cancellationToken); - - /// - public virtual async Task CreateAsync(Webhook webhook, CancellationToken cancellationToken = default) => - await ExecutePostAsync("webhooks.json", "webhook", cancellationToken, new { webhook = webhook }); - - /// - public virtual async Task UpdateAsync(long webhookId, Webhook webhook, CancellationToken cancellationToken = default) => - await ExecutePutAsync($"webhooks/{webhookId}.json", "webhook", cancellationToken, new { webhook = webhook }); - - /// - public virtual async Task DeleteAsync(long webhookId, CancellationToken cancellationToken = default) => - await ExecuteDeleteAsync($"webhooks/{webhookId}.json", cancellationToken); - } + /// + public virtual async Task CountAsync(WebhookCountFilter filter = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync("webhooks/count.json", "count", filter, cancellationToken); + + /// + public virtual async Task> ListAsync(ListFilter filter, CancellationToken cancellationToken = default) => + await ExecuteGetListAsync("webhooks.json", "webhooks", filter, cancellationToken); + + /// + public virtual async Task> ListAsync(WebhookListFilter filter = null, CancellationToken cancellationToken = default) => + await ListAsync(filter?.AsListFilter(), cancellationToken); + + /// + public virtual async Task GetAsync(long webhookId, string fields = null, CancellationToken cancellationToken = default) => + await ExecuteGetAsync($"webhooks/{webhookId}.json", "webhook", fields, cancellationToken); + + /// + public virtual async Task CreateAsync(Webhook webhook, CancellationToken cancellationToken = default) => + await ExecutePostAsync("webhooks.json", "webhook", cancellationToken, new { webhook = webhook }); + + /// + public virtual async Task UpdateAsync(long webhookId, Webhook webhook, CancellationToken cancellationToken = default) => + await ExecutePutAsync($"webhooks/{webhookId}.json", "webhook", cancellationToken, new { webhook = webhook }); + + /// + public virtual async Task DeleteAsync(long webhookId, CancellationToken cancellationToken = default) => + await ExecuteDeleteAsync($"webhooks/{webhookId}.json", cancellationToken); } \ No newline at end of file diff --git a/ShopifySharp/ShopifySharp.csproj b/ShopifySharp/ShopifySharp.csproj index dd2a7ddd..9d7f12a3 100644 --- a/ShopifySharp/ShopifySharp.csproj +++ b/ShopifySharp/ShopifySharp.csproj @@ -25,4 +25,4 @@ - \ No newline at end of file + diff --git a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedDiscountedPriceSet.cs b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedDiscountedPriceSet.cs index bbc88111..6a400b25 100644 --- a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedDiscountedPriceSet.cs +++ b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedDiscountedPriceSet.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp.WebhookPayloads.CartUpdated +namespace ShopifySharp.WebhookPayloads.CartUpdated; + +public class CartUpdatedDiscountedPriceSet { - public class CartUpdatedDiscountedPriceSet - { - [JsonProperty("shop_money")] - public CartUpdatedShopMoney ShopMoney { get; set; } + [JsonProperty("shop_money")] + public CartUpdatedShopMoney ShopMoney { get; set; } - [JsonProperty("presentment_money")] - public CartUpdatedPresentmentMoney PresentmentMoney { get; set; } - } -} + [JsonProperty("presentment_money")] + public CartUpdatedPresentmentMoney PresentmentMoney { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedLineItem.cs b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedLineItem.cs index b3af674c..287295a6 100644 --- a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedLineItem.cs +++ b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedLineItem.cs @@ -1,81 +1,80 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp.WebhookPayloads.CartUpdated +namespace ShopifySharp.WebhookPayloads.CartUpdated; + +public class CartUpdatedLineItem : ShopifyObject { - public class CartUpdatedLineItem : ShopifyObject - { - #nullable enable - [JsonProperty("properties")] - public IDictionary? Properties { get; set; } - #nullable disable +#nullable enable + [JsonProperty("properties")] + public IDictionary? Properties { get; set; } +#nullable disable - [JsonProperty("quantity")] - public int Quantity { get; set; } + [JsonProperty("quantity")] + public int Quantity { get; set; } - [JsonProperty("variant_id")] - public long VariantId { get; set; } + [JsonProperty("variant_id")] + public long VariantId { get; set; } - [JsonProperty("key")] - public string Key { get; set; } + [JsonProperty("key")] + public string Key { get; set; } - [JsonProperty("discounted_price")] - public decimal DiscountedPrice { get; set; } + [JsonProperty("discounted_price")] + public decimal DiscountedPrice { get; set; } - [JsonProperty("gift_card")] - public bool? GiftCard { get; set; } + [JsonProperty("gift_card")] + public bool? GiftCard { get; set; } - [JsonProperty("grams")] - public int? Grams { get; set; } + [JsonProperty("grams")] + public int? Grams { get; set; } - [JsonProperty("line_price")] - public decimal LinePrice { get; set; } + [JsonProperty("line_price")] + public decimal LinePrice { get; set; } - [JsonProperty("original_line_price")] - public decimal OriginalLinePrice { get; set; } + [JsonProperty("original_line_price")] + public decimal OriginalLinePrice { get; set; } - [JsonProperty("original_price")] - public decimal OriginalPrice { get; set; } + [JsonProperty("original_price")] + public decimal OriginalPrice { get; set; } - [JsonProperty("price")] - public decimal Price { get; set; } + [JsonProperty("price")] + public decimal Price { get; set; } - [JsonProperty("product_id")] - public long ProductId { get; set; } + [JsonProperty("product_id")] + public long ProductId { get; set; } - #nullable enable - [JsonProperty("sku")] - public string? Sku { get; set; } - #nullable disable +#nullable enable + [JsonProperty("sku")] + public string? Sku { get; set; } +#nullable disable - [JsonProperty("taxable")] - public bool? Taxable { get; set; } + [JsonProperty("taxable")] + public bool? Taxable { get; set; } - [JsonProperty("title")] - public string Title { get; set; } + [JsonProperty("title")] + public string Title { get; set; } - [JsonProperty("total_discount")] - public decimal TotalDiscount { get; set; } + [JsonProperty("total_discount")] + public decimal TotalDiscount { get; set; } - [JsonProperty("vendor")] - public string Vendor { get; set; } + [JsonProperty("vendor")] + public string Vendor { get; set; } - [JsonProperty("discounted_price_set")] - public CartUpdatedDiscountedPriceSet DiscountedPriceSet { get; set; } + [JsonProperty("discounted_price_set")] + public CartUpdatedDiscountedPriceSet DiscountedPriceSet { get; set; } - [JsonProperty("line_price_set")] - public CartUpdatedLinePriceSet LinePriceSet { get; set; } + [JsonProperty("line_price_set")] + public CartUpdatedLinePriceSet LinePriceSet { get; set; } - [JsonProperty("original_line_price_set")] - public CartUpdatedOriginalLinePriceSet OriginalLinePriceSet { get; set; } + [JsonProperty("original_line_price_set")] + public CartUpdatedOriginalLinePriceSet OriginalLinePriceSet { get; set; } - [JsonProperty("price_set")] - public CartUpdatedPriceSet PriceSet { get; set; } + [JsonProperty("price_set")] + public CartUpdatedPriceSet PriceSet { get; set; } - [JsonProperty("total_discount_set")] - public CartUpdatedTotalDiscountSet TotalDiscountSet { get; set; } + [JsonProperty("total_discount_set")] + public CartUpdatedTotalDiscountSet TotalDiscountSet { get; set; } - [JsonProperty("discounts")] - public ICollection Discounts { get; set; } - } -} + [JsonProperty("discounts")] + public ICollection Discounts { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedLinePriceSet.cs b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedLinePriceSet.cs index 8ebbf0dd..07f87333 100644 --- a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedLinePriceSet.cs +++ b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedLinePriceSet.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp.WebhookPayloads.CartUpdated +namespace ShopifySharp.WebhookPayloads.CartUpdated; + +public class CartUpdatedLinePriceSet { - public class CartUpdatedLinePriceSet - { - [JsonProperty("shop_money")] - public CartUpdatedShopMoney ShopMoney { get; set; } + [JsonProperty("shop_money")] + public CartUpdatedShopMoney ShopMoney { get; set; } - [JsonProperty("presentment_money")] - public CartUpdatedPresentmentMoney PresentmentMoney { get; set; } - } -} + [JsonProperty("presentment_money")] + public CartUpdatedPresentmentMoney PresentmentMoney { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedOriginalLinePriceSet.cs b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedOriginalLinePriceSet.cs index a99d449b..84a4418c 100644 --- a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedOriginalLinePriceSet.cs +++ b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedOriginalLinePriceSet.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp.WebhookPayloads.CartUpdated +namespace ShopifySharp.WebhookPayloads.CartUpdated; + +public class CartUpdatedOriginalLinePriceSet { - public class CartUpdatedOriginalLinePriceSet - { - [JsonProperty("shop_money")] - public CartUpdatedShopMoney ShopMoney { get; set; } + [JsonProperty("shop_money")] + public CartUpdatedShopMoney ShopMoney { get; set; } - [JsonProperty("presentment_money")] - public CartUpdatedPresentmentMoney PresentmentMoney { get; set; } - } -} + [JsonProperty("presentment_money")] + public CartUpdatedPresentmentMoney PresentmentMoney { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedPayload.cs b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedPayload.cs index 509b8d87..996f80df 100644 --- a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedPayload.cs +++ b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedPayload.cs @@ -4,29 +4,28 @@ using System.Collections.Generic; using Newtonsoft.Json; -namespace ShopifySharp.WebhookPayloads.CartUpdated +namespace ShopifySharp.WebhookPayloads.CartUpdated; + +/// +/// The object sent by Shopify's carts/update webhook. +/// +public class CartUpdatedPayload { - /// - /// The object sent by Shopify's carts/update webhook. - /// - public class CartUpdatedPayload - { - [JsonProperty("created_at")] - public DateTimeOffset CreatedAt { get; set; } + [JsonProperty("created_at")] + public DateTimeOffset CreatedAt { get; set; } - [JsonProperty("id")] - public string Id { get; set; } + [JsonProperty("id")] + public string Id { get; set; } - [JsonProperty("line_items")] - public ICollection LineItems { get; set; } + [JsonProperty("line_items")] + public ICollection LineItems { get; set; } - [JsonProperty("note")] - public string? Note { get; set; } + [JsonProperty("note")] + public string? Note { get; set; } - [JsonProperty("token")] - public string Token { get; set; } + [JsonProperty("token")] + public string Token { get; set; } - [JsonProperty("updated_at")] - public DateTimeOffset UpdatedAt { get; set; } - } -} + [JsonProperty("updated_at")] + public DateTimeOffset UpdatedAt { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedPresentmentMoney.cs b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedPresentmentMoney.cs index 0bf43069..0f4af20f 100644 --- a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedPresentmentMoney.cs +++ b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedPresentmentMoney.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp.WebhookPayloads.CartUpdated +namespace ShopifySharp.WebhookPayloads.CartUpdated; + +public class CartUpdatedPresentmentMoney { - public class CartUpdatedPresentmentMoney - { - [JsonProperty("amount")] - public decimal Amount { get; set; } + [JsonProperty("amount")] + public decimal Amount { get; set; } - [JsonProperty("currency_code")] - public string CurrencyCode { get; set; } - } -} + [JsonProperty("currency_code")] + public string CurrencyCode { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedPriceSet.cs b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedPriceSet.cs index 320237cf..ae398162 100644 --- a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedPriceSet.cs +++ b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedPriceSet.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp.WebhookPayloads.CartUpdated +namespace ShopifySharp.WebhookPayloads.CartUpdated; + +public class CartUpdatedPriceSet { - public class CartUpdatedPriceSet - { - [JsonProperty("shop_money")] - public CartUpdatedShopMoney ShopMoney { get; set; } + [JsonProperty("shop_money")] + public CartUpdatedShopMoney ShopMoney { get; set; } - [JsonProperty("presentment_money")] - public CartUpdatedPresentmentMoney PresentmentMoney { get; set; } - } -} + [JsonProperty("presentment_money")] + public CartUpdatedPresentmentMoney PresentmentMoney { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedShopMoney.cs b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedShopMoney.cs index 0ead36cb..35e3b67f 100644 --- a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedShopMoney.cs +++ b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedShopMoney.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp.WebhookPayloads.CartUpdated +namespace ShopifySharp.WebhookPayloads.CartUpdated; + +public class CartUpdatedShopMoney { - public class CartUpdatedShopMoney - { - [JsonProperty("amount")] - public decimal Amount { get; set; } + [JsonProperty("amount")] + public decimal Amount { get; set; } - [JsonProperty("currency_code")] - public string CurrencyCode { get; set; } - } -} + [JsonProperty("currency_code")] + public string CurrencyCode { get; set; } +} \ No newline at end of file diff --git a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedTotalDiscountSet.cs b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedTotalDiscountSet.cs index 5c58a2f6..e692b6af 100644 --- a/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedTotalDiscountSet.cs +++ b/ShopifySharp/WebhookPayloads/CartUpdated/CartUpdatedTotalDiscountSet.cs @@ -1,13 +1,12 @@ using Newtonsoft.Json; -namespace ShopifySharp.WebhookPayloads.CartUpdated +namespace ShopifySharp.WebhookPayloads.CartUpdated; + +public class CartUpdatedTotalDiscountSet { - public class CartUpdatedTotalDiscountSet - { - [JsonProperty("shop_money")] - public CartUpdatedShopMoney ShopMoney { get; set; } + [JsonProperty("shop_money")] + public CartUpdatedShopMoney ShopMoney { get; set; } - [JsonProperty("presentment_money")] - public CartUpdatedPresentmentMoney PresentmentMoney { get; set; } - } -} + [JsonProperty("presentment_money")] + public CartUpdatedPresentmentMoney PresentmentMoney { get; set; } +} \ No newline at end of file