public async Task AddHandlingSchedules(string groupIdentifier, List <TestSchedule> handlingRates) { if (handlingRates != null) { foreach (var schedule in handlingRates) { var scheduleRequest = new HandlingScheduleRequest { CreatedBy = "data factory tool", ExternalIdentifier = schedule.ExternalIdentifier, OrderAmountMax = schedule.OrderAmountMax, OrderAmountMin = schedule.OrderAmountMin, Rate = schedule.Rate, ServiceLevelCode = (int)schedule.ServiceLevelCode }; var scheduleResponse = await Client.HandlingSchedules.Create(scheduleRequest); if (!scheduleResponse.Success) { throw new Exception("Schedule cannot be created"); } var scheduleConfigRequest = new HandlingSchedulesConfigurationRequest { CreatedBy = "data factory tool" }; var scheduleConfigResponse = await Client.HandlingScheduleConfigurations.Create(groupIdentifier, schedule.ExternalIdentifier, scheduleConfigRequest); if (!scheduleConfigResponse.Success) { throw new Exception($"Schedule {schedule.ExternalIdentifier} in {groupIdentifier} cannot be added. error ~> {scheduleConfigResponse.StatusCode}"); } } } }
protected override async Task TestScenarioSetUp(ScheduleConfigurationTestData data) { //create handling schedule HandlingScheduleRequest handlingScheduleRequest = new HandlingScheduleRequest { ExternalIdentifier = data.ScheduleExtId, CreatedBy = "temporal request", Rate = 0.2m, ServiceLevelCode = 0, OrderAmountMax = 10, OrderAmountMin = 1 }; await Client.HandlingSchedules.Create(handlingScheduleRequest); //create handling group HandlingScheduleGroupRequest handlingScheduleGroupRequest = new HandlingScheduleGroupRequest { CreatedBy = "temporal request", ExternalIdentifier = data.GroupExtId, Name = "temporal name" }; await Client.HandlingScheduleGroups.Create(handlingScheduleGroupRequest); //create handling configuration HandlingSchedulesConfigurationRequest handlingSchedulesConfigurationRequest = new HandlingSchedulesConfigurationRequest { CreatedBy = "temporal request" }; await Client.HandlingScheduleConfigurations.Create(data.GroupExtId, data.ScheduleExtId, handlingSchedulesConfigurationRequest); }
public async Task AddHandlingsToGroup(string groupExtId, List <TestSchedule> schedules) { foreach (var schedule in schedules) { var scheduleRequest = new HandlingScheduleRequest { CreatedBy = "data factory tool", ExternalIdentifier = schedule.ExternalIdentifier, OrderAmountMax = schedule.OrderAmountMax, OrderAmountMin = schedule.OrderAmountMin, Rate = schedule.Rate, ServiceLevelCode = (int)schedule.ServiceLevelCode }; var scheduleResponse = await _client.HandlingSchedules.Create(scheduleRequest); if (!scheduleResponse.Success) { throw new Exception("Schedule cannot be created"); } var scheduleConfigRequest = new HandlingSchedulesConfigurationRequest { CreatedBy = "data factory tool" }; var scheduleConfigResponse = await _client.HandlingScheduleConfigurations.Create(groupExtId, schedule.ExternalIdentifier, scheduleConfigRequest); if (!scheduleConfigResponse.Success) { throw new Exception($"Schedule cannot be added into {groupExtId}"); } } }
public async Task POST_HandlingSchedulesConfiguration_NotFound() { string groupId = "notFound"; string scheduleId = "notFound"; HandlingSchedulesConfigurationRequest request = new HandlingSchedulesConfigurationRequest { CreatedBy = "post success request" }; HttpEssResponse <HandlingSchedulesConfigurationResponse> response = await Client.HandlingScheduleConfigurations.Create(groupId, scheduleId, request); //validations Assert.IsNotNull(response, "Response should not be null"); Assert.AreEqual(404, response.StatusCode); Assert.IsNull(response.Result, "result object should be null"); }
public async Task POST_HandlingSchedulesConfiguration_Success() { //test scenario setup ScheduleConfigurationTestData testData = new ScheduleConfigurationTestData { GroupExtId = "postGroupConfig01", ScheduleExtId = "postScheduleConfig01" }; //create handling schedule HandlingScheduleRequest handlingScheduleRequest = new HandlingScheduleRequest { ExternalIdentifier = testData.ScheduleExtId, CreatedBy = "temporal request", Rate = 0.2m, ServiceLevelCode = 0, OrderAmountMax = 10, OrderAmountMin = 1 }; await Client.HandlingSchedules.Create(handlingScheduleRequest); //create handling group HandlingScheduleGroupRequest handlingScheduleGroupRequest = new HandlingScheduleGroupRequest { CreatedBy = "temporal request", ExternalIdentifier = testData.GroupExtId, Name = "temporal name" }; await Client.HandlingScheduleGroups.Create(handlingScheduleGroupRequest); HandlingSchedulesConfigurationRequest request = new HandlingSchedulesConfigurationRequest { CreatedBy = "post success request" }; HttpEssResponse <HandlingSchedulesConfigurationResponse> response = await Client .HandlingScheduleConfigurations.Create(testData.GroupExtId, testData.ScheduleExtId, request); await TestScenarioCleanUp(testData); //validations Assert.IsNotNull(response, "Response object should not be null"); Assert.AreEqual(200, response.StatusCode); Assert.IsTrue(response.Success, "Response status is not success"); Assert.IsNotNull(response.Result, "Result object should not be null"); }
public async Task GET_Shipment_OnlyHandling_Success() { string identifier = "shipmentFlatRate01"; ShipmentTestData testData = new ShipmentTestData { AccountMasterExtId = identifier, FlatRateScheduleGroupExtId = identifier, HandlingScheduleGroupExtId = identifier, ShippingConfigExtId = identifier, HandlingScheduleExtId = identifier }; //create flat rate schedule group FlatRateScheduleGroupsRequest flatRateScheduleGroupRequest = new FlatRateScheduleGroupsRequest { CreatedBy = "temporal test request", ExternalIdentifier = testData.FlatRateScheduleGroupExtId, Name = "cheap flat rate" }; await Client.FlatRateScheduleGroups.Create(flatRateScheduleGroupRequest); //create handling schedule group HandlingScheduleGroupRequest handlingScheduleGroupRequest = new HandlingScheduleGroupRequest { CreatedBy = "temporal request", ExternalIdentifier = testData.HandlingScheduleGroupExtId, Name = "free handling" }; await Client.HandlingScheduleGroups.Create(handlingScheduleGroupRequest); //create handling schedule HandlingScheduleRequest handlingScheduleRequest = new HandlingScheduleRequest { CreatedBy = "temporal test request", ExternalIdentifier = testData.HandlingScheduleExtId, OrderAmountMin = 0, OrderAmountMax = 1000, Rate = 50, ServiceLevelCode = (int)ServiceLevelCodesEnum.Local }; await Client.HandlingSchedules.Create(handlingScheduleRequest); //link handling schedule with group HandlingSchedulesConfigurationRequest handlingSchedulesConfigurationRequest = new HandlingSchedulesConfigurationRequest { CreatedBy = "temporal test request" }; await Client.HandlingScheduleConfigurations.Create(handlingScheduleGroupRequest.ExternalIdentifier, handlingScheduleRequest.ExternalIdentifier, handlingSchedulesConfigurationRequest); //create shipping configuration ShippingConfigurationRequest shippingConfigurationRequest = new ShippingConfigurationRequest { CreatedBy = "temporal test request", ExternalIdentifier = testData.ShippingConfigExtId, DefaultServiceLevelCode = (int)ServiceLevelCodesEnum.Local, ServiceLevels = new List <SCServiceLevel> { new SCServiceLevel { Amount = 200, CarrierRateDiscount = 0, SortOrder = 1, Label = "temporal label", CalculationMethod = "nothing", IsEnabled = true, CarrierCode = "nothing", Code = (int)ServiceLevelCodesEnum.NextDay }, new SCServiceLevel { Amount = 200, CarrierRateDiscount = 0, SortOrder = 0, Label = "temporal label", CalculationMethod = "nothing", IsEnabled = true, CarrierCode = "nothing", Code = (int)ServiceLevelCodesEnum.Local }, new SCServiceLevel { Amount = 0, SortOrder = 2, Label = "ground", CarrierRateDiscount = 0, Code = (int)ServiceLevelCodesEnum.Ground, IsEnabled = true, CalculationMethod = "nothing", CarrierCode = "nothing" } } }; await Client.ShippingConfigurations.Create(shippingConfigurationRequest); //create shippingPreference for accountMaster ShippingAccountMasterPreferencesRequest shippingPreferenceRequest = new ShippingAccountMasterPreferencesRequest { CreatedBy = "temporal test request", UseCustomerCarrier = false, ShippingConfigurationExternalId = testData.ShippingConfigExtId, FreeFreightRules = new List <SAMFreeFreightRule> { }, FlatRateScheduleGroupExternalId = testData.FlatRateScheduleGroupExtId, HandlingScheduleGroupExternalId = testData.HandlingScheduleGroupExtId }; await Client.ShippingAccountMasterPreferences.Create(testData.AccountMasterExtId, shippingPreferenceRequest); ShipmentRequest request = new ShipmentRequest { OrderId = "00000000000000000002", ShipFromAddress = new Address { AddressLine1 = "Denver Boulder Turnpike", AddressLine2 = "", City = "Boulder", Country = "US", Name = "dfs", Postal = "80014", StateProvinceRegion = "CO" }, ShipToAddress = new Address { AddressLine1 = "Denver Boulder Turnpike", AddressLine2 = string.Empty, City = "Boulder", Country = "US", Name = "dfs", Postal = "1234567", StateProvinceRegion = "CO" }, Products = new List <ShipmentProduct> { new ShipmentProduct { Quantity = 1, CheckoutPriceExtended = 100, Shipping = new ShipmentProductShipping { Width = 12, Height = 12, IsFreeShip = false, Length = 12, IsFreightOnly = false, IsQuickShip = false, WeightDimensional = 12m, WeightActual = 2, FreightClass = 2 } } } }; HttpEssResponse <ShipmentResponse> response = await Client.Shipments.GetSingle(testData.AccountMasterExtId, request); //test data clean up await TestScenarioCleanUp(testData); //validations Assert.IsNotNull(response); Assert.AreEqual(200, response.StatusCode); Assert.IsTrue(response.Success, "Response status is not successful"); Assert.IsNotNull(response.Result, "Result object should not be null"); //specific validations var shippingRate = response.Result.ShipmentRates.FirstOrDefault(r => r.ServiceLevelCode == handlingScheduleRequest.ServiceLevelCode); //handling validations //cannot have handling without flat rate schedule Assert.AreEqual(handlingScheduleRequest.Rate, shippingRate.Handling); }
public async Task GET_Shipment_FlatRateAndHandling_Success() { string identifier = "shipmentTestD104"; ShipmentTestData testData = new ShipmentTestData { AccountMasterExtId = identifier, FlatRateScheduleGroupExtId = identifier, HandlingScheduleGroupExtId = identifier, ShippingConfigExtId = identifier, FlatRateScheduleExtId = identifier, HandlingScheduleExtId = identifier }; //create flat rate schedule group FlatRateScheduleGroupsRequest flatRateScheduleGroupRequest = new FlatRateScheduleGroupsRequest { CreatedBy = identifier, ExternalIdentifier = identifier, Name = identifier }; await Client.FlatRateScheduleGroups.Create(flatRateScheduleGroupRequest); //create handling schedule group HandlingScheduleGroupRequest handlingScheduleGroupRequest = new HandlingScheduleGroupRequest { CreatedBy = "temporal request", ExternalIdentifier = testData.HandlingScheduleGroupExtId, Name = "free handling" }; await Client.HandlingScheduleGroups.Create(handlingScheduleGroupRequest); //create a flat rate schedule FlatRateScheduleRequest flatRateScheduleRequest = new FlatRateScheduleRequest { CreatedBy = "temporal test request", ServiceLevelCode = (int)ServiceLevelCodesEnum.NextDay, ExternalIdentifier = testData.FlatRateScheduleExtId, Rate = 150, OrderAmountMin = 100, OrderAmountMax = 1000 }; await Client.FlatRateSchedules.Create(flatRateScheduleRequest); //create a flat rate and group schedules FlatRateScheduleConfigurationRequest flatRateScheduleConfigurationRequest = new FlatRateScheduleConfigurationRequest { CreatedBy = "temporal test request" }; await Client.FlatRateScheduleConfigurations.Create(testData.FlatRateScheduleGroupExtId, testData.FlatRateScheduleExtId, flatRateScheduleConfigurationRequest); //create handling schedule HandlingScheduleRequest handlingScheduleRequest = new HandlingScheduleRequest { CreatedBy = "temporal test request", ExternalIdentifier = testData.HandlingScheduleExtId, OrderAmountMin = 100, OrderAmountMax = 1000, Rate = 50, ServiceLevelCode = (int)ServiceLevelCodesEnum.NextDay }; await Client.HandlingSchedules.Create(handlingScheduleRequest); //link handling schedule with group HandlingSchedulesConfigurationRequest handlingSchedulesConfigurationRequest = new HandlingSchedulesConfigurationRequest { CreatedBy = "temporal test request" }; await Client.HandlingScheduleConfigurations.Create(handlingScheduleGroupRequest.ExternalIdentifier, handlingScheduleRequest.ExternalIdentifier, handlingSchedulesConfigurationRequest); //create shipping configuration ShippingConfigurationRequest shippingConfigurationRequest = new ShippingConfigurationRequest { CreatedBy = "temporal test request", ExternalIdentifier = testData.ShippingConfigExtId, DefaultServiceLevelCode = (int)ServiceLevelCodesEnum.Local, ServiceLevels = new List <SCServiceLevel> { new SCServiceLevel { Amount = 200, CarrierRateDiscount = 0.5, SortOrder = 1, Label = "temporal label", CalculationMethod = "nothing", IsEnabled = true, CarrierCode = "nothing", Code = (int)ServiceLevelCodesEnum.NextDay }, new SCServiceLevel { Amount = 300, CarrierRateDiscount = 0.5, SortOrder = 0, Label = "temporal label", CalculationMethod = "nothing", IsEnabled = true, CarrierCode = "nothing", Code = (int)ServiceLevelCodesEnum.Local } } }; await Client.ShippingConfigurations.Create(shippingConfigurationRequest); //create shippingPreference for accountMaster ShippingAccountMasterPreferencesRequest shippingPreferenceRequest = new ShippingAccountMasterPreferencesRequest { CreatedBy = "temporal test request", UseCustomerCarrier = false, ShippingConfigurationExternalId = testData.ShippingConfigExtId, FreeFreightRules = new List <SAMFreeFreightRule> { }, FlatRateScheduleGroupExternalId = testData.FlatRateScheduleGroupExtId, HandlingScheduleGroupExternalId = testData.HandlingScheduleGroupExtId }; await Client.ShippingAccountMasterPreferences.Create(testData.AccountMasterExtId, shippingPreferenceRequest); ShipmentRequest request = new ShipmentRequest { OrderId = "00000000000000000002", ShipFromAddress = new Address { AddressLine1 = "Denver Boulder Turnpike", AddressLine2 = "", City = "Boulder", Country = "US", Name = "dfs", Postal = "80014", StateProvinceRegion = "CO" }, ShipToAddress = new Address { AddressLine1 = "Denver Boulder Turnpike", AddressLine2 = string.Empty, City = "Boulder", Country = "US", Name = "dfs", Postal = "1234567", StateProvinceRegion = "CO" }, Products = new List <ShipmentProduct> { new ShipmentProduct { Quantity = 1, CheckoutPriceExtended = 110, Shipping = new ShipmentProductShipping { Width = 12, Height = 12, IsFreeShip = false, Length = 12, IsFreightOnly = false, IsQuickShip = false, WeightDimensional = 12m, WeightActual = 2, FreightClass = 2 } } } }; HttpEssResponse <ShipmentResponse> response = await Client.Shipments.GetSingle(testData.AccountMasterExtId, request); //test data clean up await TestScenarioCleanUp(testData); //validations Assert.IsNotNull(response); Assert.AreEqual(200, response.StatusCode); Assert.IsTrue(response.Success, "Response status is not successful"); Assert.IsNotNull(response.Result, "Result object should not be null"); //specific validations var shippingFlatRate = response.Result.ShipmentRates.FirstOrDefault(r => r.ServiceLevelCode == flatRateScheduleRequest.ServiceLevelCode); //this code checks all ServiceLevels, none of them is returning a handling value //date: 10/03/2020 //int i = 0; //while(true) //{ // bool exists = Enum.IsDefined(typeof(ServiceLevelCodesEnum), i); // if (exists) // { // flatRateScheduleRequest.ServiceLevelCode = i; // shippingFlatRate = response.Result.ShipmentRates.FirstOrDefault(r => r.ServiceLevelCode == flatRateScheduleRequest.ServiceLevelCode); // } // i++; // if (shippingFlatRate == null) continue; // if (shippingFlatRate.Handling != null) break; //} //flat rate validations Assert.IsTrue(shippingFlatRate.IsFlatRate, $"{nameof(shippingFlatRate.IsFlatRate)} prop should be true"); Assert.AreEqual(flatRateScheduleRequest.Rate, shippingFlatRate.Amount); //handling validations //Handlig value returned = null //TO:DO make handling don't return null Assert.AreEqual(null, shippingFlatRate.Handling); //Assert.AreEqual(handlingScheduleRequest.Rate, shippingFlatRate.Handling); }
public async Task <HttpEssResponse <HandlingSchedulesConfigurationResponse> > Create(string groupId, string scheduleId, HandlingSchedulesConfigurationRequest request) { string stringPayload = await Task.Run(() => JsonConvert.SerializeObject(request)); MethodUrl = $"/handlingScheduleGroups/{groupId}/schedules/{scheduleId}"; var response = await Post(stringPayload); return(response); }
public async Task GET_Shipment_Warning312() { ShipmentTestData testData = new ShipmentTestData { AccountMasterExtId = "accountM01Warning12", ShippingConfigExtId = "shippingConfigShipment02", FlatRateScheduleGroupExtId = "flatRateGroupShipment02", FlatRateScheduleExtId = "flatRateShipment02", HandlingScheduleGroupExtId = "handlingGroupShipment02", HandlingScheduleExtId = "handlingShipment02" }; string expectedDescription = "No destination address provided"; int expectedCode = 312; await TestScenarioCleanUp(testData); //create shipping configuration var shippingConfigurationRequest = new ShippingConfigurationRequest { CreatedBy = "temporal shipmentrequest", ExternalIdentifier = testData.ShippingConfigExtId, DefaultServiceLevelCode = (int)ServiceLevelCodesEnum.Ground, ServiceLevels = new List <SCServiceLevel> { new SCServiceLevel { Label = "Shipment 312 req", Amount = 12, CalculationMethod = "nothing", CarrierCode = "312", Code = (int)ServiceLevelCodesEnum.Ground, SortOrder = 5, IsEnabled = true, CarrierRateDiscount = 0.6 } } }; await Client.ShippingConfigurations.Create(shippingConfigurationRequest); //create flat rate group var flatRateGroupRequest = new FlatRateScheduleGroupsRequest { ExternalIdentifier = testData.FlatRateScheduleGroupExtId, CreatedBy = "temporal shipment request", Name = "shipment group" }; await Client.FlatRateScheduleGroups.Create(flatRateGroupRequest); //create handling group var handlingGroupRequest = new HandlingScheduleGroupRequest { ExternalIdentifier = testData.HandlingScheduleGroupExtId, CreatedBy = "temporal shipment request", Name = "shipment group" }; await Client.HandlingScheduleGroups.Create(handlingGroupRequest); //create handling schedule var handlingScheduleRequest = new HandlingScheduleRequest { CreatedBy = "shipment request", OrderAmountMin = 1, OrderAmountMax = 2, Rate = 1, ExternalIdentifier = testData.HandlingScheduleExtId, ServiceLevelCode = (int)ServiceLevelCodesEnum.Ground, }; await Client.HandlingSchedules.Create(handlingScheduleRequest); //link handling schedule with group var handlingScheduleConfigurationRequest = new HandlingSchedulesConfigurationRequest { CreatedBy = "shipment temporal request" }; await Client.HandlingScheduleConfigurations .Create(testData.HandlingScheduleGroupExtId, testData.HandlingScheduleExtId, handlingScheduleConfigurationRequest); //create shipping preference var shippingPreferenceRequest = new ShippingAccountMasterPreferencesRequest { CreatedBy = "temporal request", ShippingConfigurationExternalId = testData.ShippingConfigExtId, UseCustomerCarrier = false, FreeFreightRules = new List <SAMFreeFreightRule> { new SAMFreeFreightRule { ServiceLevelCode = (int)ServiceLevelCodesEnum.Local, ThresholdAmount = 0 } }, FlatRateScheduleGroupExternalId = testData.FlatRateScheduleGroupExtId, HandlingScheduleGroupExternalId = testData.HandlingScheduleGroupExtId }; await Client.ShippingAccountMasterPreferences.Create(testData.AccountMasterExtId, shippingPreferenceRequest); //get shipment request ShipmentRequest request = new ShipmentRequest { OrderId = "00000000000000000001", ShipFromAddress = new Address { AddressLine1 = "sample street", AddressLine2 = "apt 2", City = "boulder", Country = "us", Name = "dfs", Postal = "1234567", StateProvinceRegion = "co" }, //no destination address Products = new List <ShipmentProduct> { new ShipmentProduct { ProductSku = "sample string", CheckoutPriceExtended = 18.33m, Quantity = 1, Shipping = new ShipmentProductShipping { Width = 12, Height = 12, IsFreeShip = false, Length = 12, IsFreightOnly = false, IsQuickShip = false, WeightDimensional = 12.5m, WeightActual = 17, FreightClass = 12 } } } }; HttpEssResponse <ShipmentResponse> response = await Client.Shipments.GetSingle(testData.AccountMasterExtId, request); //clear test entities await TestScenarioCleanUp(testData); //generic endpoint validations Assert.IsNotNull(response); Assert.IsTrue(response.Success, "Response status is not successful"); Assert.IsNotNull(response.Result, "Result object should not be null"); //specific validations Assert.AreEqual(expectedCode, response.StatusCode); Assert.AreEqual(expectedDescription, response.Description); }