Skip to content

Commit 0cb4673

Browse files
committed
feat: add portal and embeddable sessions
1 parent 93aa101 commit 0cb4673

File tree

7 files changed

+175
-0
lines changed

7 files changed

+175
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# CHANGELOG
22

3+
## Next Release
4+
5+
- Adds the following functions:
6+
- `CustomerPortal.CreateAccountLink`
7+
- `Embeddable.CreateSession`
8+
39
## v7.3.0 (2025-11-10)
410

511
- Adds support for `UspsShipAccount`
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using EasyPost._base;
2+
using Newtonsoft.Json;
3+
4+
namespace EasyPost.Models.API
5+
{
6+
/// <summary>
7+
/// Class representing a CustomerPortalAccountLink.
8+
/// </summary>
9+
public class CustomerPortalAccountLink : EphemeralEasyPostObject
10+
{
11+
#region JSON Properties
12+
13+
/// <summary>
14+
/// Always returns "CustomerPortalAccountLink".
15+
/// </summary>
16+
[JsonProperty("object")]
17+
public string? Object { get; set; }
18+
19+
/// <summary>
20+
/// One-time-use session URL for initiating the Customer Portal.
21+
/// </summary>
22+
[JsonProperty("link")]
23+
public string? Link { get; set; }
24+
25+
/// <summary>
26+
/// One-time-use session URL for initiating the Customer Portal.
27+
/// </summary>
28+
[JsonProperty("created_at")]
29+
public string? CreatedAt { get; set; }
30+
31+
/// <summary>
32+
/// ISO 8601 timestamp when the link will expire (5 minutes from creation).
33+
/// </summary>
34+
[JsonProperty("expires_at")]
35+
public string? ExpiresAt { get; set; }
36+
37+
#endregion
38+
}
39+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
using EasyPost._base;
2+
using Newtonsoft.Json;
3+
4+
namespace EasyPost.Models.API
5+
{
6+
/// <summary>
7+
/// Class representing an EmbeddablesSession.
8+
/// </summary>
9+
public class EmbeddablesSession : EphemeralEasyPostObject
10+
{
11+
#region JSON Properties
12+
13+
/// <summary>
14+
/// Always returns "EmbeddablesSession".
15+
/// </summary>
16+
[JsonProperty("object")]
17+
public string? Object { get; set; }
18+
19+
/// <summary>
20+
/// Short-lived, one-time-use token that authorizes an Embeddables Components session.
21+
/// Must be provided to the client-side Embeddables script to initialize the component.
22+
/// </summary>
23+
[JsonProperty("session_id")]
24+
public string? SessionId { get; set; }
25+
26+
/// <summary>
27+
/// ISO 8601 timestamp indicating when the session was created.
28+
/// </summary>
29+
[JsonProperty("created_at")]
30+
public string? CreatedAt { get; set; }
31+
32+
/// <summary>
33+
/// ISO 8601 timestamp indicating when the session expires.
34+
/// </summary>
35+
[JsonProperty("expires_at")]
36+
public string? ExpiresAt { get; set; }
37+
38+
#endregion
39+
}
40+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
using System.Diagnostics.CodeAnalysis;
2+
using EasyPost.Models.API;
3+
using EasyPost.Utilities.Internal.Attributes;
4+
5+
namespace EasyPost.Parameters.Claim
6+
{
7+
/// <summary>
8+
/// <a href="https://docs.easypost.com/docs/customer-portals#creating-a-portal-session">Parameters</a> for <see cref="EasyPost.Services.CustomerPortalService.CreateAccountLink(CreateAccountLink, System.Threading.CancellationToken)"/> API calls.
9+
/// </summary>
10+
[ExcludeFromCodeCoverage]
11+
public class CreateAccountLink : BaseParameters<Models.API.CustomerPortalAccountLink>
12+
{
13+
#region Request Parameters
14+
15+
/// <summary>
16+
/// Type of Customer Portal session.
17+
/// </summary>
18+
[TopLevelRequestParameter(Necessity.Required, "session_type")]
19+
public string? SessionType { get; set; }
20+
21+
/// <summary>
22+
/// The User ID of the sub account for which the portal session is being created.
23+
/// </summary>
24+
[TopLevelRequestParameter(Necessity.Required, "user_id")]
25+
public string? UserId { get; set; }
26+
27+
/// <summary>
28+
/// The URL to which the sub account will be redirected if the session URL is expired, reused, or otherwise invalid.
29+
/// This should trigger a new session request.
30+
/// </summary>
31+
[TopLevelRequestParameter(Necessity.Required, "refresh_url")]
32+
public string? RefreshUrl { get; set; }
33+
34+
/// <summary>
35+
/// The URL to which the sub account will be redirected after exiting the Customer Portal session.
36+
/// This does not confirm completion of the flow; webhook or API polling is recommended for confirmation.
37+
/// </summary>
38+
[TopLevelRequestParameter(Necessity.Required, "return_url")]
39+
public string? ReturnUrl { get; set; }
40+
41+
/// <summary>
42+
/// Used to configure the Customer Portal session.
43+
/// </summary>
44+
[TopLevelRequestParameter(Necessity.Optional, "metadata")]
45+
public Dictionary<string, object>? Metadata { get; set; }
46+
47+
#endregion
48+
}
49+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// TODO
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
using EasyPost._base;
4+
using EasyPost.Exceptions.General;
5+
using EasyPost.Http;
6+
using EasyPost.Models.API;
7+
using EasyPost.Utilities.Internal.Attributes;
8+
9+
namespace EasyPost.Services
10+
{
11+
/// <summary>
12+
/// Class representing a set of CustomerPortal-related functionality.
13+
/// </summary>
14+
// ReSharper disable once ClassNeverInstantiated.Global
15+
public class CustomerPortalService : EasyPostService
16+
{
17+
/// <summary>
18+
/// Initializes a new instance of the <see cref="CustomerPortalService" /> class.
19+
/// </summary>
20+
/// <param name="client">The <see cref="EasyPostClient"/> to tie to this service and use for API calls.</param>
21+
internal CustomerPortalService(EasyPostClient client)
22+
: base(client)
23+
{
24+
}
25+
26+
#region CRUD Operations
27+
28+
/// <summary>
29+
/// Create a Portal Session.
30+
/// </summary>
31+
/// <param name="parameters">Data to use to create the Portal Session.</param>
32+
/// <param name="cancellationToken"><see cref="CancellationToken"/> to use for the HTTP request.</param>
33+
/// <returns>A <see cref="CustomerPortalAccountLink"/> object.</returns>
34+
[CrudOperations.Create]
35+
public async Task<CustomerPortalAccountLink> CreateAccountLink(Parameters.CustomerPortal.CreateAccountLink parameters, CancellationToken cancellationToken = default) => await RequestAsync<CustomerPortalAccountLink>(Method.Post, "customer_portal/account_link", cancellationToken, parameters.ToDictionary());
36+
37+
#endregion
38+
}
39+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
// TODO

0 commit comments

Comments
 (0)