diff --git a/EasyPost.Tests/ExceptionsTests/ExceptionsTest.cs b/EasyPost.Tests/ExceptionsTests/ExceptionsTest.cs index fba43920a..b92e8b304 100644 --- a/EasyPost.Tests/ExceptionsTests/ExceptionsTest.cs +++ b/EasyPost.Tests/ExceptionsTests/ExceptionsTest.cs @@ -168,7 +168,7 @@ public void TestExceptionConstructors() Assert.Equal(testMessage, invalidObjectError.Message); InvalidParameterError invalidParameterError = new(testPropertyName); - Assert.Equal(string.Format(CultureInfo.InvariantCulture, Constants.ErrorMessages.InvalidParameter, testPropertyName), invalidParameterError.Message); + Assert.Equal($"{string.Format(CultureInfo.InvariantCulture, Constants.ErrorMessages.InvalidParameter, testPropertyName)}. ", invalidParameterError.Message); JsonDeserializationError jsonDeserializationError = new(testType); Assert.Equal(string.Format(CultureInfo.InvariantCulture, Constants.ErrorMessages.JsonDeserializationError, testType.FullName), jsonDeserializationError.Message); diff --git a/EasyPost.Tests/Fixture.cs b/EasyPost.Tests/Fixture.cs index 1b4a3549b..697f6794f 100644 --- a/EasyPost.Tests/Fixture.cs +++ b/EasyPost.Tests/Fixture.cs @@ -230,6 +230,36 @@ internal static ParameterSets.CarrierAccount.Create Create(Dictionary>("registration_data"), }; } + + internal static ParameterSets.CarrierAccount.CreateFedEx CreateFedEx(Dictionary? fixture) + { + fixture ??= new Dictionary(); + + return new ParameterSets.CarrierAccount.CreateFedEx + { + Description = fixture.GetOrNull("description"), + Reference = fixture.GetOrNull("reference"), + Credentials = fixture.GetOrNull>("credentials"), + TestCredentials = fixture.GetOrNull>("test_credentials"), + AccountNumber = "123456789", + CorporateAddressCity = "San Francisco", + CorporateAddressCountryCode = "US", + CorporateAddressPostalCode = "94105", + CorporateAddressState = "CA", + CorporateAddressStreet = "345 California St", + CorporateCompanyName = "EasyPost", + CorporateEmailAddress = "me@example.com", + CorporateFirstName = "Demo", + CorporateLastName = "User", + CorporateJobTitle = "Developer", + CorporatePhoneNumber = "5555555555", + ShippingAddressCity = "San Francisco", + ShippingAddressCountryCode = "US", + ShippingAddressPostalCode = "94105", + ShippingAddressState = "CA", + ShippingAddressStreet = "345 California St", + }; + } } internal static class CustomsInfo @@ -618,7 +648,7 @@ internal static ParameterSets.Shipment.Create Create(Dictionary? Parcel = Parcels.Create(parcelFixture), CustomsInfo = CustomsInfo.Create(customsInfoFixture), Options = Options(optionsFixture), - CarbonOffset = fixture.GetOrDefault("carbon_offset"), // this will always be true or false, never null + CarbonOffset = fixture.GetOrDefault("carbon_offset"), // this will always be true or false, never null CarrierAccountIds = fixture.GetOrNull>("carrier_accounts"), Carrier = fixture.GetOrNull("carrier"), Service = fixture.GetOrNull("service"), diff --git a/EasyPost.Tests/ParametersTests/ParametersTest.cs b/EasyPost.Tests/ParametersTests/ParametersTest.cs index a8bff19f0..993ff035b 100644 --- a/EasyPost.Tests/ParametersTests/ParametersTest.cs +++ b/EasyPost.Tests/ParametersTests/ParametersTest.cs @@ -106,6 +106,44 @@ public void TestParametersToDictionaryWithSubDictionary() Assert.Equal(streetB, addressData["street1"]); } + [Fact] + [Testing.Exception] + public void TestRequiredAndOptionalParameterValidation() + { + var parametersWithBothParameterSet = new ParameterSetWithRequiredAndOptionalParameters + { + RequiredParameter = "required", + OptionalParameter = "optional", + }; + // should not throw an exception when serializing to a dictionary + parametersWithBothParameterSet.ToDictionary(); + + var parametersWithOnlyRequiredParameterSet = new ParameterSetWithRequiredAndOptionalParameters + { + RequiredParameter = "required", + }; + + // should not throw an exception when serializing to a dictionary + parametersWithOnlyRequiredParameterSet.ToDictionary(); + + var parametersWithOnlyOptionalParameterSet = new ParameterSetWithRequiredAndOptionalParameters + { + OptionalParameter = "optional", + }; + + // should throw an exception when serializing to a dictionary + Assert.Throws(() => parametersWithOnlyOptionalParameterSet.ToDictionary()); + } + + private sealed class ParameterSetWithRequiredAndOptionalParameters : Parameters.BaseParameters + { + [TopLevelRequestParameter(Necessity.Required, "test", "required")] + public string? RequiredParameter { get; set; } + + [TopLevelRequestParameter(Necessity.Optional, "test", "optional")] + public string? OptionalParameter { get; set; } + } + /// /// This test proves that we can reuse the Addresses.Create parameter object, /// with its serialization logic adapting to whether it is a top-level parameter object @@ -200,7 +238,7 @@ public async Task TestDisallowUsingParameterObjectDictionariesInDictionaryFuncti Street1 = street, }; - Dictionary dictionary = addressCreationParameters.ToDictionary(); // this method is "internal", so end-users won't have access to it, for reasons seen below + Dictionary dictionary = addressCreationParameters.ToDictionary(); // this method is "internal", so end-users won't have access to it, for reasons seen below // At this point, the data has already been wrapped properly by the .ToDictionary() method, and this method expects raw (unwrapped) data // This will cause a double-wrapping, sending malformed data to the API diff --git a/EasyPost.Tests/ServicesTests/WithParameters/CarrierAccountServiceTest.cs b/EasyPost.Tests/ServicesTests/WithParameters/CarrierAccountServiceTest.cs index 0600ae213..f8506f25c 100644 --- a/EasyPost.Tests/ServicesTests/WithParameters/CarrierAccountServiceTest.cs +++ b/EasyPost.Tests/ServicesTests/WithParameters/CarrierAccountServiceTest.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.Threading.Tasks; using EasyPost.Exceptions.API; +using EasyPost.Exceptions.General; using EasyPost.Models.API; using EasyPost.Tests._Utilities; using EasyPost.Tests._Utilities.Attributes; @@ -57,28 +58,49 @@ public async Task TestCreateWithCustomWorkflow() UseVCR("create_with_custom_workflow"); // Carriers like FedEx and UPS should hit the `/carrier_accounts/register` endpoint - try - { - Dictionary data = Fixtures.BasicCarrierAccount; - data["type"] = "FedexAccount"; - data["registration_data"] = new Dictionary(); + Dictionary data = Fixtures.BasicCarrierAccount; - Parameters.CarrierAccount.Create parameters = Fixtures.Parameters.CarrierAccounts.Create(data); + Parameters.CarrierAccount.Create parameters = Fixtures.Parameters.CarrierAccounts.CreateFedEx(data); + try + { + // confirms we can pass in CreateFedEx and CreateUps parameters to the same Create method because they are children of the generic Create class CarrierAccount carrierAccount = await Client.CarrierAccount.Create(parameters); CleanUpAfterTest(carrierAccount.Id); } - catch (InvalidRequestError e) + + catch (BadRequestError e) { // the data we're sending is invalid, we want to check that the API error is because of malformed data and not due to the endpoint - Assert.Equal(422, e.StatusCode); // 422 is fine. We don't want a 404 not found + Assert.Equal(400, e.StatusCode); // 400 is fine. We don't want a 404 not found Assert.NotNull(e.Errors); - Assert.Contains(e.Errors, error => error is { Field: "account_number", Message: "must be present and a string" }); + Assert.Contains(e.Errors, error => error is { Message: "Invalid Customer Account Nbr" }); // Check the cassette to make sure the endpoint is correct (it should be carrier_accounts/register) + // Check the cassette to make sure the "registration_data" key is populated in the request body } } + [Fact] + [CrudOperations.Create] + [Testing.Exception] + public async Task TestPreventUsersUsingGenericParameterSetWithCustomWorkflow() + { + UseVCR("prevent_users_using_generic_parameter_set_with_custom_workflow"); + + // Generic Create parameter set configured for DHL + Dictionary data = Fixtures.BasicCarrierAccount; + + // Override the type to be a custom type + data["type"] = Constants.CarrierAccountTypes.FedExAccount; + data["registration_data"] = new Dictionary(); + + Parameters.CarrierAccount.Create parameters = Fixtures.Parameters.CarrierAccounts.Create(data); + + // should raise an exception because we're using a generic Create set with a custom workflow type (FedExAccount) + await Assert.ThrowsAsync(async () => await Client.CarrierAccount.Create(parameters)); + } + [Fact] [CrudOperations.Update] [Testing.Function] diff --git a/EasyPost.Tests/cassettes/net/carrier_account_service_with_parameters/create.json b/EasyPost.Tests/cassettes/net/carrier_account_service_with_parameters/create.json index 73722d9a8..2ce8b73f1 100644 --- a/EasyPost.Tests/cassettes/net/carrier_account_service_with_parameters/create.json +++ b/EasyPost.Tests/cassettes/net/carrier_account_service_with_parameters/create.json @@ -1,7 +1,7 @@ [ { - "Duration": 495, - "RecordedAt": "2023-04-25T21:17:07.055498-06:00", + "Duration": 497, + "RecordedAt": "2023-08-28T14:42:19.056221-06:00", "Request": { "Body": "{\"carrier_account\":{\"credentials\":{},\"test_credentials\":{},\"type\":\"DhlEcsAccount\"}}", "BodyContentType": "Json", @@ -17,7 +17,7 @@ "Uri": "https://api.easypost.com/v2/carrier_accounts" }, "Response": { - "Body": "{\"id\":\"ca_861ed435eb4a4507a4c03d28b1ea42f5\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-04-26T03:17:07Z\",\"updated_at\":\"2023-04-26T03:17:07Z\",\"description\":\"DHL eCommerce Solutions Account\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", + "Body": "{\"id\":\"ca_df0f7ebc19d145f2b27140f75e0ae833\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-08-28T20:42:19Z\",\"updated_at\":\"2023-08-28T20:42:19Z\",\"description\":\"DHL eCommerce Solutions Account\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", "BodyContentType": "Json", "ContentHeaders": { "Expires": "0", @@ -32,15 +32,15 @@ "x-download-options": "noopen", "x-permitted-cross-domain-policies": "none", "Referrer-Policy": "strict-origin-when-cross-origin", - "x-ep-request-uuid": "d4af614b644897b2e1aa6e3900094645", + "x-ep-request-uuid": "72745c0164ed06aaf41dae5800037ea3", "Cache-Control": "no-store, no-cache, private", "Pragma": "no-cache", - "ETag": "W/\"06d53078d915b2d92cab13769da687ed\"", - "x-runtime": "0.107862", - "x-node": "bigweb8nuq", - "x-version-label": "easypost-202304252326-79950b6035-master", + "ETag": "W/\"cf37c4c11197e4344cfbfc0e3f556024\"", + "x-runtime": "0.120716", + "x-node": "bigweb41nuq", + "x-version-label": "easypost-202308252358-79b9940f30-master", "x-backend": "easypost", - "x-proxied": "intlb1nuq a29e4ad05c,intlb1wdc a29e4ad05c,extlb4wdc a29e4ad05c", + "x-proxied": "intlb1nuq 2bcb349163,intlb1wdc 2bcb349163,extlb4wdc 003ad9bca0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" }, "Status": { @@ -50,8 +50,8 @@ } }, { - "Duration": 305, - "RecordedAt": "2023-04-25T21:17:07.371075-06:00", + "Duration": 210, + "RecordedAt": "2023-08-28T14:42:19.274844-06:00", "Request": { "Body": "", "BodyContentType": "Text", @@ -61,10 +61,10 @@ "Authorization": "", "User-Agent": "" }, - "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_861ed435eb4a4507a4c03d28b1ea42f5" + "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_df0f7ebc19d145f2b27140f75e0ae833" }, "Response": { - "Body": "{\"id\":\"ca_861ed435eb4a4507a4c03d28b1ea42f5\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-04-26T03:17:07Z\",\"updated_at\":\"2023-04-26T03:17:07Z\",\"description\":\"DHL eCommerce Solutions Account\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", + "Body": "{\"id\":\"ca_df0f7ebc19d145f2b27140f75e0ae833\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-08-28T20:42:19Z\",\"updated_at\":\"2023-08-28T20:42:19Z\",\"description\":\"DHL eCommerce Solutions Account\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", "BodyContentType": "Json", "ContentHeaders": { "Expires": "0", @@ -79,15 +79,15 @@ "x-download-options": "noopen", "x-permitted-cross-domain-policies": "none", "Referrer-Policy": "strict-origin-when-cross-origin", - "x-ep-request-uuid": "d4af614b644897b3e1aa6e3900094661", + "x-ep-request-uuid": "72745c0164ed06abf41dae5800037ebf", "Cache-Control": "no-store, no-cache, private", "Pragma": "no-cache", - "ETag": "W/\"06d53078d915b2d92cab13769da687ed\"", - "x-runtime": "0.106327", - "x-node": "bigweb2nuq", - "x-version-label": "easypost-202304252326-79950b6035-master", + "ETag": "W/\"cf37c4c11197e4344cfbfc0e3f556024\"", + "x-runtime": "0.029051", + "x-node": "bigweb41nuq", + "x-version-label": "easypost-202308252358-79b9940f30-master", "x-backend": "easypost", - "x-proxied": "intlb2nuq a29e4ad05c,intlb1wdc a29e4ad05c,extlb4wdc a29e4ad05c", + "x-proxied": "intlb1nuq 2bcb349163,intlb1wdc 2bcb349163,extlb4wdc 003ad9bca0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" }, "Status": { @@ -97,8 +97,8 @@ } }, { - "Duration": 308, - "RecordedAt": "2023-04-25T21:17:07.689754-06:00", + "Duration": 397, + "RecordedAt": "2023-08-28T14:42:19.679871-06:00", "Request": { "Body": "", "BodyContentType": "Text", @@ -108,7 +108,7 @@ "Authorization": "", "User-Agent": "" }, - "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_861ed435eb4a4507a4c03d28b1ea42f5" + "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_df0f7ebc19d145f2b27140f75e0ae833" }, "Response": { "Body": "{}", @@ -126,15 +126,15 @@ "x-download-options": "noopen", "x-permitted-cross-domain-policies": "none", "Referrer-Policy": "strict-origin-when-cross-origin", - "x-ep-request-uuid": "d4af614b644897b3e1aa6e3900094680", + "x-ep-request-uuid": "72745c0164ed06abf41dae5800037ed0", "Cache-Control": "no-store, no-cache, private", "Pragma": "no-cache", "ETag": "W/\"44136fa355b3678a1146ad16f7e8649e\"", - "x-runtime": "0.112106", - "x-node": "bigweb9nuq", - "x-version-label": "easypost-202304252326-79950b6035-master", + "x-runtime": "0.212968", + "x-node": "bigweb36nuq", + "x-version-label": "easypost-202308252358-79b9940f30-master", "x-backend": "easypost", - "x-proxied": "intlb1nuq a29e4ad05c,intlb2wdc a29e4ad05c,extlb4wdc a29e4ad05c", + "x-proxied": "intlb1nuq 2bcb349163,intlb2wdc 2bcb349163,extlb4wdc 003ad9bca0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" }, "Status": { diff --git a/EasyPost.Tests/cassettes/net/carrier_account_service_with_parameters/create_with_custom_workflow.json b/EasyPost.Tests/cassettes/net/carrier_account_service_with_parameters/create_with_custom_workflow.json index 51bdfbd8b..7bb6621dc 100644 --- a/EasyPost.Tests/cassettes/net/carrier_account_service_with_parameters/create_with_custom_workflow.json +++ b/EasyPost.Tests/cassettes/net/carrier_account_service_with_parameters/create_with_custom_workflow.json @@ -1,13 +1,13 @@ [ { - "Duration": 380, - "RecordedAt": "2023-04-25T21:17:08.084642-06:00", + "Duration": 765, + "RecordedAt": "2023-08-28T14:42:20.463087-06:00", "Request": { - "Body": "{\"carrier_account\":{\"credentials\":{},\"test_credentials\":{},\"type\":\"FedexAccount\",\"registration_data\":{}}}", + "Body": "{\"carrier_account\":{\"registration_data\":{\"account_number\":\"123456789\",\"corporate_city\":\"San Francisco\",\"corporate_country_code\":\"US\",\"corporate_postal_code\":\"94105\",\"corporate_state\":\"CA\",\"corporate_streets\":\"345 California St\",\"corporate_company_name\":\"EasyPost\",\"corporate_email_address\":\"me@example.com\",\"corporate_first_name\":\"Demo\",\"corporate_job_title\":\"Developer\",\"corporate_last_name\":\"User\",\"corporate_phone_number\":\"5555555555\",\"shipping_city\":\"San Francisco\",\"shipping_country_code\":\"US\",\"shipping_postal_code\":\"94105\",\"shipping_state\":\"CA\",\"shipping_streets\":\"345 California St\"},\"credentials\":{},\"test_credentials\":{},\"type\":\"FedexAccount\"}}", "BodyContentType": "Json", "ContentHeaders": { "Content-Type": "application/json; charset=utf-8", - "Content-Length": "299" + "Content-Length": "848" }, "Method": "POST", "RequestHeaders": { @@ -17,12 +17,12 @@ "Uri": "https://api.easypost.com/v2/carrier_accounts/register" }, "Response": { - "Body": "{\"error\":{\"code\":\"UNPROCESSABLE_ENTITY\",\"message\":\"The request was understood, but cannot be processed.\",\"errors\":[{\"field\":\"shipping_streets\",\"message\":\"must be present and a string\"},{\"field\":\"shipping_city\",\"message\":\"must be present and a string\"},{\"field\":\"shipping_state\",\"message\":\"must be present and a string\"},{\"field\":\"shipping_postal_code\",\"message\":\"must be present and a string\"},{\"field\":\"shipping_country_code\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_first_name\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_last_name\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_job_title\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_company_name\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_phone_number\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_email_address\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_streets\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_city\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_state\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_postal_code\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_country_code\",\"message\":\"must be present and a string\"},{\"field\":\"account_number\",\"message\":\"must be present and a string\"}]}}", + "Body": "{\"error\":{\"code\":\"BAD_REQUEST\",\"message\":\"Malformed request. Please check the contents and retry.\",\"errors\":[{\"code\":\"3001\",\"message\":\"Invalid Customer Account Nbr\"}]}}", "BodyContentType": "Json", "ContentHeaders": { "Expires": "0", "Content-Type": "application/json; charset=utf-8", - "Content-Length": "1347" + "Content-Length": "168" }, "HttpVersion": "1.1", "ResponseHeaders": { @@ -32,19 +32,19 @@ "x-download-options": "noopen", "x-permitted-cross-domain-policies": "none", "Referrer-Policy": "strict-origin-when-cross-origin", - "x-ep-request-uuid": "72c23981644897b4e198efc200080b10", + "x-ep-request-uuid": "f17fc6ca64ed06acf451c98a000d0953", "Cache-Control": "no-store, no-cache, private", "Pragma": "no-cache", - "x-runtime": "0.031220", - "x-node": "bigweb9nuq", - "x-version-label": "easypost-202304252326-79950b6035-master", + "x-runtime": "0.358320", + "x-node": "bigweb34nuq", + "x-version-label": "easypost-202308252358-79b9940f30-master", "x-backend": "easypost", - "x-proxied": "intlb1nuq a29e4ad05c,intlb1wdc a29e4ad05c,extlb3wdc a29e4ad05c", + "x-proxied": "intlb1nuq 2bcb349163,intlb2wdc 2bcb349163,extlb3wdc 003ad9bca0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" }, "Status": { - "Code": 422, - "Message": "Unprocessable Entity" + "Code": 400, + "Message": "Bad Request" } } } diff --git a/EasyPost.Tests/cassettes/net/carrier_account_service_with_parameters/update.json b/EasyPost.Tests/cassettes/net/carrier_account_service_with_parameters/update.json index 6d32ca9d0..19615a4b4 100644 --- a/EasyPost.Tests/cassettes/net/carrier_account_service_with_parameters/update.json +++ b/EasyPost.Tests/cassettes/net/carrier_account_service_with_parameters/update.json @@ -1,7 +1,7 @@ [ { - "Duration": 553, - "RecordedAt": "2023-04-25T21:17:06.023764-06:00", + "Duration": 911, + "RecordedAt": "2023-08-28T14:42:17.956817-06:00", "Request": { "Body": "{\"carrier_account\":{\"credentials\":{},\"test_credentials\":{},\"type\":\"DhlEcsAccount\"}}", "BodyContentType": "Json", @@ -17,7 +17,7 @@ "Uri": "https://api.easypost.com/v2/carrier_accounts" }, "Response": { - "Body": "{\"id\":\"ca_2e5389c35758460dbdd8a9c9d0ba6a9a\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-04-26T03:17:06Z\",\"updated_at\":\"2023-04-26T03:17:06Z\",\"description\":\"DHL eCommerce Solutions Account\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", + "Body": "{\"id\":\"ca_4d737e02f8264c628f27c7754a740792\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-08-28T20:42:17Z\",\"updated_at\":\"2023-08-28T20:42:17Z\",\"description\":\"DHL eCommerce Solutions Account\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", "BodyContentType": "Json", "ContentHeaders": { "Expires": "0", @@ -32,15 +32,15 @@ "x-download-options": "noopen", "x-permitted-cross-domain-policies": "none", "Referrer-Policy": "strict-origin-when-cross-origin", - "x-ep-request-uuid": "d677fdb5644897b2e1bed1c20008c9b8", + "x-ep-request-uuid": "2c07ce3764ed06a9f40a73ac00014f36", "Cache-Control": "no-store, no-cache, private", "Pragma": "no-cache", - "ETag": "W/\"236205dbbaa0afe97e4b10703e32e089\"", - "x-runtime": "0.117437", - "x-node": "bigweb1nuq", - "x-version-label": "easypost-202304252326-79950b6035-master", + "ETag": "W/\"802cd80ec02ee03f5acf69b136a70056\"", + "x-runtime": "0.227181", + "x-node": "bigweb35nuq", + "x-version-label": "easypost-202308252358-79b9940f30-master", "x-backend": "easypost", - "x-proxied": "intlb2nuq a29e4ad05c,extlb2nuq a29e4ad05c", + "x-proxied": "intlb1nuq 2bcb349163,extlb2nuq 003ad9bca0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" }, "Status": { @@ -50,8 +50,8 @@ } }, { - "Duration": 171, - "RecordedAt": "2023-04-25T21:17:06.263734-06:00", + "Duration": 164, + "RecordedAt": "2023-08-28T14:42:18.177268-06:00", "Request": { "Body": "{\"carrier_account\":{\"description\":\"my custom description\"}}", "BodyContentType": "Json", @@ -64,10 +64,10 @@ "Authorization": "", "User-Agent": "" }, - "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_2e5389c35758460dbdd8a9c9d0ba6a9a" + "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_4d737e02f8264c628f27c7754a740792" }, "Response": { - "Body": "{\"id\":\"ca_2e5389c35758460dbdd8a9c9d0ba6a9a\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-04-26T03:17:06Z\",\"updated_at\":\"2023-04-26T03:17:06Z\",\"description\":\"my custom description\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", + "Body": "{\"id\":\"ca_4d737e02f8264c628f27c7754a740792\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-08-28T20:42:17Z\",\"updated_at\":\"2023-08-28T20:42:18Z\",\"description\":\"my custom description\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", "BodyContentType": "Json", "ContentHeaders": { "Expires": "0", @@ -82,15 +82,15 @@ "x-download-options": "noopen", "x-permitted-cross-domain-policies": "none", "Referrer-Policy": "strict-origin-when-cross-origin", - "x-ep-request-uuid": "d677fdb5644897b2e1bed1c20008c9eb", + "x-ep-request-uuid": "2c07ce3764ed06aaf40a73ac00014f54", "Cache-Control": "no-store, no-cache, private", "Pragma": "no-cache", - "ETag": "W/\"79b8a78a445841c6650f3afcb89ebd04\"", - "x-runtime": "0.123185", - "x-node": "bigweb4nuq", - "x-version-label": "easypost-202304252326-79950b6035-master", + "ETag": "W/\"41edc266c3a8fb016b68696d793b93ad\"", + "x-runtime": "0.120572", + "x-node": "bigweb39nuq", + "x-version-label": "easypost-202308252358-79b9940f30-master", "x-backend": "easypost", - "x-proxied": "intlb1nuq a29e4ad05c,extlb2nuq a29e4ad05c", + "x-proxied": "intlb1nuq 2bcb349163,extlb2nuq 003ad9bca0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" }, "Status": { @@ -100,8 +100,8 @@ } }, { - "Duration": 78, - "RecordedAt": "2023-04-25T21:17:06.382304-06:00", + "Duration": 74, + "RecordedAt": "2023-08-28T14:42:18.288989-06:00", "Request": { "Body": "", "BodyContentType": "Text", @@ -111,10 +111,10 @@ "Authorization": "", "User-Agent": "" }, - "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_2e5389c35758460dbdd8a9c9d0ba6a9a" + "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_4d737e02f8264c628f27c7754a740792" }, "Response": { - "Body": "{\"id\":\"ca_2e5389c35758460dbdd8a9c9d0ba6a9a\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-04-26T03:17:06Z\",\"updated_at\":\"2023-04-26T03:17:06Z\",\"description\":\"my custom description\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", + "Body": "{\"id\":\"ca_4d737e02f8264c628f27c7754a740792\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-08-28T20:42:17Z\",\"updated_at\":\"2023-08-28T20:42:18Z\",\"description\":\"my custom description\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", "BodyContentType": "Json", "ContentHeaders": { "Expires": "0", @@ -129,15 +129,15 @@ "x-download-options": "noopen", "x-permitted-cross-domain-policies": "none", "Referrer-Policy": "strict-origin-when-cross-origin", - "x-ep-request-uuid": "d677fdb5644897b2e1bed1c20008ca09", + "x-ep-request-uuid": "2c07ce3764ed06aaf40a73ac00014f67", "Cache-Control": "no-store, no-cache, private", "Pragma": "no-cache", - "ETag": "W/\"79b8a78a445841c6650f3afcb89ebd04\"", - "x-runtime": "0.027493", - "x-node": "bigweb4nuq", - "x-version-label": "easypost-202304252326-79950b6035-master", + "ETag": "W/\"41edc266c3a8fb016b68696d793b93ad\"", + "x-runtime": "0.028372", + "x-node": "bigweb41nuq", + "x-version-label": "easypost-202308252358-79b9940f30-master", "x-backend": "easypost", - "x-proxied": "intlb2nuq a29e4ad05c,extlb2nuq a29e4ad05c", + "x-proxied": "intlb1nuq 2bcb349163,extlb2nuq 003ad9bca0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" }, "Status": { @@ -147,8 +147,8 @@ } }, { - "Duration": 157, - "RecordedAt": "2023-04-25T21:17:06.547797-06:00", + "Duration": 236, + "RecordedAt": "2023-08-28T14:42:18.53858-06:00", "Request": { "Body": "", "BodyContentType": "Text", @@ -158,7 +158,7 @@ "Authorization": "", "User-Agent": "" }, - "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_2e5389c35758460dbdd8a9c9d0ba6a9a" + "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_4d737e02f8264c628f27c7754a740792" }, "Response": { "Body": "{}", @@ -176,15 +176,15 @@ "x-download-options": "noopen", "x-permitted-cross-domain-policies": "none", "Referrer-Policy": "strict-origin-when-cross-origin", - "x-ep-request-uuid": "d677fdb5644897b2e1bed1c20008ca17", + "x-ep-request-uuid": "2c07ce3764ed06aaf40a73ac00014f6c", "Cache-Control": "no-store, no-cache, private", "Pragma": "no-cache", "ETag": "W/\"44136fa355b3678a1146ad16f7e8649e\"", - "x-runtime": "0.117694", - "x-node": "bigweb8nuq", - "x-version-label": "easypost-202304252326-79950b6035-master", + "x-runtime": "0.195496", + "x-node": "bigweb38nuq", + "x-version-label": "easypost-202308252358-79b9940f30-master", "x-backend": "easypost", - "x-proxied": "intlb2nuq a29e4ad05c,extlb2nuq a29e4ad05c", + "x-proxied": "intlb2nuq 2bcb349163,extlb2nuq 003ad9bca0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" }, "Status": { diff --git a/EasyPost.Tests/cassettes/netstandard/carrier_account_service_with_parameters/create.json b/EasyPost.Tests/cassettes/netstandard/carrier_account_service_with_parameters/create.json index a48f1067a..ae0347e7b 100644 --- a/EasyPost.Tests/cassettes/netstandard/carrier_account_service_with_parameters/create.json +++ b/EasyPost.Tests/cassettes/netstandard/carrier_account_service_with_parameters/create.json @@ -1,7 +1,7 @@ [ { - "Duration": 487, - "RecordedAt": "2023-03-15T16:18:03.712177-06:00", + "Duration": 466, + "RecordedAt": "2023-08-28T14:48:55.287183-06:00", "Request": { "Body": "{\"carrier_account\":{\"credentials\":{},\"test_credentials\":{},\"type\":\"DhlEcsAccount\"}}", "BodyContentType": "Json", @@ -12,14 +12,12 @@ "Method": "POST", "RequestHeaders": { "Authorization": "", - "content_type": "application/json", - "Accept": "application/json,text/json,text/x-json,text/javascript,application/xml,text/xml", "User-Agent": "" }, "Uri": "https://api.easypost.com/v2/carrier_accounts" }, "Response": { - "Body": "{\"id\":\"ca_f54473759d1e46cfb4957b0ab8beef1a\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-03-15T22:18:03Z\",\"updated_at\":\"2023-03-15T22:18:03Z\",\"description\":\"DHL eCommerce Solutions Account\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", + "Body": "{\"id\":\"ca_68f5d528b6604cc8ad511b7ecac0e55a\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-08-28T20:48:55Z\",\"updated_at\":\"2023-08-28T20:48:55Z\",\"description\":\"DHL eCommerce Solutions Account\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", "BodyContentType": "Json", "ContentHeaders": { "Expires": "0", @@ -34,15 +32,15 @@ "x-download-options": "noopen", "x-permitted-cross-domain-policies": "none", "referrer-policy": "strict-origin-when-cross-origin", - "x-ep-request-uuid": "f46ccd146412441be660bbe900050c93", + "x-ep-request-uuid": "f17fc6cf64ed0837f450a4f1000d8d77", "Cache-Control": "no-store, no-cache, private", "Pragma": "no-cache", - "ETag": "W/\"e5b846917019f11e3dd483dcd6fe896e\"", - "x-runtime": "0.121496", - "x-node": "bigweb4nuq", - "x-version-label": "easypost-202303142258-f5b873fcbd-master", + "ETag": "W/\"1a5051d8d6c18a69399dda03600a9a14\"", + "x-runtime": "0.106863", + "x-node": "bigweb41nuq", + "x-version-label": "easypost-202308252358-79b9940f30-master", "x-backend": "easypost", - "x-proxied": "intlb2nuq a40ea751fd,intlb1wdc a40ea751fd,extlb3wdc a40ea751fd", + "x-proxied": "intlb1nuq 2bcb349163,intlb1wdc 2bcb349163,extlb3wdc 003ad9bca0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" }, "Status": { @@ -52,8 +50,8 @@ } }, { - "Duration": 236, - "RecordedAt": "2023-03-15T16:18:03.976893-06:00", + "Duration": 306, + "RecordedAt": "2023-08-28T14:48:55.608275-06:00", "Request": { "Body": "", "BodyContentType": "Text", @@ -61,14 +59,12 @@ "Method": "GET", "RequestHeaders": { "Authorization": "", - "content_type": "application/json", - "Accept": "application/json,text/json,text/x-json,text/javascript,application/xml,text/xml", "User-Agent": "" }, - "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_f54473759d1e46cfb4957b0ab8beef1a" + "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_68f5d528b6604cc8ad511b7ecac0e55a" }, "Response": { - "Body": "{\"id\":\"ca_f54473759d1e46cfb4957b0ab8beef1a\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-03-15T22:18:03Z\",\"updated_at\":\"2023-03-15T22:18:03Z\",\"description\":\"DHL eCommerce Solutions Account\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", + "Body": "{\"id\":\"ca_68f5d528b6604cc8ad511b7ecac0e55a\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-08-28T20:48:55Z\",\"updated_at\":\"2023-08-28T20:48:55Z\",\"description\":\"DHL eCommerce Solutions Account\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", "BodyContentType": "Json", "ContentHeaders": { "Expires": "0", @@ -83,15 +79,15 @@ "x-download-options": "noopen", "x-permitted-cross-domain-policies": "none", "referrer-policy": "strict-origin-when-cross-origin", - "x-ep-request-uuid": "f46ccd146412441be660bbe900050cb6", + "x-ep-request-uuid": "f17fc6cf64ed0837f450a4f1000d8d9a", "Cache-Control": "no-store, no-cache, private", "Pragma": "no-cache", - "ETag": "W/\"e5b846917019f11e3dd483dcd6fe896e\"", - "x-runtime": "0.038347", - "x-node": "bigweb5nuq", - "x-version-label": "easypost-202303142258-f5b873fcbd-master", + "ETag": "W/\"1a5051d8d6c18a69399dda03600a9a14\"", + "x-runtime": "0.120709", + "x-node": "bigweb40nuq", + "x-version-label": "easypost-202308252358-79b9940f30-master", "x-backend": "easypost", - "x-proxied": "intlb1nuq a40ea751fd,intlb1wdc a40ea751fd,extlb3wdc a40ea751fd", + "x-proxied": "intlb1nuq 2bcb349163,intlb1wdc 2bcb349163,extlb3wdc 003ad9bca0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" }, "Status": { @@ -101,8 +97,8 @@ } }, { - "Duration": 318, - "RecordedAt": "2023-03-15T16:18:04.308925-06:00", + "Duration": 295, + "RecordedAt": "2023-08-28T14:48:55.916517-06:00", "Request": { "Body": "", "BodyContentType": "Text", @@ -110,11 +106,9 @@ "Method": "DELETE", "RequestHeaders": { "Authorization": "", - "content_type": "application/json", - "Accept": "application/json,text/json,text/x-json,text/javascript,application/xml,text/xml", "User-Agent": "" }, - "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_f54473759d1e46cfb4957b0ab8beef1a" + "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_68f5d528b6604cc8ad511b7ecac0e55a" }, "Response": { "Body": "{}", @@ -132,15 +126,15 @@ "x-download-options": "noopen", "x-permitted-cross-domain-policies": "none", "referrer-policy": "strict-origin-when-cross-origin", - "x-ep-request-uuid": "f46ccd146412441ce660bbe900050cc8", + "x-ep-request-uuid": "f17fc6cf64ed0837f450a4f1000d8dbc", "Cache-Control": "no-store, no-cache, private", "Pragma": "no-cache", "ETag": "W/\"44136fa355b3678a1146ad16f7e8649e\"", - "x-runtime": "0.122399", - "x-node": "bigweb9nuq", - "x-version-label": "easypost-202303142258-f5b873fcbd-master", + "x-runtime": "0.118070", + "x-node": "bigweb33nuq", + "x-version-label": "easypost-202308252358-79b9940f30-master", "x-backend": "easypost", - "x-proxied": "intlb2nuq a40ea751fd,intlb2wdc a40ea751fd,extlb3wdc a40ea751fd", + "x-proxied": "intlb2nuq 2bcb349163,intlb1wdc 2bcb349163,extlb3wdc 003ad9bca0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" }, "Status": { diff --git a/EasyPost.Tests/cassettes/netstandard/carrier_account_service_with_parameters/create_with_custom_workflow.json b/EasyPost.Tests/cassettes/netstandard/carrier_account_service_with_parameters/create_with_custom_workflow.json index 70e570ed3..efe40e6fa 100644 --- a/EasyPost.Tests/cassettes/netstandard/carrier_account_service_with_parameters/create_with_custom_workflow.json +++ b/EasyPost.Tests/cassettes/netstandard/carrier_account_service_with_parameters/create_with_custom_workflow.json @@ -1,30 +1,28 @@ [ { - "Duration": 295, - "RecordedAt": "2023-03-15T16:18:04.621405-06:00", + "Duration": 714, + "RecordedAt": "2023-08-28T14:45:51.457537-06:00", "Request": { - "Body": "{\"carrier_account\":{\"credentials\":{},\"test_credentials\":{},\"type\":\"FedexAccount\",\"registration_data\":{}}}", + "Body": "{\"carrier_account\":{\"registration_data\":{\"account_number\":\"123456789\",\"corporate_city\":\"San Francisco\",\"corporate_country_code\":\"US\",\"corporate_postal_code\":\"94105\",\"corporate_state\":\"CA\",\"corporate_streets\":\"345 California St\",\"corporate_company_name\":\"EasyPost\",\"corporate_email_address\":\"me@example.com\",\"corporate_first_name\":\"Demo\",\"corporate_job_title\":\"Developer\",\"corporate_last_name\":\"User\",\"corporate_phone_number\":\"5555555555\",\"shipping_city\":\"San Francisco\",\"shipping_country_code\":\"US\",\"shipping_postal_code\":\"94105\",\"shipping_state\":\"CA\",\"shipping_streets\":\"345 California St\"},\"credentials\":{},\"test_credentials\":{},\"type\":\"FedexAccount\"}}", "BodyContentType": "Json", "ContentHeaders": { "Content-Type": "application/json; charset=utf-8", - "Content-Length": "299" + "Content-Length": "848" }, "Method": "POST", "RequestHeaders": { "Authorization": "", - "content_type": "application/json", - "Accept": "application/json,text/json,text/x-json,text/javascript,application/xml,text/xml", "User-Agent": "" }, "Uri": "https://api.easypost.com/v2/carrier_accounts/register" }, "Response": { - "Body": "{\"error\":{\"code\":\"UNPROCESSABLE_ENTITY\",\"message\":\"The request was understood, but cannot be processed.\",\"errors\":[{\"field\":\"shipping_streets\",\"message\":\"must be present and a string\"},{\"field\":\"shipping_city\",\"message\":\"must be present and a string\"},{\"field\":\"shipping_state\",\"message\":\"must be present and a string\"},{\"field\":\"shipping_postal_code\",\"message\":\"must be present and a string\"},{\"field\":\"shipping_country_code\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_first_name\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_last_name\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_job_title\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_company_name\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_phone_number\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_email_address\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_streets\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_city\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_state\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_postal_code\",\"message\":\"must be present and a string\"},{\"field\":\"corporate_country_code\",\"message\":\"must be present and a string\"},{\"field\":\"account_number\",\"message\":\"must be present and a string\"}]}}", + "Body": "{\"error\":{\"code\":\"BAD_REQUEST\",\"message\":\"Malformed request. Please check the contents and retry.\",\"errors\":[{\"code\":\"3001\",\"message\":\"Invalid Customer Account Nbr\"}]}}", "BodyContentType": "Json", "ContentHeaders": { "Expires": "0", "Content-Type": "application/json; charset=utf-8", - "Content-Length": "1347" + "Content-Length": "168" }, "HttpVersion": "1.1", "ResponseHeaders": { @@ -34,19 +32,19 @@ "x-download-options": "noopen", "x-permitted-cross-domain-policies": "none", "referrer-policy": "strict-origin-when-cross-origin", - "x-ep-request-uuid": "287eb8e96412441ce6871586002c370e", + "x-ep-request-uuid": "2c07ce3864ed077ff3fa002d00019b39", "Cache-Control": "no-store, no-cache, private", "Pragma": "no-cache", - "x-runtime": "0.125676", - "x-node": "bigweb4nuq", - "x-version-label": "easypost-202303142258-f5b873fcbd-master", + "x-runtime": "0.327908", + "x-node": "bigweb39nuq", + "x-version-label": "easypost-202308252358-79b9940f30-master", "x-backend": "easypost", - "x-proxied": "intlb1nuq a40ea751fd,extlb1nuq a40ea751fd", + "x-proxied": "intlb1nuq 2bcb349163,extlb2nuq 003ad9bca0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" }, "Status": { - "Code": 422, - "Message": "Unprocessable Entity" + "Code": 400, + "Message": "Bad Request" } } } diff --git a/EasyPost.Tests/cassettes/netstandard/carrier_account_service_with_parameters/update.json b/EasyPost.Tests/cassettes/netstandard/carrier_account_service_with_parameters/update.json index c8c74d187..b9578f43e 100644 --- a/EasyPost.Tests/cassettes/netstandard/carrier_account_service_with_parameters/update.json +++ b/EasyPost.Tests/cassettes/netstandard/carrier_account_service_with_parameters/update.json @@ -1,7 +1,7 @@ [ { - "Duration": 485, - "RecordedAt": "2023-04-26T10:44:59.86298-06:00", + "Duration": 467, + "RecordedAt": "2023-08-28T14:48:54.162377-06:00", "Request": { "Body": "{\"carrier_account\":{\"credentials\":{},\"test_credentials\":{},\"type\":\"DhlEcsAccount\"}}", "BodyContentType": "Json", @@ -17,7 +17,7 @@ "Uri": "https://api.easypost.com/v2/carrier_accounts" }, "Response": { - "Body": "{\"id\":\"ca_b975625f21134c2f96f8eb829d0e98d6\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-04-26T16:44:59Z\",\"updated_at\":\"2023-04-26T16:44:59Z\",\"description\":\"DHL eCommerce Solutions Account\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", + "Body": "{\"id\":\"ca_b9f082277aad4056b80c72b1172f7f0b\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-08-28T20:48:54Z\",\"updated_at\":\"2023-08-28T20:48:54Z\",\"description\":\"DHL eCommerce Solutions Account\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", "BodyContentType": "Json", "ContentHeaders": { "Expires": "0", @@ -32,15 +32,15 @@ "x-download-options": "noopen", "x-permitted-cross-domain-policies": "none", "referrer-policy": "strict-origin-when-cross-origin", - "x-ep-request-uuid": "46503e086449550be186db200016c4cb", + "x-ep-request-uuid": "80ef0aca64ed0836f41d14aa000385ff", "Cache-Control": "no-store, no-cache, private", "Pragma": "no-cache", - "ETag": "W/\"76f95f23220586e51839eedcc9cb6ff5\"", - "x-runtime": "0.112891", - "x-node": "bigweb5nuq", - "x-version-label": "easypost-202304252326-79950b6035-master", + "ETag": "W/\"a48b2a039c3b7281931e4eb0a4f60e62\"", + "x-runtime": "0.108200", + "x-node": "bigweb33nuq", + "x-version-label": "easypost-202308252358-79b9940f30-master", "x-backend": "easypost", - "x-proxied": "intlb2nuq a29e4ad05c,intlb1wdc a29e4ad05c,extlb4wdc a29e4ad05c", + "x-proxied": "intlb1nuq 2bcb349163,extlb1nuq 003ad9bca0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" }, "Status": { @@ -50,8 +50,8 @@ } }, { - "Duration": 327, - "RecordedAt": "2023-04-26T10:45:00.207311-06:00", + "Duration": 173, + "RecordedAt": "2023-08-28T14:48:54.388926-06:00", "Request": { "Body": "{\"carrier_account\":{\"description\":\"my custom description\"}}", "BodyContentType": "Json", @@ -64,10 +64,10 @@ "Authorization": "", "User-Agent": "" }, - "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_b975625f21134c2f96f8eb829d0e98d6" + "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_b9f082277aad4056b80c72b1172f7f0b" }, "Response": { - "Body": "{\"id\":\"ca_b975625f21134c2f96f8eb829d0e98d6\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-04-26T16:44:59Z\",\"updated_at\":\"2023-04-26T16:45:00Z\",\"description\":\"my custom description\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", + "Body": "{\"id\":\"ca_b9f082277aad4056b80c72b1172f7f0b\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-08-28T20:48:54Z\",\"updated_at\":\"2023-08-28T20:48:54Z\",\"description\":\"my custom description\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", "BodyContentType": "Json", "ContentHeaders": { "Expires": "0", @@ -82,15 +82,15 @@ "x-download-options": "noopen", "x-permitted-cross-domain-policies": "none", "referrer-policy": "strict-origin-when-cross-origin", - "x-ep-request-uuid": "46503e086449550be186db200016c4f5", + "x-ep-request-uuid": "80ef0aca64ed0836f41d14aa0003861b", "Cache-Control": "no-store, no-cache, private", "Pragma": "no-cache", - "ETag": "W/\"5a9f42d41b6b5e3df4fb79d47b87aaa3\"", - "x-runtime": "0.132030", - "x-node": "bigweb11nuq", - "x-version-label": "easypost-202304252326-79950b6035-master", + "ETag": "W/\"2ac4055abc3fcb44e19df9d046ca86d5\"", + "x-runtime": "0.130887", + "x-node": "bigweb35nuq", + "x-version-label": "easypost-202308252358-79b9940f30-master", "x-backend": "easypost", - "x-proxied": "intlb2nuq a29e4ad05c,intlb2wdc a29e4ad05c,extlb4wdc a29e4ad05c", + "x-proxied": "intlb1nuq 2bcb349163,extlb1nuq 003ad9bca0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" }, "Status": { @@ -100,8 +100,8 @@ } }, { - "Duration": 208, - "RecordedAt": "2023-04-26T10:45:00.428935-06:00", + "Duration": 68, + "RecordedAt": "2023-08-28T14:48:54.497532-06:00", "Request": { "Body": "", "BodyContentType": "Text", @@ -111,10 +111,10 @@ "Authorization": "", "User-Agent": "" }, - "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_b975625f21134c2f96f8eb829d0e98d6" + "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_b9f082277aad4056b80c72b1172f7f0b" }, "Response": { - "Body": "{\"id\":\"ca_b975625f21134c2f96f8eb829d0e98d6\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-04-26T16:44:59Z\",\"updated_at\":\"2023-04-26T16:45:00Z\",\"description\":\"my custom description\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", + "Body": "{\"id\":\"ca_b9f082277aad4056b80c72b1172f7f0b\",\"object\":\"CarrierAccount\",\"type\":\"DhlEcsAccount\",\"clone\":false,\"created_at\":\"2023-08-28T20:48:54Z\",\"updated_at\":\"2023-08-28T20:48:54Z\",\"description\":\"my custom description\",\"reference\":null,\"billing_type\":\"carrier\",\"readable\":\"DHL eCommerce Solutions\",\"logo\":null,\"fields\":{\"credentials\":{},\"test_credentials\":{}},\"credentials\":{},\"test_credentials\":{}}", "BodyContentType": "Json", "ContentHeaders": { "Expires": "0", @@ -129,15 +129,15 @@ "x-download-options": "noopen", "x-permitted-cross-domain-policies": "none", "referrer-policy": "strict-origin-when-cross-origin", - "x-ep-request-uuid": "46503e086449550ce186db200016c511", + "x-ep-request-uuid": "80ef0aca64ed0836f41d14aa0003863b", "Cache-Control": "no-store, no-cache, private", "Pragma": "no-cache", - "ETag": "W/\"5a9f42d41b6b5e3df4fb79d47b87aaa3\"", - "x-runtime": "0.025453", - "x-node": "bigweb11nuq", - "x-version-label": "easypost-202304252326-79950b6035-master", + "ETag": "W/\"2ac4055abc3fcb44e19df9d046ca86d5\"", + "x-runtime": "0.027299", + "x-node": "bigweb41nuq", + "x-version-label": "easypost-202308252358-79b9940f30-master", "x-backend": "easypost", - "x-proxied": "intlb2nuq a29e4ad05c,intlb2wdc a29e4ad05c,extlb4wdc a29e4ad05c", + "x-proxied": "intlb2nuq 2bcb349163,extlb1nuq 003ad9bca0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" }, "Status": { @@ -147,8 +147,8 @@ } }, { - "Duration": 304, - "RecordedAt": "2023-04-26T10:45:00.744508-06:00", + "Duration": 278, + "RecordedAt": "2023-08-28T14:48:54.795368-06:00", "Request": { "Body": "", "BodyContentType": "Text", @@ -158,7 +158,7 @@ "Authorization": "", "User-Agent": "" }, - "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_b975625f21134c2f96f8eb829d0e98d6" + "Uri": "https://api.easypost.com/v2/carrier_accounts/ca_b9f082277aad4056b80c72b1172f7f0b" }, "Response": { "Body": "{}", @@ -176,15 +176,16 @@ "x-download-options": "noopen", "x-permitted-cross-domain-policies": "none", "referrer-policy": "strict-origin-when-cross-origin", - "x-ep-request-uuid": "46503e086449550ce186db200016c527", + "x-ep-request-uuid": "80ef0aca64ed0836f41d14aa00038647", "Cache-Control": "no-store, no-cache, private", "Pragma": "no-cache", "ETag": "W/\"44136fa355b3678a1146ad16f7e8649e\"", - "x-runtime": "0.117254", - "x-node": "bigweb5nuq", - "x-version-label": "easypost-202304252326-79950b6035-master", + "x-runtime": "0.235367", + "x-node": "bigweb32nuq", + "x-version-label": "easypost-202308252358-79b9940f30-master", "x-backend": "easypost", - "x-proxied": "intlb2nuq a29e4ad05c,intlb2wdc a29e4ad05c,extlb4wdc a29e4ad05c", + "x-canary": "direct", + "x-proxied": "intlb2nuq 2bcb349163,extlb1nuq 003ad9bca0", "Strict-Transport-Security": "max-age=31536000; includeSubDomains; preload" }, "Status": { diff --git a/EasyPost/Constants.cs b/EasyPost/Constants.cs index cfad4118a..e89882412 100644 --- a/EasyPost/Constants.cs +++ b/EasyPost/Constants.cs @@ -119,13 +119,17 @@ public static class ErrorMessages /// public static class CarrierAccountTypes { + public const string FedExAccount = "FedexAccount"; + + public const string UpsAccount = "UpsAccount"; + /// /// Carrier account types that support custom workflows. /// internal static List CarrierTypesWithCustomWorkflows => new() { - "FedexAccount", - "UpsAccount", + FedExAccount, + UpsAccount, }; } } diff --git a/EasyPost/Exceptions/General/InvalidParameterError.cs b/EasyPost/Exceptions/General/InvalidParameterError.cs index 86d103b21..131f6c788 100644 --- a/EasyPost/Exceptions/General/InvalidParameterError.cs +++ b/EasyPost/Exceptions/General/InvalidParameterError.cs @@ -11,8 +11,9 @@ public class InvalidParameterError : ValidationError /// Initializes a new instance of the class. /// /// The name of the invalid parameter. - internal InvalidParameterError(string parameterName) - : base(string.Format(CultureInfo.InvariantCulture, Constants.ErrorMessages.InvalidParameter, parameterName)) + /// Additional message to include in error message. + internal InvalidParameterError(string parameterName, string? followUpMessage = "") + : base($"{string.Format(CultureInfo.InvariantCulture, Constants.ErrorMessages.InvalidParameter, parameterName)}. {followUpMessage}") { } } diff --git a/EasyPost/Parameters/CarrierAccount/CreateFedEx.cs b/EasyPost/Parameters/CarrierAccount/CreateFedEx.cs new file mode 100644 index 000000000..ce639cc58 --- /dev/null +++ b/EasyPost/Parameters/CarrierAccount/CreateFedEx.cs @@ -0,0 +1,75 @@ +using System.Diagnostics.CodeAnalysis; +using EasyPost.Utilities.Internal.Attributes; + +namespace EasyPost.Parameters.CarrierAccount +{ + /// + /// Parameters for API calls. + /// + [ExcludeFromCodeCoverage] + public class CreateFedEx : Create + { + #region Request Parameters + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "account_number")] + public string? AccountNumber { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "corporate_city")] + public string? CorporateAddressCity { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "corporate_country_code")] + public string? CorporateAddressCountryCode { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "corporate_postal_code")] + public string? CorporateAddressPostalCode { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "corporate_state")] + public string? CorporateAddressState { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "corporate_streets")] + public string? CorporateAddressStreet { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "corporate_company_name")] + public string? CorporateCompanyName { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "corporate_email_address")] + public string? CorporateEmailAddress { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "corporate_first_name")] + public string? CorporateFirstName { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "corporate_job_title")] + public string? CorporateJobTitle { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "corporate_last_name")] + public string? CorporateLastName { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "corporate_phone_number")] + public string? CorporatePhoneNumber { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "shipping_city")] + public string? ShippingAddressCity { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "shipping_country_code")] + public string? ShippingAddressCountryCode { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "shipping_postal_code")] + public string? ShippingAddressPostalCode { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "shipping_state")] + public string? ShippingAddressState { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "shipping_streets")] + public string? ShippingAddressStreet { get; set; } + + #endregion + + /// + /// Construct a new set of parameters. + /// + public CreateFedEx() + { + Type = Constants.CarrierAccountTypes.FedExAccount; + } + } +} diff --git a/EasyPost/Parameters/CarrierAccount/CreateUps.cs b/EasyPost/Parameters/CarrierAccount/CreateUps.cs new file mode 100644 index 000000000..d5b0f115a --- /dev/null +++ b/EasyPost/Parameters/CarrierAccount/CreateUps.cs @@ -0,0 +1,78 @@ +using System.Diagnostics.CodeAnalysis; +using EasyPost.Utilities.Internal.Attributes; + +namespace EasyPost.Parameters.CarrierAccount +{ + /// + /// Parameters for API calls. + /// + [ExcludeFromCodeCoverage] + public class CreateUps : Create + { + #region Request Parameters + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "account_number")] + public string? AccountNumber { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "city")] + public string? City { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "company")] + public string? CompanyName { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "country")] + public string? Country { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "email")] + public string? Email { get; set; } + + [TopLevelRequestParameter(Necessity.Optional, "carrier_account", "registration_data", "invoice_amount")] + public string? InvoiceAmount { get; set; } + + [TopLevelRequestParameter(Necessity.Optional, "carrier_account", "registration_data", "invoice_control_id")] + public string? InvoiceControlId { get; set; } + + [TopLevelRequestParameter(Necessity.Optional, "carrier_account", "registration_data", "invoice_currency")] + public string? InvoiceCurrency { get; set; } + + [TopLevelRequestParameter(Necessity.Optional, "carrier_account", "registration_data", "invoice_date")] + public string? InvoiceDate { get; set; } + + [TopLevelRequestParameter(Necessity.Optional, "carrier_account", "registration_data", "invoice_number")] + public string? InvoiceNumber { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "phone")] + public string? PhoneNumber { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "postal_code")] + public string? PostalCode { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "title")] + public string? RegistrarJobTitle { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "name")] + public string? RegistrarName { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "state")] + public string? State { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "street1")] + public string? Street { get; set; } + + [TopLevelRequestParameter(Necessity.Optional, "carrier_account", "registration_data", "street2")] + public string? Street2 { get; set; } + + [TopLevelRequestParameter(Necessity.Required, "carrier_account", "registration_data", "website")] + public string? Website { get; set; } + + #endregion + + /// + /// Construct a new set of parameters. + /// + public CreateUps() + { + Type = Constants.CarrierAccountTypes.UpsAccount; + } + } +} diff --git a/EasyPost/Services/CarrierAccountService.cs b/EasyPost/Services/CarrierAccountService.cs index bbd70e365..82b8ce180 100644 --- a/EasyPost/Services/CarrierAccountService.cs +++ b/EasyPost/Services/CarrierAccountService.cs @@ -68,6 +68,12 @@ public async Task Create(Parameters.CarrierAccount.Create parame throw new MissingParameterError(nameof(parameters.Type)); } + // stop the user from using a generic Create parameter set when creating a carrier account with a custom workflow (e.g. FedExAccount) + if (parameters.GetType() == typeof(Parameters.CarrierAccount.Create) && Constants.CarrierAccountTypes.CarrierTypesWithCustomWorkflows.Contains(parameters.Type)) + { + throw new InvalidParameterError("parameters", $"Use a {parameters.Type} custom workflow parameter set instead."); + } + string endpoint = SelectCarrierAccountCreationEndpoint(parameters.Type); return await RequestAsync(Method.Post, endpoint, cancellationToken, parameters.ToDictionary());