diff --git a/ShopifySharp.Tests/Fulfillment_Tests.cs b/ShopifySharp.Tests/Fulfillment_Tests.cs index 100abeac..20b09e53 100644 --- a/ShopifySharp.Tests/Fulfillment_Tests.cs +++ b/ShopifySharp.Tests/Fulfillment_Tests.cs @@ -109,6 +109,24 @@ public async Task Creates_Fulfillments_With_Tracking_Number() Assert.NotEmpty(created.TrackingUrls); } + [Fact] + public async Task Creates_Fulfillments_With_Origin_Address() + { + var order = await Fixture.CreateOrder(); + var created = await Fixture.Create(order.Id.Value, originAddress: true); + + Assert.NotNull(created); + Assert.True(created.Id.HasValue); + Assert.Equal("success", created.Status); + Assert.Equal("US", created.OriginAddress.CountryCode); + Assert.Equal("MN", created.OriginAddress.ProvinceCode); + Assert.Equal("123 4th Street", created.OriginAddress.Address1); + Assert.Equal("Minneapolis", created.OriginAddress.City); + Assert.Equal("MN", created.OriginAddress.ProvinceCode); + Assert.Equal("55401", created.OriginAddress.Zip); + Assert.Equal("US", created.OriginAddress.CountryCode); + } + [Fact] public async Task Creates_Partial_Fulfillments() { @@ -270,7 +288,7 @@ public async Task> ListFulfillmentOrders(long orde return orders; } - public async Task Create(long orderId, bool partialFulfillment = false) + public async Task Create(long orderId, bool partialFulfillment = false, bool originAddress = false) { var fulfillmentOrders = await ListFulfillmentOrders(orderId); var lineItems = fulfillmentOrders.Select(o => new LineItemsByFulfillmentOrder @@ -294,6 +312,16 @@ public async Task Create(long orderId, bool partialFulfillment = fa Company = "Jack Black's Pack, Stack and Track", Url = "https://example.com/123456789", Number = "123456789" + }, + OriginAddress = originAddress == false + ? null + : new FulfillmentOriginAddress + { + Address1 = "123 4th Street", + City = "Minneapolis", + ProvinceCode = "MN", + Zip = "55401", + CountryCode = "US" } }); diff --git a/ShopifySharp/Entities/Fulfillment.cs b/ShopifySharp/Entities/Fulfillment.cs index e487c960..0750c398 100644 --- a/ShopifySharp/Entities/Fulfillment.cs +++ b/ShopifySharp/Entities/Fulfillment.cs @@ -128,9 +128,9 @@ public class Fulfillment : ShopifyObject public string Name { get; set; } /// - /// The address of the fulfillment location + /// The address of the fulfillment location. /// [JsonProperty("origin_address")] - public Address OriginAddress { get; set; } + public FulfillmentOriginAddress OriginAddress { get; set; } } } diff --git a/ShopifySharp/Entities/FulfillmentOriginAddress.cs b/ShopifySharp/Entities/FulfillmentOriginAddress.cs new file mode 100644 index 00000000..5c835f2d --- /dev/null +++ b/ShopifySharp/Entities/FulfillmentOriginAddress.cs @@ -0,0 +1,43 @@ +using Newtonsoft.Json; + +namespace ShopifySharp +{ + public class FulfillmentOriginAddress + { + /// + /// 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 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; } + + /// + /// 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; } + } +} \ No newline at end of file diff --git a/ShopifySharp/Entities/FulfillmentShipping.cs b/ShopifySharp/Entities/FulfillmentShipping.cs index 95366727..b58493ef 100644 --- a/ShopifySharp/Entities/FulfillmentShipping.cs +++ b/ShopifySharp/Entities/FulfillmentShipping.cs @@ -28,10 +28,16 @@ public class FulfillmentShipping [JsonProperty("tracking_info")] public TrackingInfo TrackingInfo { get; set; } + /// + /// The address of the fulfillment location. + /// + [JsonProperty("origin_address")] + public FulfillmentOriginAddress OriginAddress { 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("line_items_by_fulfillment_order")] public IEnumerable FulfillmentRequestOrderLineItems { get; set; } } -} \ No newline at end of file +}