Skip to content

Commit ebb4aca

Browse files
feat: add support for carrier open endpoint (#671)
# Description - Adds support for FedexDefaultAccount, GofoWalletAccount, UpsDapAccount, UniUniWalletAccount, and VehoWalletAccount by properly routing carrier-account create requests to the /carrier_accounts/open endpoint. # Testing - Adds new parametrized test to ensure all custom url carrier accounts route properly # Pull Request Type Please select the option(s) that are relevant to this PR. - [ ] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [ ] Improvement (fixing a typo, updating readme, renaming a variable name, etc) --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent bd4cce7 commit ebb4aca

22 files changed

Lines changed: 918 additions & 36 deletions

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
- Makes `ReferralCustomer.RetrieveEasypostStripeApiKey` public to help facilitate adding credit cards using Stripe.js
88
- Correctly passes `end_shipper_id` param instead of `end_shipper` in shipment buy calls (closes [669](https://github.com/EasyPost/easypost-csharp/issues/669))
99
- Add `Surcharge` model and `Surcharges` property to `Rate` class
10+
- Adds support for `FedexDefaultAccount`, `GofoWalletAccount`, `UpsDapAccount`, `UniUniWalletAccount`, and `VehoWalletAccount` by properly routing carrier-account create requests to the `/carrier_accounts/open` endpoint
1011

1112
## v7.10.0 (2026-07-24)
1213

‎EasyPost.Tests/ServicesTests/CarrierAccountServiceTest.cs‎

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,29 @@ public async Task TestCreate()
5050
Assert.Equal("DhlEcsAccount", carrierAccount.Type);
5151
}
5252

53-
[Fact]
53+
[Theory]
5454
[CrudOperations.Create]
5555
[Testing.Parameters]
56-
public async Task TestCreateWithCustomWorkflow()
56+
[InlineData("FedexAccount")]
57+
[InlineData("FedexSmartpostAccount")]
58+
[InlineData("AmazonShippingAccount")]
59+
[InlineData("UpsAccount")]
60+
[InlineData("UpsMailInnovationsAccount")]
61+
[InlineData("UpsSurepostAccount")]
62+
[InlineData("UspsShipAccount")]
63+
[InlineData("FedexDefaultAccount")]
64+
[InlineData("GofoWalletAccount")]
65+
[InlineData("UpsDapAccount")]
66+
[InlineData("UniUniWalletAccount")]
67+
[InlineData("VehoWalletAccount")]
68+
public async Task TestCreateWithCustomWorkflow(string carrierType)
5769
{
5870
UseVCR("create_with_custom_workflow");
5971

60-
// FedEx or UPS should trigger a function error since not supported by legacy parameter method
61-
try
62-
{
63-
Dictionary<string, object> parameters = Fixtures.BasicCarrierAccount;
64-
parameters["type"] = CarrierAccountType.FedEx.Name;
65-
parameters["registration_data"] = new Dictionary<string, object>();
72+
Dictionary<string, object> parameters = Fixtures.BasicCarrierAccount;
73+
parameters["type"] = carrierType;
6674

67-
CarrierAccount carrierAccount = await Client.CarrierAccount.Create(parameters);
68-
CleanUpAfterTest(carrierAccount.Id);
69-
}
70-
catch (InvalidFunctionError e)
71-
{
72-
// Function should have been halted due to incompatible carrier account type
73-
Assert.NotNull(e);
74-
}
75+
await Assert.ThrowsAsync<InvalidFunctionError>(async () => await Client.CarrierAccount.Create(parameters));
7576
}
7677

7778
[Fact]

‎EasyPost.Tests/ServicesTests/WithParameters/CarrierAccountServiceTest.cs‎

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
using System.Collections.Generic;
2+
using System.IO;
3+
using System.Linq;
24
using System.Threading.Tasks;
35
using EasyPost.Exceptions.API;
46
using EasyPost.Exceptions.General;
57
using EasyPost.Models.API;
68
using EasyPost.Tests._Utilities;
79
using EasyPost.Tests._Utilities.Attributes;
810
using EasyPost.Utilities.Internal.Attributes;
11+
using Newtonsoft.Json.Linq;
912
using Xunit;
1013

1114
namespace EasyPost.Tests.ServicesTests.WithParameters
@@ -110,6 +113,28 @@ public async Task TestCreateUps()
110113
Assert.StartsWith("ca_", carrierAccount.Id);
111114
}
112115

116+
[Theory]
117+
[CrudOperations.Create]
118+
[Testing.Parameters]
119+
[MemberData(nameof(CreateUrlRoutingData))]
120+
public async Task TestCreateUrlRouting(Parameters.CarrierAccount.ACreate parameters, string cassetteName, string expectedEndpoint, string expectedBodyKey)
121+
{
122+
UseVCR(cassetteName);
123+
124+
try
125+
{
126+
CarrierAccount carrierAccount = await Client.CarrierAccount.Create(parameters);
127+
CleanUpAfterTest(carrierAccount.Id);
128+
}
129+
catch (ApiError error)
130+
{
131+
Assert.NotEqual(404, error.StatusCode);
132+
Assert.NotEqual(500, error.StatusCode);
133+
}
134+
135+
AssertCassetteRequest(cassetteName, expectedEndpoint, expectedBodyKey);
136+
}
137+
113138
[Fact]
114139
[CrudOperations.Create]
115140
[Testing.Exception]
@@ -196,6 +221,63 @@ public async Task TestUpdateUps()
196221

197222
#endregion
198223

224+
public static IEnumerable<object[]> CreateUrlRoutingData()
225+
{
226+
yield return new object[] { Fixtures.Parameters.CarrierAccounts.CreateFedEx(new Dictionary<string, object>()), "create_url_routing_fedex", "/carrier_accounts/register", "carrier_account" };
227+
yield return new object[] { CreateFedExSmartPostParameters(), "create_url_routing_fedex_smartpost", "/carrier_accounts/register", "carrier_account" };
228+
yield return new object[] { new Parameters.CarrierAccount.CreateFedExDefault(), "create_url_routing_fedex_default", "/carrier_accounts/open", "carrier_account" };
229+
yield return new object[] { new Parameters.CarrierAccount.CreateGofoWallet(), "create_url_routing_gofo_wallet", "/carrier_accounts/open", "carrier_account" };
230+
yield return new object[] { new Parameters.CarrierAccount.CreateUpsDap(), "create_url_routing_ups_dap", "/carrier_accounts/open", "carrier_account" };
231+
yield return new object[] { new Parameters.CarrierAccount.CreateUniUniWallet(), "create_url_routing_uniuni_wallet", "/carrier_accounts/open", "carrier_account" };
232+
yield return new object[] { new Parameters.CarrierAccount.CreateVehoWallet(), "create_url_routing_veho_wallet", "/carrier_accounts/open", "carrier_account" };
233+
yield return new object[] { new Parameters.CarrierAccount.CreateOauth { Type = CarrierAccountType.AmazonShippingAccount.Name }, "create_url_routing_amazon_shipping", "/carrier_accounts/register_oauth", "carrier_account_oauth_registrations" };
234+
yield return new object[] { Fixtures.Parameters.CarrierAccounts.CreateUps(new Dictionary<string, object>()), "create_url_routing_ups", "/carrier_accounts/register_oauth", "carrier_account_oauth_registrations" };
235+
yield return new object[] { new Parameters.CarrierAccount.CreateUpsMailInnovations { AccountNumber = "123456789" }, "create_url_routing_ups_mail_innovations", "/carrier_accounts/register_oauth", "carrier_account_oauth_registrations" };
236+
yield return new object[] { new Parameters.CarrierAccount.CreateUpsSurePost { AccountNumber = "123456789" }, "create_url_routing_ups_surepost", "/carrier_accounts/register_oauth", "carrier_account_oauth_registrations" };
237+
yield return new object[] { new Parameters.CarrierAccount.CreateOauth { Type = CarrierAccountType.UspsShipAccount.Name }, "create_url_routing_usps_ship", "/carrier_accounts/register_oauth", "carrier_account_oauth_registrations" };
238+
}
239+
240+
private static Parameters.CarrierAccount.CreateFedExSmartPost CreateFedExSmartPostParameters()
241+
{
242+
return new Parameters.CarrierAccount.CreateFedExSmartPost
243+
{
244+
AccountNumber = "123456789",
245+
HubId = "1234",
246+
CorporateAddressCity = "San Francisco",
247+
CorporateAddressCountryCode = "US",
248+
CorporateAddressPostalCode = "94105",
249+
CorporateAddressState = "CA",
250+
CorporateAddressStreet = "345 California St",
251+
CorporateCompanyName = "EasyPost",
252+
CorporateEmailAddress = "me@example.com",
253+
CorporateFirstName = "Demo",
254+
CorporateLastName = "User",
255+
CorporateJobTitle = "Developer",
256+
CorporatePhoneNumber = "5555555555",
257+
ShippingAddressCity = "San Francisco",
258+
ShippingAddressCountryCode = "US",
259+
ShippingAddressPostalCode = "94105",
260+
ShippingAddressState = "CA",
261+
ShippingAddressStreet = "345 California St",
262+
};
263+
}
264+
265+
private static void AssertCassetteRequest(string cassetteName, string expectedEndpoint, string expectedBodyKey)
266+
{
267+
string cassettePath = Path.GetFullPath(Path.Combine(TestUtils.GetSourceFileDirectory(), "..", "..", "cassettes", "carrier_account_service_with_parameters", $"{cassetteName}.json"));
268+
string cassetteJson = File.ReadAllText(cassettePath);
269+
JArray interactions = JArray.Parse(cassetteJson);
270+
JToken? interaction = interactions.FirstOrDefault();
271+
272+
Assert.NotNull(interaction);
273+
274+
string? requestUri = interaction!["Request"]?["Uri"]?.Value<string>();
275+
string? requestBody = interaction["Request"]?["Body"]?.Value<string>();
276+
277+
Assert.EndsWith(expectedEndpoint, requestUri);
278+
Assert.Contains(expectedBodyKey, requestBody);
279+
}
280+
199281
#endregion
200282
}
201283
}

‎EasyPost.Tests/cassettes/carrier_account_service_with_parameters/create_url_routing_amazon_shipping.json‎

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎EasyPost.Tests/cassettes/carrier_account_service_with_parameters/create_url_routing_fedex.json‎

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎EasyPost.Tests/cassettes/carrier_account_service_with_parameters/create_url_routing_fedex_default.json‎

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎EasyPost.Tests/cassettes/carrier_account_service_with_parameters/create_url_routing_fedex_smartpost.json‎

Lines changed: 53 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)