@tolt/api 0.2.0 → 0.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.
Files changed (155) hide show
  1. package/dist/api/errors/TooManyRequestsError.d.ts +7 -0
  2. package/dist/api/errors/TooManyRequestsError.js +17 -0
  3. package/dist/api/errors/index.d.ts +1 -0
  4. package/dist/api/errors/index.js +1 -0
  5. package/dist/api/resources/clicks/client/Client.d.ts +10 -4
  6. package/dist/api/resources/clicks/client/Client.js +22 -24
  7. package/dist/api/resources/clicks/client/requests/index.d.ts +0 -1
  8. package/dist/api/resources/clicks/types/CreateClickRequest.d.ts +1 -0
  9. package/dist/api/resources/clicks/types/{ListClicksResponse.d.ts → CreateClickResponse.d.ts} +2 -3
  10. package/dist/api/resources/clicks/types/index.d.ts +2 -2
  11. package/dist/api/resources/clicks/types/index.js +2 -2
  12. package/dist/api/resources/commissions/client/Client.d.ts +45 -0
  13. package/dist/api/resources/commissions/client/Client.js +154 -1
  14. package/dist/api/resources/commissions/client/requests/BulkApproveCommissionsRequest.d.ts +10 -0
  15. package/dist/api/resources/commissions/client/requests/BulkApproveCommissionsRequest.js +2 -0
  16. package/dist/api/resources/commissions/client/requests/BulkDeclineCommissionsRequest.d.ts +10 -0
  17. package/dist/api/resources/commissions/client/requests/BulkDeclineCommissionsRequest.js +2 -0
  18. package/dist/api/resources/commissions/client/requests/ListCommissionsRequest.d.ts +13 -0
  19. package/dist/api/resources/commissions/client/requests/UpdateCommissionRequest.d.ts +3 -3
  20. package/dist/api/resources/commissions/client/requests/index.d.ts +2 -0
  21. package/dist/api/resources/commissions/types/BulkApproveCommissionsResponse.d.ts +6 -0
  22. package/dist/api/resources/commissions/types/BulkApproveCommissionsResponse.js +2 -0
  23. package/dist/api/resources/commissions/types/BulkDeclineCommissionsResponse.d.ts +6 -0
  24. package/dist/api/resources/commissions/types/BulkDeclineCommissionsResponse.js +2 -0
  25. package/dist/api/resources/commissions/types/ListCommissionsRequestSort.d.ts +6 -0
  26. package/dist/api/resources/commissions/types/ListCommissionsRequestSort.js +6 -0
  27. package/dist/api/resources/commissions/types/ListCommissionsResponse.d.ts +4 -0
  28. package/dist/api/resources/commissions/types/index.d.ts +3 -0
  29. package/dist/api/resources/commissions/types/index.js +3 -0
  30. package/dist/api/resources/customers/client/Client.d.ts +5 -1
  31. package/dist/api/resources/customers/client/Client.js +22 -4
  32. package/dist/api/resources/customers/client/requests/CreateCustomerRequest.d.ts +5 -5
  33. package/dist/api/resources/customers/client/requests/ListCustomersRequest.d.ts +13 -0
  34. package/dist/api/resources/customers/client/requests/UpdateCustomerRequest.d.ts +6 -6
  35. package/dist/api/resources/customers/types/ListCustomersRequestSort.d.ts +6 -0
  36. package/dist/api/resources/customers/types/ListCustomersRequestSort.js +6 -0
  37. package/dist/api/resources/customers/types/ListCustomersResponse.d.ts +4 -0
  38. package/dist/api/resources/customers/types/index.d.ts +1 -0
  39. package/dist/api/resources/customers/types/index.js +1 -0
  40. package/dist/api/resources/embed/client/Client.d.ts +1 -0
  41. package/dist/api/resources/embed/client/Client.js +3 -0
  42. package/dist/api/resources/embed/client/requests/CreateEmbedTokenRequest.d.ts +2 -2
  43. package/dist/api/resources/flows/client/Client.d.ts +2 -0
  44. package/dist/api/resources/flows/client/Client.js +13 -1
  45. package/dist/api/resources/flows/client/requests/ListFlowsRequest.d.ts +13 -0
  46. package/dist/api/resources/flows/types/ListFlowsRequestSort.d.ts +6 -0
  47. package/dist/api/resources/flows/types/ListFlowsRequestSort.js +6 -0
  48. package/dist/api/resources/flows/types/ListFlowsResponse.d.ts +4 -0
  49. package/dist/api/resources/flows/types/index.d.ts +1 -0
  50. package/dist/api/resources/flows/types/index.js +1 -0
  51. package/dist/api/resources/groups/client/Client.d.ts +2 -0
  52. package/dist/api/resources/groups/client/Client.js +13 -1
  53. package/dist/api/resources/groups/client/requests/ListGroupsRequest.d.ts +13 -0
  54. package/dist/api/resources/groups/types/ListGroupsRequestSort.d.ts +6 -0
  55. package/dist/api/resources/groups/types/ListGroupsRequestSort.js +6 -0
  56. package/dist/api/resources/groups/types/ListGroupsResponse.d.ts +4 -0
  57. package/dist/api/resources/groups/types/index.d.ts +1 -0
  58. package/dist/api/resources/groups/types/index.js +1 -0
  59. package/dist/api/resources/links/client/Client.d.ts +6 -1
  60. package/dist/api/resources/links/client/Client.js +23 -2
  61. package/dist/api/resources/links/client/requests/CreateLinkRequest.d.ts +2 -2
  62. package/dist/api/resources/links/client/requests/ListLinksRequest.d.ts +13 -0
  63. package/dist/api/resources/links/types/ListLinksRequestSort.d.ts +6 -0
  64. package/dist/api/resources/links/types/ListLinksRequestSort.js +6 -0
  65. package/dist/api/resources/links/types/ListLinksResponse.d.ts +4 -0
  66. package/dist/api/resources/links/types/index.d.ts +1 -0
  67. package/dist/api/resources/links/types/index.js +1 -0
  68. package/dist/api/resources/partners/client/Client.d.ts +85 -0
  69. package/dist/api/resources/partners/client/Client.js +273 -1
  70. package/dist/api/resources/partners/client/requests/BulkApprovePartnersRequest.d.ts +10 -0
  71. package/dist/api/resources/partners/client/requests/BulkApprovePartnersRequest.js +2 -0
  72. package/dist/api/resources/partners/client/requests/BulkRejectPartnersRequest.d.ts +11 -0
  73. package/dist/api/resources/partners/client/requests/BulkRejectPartnersRequest.js +2 -0
  74. package/dist/api/resources/partners/client/requests/CreatePartnerRequest.d.ts +41 -0
  75. package/dist/api/resources/partners/client/requests/CreatePartnerRequest.js +8 -0
  76. package/dist/api/resources/partners/client/requests/ListPartnersRequest.d.ts +13 -0
  77. package/dist/api/resources/partners/client/requests/RejectPartnerRequest.d.ts +1 -1
  78. package/dist/api/resources/partners/client/requests/SuspendPartnerRequest.d.ts +1 -1
  79. package/dist/api/resources/partners/client/requests/UpdatePartnerRequest.d.ts +16 -0
  80. package/dist/api/resources/partners/client/requests/UpdatePartnerRequest.js +2 -0
  81. package/dist/api/resources/partners/client/requests/index.d.ts +4 -0
  82. package/dist/api/resources/partners/client/requests/index.js +1 -1
  83. package/dist/api/resources/partners/types/BulkApprovePartnersResponse.d.ts +6 -0
  84. package/dist/api/resources/partners/types/BulkApprovePartnersResponse.js +2 -0
  85. package/dist/api/resources/partners/types/BulkRejectPartnersResponse.d.ts +6 -0
  86. package/dist/api/resources/partners/types/BulkRejectPartnersResponse.js +2 -0
  87. package/dist/api/resources/partners/types/CreatePartnerResponse.d.ts +6 -0
  88. package/dist/api/resources/partners/types/CreatePartnerResponse.js +2 -0
  89. package/dist/api/resources/partners/types/GetPartnerResponse.d.ts +1 -1
  90. package/dist/api/resources/partners/types/ListPartnersRequestSort.d.ts +6 -0
  91. package/dist/api/resources/partners/types/ListPartnersRequestSort.js +6 -0
  92. package/dist/api/resources/partners/types/ListPartnersResponse.d.ts +5 -1
  93. package/dist/api/resources/partners/types/UpdatePartnerResponse.d.ts +6 -0
  94. package/dist/api/resources/partners/types/UpdatePartnerResponse.js +2 -0
  95. package/dist/api/resources/partners/types/index.d.ts +5 -0
  96. package/dist/api/resources/partners/types/index.js +5 -0
  97. package/dist/api/resources/programs/client/Client.d.ts +2 -0
  98. package/dist/api/resources/programs/client/Client.js +13 -1
  99. package/dist/api/resources/programs/client/requests/ListProgramsRequest.d.ts +13 -0
  100. package/dist/api/resources/programs/types/ListProgramsRequestSort.d.ts +6 -0
  101. package/dist/api/resources/programs/types/ListProgramsRequestSort.js +6 -0
  102. package/dist/api/resources/programs/types/ListProgramsResponse.d.ts +4 -0
  103. package/dist/api/resources/programs/types/index.d.ts +1 -0
  104. package/dist/api/resources/programs/types/index.js +1 -0
  105. package/dist/api/resources/promotionCodes/client/Client.d.ts +6 -1
  106. package/dist/api/resources/promotionCodes/client/Client.js +23 -2
  107. package/dist/api/resources/promotionCodes/client/requests/CreatePromotionCodeRequest.d.ts +2 -2
  108. package/dist/api/resources/promotionCodes/client/requests/ListPromotionCodesRequest.d.ts +13 -0
  109. package/dist/api/resources/promotionCodes/types/ListPromotionCodesRequestSort.d.ts +6 -0
  110. package/dist/api/resources/promotionCodes/types/ListPromotionCodesRequestSort.js +6 -0
  111. package/dist/api/resources/promotionCodes/types/ListPromotionCodesResponse.d.ts +4 -0
  112. package/dist/api/resources/promotionCodes/types/index.d.ts +1 -0
  113. package/dist/api/resources/promotionCodes/types/index.js +1 -0
  114. package/dist/api/resources/reports/client/Client.d.ts +5 -0
  115. package/dist/api/resources/reports/client/Client.js +15 -0
  116. package/dist/api/resources/transactions/client/Client.d.ts +8 -1
  117. package/dist/api/resources/transactions/client/Client.js +29 -2
  118. package/dist/api/resources/transactions/client/requests/CreateTransactionRequest.d.ts +5 -5
  119. package/dist/api/resources/transactions/client/requests/ListTransactionsRequest.d.ts +13 -0
  120. package/dist/api/resources/transactions/client/requests/UpdateTransactionRequest.d.ts +4 -4
  121. package/dist/api/resources/transactions/types/ListTransactionsRequestSort.d.ts +6 -0
  122. package/dist/api/resources/transactions/types/ListTransactionsRequestSort.js +6 -0
  123. package/dist/api/resources/transactions/types/ListTransactionsResponse.d.ts +4 -0
  124. package/dist/api/resources/transactions/types/index.d.ts +1 -0
  125. package/dist/api/resources/transactions/types/index.js +1 -0
  126. package/dist/api/types/BulkResult.d.ts +24 -0
  127. package/dist/api/types/BulkResult.js +14 -0
  128. package/dist/api/types/Click.d.ts +5 -5
  129. package/dist/api/types/Commission.d.ts +13 -13
  130. package/dist/api/types/CreatedPartner.d.ts +21 -0
  131. package/dist/api/types/CreatedPartner.js +2 -0
  132. package/dist/api/types/Customer.d.ts +11 -11
  133. package/dist/api/types/EmbedToken.d.ts +1 -1
  134. package/dist/api/types/Error_.d.ts +34 -0
  135. package/dist/api/types/Error_.js +21 -1
  136. package/dist/api/types/Flow.d.ts +8 -8
  137. package/dist/api/types/Group.d.ts +9 -9
  138. package/dist/api/types/Link.d.ts +5 -5
  139. package/dist/api/types/Partner.d.ts +14 -8
  140. package/dist/api/types/PartnerDetails.d.ts +16 -0
  141. package/dist/api/types/PartnerDetails.js +2 -0
  142. package/dist/api/types/Program.d.ts +8 -8
  143. package/dist/api/types/PromotionCode.d.ts +8 -8
  144. package/dist/api/types/ReportsLinkRow.d.ts +2 -2
  145. package/dist/api/types/ReportsOverview.d.ts +3 -3
  146. package/dist/api/types/ReportsPartnerRow.d.ts +4 -4
  147. package/dist/api/types/Transaction.d.ts +17 -17
  148. package/dist/api/types/index.d.ts +3 -0
  149. package/dist/api/types/index.js +3 -0
  150. package/package.json +1 -1
  151. package/dist/api/resources/clicks/client/requests/ListClicksRequest.d.ts +0 -16
  152. package/dist/api/resources/clicks/types/ListClicksRequestOrder.d.ts +0 -5
  153. package/dist/api/resources/clicks/types/ListClicksRequestOrder.js +0 -5
  154. /package/dist/api/resources/clicks/{client/requests/ListClicksRequest.js → types/CreateClickRequest.js} +0 -0
  155. /package/dist/api/resources/clicks/types/{ListClicksResponse.js → CreateClickResponse.js} +0 -0
@@ -0,0 +1,7 @@
1
+ import type * as core from "../../core/index.js";
2
+ import * as errors from "../../errors/index.js";
3
+ import type * as ToltApi from "../index.js";
4
+ export declare class TooManyRequestsError extends errors.ToltApiError {
5
+ readonly body: ToltApi.Error_;
6
+ constructor(body: ToltApi.Error_, rawResponse?: core.RawResponse);
7
+ }
@@ -0,0 +1,17 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ import * as errors from "../../errors/index.js";
3
+ export class TooManyRequestsError extends errors.ToltApiError {
4
+ constructor(body, rawResponse) {
5
+ super({
6
+ message: "TooManyRequestsError",
7
+ statusCode: 429,
8
+ body: body,
9
+ rawResponse: rawResponse,
10
+ });
11
+ Object.setPrototypeOf(this, new.target.prototype);
12
+ if (Error.captureStackTrace) {
13
+ Error.captureStackTrace(this, this.constructor);
14
+ }
15
+ this.name = "TooManyRequestsError";
16
+ }
17
+ }
@@ -1,4 +1,5 @@
1
1
  export * from "./BadRequestError.js";
2
2
  export * from "./ConflictError.js";
3
3
  export * from "./NotFoundError.js";
4
+ export * from "./TooManyRequestsError.js";
4
5
  export * from "./UnauthorizedError.js";
@@ -1,4 +1,5 @@
1
1
  export * from "./BadRequestError.js";
2
2
  export * from "./ConflictError.js";
3
3
  export * from "./NotFoundError.js";
4
+ export * from "./TooManyRequestsError.js";
4
5
  export * from "./UnauthorizedError.js";
@@ -11,25 +11,31 @@ export declare class ClicksClient {
11
11
  protected readonly _options: NormalizedClientOptionsWithAuth<ClicksClient.Options>;
12
12
  constructor(options: ClicksClient.Options);
13
13
  /**
14
- * @param {ToltApi.ListClicksRequest} request
14
+ * Records a click on a partner's link from your own server, for visits the browser script cannot see. Identify the source by link_id, by partner_id with an optional link_id, or by the link's param and value; the partner and program are resolved from it. Pass the returned id as click_id when you create the customer.
15
+ *
16
+ * @param {ToltApi.CreateClickRequest} request
15
17
  * @param {ClicksClient.RequestOptions} requestOptions - Request-specific configuration.
16
18
  *
17
19
  * @throws {@link ToltApi.BadRequestError}
18
20
  * @throws {@link ToltApi.UnauthorizedError}
21
+ * @throws {@link ToltApi.TooManyRequestsError}
19
22
  * @throws {@link errors.ToltApiError}
20
23
  * @throws {@link errors.ToltApiTimeoutError}
21
24
  *
22
25
  * @example
23
- * await client.clicks.listClicks()
26
+ * await client.clicks.createClick({
27
+ * "key": "value"
28
+ * })
24
29
  */
25
- listClicks(request?: ToltApi.ListClicksRequest, requestOptions?: ClicksClient.RequestOptions): core.HttpResponsePromise<ToltApi.ListClicksResponse>;
26
- private __listClicks;
30
+ createClick(request: ToltApi.CreateClickRequest, requestOptions?: ClicksClient.RequestOptions): core.HttpResponsePromise<ToltApi.CreateClickResponse>;
31
+ private __createClick;
27
32
  /**
28
33
  * @param {ToltApi.GetClickRequest} request
29
34
  * @param {ClicksClient.RequestOptions} requestOptions - Request-specific configuration.
30
35
  *
31
36
  * @throws {@link ToltApi.UnauthorizedError}
32
37
  * @throws {@link ToltApi.NotFoundError}
38
+ * @throws {@link ToltApi.TooManyRequestsError}
33
39
  * @throws {@link errors.ToltApiError}
34
40
  * @throws {@link errors.ToltApiTimeoutError}
35
41
  *
@@ -2,6 +2,7 @@
2
2
  import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";
3
3
  import { mergeHeaders } from "../../../../core/headers.js";
4
4
  import * as core from "../../../../core/index.js";
5
+ import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js";
5
6
  import * as environments from "../../../../environments.js";
6
7
  import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";
7
8
  import * as errors from "../../../../errors/index.js";
@@ -11,46 +12,38 @@ export class ClicksClient {
11
12
  this._options = normalizeClientOptionsWithAuth(options);
12
13
  }
13
14
  /**
14
- * @param {ToltApi.ListClicksRequest} request
15
+ * Records a click on a partner's link from your own server, for visits the browser script cannot see. Identify the source by link_id, by partner_id with an optional link_id, or by the link's param and value; the partner and program are resolved from it. Pass the returned id as click_id when you create the customer.
16
+ *
17
+ * @param {ToltApi.CreateClickRequest} request
15
18
  * @param {ClicksClient.RequestOptions} requestOptions - Request-specific configuration.
16
19
  *
17
20
  * @throws {@link ToltApi.BadRequestError}
18
21
  * @throws {@link ToltApi.UnauthorizedError}
22
+ * @throws {@link ToltApi.TooManyRequestsError}
19
23
  * @throws {@link errors.ToltApiError}
20
24
  * @throws {@link errors.ToltApiTimeoutError}
21
25
  *
22
26
  * @example
23
- * await client.clicks.listClicks()
27
+ * await client.clicks.createClick({
28
+ * "key": "value"
29
+ * })
24
30
  */
25
- listClicks(request = {}, requestOptions) {
26
- return core.HttpResponsePromise.fromPromise(this.__listClicks(request, requestOptions));
31
+ createClick(request, requestOptions) {
32
+ return core.HttpResponsePromise.fromPromise(this.__createClick(request, requestOptions));
27
33
  }
28
- async __listClicks(request = {}, requestOptions) {
29
- const { limit, order, starting_after: startingAfter, program_id: programId, partner_id: partnerId, link_id: linkId, country, device, browser, } = request;
30
- const _queryParams = {
31
- limit,
32
- order: order != null ? order : undefined,
33
- starting_after: startingAfter,
34
- program_id: programId,
35
- partner_id: partnerId,
36
- link_id: linkId,
37
- country,
38
- device,
39
- browser,
40
- };
34
+ async __createClick(request, requestOptions) {
41
35
  const _authRequest = await this._options.authProvider.getAuthRequest();
42
36
  const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
43
37
  const _response = await core.fetcher({
44
38
  url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
45
39
  (await core.Supplier.get(this._options.environment)) ??
46
40
  environments.ToltApiEnvironment.Production, "v2/clicks"),
47
- method: "GET",
41
+ method: "POST",
48
42
  headers: _headers,
49
- queryString: core.url
50
- .queryBuilder()
51
- .addMany(_queryParams)
52
- .mergeAdditional(requestOptions?.queryParams)
53
- .build(),
43
+ contentType: "application/json",
44
+ queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
45
+ requestType: "json",
46
+ body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters),
54
47
  timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
55
48
  maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
56
49
  abortSignal: requestOptions?.abortSignal,
@@ -66,6 +59,8 @@ export class ClicksClient {
66
59
  throw new ToltApi.BadRequestError(_response.error.body, _response.rawResponse);
67
60
  case 401:
68
61
  throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
62
+ case 429:
63
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
69
64
  default:
70
65
  throw new errors.ToltApiError({
71
66
  statusCode: _response.error.statusCode,
@@ -74,7 +69,7 @@ export class ClicksClient {
74
69
  });
75
70
  }
76
71
  }
77
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v2/clicks");
72
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v2/clicks");
78
73
  }
79
74
  /**
80
75
  * @param {ToltApi.GetClickRequest} request
@@ -82,6 +77,7 @@ export class ClicksClient {
82
77
  *
83
78
  * @throws {@link ToltApi.UnauthorizedError}
84
79
  * @throws {@link ToltApi.NotFoundError}
80
+ * @throws {@link ToltApi.TooManyRequestsError}
85
81
  * @throws {@link errors.ToltApiError}
86
82
  * @throws {@link errors.ToltApiTimeoutError}
87
83
  *
@@ -119,6 +115,8 @@ export class ClicksClient {
119
115
  throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
120
116
  case 404:
121
117
  throw new ToltApi.NotFoundError(_response.error.body, _response.rawResponse);
118
+ case 429:
119
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
122
120
  default:
123
121
  throw new errors.ToltApiError({
124
122
  statusCode: _response.error.statusCode,
@@ -1,2 +1 @@
1
1
  export type { GetClickRequest } from "./GetClickRequest.js";
2
- export type { ListClicksRequest } from "./ListClicksRequest.js";
@@ -0,0 +1 @@
1
+ export type CreateClickRequest = unknown;
@@ -1,7 +1,6 @@
1
1
  import type * as ToltApi from "../../../index.js";
2
- export interface ListClicksResponse {
2
+ export interface CreateClickResponse {
3
3
  success: boolean;
4
4
  message: string;
5
- data: ToltApi.Click[];
6
- has_more: boolean;
5
+ data: ToltApi.Click;
7
6
  }
@@ -1,3 +1,3 @@
1
+ export * from "./CreateClickRequest.js";
2
+ export * from "./CreateClickResponse.js";
1
3
  export * from "./GetClickResponse.js";
2
- export * from "./ListClicksRequestOrder.js";
3
- export * from "./ListClicksResponse.js";
@@ -1,3 +1,3 @@
1
+ export * from "./CreateClickRequest.js";
2
+ export * from "./CreateClickResponse.js";
1
3
  export * from "./GetClickResponse.js";
2
- export * from "./ListClicksRequestOrder.js";
3
- export * from "./ListClicksResponse.js";
@@ -10,12 +10,51 @@ export declare namespace CommissionsClient {
10
10
  export declare class CommissionsClient {
11
11
  protected readonly _options: NormalizedClientOptionsWithAuth<CommissionsClient.Options>;
12
12
  constructor(options: CommissionsClient.Options);
13
+ /**
14
+ * Approves up to 100 commissions. Each id is processed on its own and the response reports the outcome per id, with the error code for any that were refused.
15
+ *
16
+ * @param {ToltApi.BulkApproveCommissionsRequest} request
17
+ * @param {CommissionsClient.RequestOptions} requestOptions - Request-specific configuration.
18
+ *
19
+ * @throws {@link ToltApi.BadRequestError}
20
+ * @throws {@link ToltApi.UnauthorizedError}
21
+ * @throws {@link ToltApi.TooManyRequestsError}
22
+ * @throws {@link errors.ToltApiError}
23
+ * @throws {@link errors.ToltApiTimeoutError}
24
+ *
25
+ * @example
26
+ * await client.commissions.bulkApproveCommissions({
27
+ * ids: ["part_9fQ2xLL", "part_3RtV9k"]
28
+ * })
29
+ */
30
+ bulkApproveCommissions(request: ToltApi.BulkApproveCommissionsRequest, requestOptions?: CommissionsClient.RequestOptions): core.HttpResponsePromise<ToltApi.BulkApproveCommissionsResponse>;
31
+ private __bulkApproveCommissions;
32
+ /**
33
+ * Declines up to 100 commissions. Each id is processed on its own and the response reports the outcome per id, with the error code for any that were refused.
34
+ *
35
+ * @param {ToltApi.BulkDeclineCommissionsRequest} request
36
+ * @param {CommissionsClient.RequestOptions} requestOptions - Request-specific configuration.
37
+ *
38
+ * @throws {@link ToltApi.BadRequestError}
39
+ * @throws {@link ToltApi.UnauthorizedError}
40
+ * @throws {@link ToltApi.TooManyRequestsError}
41
+ * @throws {@link errors.ToltApiError}
42
+ * @throws {@link errors.ToltApiTimeoutError}
43
+ *
44
+ * @example
45
+ * await client.commissions.bulkDeclineCommissions({
46
+ * ids: ["part_9fQ2xLL", "part_3RtV9k"]
47
+ * })
48
+ */
49
+ bulkDeclineCommissions(request: ToltApi.BulkDeclineCommissionsRequest, requestOptions?: CommissionsClient.RequestOptions): core.HttpResponsePromise<ToltApi.BulkDeclineCommissionsResponse>;
50
+ private __bulkDeclineCommissions;
13
51
  /**
14
52
  * @param {ToltApi.ListCommissionsRequest} request
15
53
  * @param {CommissionsClient.RequestOptions} requestOptions - Request-specific configuration.
16
54
  *
17
55
  * @throws {@link ToltApi.BadRequestError}
18
56
  * @throws {@link ToltApi.UnauthorizedError}
57
+ * @throws {@link ToltApi.TooManyRequestsError}
19
58
  * @throws {@link errors.ToltApiError}
20
59
  * @throws {@link errors.ToltApiTimeoutError}
21
60
  *
@@ -31,6 +70,7 @@ export declare class CommissionsClient {
31
70
  * @throws {@link ToltApi.BadRequestError}
32
71
  * @throws {@link ToltApi.UnauthorizedError}
33
72
  * @throws {@link ToltApi.ConflictError}
73
+ * @throws {@link ToltApi.TooManyRequestsError}
34
74
  * @throws {@link errors.ToltApiError}
35
75
  * @throws {@link errors.ToltApiTimeoutError}
36
76
  *
@@ -47,6 +87,7 @@ export declare class CommissionsClient {
47
87
  *
48
88
  * @throws {@link ToltApi.UnauthorizedError}
49
89
  * @throws {@link ToltApi.NotFoundError}
90
+ * @throws {@link ToltApi.TooManyRequestsError}
50
91
  * @throws {@link errors.ToltApiError}
51
92
  * @throws {@link errors.ToltApiTimeoutError}
52
93
  *
@@ -65,6 +106,7 @@ export declare class CommissionsClient {
65
106
  * @throws {@link ToltApi.UnauthorizedError}
66
107
  * @throws {@link ToltApi.NotFoundError}
67
108
  * @throws {@link ToltApi.ConflictError}
109
+ * @throws {@link ToltApi.TooManyRequestsError}
68
110
  * @throws {@link errors.ToltApiError}
69
111
  * @throws {@link errors.ToltApiTimeoutError}
70
112
  *
@@ -83,6 +125,7 @@ export declare class CommissionsClient {
83
125
  * @throws {@link ToltApi.UnauthorizedError}
84
126
  * @throws {@link ToltApi.NotFoundError}
85
127
  * @throws {@link ToltApi.ConflictError}
128
+ * @throws {@link ToltApi.TooManyRequestsError}
86
129
  * @throws {@link errors.ToltApiError}
87
130
  * @throws {@link errors.ToltApiTimeoutError}
88
131
  *
@@ -101,6 +144,7 @@ export declare class CommissionsClient {
101
144
  * @throws {@link ToltApi.UnauthorizedError}
102
145
  * @throws {@link ToltApi.NotFoundError}
103
146
  * @throws {@link ToltApi.ConflictError}
147
+ * @throws {@link ToltApi.TooManyRequestsError}
104
148
  * @throws {@link errors.ToltApiError}
105
149
  * @throws {@link errors.ToltApiTimeoutError}
106
150
  *
@@ -119,6 +163,7 @@ export declare class CommissionsClient {
119
163
  * @throws {@link ToltApi.UnauthorizedError}
120
164
  * @throws {@link ToltApi.NotFoundError}
121
165
  * @throws {@link ToltApi.ConflictError}
166
+ * @throws {@link ToltApi.TooManyRequestsError}
122
167
  * @throws {@link errors.ToltApiError}
123
168
  * @throws {@link errors.ToltApiTimeoutError}
124
169
  *
@@ -11,12 +11,139 @@ export class CommissionsClient {
11
11
  constructor(options) {
12
12
  this._options = normalizeClientOptionsWithAuth(options);
13
13
  }
14
+ /**
15
+ * Approves up to 100 commissions. Each id is processed on its own and the response reports the outcome per id, with the error code for any that were refused.
16
+ *
17
+ * @param {ToltApi.BulkApproveCommissionsRequest} request
18
+ * @param {CommissionsClient.RequestOptions} requestOptions - Request-specific configuration.
19
+ *
20
+ * @throws {@link ToltApi.BadRequestError}
21
+ * @throws {@link ToltApi.UnauthorizedError}
22
+ * @throws {@link ToltApi.TooManyRequestsError}
23
+ * @throws {@link errors.ToltApiError}
24
+ * @throws {@link errors.ToltApiTimeoutError}
25
+ *
26
+ * @example
27
+ * await client.commissions.bulkApproveCommissions({
28
+ * ids: ["part_9fQ2xLL", "part_3RtV9k"]
29
+ * })
30
+ */
31
+ bulkApproveCommissions(request, requestOptions) {
32
+ return core.HttpResponsePromise.fromPromise(this.__bulkApproveCommissions(request, requestOptions));
33
+ }
34
+ async __bulkApproveCommissions(request, requestOptions) {
35
+ const _authRequest = await this._options.authProvider.getAuthRequest();
36
+ const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
37
+ const _response = await core.fetcher({
38
+ url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
39
+ (await core.Supplier.get(this._options.environment)) ??
40
+ environments.ToltApiEnvironment.Production, "v2/commissions/bulk/approve"),
41
+ method: "POST",
42
+ headers: _headers,
43
+ contentType: "application/json",
44
+ queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
45
+ requestType: "json",
46
+ body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters),
47
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
48
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
49
+ abortSignal: requestOptions?.abortSignal,
50
+ fetchFn: this._options?.fetch,
51
+ logging: this._options.logging,
52
+ });
53
+ if (_response.ok) {
54
+ return {
55
+ data: _response.body,
56
+ rawResponse: _response.rawResponse,
57
+ };
58
+ }
59
+ if (_response.error.reason === "status-code") {
60
+ switch (_response.error.statusCode) {
61
+ case 400:
62
+ throw new ToltApi.BadRequestError(_response.error.body, _response.rawResponse);
63
+ case 401:
64
+ throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
65
+ case 429:
66
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
67
+ default:
68
+ throw new errors.ToltApiError({
69
+ statusCode: _response.error.statusCode,
70
+ body: _response.error.body,
71
+ rawResponse: _response.rawResponse,
72
+ });
73
+ }
74
+ }
75
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v2/commissions/bulk/approve");
76
+ }
77
+ /**
78
+ * Declines up to 100 commissions. Each id is processed on its own and the response reports the outcome per id, with the error code for any that were refused.
79
+ *
80
+ * @param {ToltApi.BulkDeclineCommissionsRequest} request
81
+ * @param {CommissionsClient.RequestOptions} requestOptions - Request-specific configuration.
82
+ *
83
+ * @throws {@link ToltApi.BadRequestError}
84
+ * @throws {@link ToltApi.UnauthorizedError}
85
+ * @throws {@link ToltApi.TooManyRequestsError}
86
+ * @throws {@link errors.ToltApiError}
87
+ * @throws {@link errors.ToltApiTimeoutError}
88
+ *
89
+ * @example
90
+ * await client.commissions.bulkDeclineCommissions({
91
+ * ids: ["part_9fQ2xLL", "part_3RtV9k"]
92
+ * })
93
+ */
94
+ bulkDeclineCommissions(request, requestOptions) {
95
+ return core.HttpResponsePromise.fromPromise(this.__bulkDeclineCommissions(request, requestOptions));
96
+ }
97
+ async __bulkDeclineCommissions(request, requestOptions) {
98
+ const _authRequest = await this._options.authProvider.getAuthRequest();
99
+ const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
100
+ const _response = await core.fetcher({
101
+ url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
102
+ (await core.Supplier.get(this._options.environment)) ??
103
+ environments.ToltApiEnvironment.Production, "v2/commissions/bulk/decline"),
104
+ method: "POST",
105
+ headers: _headers,
106
+ contentType: "application/json",
107
+ queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
108
+ requestType: "json",
109
+ body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters),
110
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
111
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
112
+ abortSignal: requestOptions?.abortSignal,
113
+ fetchFn: this._options?.fetch,
114
+ logging: this._options.logging,
115
+ });
116
+ if (_response.ok) {
117
+ return {
118
+ data: _response.body,
119
+ rawResponse: _response.rawResponse,
120
+ };
121
+ }
122
+ if (_response.error.reason === "status-code") {
123
+ switch (_response.error.statusCode) {
124
+ case 400:
125
+ throw new ToltApi.BadRequestError(_response.error.body, _response.rawResponse);
126
+ case 401:
127
+ throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
128
+ case 429:
129
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
130
+ default:
131
+ throw new errors.ToltApiError({
132
+ statusCode: _response.error.statusCode,
133
+ body: _response.error.body,
134
+ rawResponse: _response.rawResponse,
135
+ });
136
+ }
137
+ }
138
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v2/commissions/bulk/decline");
139
+ }
14
140
  /**
15
141
  * @param {ToltApi.ListCommissionsRequest} request
16
142
  * @param {CommissionsClient.RequestOptions} requestOptions - Request-specific configuration.
17
143
  *
18
144
  * @throws {@link ToltApi.BadRequestError}
19
145
  * @throws {@link ToltApi.UnauthorizedError}
146
+ * @throws {@link ToltApi.TooManyRequestsError}
20
147
  * @throws {@link errors.ToltApiError}
21
148
  * @throws {@link errors.ToltApiTimeoutError}
22
149
  *
@@ -27,11 +154,17 @@ export class CommissionsClient {
27
154
  return core.HttpResponsePromise.fromPromise(this.__listCommissions(request, requestOptions));
28
155
  }
29
156
  async __listCommissions(request = {}, requestOptions) {
30
- const { limit, order, starting_after: startingAfter, program_id: programId, partner_id: partnerId, customer_id: customerId, transaction_id: transactionId, status, type: type_, search, } = request;
157
+ const { limit, order, sort, starting_after: startingAfter, ending_before: endingBefore, created_after: createdAfter, created_before: createdBefore, updated_after: updatedAfter, updated_before: updatedBefore, program_id: programId, partner_id: partnerId, customer_id: customerId, transaction_id: transactionId, status, type: type_, search, } = request;
31
158
  const _queryParams = {
32
159
  limit,
33
160
  order: order != null ? order : undefined,
161
+ sort: sort != null ? sort : undefined,
34
162
  starting_after: startingAfter,
163
+ ending_before: endingBefore,
164
+ created_after: createdAfter != null ? createdAfter : undefined,
165
+ created_before: createdBefore != null ? createdBefore : undefined,
166
+ updated_after: updatedAfter != null ? updatedAfter : undefined,
167
+ updated_before: updatedBefore != null ? updatedBefore : undefined,
35
168
  program_id: programId,
36
169
  partner_id: partnerId,
37
170
  customer_id: customerId,
@@ -68,6 +201,8 @@ export class CommissionsClient {
68
201
  throw new ToltApi.BadRequestError(_response.error.body, _response.rawResponse);
69
202
  case 401:
70
203
  throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
204
+ case 429:
205
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
71
206
  default:
72
207
  throw new errors.ToltApiError({
73
208
  statusCode: _response.error.statusCode,
@@ -85,6 +220,7 @@ export class CommissionsClient {
85
220
  * @throws {@link ToltApi.BadRequestError}
86
221
  * @throws {@link ToltApi.UnauthorizedError}
87
222
  * @throws {@link ToltApi.ConflictError}
223
+ * @throws {@link ToltApi.TooManyRequestsError}
88
224
  * @throws {@link errors.ToltApiError}
89
225
  * @throws {@link errors.ToltApiTimeoutError}
90
226
  *
@@ -126,6 +262,8 @@ export class CommissionsClient {
126
262
  throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
127
263
  case 409:
128
264
  throw new ToltApi.ConflictError(_response.error.body, _response.rawResponse);
265
+ case 429:
266
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
129
267
  default:
130
268
  throw new errors.ToltApiError({
131
269
  statusCode: _response.error.statusCode,
@@ -142,6 +280,7 @@ export class CommissionsClient {
142
280
  *
143
281
  * @throws {@link ToltApi.UnauthorizedError}
144
282
  * @throws {@link ToltApi.NotFoundError}
283
+ * @throws {@link ToltApi.TooManyRequestsError}
145
284
  * @throws {@link errors.ToltApiError}
146
285
  * @throws {@link errors.ToltApiTimeoutError}
147
286
  *
@@ -179,6 +318,8 @@ export class CommissionsClient {
179
318
  throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
180
319
  case 404:
181
320
  throw new ToltApi.NotFoundError(_response.error.body, _response.rawResponse);
321
+ case 429:
322
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
182
323
  default:
183
324
  throw new errors.ToltApiError({
184
325
  statusCode: _response.error.statusCode,
@@ -197,6 +338,7 @@ export class CommissionsClient {
197
338
  * @throws {@link ToltApi.UnauthorizedError}
198
339
  * @throws {@link ToltApi.NotFoundError}
199
340
  * @throws {@link ToltApi.ConflictError}
341
+ * @throws {@link ToltApi.TooManyRequestsError}
200
342
  * @throws {@link errors.ToltApiError}
201
343
  * @throws {@link errors.ToltApiTimeoutError}
202
344
  *
@@ -241,6 +383,8 @@ export class CommissionsClient {
241
383
  throw new ToltApi.NotFoundError(_response.error.body, _response.rawResponse);
242
384
  case 409:
243
385
  throw new ToltApi.ConflictError(_response.error.body, _response.rawResponse);
386
+ case 429:
387
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
244
388
  default:
245
389
  throw new errors.ToltApiError({
246
390
  statusCode: _response.error.statusCode,
@@ -259,6 +403,7 @@ export class CommissionsClient {
259
403
  * @throws {@link ToltApi.UnauthorizedError}
260
404
  * @throws {@link ToltApi.NotFoundError}
261
405
  * @throws {@link ToltApi.ConflictError}
406
+ * @throws {@link ToltApi.TooManyRequestsError}
262
407
  * @throws {@link errors.ToltApiError}
263
408
  * @throws {@link errors.ToltApiTimeoutError}
264
409
  *
@@ -300,6 +445,8 @@ export class CommissionsClient {
300
445
  throw new ToltApi.NotFoundError(_response.error.body, _response.rawResponse);
301
446
  case 409:
302
447
  throw new ToltApi.ConflictError(_response.error.body, _response.rawResponse);
448
+ case 429:
449
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
303
450
  default:
304
451
  throw new errors.ToltApiError({
305
452
  statusCode: _response.error.statusCode,
@@ -318,6 +465,7 @@ export class CommissionsClient {
318
465
  * @throws {@link ToltApi.UnauthorizedError}
319
466
  * @throws {@link ToltApi.NotFoundError}
320
467
  * @throws {@link ToltApi.ConflictError}
468
+ * @throws {@link ToltApi.TooManyRequestsError}
321
469
  * @throws {@link errors.ToltApiError}
322
470
  * @throws {@link errors.ToltApiTimeoutError}
323
471
  *
@@ -359,6 +507,8 @@ export class CommissionsClient {
359
507
  throw new ToltApi.NotFoundError(_response.error.body, _response.rawResponse);
360
508
  case 409:
361
509
  throw new ToltApi.ConflictError(_response.error.body, _response.rawResponse);
510
+ case 429:
511
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
362
512
  default:
363
513
  throw new errors.ToltApiError({
364
514
  statusCode: _response.error.statusCode,
@@ -377,6 +527,7 @@ export class CommissionsClient {
377
527
  * @throws {@link ToltApi.UnauthorizedError}
378
528
  * @throws {@link ToltApi.NotFoundError}
379
529
  * @throws {@link ToltApi.ConflictError}
530
+ * @throws {@link ToltApi.TooManyRequestsError}
380
531
  * @throws {@link errors.ToltApiError}
381
532
  * @throws {@link errors.ToltApiTimeoutError}
382
533
  *
@@ -418,6 +569,8 @@ export class CommissionsClient {
418
569
  throw new ToltApi.NotFoundError(_response.error.body, _response.rawResponse);
419
570
  case 409:
420
571
  throw new ToltApi.ConflictError(_response.error.body, _response.rawResponse);
572
+ case 429:
573
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
421
574
  default:
422
575
  throw new errors.ToltApiError({
423
576
  statusCode: _response.error.statusCode,
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * ids: ["part_9fQ2xLL", "part_3RtV9k"]
5
+ * }
6
+ */
7
+ export interface BulkApproveCommissionsRequest {
8
+ /** Up to 100 ids. Duplicates are processed once. */
9
+ ids: string[];
10
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * ids: ["part_9fQ2xLL", "part_3RtV9k"]
5
+ * }
6
+ */
7
+ export interface BulkDeclineCommissionsRequest {
8
+ /** Up to 100 ids. Duplicates are processed once. */
9
+ ids: string[];
10
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -6,7 +6,20 @@ import type * as ToltApi from "../../../../index.js";
6
6
  export interface ListCommissionsRequest {
7
7
  limit?: number;
8
8
  order?: ToltApi.ListCommissionsRequestOrder;
9
+ /** Column the list is ordered and paged by. */
10
+ sort?: ToltApi.ListCommissionsRequestSort;
11
+ /** Continue after a position: the next_cursor of a previous page, or an item id when sorting by created_at. Cannot be combined with ending_before. */
9
12
  starting_after?: string;
13
+ /** Page backward from a position: the prev_cursor of a previous page, or an item id when sorting by created_at. Cannot be combined with starting_after. */
14
+ ending_before?: string;
15
+ /** Only items created at or after this ISO 8601 time. */
16
+ created_after?: string;
17
+ /** Only items created before this ISO 8601 time. */
18
+ created_before?: string;
19
+ /** Only items updated at or after this ISO 8601 time. Combine with sort=updated_at to sync changes. */
20
+ updated_after?: string;
21
+ /** Only items updated before this ISO 8601 time. */
22
+ updated_before?: string;
10
23
  program_id?: string;
11
24
  partner_id?: string;
12
25
  customer_id?: string;
@@ -12,7 +12,7 @@ export interface UpdateCommissionRequest {
12
12
  revenue?: number;
13
13
  status?: string | null;
14
14
  source?: string | null;
15
- chargeId?: string | null;
16
- transactionId?: string | null;
17
- createdAt?: string;
15
+ charge_id?: string | null;
16
+ transaction_id?: string | null;
17
+ created_at?: string;
18
18
  }
@@ -1,4 +1,6 @@
1
1
  export type { ApproveCommissionRequest } from "./ApproveCommissionRequest.js";
2
+ export type { BulkApproveCommissionsRequest } from "./BulkApproveCommissionsRequest.js";
3
+ export type { BulkDeclineCommissionsRequest } from "./BulkDeclineCommissionsRequest.js";
2
4
  export type { DeclineCommissionRequest } from "./DeclineCommissionRequest.js";
3
5
  export type { DeleteCommissionRequest } from "./DeleteCommissionRequest.js";
4
6
  export type { GetCommissionRequest } from "./GetCommissionRequest.js";
@@ -0,0 +1,6 @@
1
+ import type * as ToltApi from "../../../index.js";
2
+ export interface BulkApproveCommissionsResponse {
3
+ success: boolean;
4
+ message: string;
5
+ data: ToltApi.BulkResult;
6
+ }