Skip to content

Commit 34eeaef

Browse files
committed
feat: add typescript definitions for customer portal and embeddable sessions
1 parent 7b79d05 commit 34eeaef

File tree

6 files changed

+108
-0
lines changed

6 files changed

+108
-0
lines changed
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { ICustomerPortalAccountLinkCreateParameters } from './CustomerPortalAccountLinkCreateParameters';
2+
3+
/**
4+
* Class representing an EasyPost CustomerPortalAccountLink object.
5+
*
6+
*/
7+
export declare interface ICustomerPortalAccountLink {
8+
/** Always returns "CustomerPortalAccountLink". */
9+
object: string;
10+
11+
/** One-time-use session URL for initiating the Customer Portal. */
12+
link: string;
13+
14+
/** One-time-use session URL for initiating the Customer Portal. */
15+
created_at: string;
16+
17+
/** ISO 8601 timestamp when the link will expire (5 minutes from creation). */
18+
expires_at: string;
19+
}
20+
21+
export declare class CustomerPortalAccountLink implements ICustomerPortalAccountLink {
22+
public constructor(input: ICustomerPortalAccountLinkCreateParameters);
23+
24+
object: 'CustomerPortalAccountLink';
25+
link: string;
26+
created_at: string;
27+
expires_at: string;
28+
29+
/**
30+
* Create a Portal Session.
31+
*
32+
* @see https://docs.easypost.com/docs/customer-portals#creating-a-portal-session
33+
*
34+
* @param {Object} params The parameters to create a {@link CustomerPortalAccountLink} with.
35+
* @returns {Promise<CustomerPortalAccountLink>} The {@link CustomerPortalAccountLink}.
36+
*/
37+
static createAccountLink(params: Object): Promise<CustomerPortalAccountLink>;
38+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
export declare interface ICustomerPortalAccountLinkCreateParameters {
2+
/** Type of Customer Portal session. */
3+
session_type: 'account_onboarding' | 'account_management';
4+
5+
/** The User ID of the sub account for which the portal session is being created. */
6+
user_id: string;
7+
8+
/** The URL to which the sub account will be redirected if the session URL is expired, reused, or otherwise invalid. This should trigger a new session request. */
9+
refresh_url: string;
10+
11+
/**
12+
* The URL to which the sub account will be redirected after exiting the Customer Portal session.
13+
* This does not confirm completion of the flow; webhook or API polling is recommended for confirmation.
14+
*/
15+
return_url: string;
16+
17+
/**
18+
* Used to configure the Customer Portal session.
19+
*/
20+
metadata?: object;
21+
}

types/CustomerPortal/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './CustomerPortalAccountLink';
2+
export * from './CustomerPortalAccountLinkCreateParameters';
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { IEmbeddablesSessionCreateParameters } from './EmbeddablesSessionCreateParameters';
2+
3+
/**
4+
* Class representing an EasyPost EmbeddablesSession object.
5+
*
6+
*/
7+
export declare interface IEmbeddablesSession {
8+
/** Always returns "EmbeddablesSession". */
9+
object: string;
10+
11+
/** Short-lived, one-time-use token that authorizes an Embeddables Components session. Must be provided to the client-side Embeddables script to initialize the component. */
12+
session_id: string;
13+
14+
/** ISO 8601 timestamp indicating when the session was created. */
15+
created_at: string;
16+
17+
/** ISO 8601 timestamp indicating when the session expires. */
18+
expires_at: string;
19+
}
20+
21+
export declare class EmbeddablesSession implements IEmbeddablesSession {
22+
public constructor(input: IEmbeddablesSessionCreateParameters);
23+
24+
object: 'EmbeddablesSession';
25+
session_id: string;
26+
created_at: string;
27+
expires_at: string;
28+
29+
/**
30+
* Create a Portal Session.
31+
*
32+
* @see https://docs.easypost.com/docs/embeddables#create-an-embeddable-session
33+
*
34+
* @param {Object} params The parameters to create a {@link EmbeddablesSession} with.
35+
* @returns {Promise<EmbeddablesSession>} The {@link EmbeddablesSession}.
36+
*/
37+
static createSession(params: Object): Promise<EmbeddablesSession>;
38+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export declare interface IEmbeddablesSessionCreateParameters {
2+
/** The integrator’s domain in bare-host format (e.g., example.com), excluding protocol and subdomains. */
3+
origin_host: string;
4+
5+
/** The User ID of the sub account for which the embeddable session is being created. */
6+
user_id: string;
7+
}

types/Embeddable/index.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './EmbeddablesSession';
2+
export * from './EmbeddablesSessionCreateParameters';

0 commit comments

Comments
 (0)