Skip to content

Commit

Permalink
Merged in GUARD-737-Make-Shipments-Sync-As-Optional (pull request #5)
Browse files Browse the repository at this point in the history
2020-08-15 GUARD-737 Large-Delays-On-Syncs

Approved-by: Maxim Strelsov
  • Loading branch information
fabulaspb committed Aug 31, 2020
2 parents c4bc73b + 93266a9 commit 230b9bc
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/Global/GlobalAssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
// [assembly: AssemblyVersion("1.0.*")]

// Keep in track with CA API version
[ assembly : AssemblyVersion( "1.4.1.0" ) ]
[ assembly : AssemblyVersion( "1.4.2.0" ) ]
2 changes: 1 addition & 1 deletion src/ShipStationAccess/V2/IShipStationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
9 changes: 6 additions & 3 deletions src/ShipStationAccess/V2/ShipStationService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 >();
Expand All @@ -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 );
Expand Down
13 changes: 12 additions & 1 deletion src/ShipStationAccessTests/Orders/OrderTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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 );
}
Expand Down

0 comments on commit 230b9bc

Please sign in to comment.