diff --git a/EasyPost.Tests/ServicesTests/WithParameters/CarrierAccountServiceTest.cs b/EasyPost.Tests/ServicesTests/WithParameters/CarrierAccountServiceTest.cs index ef955e6c..4f74e02c 100644 --- a/EasyPost.Tests/ServicesTests/WithParameters/CarrierAccountServiceTest.cs +++ b/EasyPost.Tests/ServicesTests/WithParameters/CarrierAccountServiceTest.cs @@ -95,23 +95,12 @@ public async Task TestCreateUps() Parameters.CarrierAccount.CreateUps parameters = Fixtures.Parameters.CarrierAccounts.CreateUps(data); - try - { - // confirms we can pass in 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 (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(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 { Message: "Invalid Customer Account Nbr" }); + // confirms we can pass in 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); - // Check the cassette to make sure the endpoint is correct (it should be ups_oauth_registrations) - // Check the cassette to make sure the "ups_oauth_registrations" key is populated in the request body - } + Assert.IsType(carrierAccount); + Assert.StartsWith("ca_", carrierAccount.Id); } [Fact] diff --git a/EasyPost/Constants.cs b/EasyPost/Constants.cs index fa12c6f0..4e9d921f 100644 --- a/EasyPost/Constants.cs +++ b/EasyPost/Constants.cs @@ -165,15 +165,12 @@ internal static string DeriveCreateEndpoint(string carrierType) var @switch = new SwitchCase { - { CarrierAccountType.FedEx.Name, () => endpoint = CustomCreateEndpoint }, - { CarrierAccountType.FedExSmartPost.Name, () => endpoint = CustomCreateEndpoint }, - { CarrierAccountType.Ups.Name, () => endpoint = UpsOAuthCreateEndpoint }, - { CarrierAccountType.UpsMailInnovations.Name, () => endpoint = UpsOAuthCreateEndpoint }, - { CarrierAccountType.UpsSurePost.Name, () => endpoint = UpsOAuthCreateEndpoint }, + { new List { CarrierAccountType.FedEx.Name, CarrierAccountType.FedExSmartPost.Name }.Contains(carrierType), () => endpoint = CustomCreateEndpoint }, + { new List { CarrierAccountType.Ups.Name, CarrierAccountType.UpsMailInnovations.Name, CarrierAccountType.UpsSurePost.Name }.Contains(carrierType), () => endpoint = UpsOAuthCreateEndpoint }, { SwitchCaseScenario.Default, () => endpoint = StandardCreateEndpoint }, }; - @switch.MatchFirst(carrierType); + @switch.MatchFirstTrue(); return endpoint; } @@ -184,13 +181,11 @@ internal static string DeriveUpdateEndpoint(string carrierType, string id) var @switch = new SwitchCase { - { CarrierAccountType.Ups.Name, () => endpoint = string.Format(CultureInfo.InvariantCulture, UpsOAuthUpdateEndpoint, id) }, - { CarrierAccountType.UpsMailInnovations.Name, () => endpoint = string.Format(CultureInfo.InvariantCulture, UpsOAuthUpdateEndpoint, id) }, - { CarrierAccountType.UpsSurePost.Name, () => endpoint = string.Format(CultureInfo.InvariantCulture, UpsOAuthUpdateEndpoint, id) }, + { new List { CarrierAccountType.Ups.Name, CarrierAccountType.UpsMailInnovations.Name, CarrierAccountType.UpsSurePost.Name }.Contains(carrierType), () => endpoint = string.Format(CultureInfo.InvariantCulture, UpsOAuthUpdateEndpoint, id) }, { SwitchCaseScenario.Default, () => endpoint = string.Format(CultureInfo.InvariantCulture, StandardUpdateEndpoint, id) }, }; - @switch.MatchFirst(carrierType); + @switch.MatchFirstTrue(); return endpoint; }