@tolt/api 1.3.0 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@ import * as core from "./core/index.js";
5
5
  export function normalizeClientOptions(options) {
6
6
  const headers = mergeHeaders({
7
7
  "X-Fern-Language": "JavaScript",
8
- "User-Agent": "tolt-typescript/1.3.0",
8
+ "User-Agent": "tolt-typescript/1.4.0",
9
9
  "X-Fern-Runtime": core.RUNTIME.type,
10
10
  "X-Fern-Runtime-Version": core.RUNTIME.version,
11
11
  }, options?.headers);
@@ -11,7 +11,7 @@ export declare class EmbedTokensClient {
11
11
  protected readonly _options: NormalizedClientOptionsWithAuth<EmbedTokensClient.Options>;
12
12
  constructor(options: EmbedTokensClient.Options);
13
13
  /**
14
- * Mint a short-lived, partner-scoped token for the embedded referral dashboard. Safe to send to the browser. With partner (email and program_id), the partner is created when the program has none with that email, so one call covers a user's first visit.
14
+ * Mint a short-lived, partner-scoped token for the embedded referral dashboard. Safe to send to the browser. With partner (email and program_id, plus your own external_id), the partner is found by external_id, then by email, and created when the program has neither, so one call covers a user's first visit.
15
15
  *
16
16
  * @param {ToltApi.CreateEmbedTokenRequest} request
17
17
  * @param {EmbedTokensClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -19,6 +19,7 @@ export declare class EmbedTokensClient {
19
19
  * @throws {@link ToltApi.BadRequestError}
20
20
  * @throws {@link ToltApi.UnauthorizedError}
21
21
  * @throws {@link ToltApi.NotFoundError}
22
+ * @throws {@link ToltApi.ConflictError}
22
23
  * @throws {@link ToltApi.ContentTooLargeError}
23
24
  * @throws {@link ToltApi.TooManyRequestsError}
24
25
  * @throws {@link errors.ToltApiError}
@@ -12,7 +12,7 @@ export class EmbedTokensClient {
12
12
  this._options = normalizeClientOptionsWithAuth(options);
13
13
  }
14
14
  /**
15
- * Mint a short-lived, partner-scoped token for the embedded referral dashboard. Safe to send to the browser. With partner (email and program_id), the partner is created when the program has none with that email, so one call covers a user's first visit.
15
+ * Mint a short-lived, partner-scoped token for the embedded referral dashboard. Safe to send to the browser. With partner (email and program_id, plus your own external_id), the partner is found by external_id, then by email, and created when the program has neither, so one call covers a user's first visit.
16
16
  *
17
17
  * @param {ToltApi.CreateEmbedTokenRequest} request
18
18
  * @param {EmbedTokensClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -20,6 +20,7 @@ export class EmbedTokensClient {
20
20
  * @throws {@link ToltApi.BadRequestError}
21
21
  * @throws {@link ToltApi.UnauthorizedError}
22
22
  * @throws {@link ToltApi.NotFoundError}
23
+ * @throws {@link ToltApi.ConflictError}
23
24
  * @throws {@link ToltApi.ContentTooLargeError}
24
25
  * @throws {@link ToltApi.TooManyRequestsError}
25
26
  * @throws {@link errors.ToltApiError}
@@ -61,6 +62,8 @@ export class EmbedTokensClient {
61
62
  throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
62
63
  case 404:
63
64
  throw new ToltApi.NotFoundError(_response.error.body, _response.rawResponse);
65
+ case 409:
66
+ throw new ToltApi.ConflictError(_response.error.body, _response.rawResponse);
64
67
  case 413:
65
68
  throw new ToltApi.ContentTooLargeError(_response.error.body, _response.rawResponse);
66
69
  case 429:
@@ -5,18 +5,20 @@
5
5
  export interface CreateEmbedTokenRequest {
6
6
  /** Id of an existing partner (part_...). Send this or partner, not both. */
7
7
  partner_id?: string;
8
- /** Find the partner by email within the program, or create them (active, with a referral link) when the program has no partner with that email. Send this or partner_id, not both. */
8
+ /** Find the partner by external_id or email within the program, or create them (active, with a referral link) when the program has no such partner. Send this or partner_id, not both. */
9
9
  partner?: CreateEmbedTokenRequest.Partner;
10
10
  }
11
11
  export declare namespace CreateEmbedTokenRequest {
12
12
  /**
13
- * Find the partner by email within the program, or create them (active, with a referral link) when the program has no partner with that email. Send this or partner_id, not both.
13
+ * Find the partner by external_id or email within the program, or create them (active, with a referral link) when the program has no such partner. Send this or partner_id, not both.
14
14
  */
15
15
  interface Partner {
16
16
  /** Email of the partner, matched without regard to case. */
17
17
  email: string;
18
18
  /** Program the partner belongs to (prg_...). */
19
19
  program_id: string;
20
+ /** Your own id for the partner, such as the user id in your app. Matched before email, so the partner is still found after their email changes. Saved on a partner found by email who has none yet, and on a newly created partner. */
21
+ external_id?: string | undefined;
20
22
  /** First name, used only when the partner is created. */
21
23
  first_name?: string | undefined;
22
24
  /** Last name, used only when the partner is created. */
@@ -52,7 +52,7 @@ export declare class PartnersClient {
52
52
  bulkReject(request: ToltApi.BulkRejectPartnersRequest, requestOptions?: PartnersClient.RequestOptions): core.HttpResponsePromise<ToltApi.BulkRejectPartnersResponse>;
53
53
  private __bulkReject;
54
54
  /**
55
- * Lists onboarded partners. Filter by status, program or group, search by name, email or company, and page with cursors.
55
+ * Lists onboarded partners. Filter by status, program, group or external_id, search by name, email or company, and page with cursors.
56
56
  *
57
57
  * @param {ToltApi.ListPartnersRequest} request
58
58
  * @param {PartnersClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -86,6 +86,7 @@ export declare class PartnersClient {
86
86
  * await client.partners.create({
87
87
  * email: "sam@example.com",
88
88
  * program_id: "prg_T6z8aRW3XCmvFWP972RKxpAd",
89
+ * external_id: "user_123",
89
90
  * first_name: "Sam",
90
91
  * last_name: "Taylor",
91
92
  * group_id: "grp_zUQ8Pt281MsbNDApmDPN3Y2a",
@@ -126,6 +127,7 @@ export declare class PartnersClient {
126
127
  * @throws {@link ToltApi.BadRequestError}
127
128
  * @throws {@link ToltApi.UnauthorizedError}
128
129
  * @throws {@link ToltApi.NotFoundError}
130
+ * @throws {@link ToltApi.ConflictError}
129
131
  * @throws {@link ToltApi.ContentTooLargeError}
130
132
  * @throws {@link ToltApi.TooManyRequestsError}
131
133
  * @throws {@link errors.ToltApiError}
@@ -139,7 +139,7 @@ export class PartnersClient {
139
139
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v2/partners/bulk/reject");
140
140
  }
141
141
  /**
142
- * Lists onboarded partners. Filter by status, program or group, search by name, email or company, and page with cursors.
142
+ * Lists onboarded partners. Filter by status, program, group or external_id, search by name, email or company, and page with cursors.
143
143
  *
144
144
  * @param {ToltApi.ListPartnersRequest} request
145
145
  * @param {PartnersClient.RequestOptions} requestOptions - Request-specific configuration.
@@ -156,7 +156,7 @@ export class PartnersClient {
156
156
  */
157
157
  async list(request = {}, requestOptions) {
158
158
  const list = core.HttpResponsePromise.interceptFunction(async (request) => {
159
- const { limit, order, sort, starting_after: startingAfter, ending_before: endingBefore, created_after: createdAfter, created_before: createdBefore, updated_after: updatedAfter, updated_before: updatedBefore, status, program_id: programId, group_id: groupId, tag_id: tagId, search, } = request;
159
+ const { limit, order, sort, starting_after: startingAfter, ending_before: endingBefore, created_after: createdAfter, created_before: createdBefore, updated_after: updatedAfter, updated_before: updatedBefore, status, program_id: programId, group_id: groupId, tag_id: tagId, external_id: externalId, search, } = request;
160
160
  const _queryParams = {
161
161
  limit,
162
162
  order: order != null ? order : undefined,
@@ -171,6 +171,7 @@ export class PartnersClient {
171
171
  program_id: programId,
172
172
  group_id: groupId,
173
173
  tag_id: tagId,
174
+ external_id: externalId,
174
175
  search,
175
176
  };
176
177
  const _authRequest = await this._options.authProvider.getAuthRequest();
@@ -245,6 +246,7 @@ export class PartnersClient {
245
246
  * await client.partners.create({
246
247
  * email: "sam@example.com",
247
248
  * program_id: "prg_T6z8aRW3XCmvFWP972RKxpAd",
249
+ * external_id: "user_123",
248
250
  * first_name: "Sam",
249
251
  * last_name: "Taylor",
250
252
  * group_id: "grp_zUQ8Pt281MsbNDApmDPN3Y2a",
@@ -371,6 +373,7 @@ export class PartnersClient {
371
373
  * @throws {@link ToltApi.BadRequestError}
372
374
  * @throws {@link ToltApi.UnauthorizedError}
373
375
  * @throws {@link ToltApi.NotFoundError}
376
+ * @throws {@link ToltApi.ConflictError}
374
377
  * @throws {@link ToltApi.ContentTooLargeError}
375
378
  * @throws {@link ToltApi.TooManyRequestsError}
376
379
  * @throws {@link errors.ToltApiError}
@@ -418,6 +421,8 @@ export class PartnersClient {
418
421
  throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
419
422
  case 404:
420
423
  throw new ToltApi.NotFoundError(_response.error.body, _response.rawResponse);
424
+ case 409:
425
+ throw new ToltApi.ConflictError(_response.error.body, _response.rawResponse);
421
426
  case 413:
422
427
  throw new ToltApi.ContentTooLargeError(_response.error.body, _response.rawResponse);
423
428
  case 429:
@@ -3,6 +3,7 @@
3
3
  * {
4
4
  * email: "sam@example.com",
5
5
  * program_id: "prg_T6z8aRW3XCmvFWP972RKxpAd",
6
+ * external_id: "user_123",
6
7
  * first_name: "Sam",
7
8
  * last_name: "Taylor",
8
9
  * group_id: "grp_zUQ8Pt281MsbNDApmDPN3Y2a",
@@ -17,6 +18,8 @@ export interface CreatePartnerRequest {
17
18
  email: string;
18
19
  /** Id of the program to add the partner to (prg_...), as returned when listing programs. */
19
20
  program_id: string;
21
+ /** Your own id for this partner, such as the user id in your app, so you can find them by it later. No other partner in the program can have it. */
22
+ external_id?: string;
20
23
  /** Partner's first name. With last_name it is used for the default link value when link is omitted. */
21
24
  first_name?: string;
22
25
  /** Partner's last name. With first_name it makes up the name shown for the partner unless display_name is set. */
@@ -30,6 +30,8 @@ export interface ListPartnersRequest {
30
30
  group_id?: string;
31
31
  /** Limit to partners with this tag, by the tag id (ptag_...) as returned when listing partner tags. */
32
32
  tag_id?: string;
33
+ /** Keep only partners with this external_id, matched exactly. Add program_id to get at most one partner. */
34
+ external_id?: string;
33
35
  /** Text matched anywhere in the partner's id, email, first name, last name or company name, ignoring case. */
34
36
  search?: string;
35
37
  }
@@ -19,6 +19,8 @@ export interface UpdatePartnerRequest {
19
19
  country_code?: string | null;
20
20
  /** URL of the partner's website, starting with http:// or https://; null clears it. */
21
21
  website_url?: string | null;
22
+ /** Your own id for this partner, such as the user id in your app. No other partner in the program can have it; null clears it. */
23
+ external_id?: string | null;
22
24
  /** Id of a group in the partner's program to move them to (grp_...), as returned when listing groups. Commission flows scoped to that group then apply to them; null removes them from their group. */
23
25
  group_id?: string | null;
24
26
  }
@@ -2,6 +2,8 @@ import type * as ToltApi from "../index.js";
2
2
  export interface CreatedPartner {
3
3
  id: string;
4
4
  email: string;
5
+ /** Your own id for the partner, such as the user id in your app, or null. */
6
+ external_id: string | null;
5
7
  first_name: string | null;
6
8
  last_name: string | null;
7
9
  company_name: string | null;
@@ -1,6 +1,8 @@
1
1
  export interface Partner {
2
2
  id: string;
3
3
  email: string;
4
+ /** Your own id for the partner, such as the user id in your app, or null. */
5
+ external_id: string | null;
4
6
  first_name: string | null;
5
7
  last_name: string | null;
6
8
  company_name: string | null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tolt/api",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "TypeScript SDK for the Tolt Public API",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {