diff --git a/src/Global/GlobalAssemblyInfo.cs b/src/Global/GlobalAssemblyInfo.cs index f2ca3bc..0cdcb95 100644 --- a/src/Global/GlobalAssemblyInfo.cs +++ b/src/Global/GlobalAssemblyInfo.cs @@ -23,4 +23,4 @@ // [assembly: AssemblyVersion("1.0.*")] // Keep in track with CA API version -[ assembly : AssemblyVersion( "1.4.1.0" ) ] \ No newline at end of file +[ assembly : AssemblyVersion( "1.4.2.0" ) ] \ No newline at end of file diff --git a/src/ShipStationAccess/V2/IShipStationService.cs b/src/ShipStationAccess/V2/IShipStationService.cs index 38dd5c2..758088b 100644 --- a/src/ShipStationAccess/V2/IShipStationService.cs +++ b/src/ShipStationAccess/V2/IShipStationService.cs @@ -13,7 +13,7 @@ namespace ShipStationAccess.V2 public interface IShipStationService { IEnumerable< ShipStationOrder > GetOrders( DateTime dateFrom, DateTime dateTo, Func< ShipStationOrder, ShipStationOrder > processOrder = null ); - Task< IEnumerable< ShipStationOrder > > GetOrdersAsync( DateTime dateFrom, DateTime dateTo, Func< ShipStationOrder, Task< ShipStationOrder > > processOrder = null ); + Task< IEnumerable< ShipStationOrder > > GetOrdersAsync( DateTime dateFrom, DateTime dateTo, bool getShipmentsAndFulfillments = true, Func< ShipStationOrder, Task< ShipStationOrder > > processOrder = null ); IEnumerable< ShipStationOrder > GetOrders( string storeId, string orderNumber ); ShipStationOrder GetOrderById( string orderId ); diff --git a/src/ShipStationAccess/V2/ShipStationService.cs b/src/ShipStationAccess/V2/ShipStationService.cs index 79f8308..50a5c1a 100644 --- a/src/ShipStationAccess/V2/ShipStationService.cs +++ b/src/ShipStationAccess/V2/ShipStationService.cs @@ -141,7 +141,7 @@ public IEnumerable< ShipStationOrder > GetOrders( DateTime dateFrom, DateTime da return orders; } - public async Task< IEnumerable< ShipStationOrder > > GetOrdersAsync( DateTime dateFrom, DateTime dateTo, Func< ShipStationOrder, Task< ShipStationOrder > > processOrder = null ) + public async Task< IEnumerable< ShipStationOrder > > GetOrdersAsync( DateTime dateFrom, DateTime dateTo, bool getShipmentsAndFulfillments = true, Func< ShipStationOrder, Task< ShipStationOrder > > processOrder = null ) { var orders = new List< ShipStationOrder >(); var processedOrderIds = new HashSet< long >(); @@ -162,8 +162,11 @@ public async Task< IEnumerable< ShipStationOrder > > GetOrdersAsync( DateTime da foreach( var order in processedOrders ) { - order.Shipments = await GetOrderShipmentsByIdAsync( order.OrderId.ToString() ).ConfigureAwait( false ); - order.Fulfillments = await GetOrderFulfillmentsByIdAsync( order.OrderId.ToString() ).ConfigureAwait( false ); + if ( getShipmentsAndFulfillments ) + { + order.Shipments = await GetOrderShipmentsByIdAsync( order.OrderId.ToString() ).ConfigureAwait( false ); + order.Fulfillments = await GetOrderFulfillmentsByIdAsync( order.OrderId.ToString() ).ConfigureAwait( false ); + } orders.Add( order ); processedOrderIds.Add( order.OrderId ); diff --git a/src/ShipStationAccessTests/Orders/OrderTests.cs b/src/ShipStationAccessTests/Orders/OrderTests.cs index 5631299..1da25d8 100644 --- a/src/ShipStationAccessTests/Orders/OrderTests.cs +++ b/src/ShipStationAccessTests/Orders/OrderTests.cs @@ -58,6 +58,17 @@ public async Task GetOrdersAsync() orders.Count().Should().BeGreaterThan( 0 ); } + [ Test ] + public async Task GetOrdersWithoutShipmentsAndFulfillmentsAsync() + { + var service = this.ShipStationFactory.CreateServiceV2( this._credentials ); + var orders = await service.GetOrdersAsync( DateTime.UtcNow.AddDays( -3 ), DateTime.UtcNow, false ); + + orders.Count().Should().BeGreaterThan( 0 ); + orders.Any( o => o.Shipments != null ).Should().Be( false ); + orders.Any( o => o.Fulfillments != null ).Should().Be( false ); + } + [ Test ] public async Task GetOrderShipmentsAsync() { @@ -171,7 +182,7 @@ public async Task UpdateOrderOnGetOrdersAsync() await service.UpdateOrderAsync( o ); return o; }; - var orders = await service.GetOrdersAsync( DateTime.UtcNow.AddDays( -7 ), DateTime.UtcNow, updateOrderLocation ); + var orders = await service.GetOrdersAsync( DateTime.UtcNow.AddDays( -7 ), DateTime.UtcNow, true, updateOrderLocation ); orders.Count().Should().BeGreaterThan( 0 ); }