Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# CHANGELOG

## Next Release

- Adds the following functions:
- `CustomerPortal.CreateAccountLink`
- `Embeddable.CreateSession`

## v7.3.0 (2025-11-10)

- Adds support for `UspsShipAccount`
Expand Down
4 changes: 1 addition & 3 deletions EasyPost.Integration/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@ public class Utils

private static readonly List<string> BodyCensors =
[
"api_keys",
"children",
"client_ip",
"credentials",
"email",
"fields",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewer Note

These did not match the rest of our libs and incorrectly was excluding the children key which we needed present to get the user ID from in tests.

"key",
"keys",
"phone_number",
"phone",
"test_credentials"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using EasyPost.Models.API;
using EasyPost.Parameters.CustomerPortal;
using EasyPost.Parameters.User;
using EasyPost.Tests._Utilities;
using EasyPost.Tests._Utilities.Attributes;
using EasyPost.Utilities.Internal.Attributes;
using Xunit;

namespace EasyPost.Tests.ServicesTests.WithParameters
{
public class CustomerPortalServiceTests : UnitTest
{
public CustomerPortalServiceTests() : base("customer_portal_service_with_parameters", TestUtils.ApiKey.Production)
{
}

#region Tests

#region Test CRUD Operations

[Fact]
[CrudOperations.Read]
[Testing.Function]
public async Task TestCreateAccountLink()
{
UseVCR("create_account_link");

Dictionary<string, object> fixture = new Dictionary<string, object> { { "page_size", Fixtures.PageSize } };
AllChildren childrenParameters = Fixtures.Parameters.Users.AllChildren(fixture);
ChildUserCollection childUserCollection = await Client.User.AllChildren(childrenParameters);

Parameters.CustomerPortal.CreateAccountLink parameters = new()
{
SessionType = "account_onboarding",
UserId = childUserCollection.Children[0].Id,
RefreshUrl = "https://example.com/refresh",
ReturnUrl = "https://example.com/return",
};
CustomerPortalAccountLink accountLink = await Client.CustomerPortal.CreateAccountLink(parameters);

Assert.IsType<CustomerPortalAccountLink>(accountLink);
}

#endregion

#endregion
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using EasyPost.Models.API;
using EasyPost.Parameters.Embeddable;
using EasyPost.Parameters.User;
using EasyPost.Tests._Utilities;
using EasyPost.Tests._Utilities.Attributes;
using EasyPost.Utilities.Internal.Attributes;
using Xunit;

namespace EasyPost.Tests.ServicesTests.WithParameters
{
public class EmbeddableServiceTests : UnitTest
{
public EmbeddableServiceTests() : base("embeddable_service_with_parameters", TestUtils.ApiKey.Production)
{
}

#region Tests

#region Test CRUD Operations

[Fact]
[CrudOperations.Read]
[Testing.Function]
public async Task TestCreateSession()
{
UseVCR("create_session");

Dictionary<string, object> fixture = new Dictionary<string, object> { { "page_size", Fixtures.PageSize } };
AllChildren childrenParameters = Fixtures.Parameters.Users.AllChildren(fixture);
ChildUserCollection childUserCollection = await Client.User.AllChildren(childrenParameters);

Parameters.Embeddable.CreateSession parameters = new()
{
OriginHost = "https://example.com",
UserId = childUserCollection.Children[0].Id,
};
EmbeddablesSession session = await Client.Embeddable.CreateSession(parameters);

Assert.IsType<EmbeddablesSession>(session);
}

#endregion

#endregion
}
}
4 changes: 1 addition & 3 deletions EasyPost.Tests/TestUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,11 @@ public class TestUtils

private static readonly List<string> BodyCensors =
[
"api_keys",
"children",
"client_ip",
"credentials",
"email",
"fields",
"key",
"keys",
"phone_number",
"phone",
"test_credentials"
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions EasyPost/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ public class Client : EasyPostClient
/// </summary>
public ClaimService Claim => new ClaimService(this);

/// <summary>
/// Access CustomerPortal-related functionality.
/// </summary>
public CustomerPortalService CustomerPortal => new CustomerPortalService(this);

/// <summary>
/// Access Customs Info-related functionality.
/// </summary>
Expand All @@ -63,6 +68,11 @@ public class Client : EasyPostClient
/// </summary>
public CustomsItemService CustomsItem => new CustomsItemService(this);

/// <summary>
/// Access Embeddable-related functionality.
/// </summary>
public EmbeddableService Embeddable => new EmbeddableService(this);

/// <summary>
/// Access EndShipper-related functionality.
/// </summary>
Expand Down
33 changes: 33 additions & 0 deletions EasyPost/Models/API/CustomerPortalAccountLink.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using EasyPost._base;
using Newtonsoft.Json;

namespace EasyPost.Models.API
{
/// <summary>
/// Class representing a CustomerPortalAccountLink.
/// </summary>
public class CustomerPortalAccountLink : EphemeralEasyPostObject
{
#region JSON Properties

/// <summary>
/// One-time-use session URL for initiating the Customer Portal.
/// </summary>
[JsonProperty("link")]
public string? Link { get; set; }

/// <summary>
/// One-time-use session URL for initiating the Customer Portal.
/// </summary>
[JsonProperty("created_at")]
public string? CreatedAt { get; set; }

/// <summary>
/// ISO 8601 timestamp when the link will expire (5 minutes from creation).
/// </summary>
[JsonProperty("expires_at")]
public string? ExpiresAt { get; set; }

#endregion
}
}
Loading
Loading