Skip to content

Commit

Permalink
Merge pull request #900 from nozzlegear/fix-897
Browse files Browse the repository at this point in the history
Add FulfillmentShipping.OriginAddress
  • Loading branch information
nozzlegear committed Jul 13, 2023
2 parents e6b7364 + d497856 commit d2b5e07
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 4 deletions.
30 changes: 29 additions & 1 deletion ShopifySharp.Tests/Fulfillment_Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -270,7 +288,7 @@ public async Task<IEnumerable<FulfillmentOrder>> ListFulfillmentOrders(long orde
return orders;
}

public async Task<Fulfillment> Create(long orderId, bool partialFulfillment = false)
public async Task<Fulfillment> Create(long orderId, bool partialFulfillment = false, bool originAddress = false)
{
var fulfillmentOrders = await ListFulfillmentOrders(orderId);
var lineItems = fulfillmentOrders.Select(o => new LineItemsByFulfillmentOrder
Expand All @@ -294,6 +312,16 @@ public async Task<Fulfillment> 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"
}
});

Expand Down
4 changes: 2 additions & 2 deletions ShopifySharp/Entities/Fulfillment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,9 @@ public class Fulfillment : ShopifyObject
public string Name { get; set; }

/// <summary>
/// The address of the fulfillment location
/// The address of the fulfillment location.
/// </summary>
[JsonProperty("origin_address")]
public Address OriginAddress { get; set; }
public FulfillmentOriginAddress OriginAddress { get; set; }
}
}
43 changes: 43 additions & 0 deletions ShopifySharp/Entities/FulfillmentOriginAddress.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using Newtonsoft.Json;

namespace ShopifySharp
{
public class FulfillmentOriginAddress
{
/// <summary>
/// The street address of the fulfillment location.
/// </summary>
[JsonProperty("address1")]
public string Address1 { get; set; }

/// <summary>
/// The second line of the address. Typically the number of the apartment, suite, or unit.
/// </summary>
[JsonProperty("address2")]
public string Address2 { get; set; }

/// <summary>
/// The city of the fulfillment location.
/// </summary>
[JsonProperty("city")]
public string City { get; set; }

/// <summary>
/// (Required) The two-letter country code (ISO 3166-1 alpha-2 format) of the fulfillment location.
/// </summary>
[JsonProperty("country_code")]
public string CountryCode { get; set; }

/// <summary>
/// The province of the fulfillment location.
/// </summary>
[JsonProperty("province_code")]
public string ProvinceCode { get; set; }

/// <summary>
/// The zip code of the fulfillment location.
/// </summary>
[JsonProperty("zip")]
public string Zip { get; set; }
}
}
8 changes: 7 additions & 1 deletion ShopifySharp/Entities/FulfillmentShipping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,16 @@ public class FulfillmentShipping
[JsonProperty("tracking_info")]
public TrackingInfo TrackingInfo { get; set; }

/// <summary>
/// The address of the fulfillment location.
/// </summary>
[JsonProperty("origin_address")]
public FulfillmentOriginAddress OriginAddress { get; set; }

/// <summary>
/// The fulfillment order line items to be requested for fulfillment. If left blank, all line items of the fulfillment order are requested for fulfillment.
/// </summary>
[JsonProperty("line_items_by_fulfillment_order")]
public IEnumerable<LineItemsByFulfillmentOrder> FulfillmentRequestOrderLineItems { get; set; }
}
}
}

0 comments on commit d2b5e07

Please sign in to comment.