@tolt/api 0.1.1 → 0.3.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 (209) hide show
  1. package/dist/Client.d.ts +3 -0
  2. package/dist/Client.js +4 -0
  3. package/dist/api/errors/TooManyRequestsError.d.ts +7 -0
  4. package/dist/api/errors/TooManyRequestsError.js +17 -0
  5. package/dist/api/errors/index.d.ts +1 -0
  6. package/dist/api/errors/index.js +1 -0
  7. package/dist/api/resources/clicks/client/Client.d.ts +10 -4
  8. package/dist/api/resources/clicks/client/Client.js +22 -24
  9. package/dist/api/resources/clicks/client/requests/index.d.ts +0 -1
  10. package/dist/api/resources/clicks/types/CreateClickRequest.d.ts +1 -0
  11. package/dist/api/resources/clicks/types/CreateClickResponse.d.ts +6 -0
  12. package/dist/api/resources/clicks/types/index.d.ts +2 -2
  13. package/dist/api/resources/clicks/types/index.js +2 -2
  14. package/dist/api/resources/commissions/client/Client.d.ts +45 -0
  15. package/dist/api/resources/commissions/client/Client.js +154 -1
  16. package/dist/api/resources/commissions/client/requests/BulkApproveCommissionsRequest.d.ts +10 -0
  17. package/dist/api/resources/commissions/client/requests/BulkDeclineCommissionsRequest.d.ts +10 -0
  18. package/dist/api/resources/commissions/client/requests/BulkDeclineCommissionsRequest.js +2 -0
  19. package/dist/api/resources/commissions/client/requests/ListCommissionsRequest.d.ts +13 -0
  20. package/dist/api/resources/commissions/client/requests/UpdateCommissionRequest.d.ts +3 -3
  21. package/dist/api/resources/commissions/client/requests/index.d.ts +2 -0
  22. package/dist/api/resources/commissions/types/BulkApproveCommissionsResponse.d.ts +6 -0
  23. package/dist/api/resources/commissions/types/BulkApproveCommissionsResponse.js +2 -0
  24. package/dist/api/resources/commissions/types/BulkDeclineCommissionsResponse.d.ts +6 -0
  25. package/dist/api/resources/commissions/types/BulkDeclineCommissionsResponse.js +2 -0
  26. package/dist/api/resources/commissions/types/ListCommissionsRequestSort.d.ts +6 -0
  27. package/dist/api/resources/commissions/types/ListCommissionsRequestSort.js +6 -0
  28. package/dist/api/resources/commissions/types/ListCommissionsResponse.d.ts +4 -0
  29. package/dist/api/resources/commissions/types/index.d.ts +3 -0
  30. package/dist/api/resources/commissions/types/index.js +3 -0
  31. package/dist/api/resources/customers/client/Client.d.ts +7 -4
  32. package/dist/api/resources/customers/client/Client.js +25 -6
  33. package/dist/api/resources/customers/client/requests/CreateCustomerRequest.d.ts +14 -0
  34. package/dist/api/resources/customers/client/requests/CreateCustomerRequest.js +2 -0
  35. package/dist/api/resources/customers/client/requests/ListCustomersRequest.d.ts +13 -0
  36. package/dist/api/resources/customers/client/requests/UpdateCustomerRequest.d.ts +6 -6
  37. package/dist/api/resources/customers/client/requests/index.d.ts +1 -0
  38. package/dist/api/resources/customers/types/ListCustomersRequestSort.d.ts +6 -0
  39. package/dist/api/resources/customers/types/ListCustomersRequestSort.js +6 -0
  40. package/dist/api/resources/customers/types/ListCustomersResponse.d.ts +4 -0
  41. package/dist/api/resources/customers/types/index.d.ts +1 -1
  42. package/dist/api/resources/customers/types/index.js +1 -1
  43. package/dist/api/resources/embed/client/Client.d.ts +31 -0
  44. package/dist/api/resources/embed/client/Client.js +75 -0
  45. package/dist/api/resources/embed/client/index.d.ts +1 -0
  46. package/dist/api/resources/embed/client/index.js +1 -0
  47. package/dist/api/resources/embed/client/requests/CreateEmbedTokenRequest.d.ts +14 -0
  48. package/dist/api/resources/embed/client/requests/CreateEmbedTokenRequest.js +2 -0
  49. package/dist/api/resources/embed/client/requests/index.d.ts +1 -0
  50. package/dist/api/resources/embed/client/requests/index.js +1 -0
  51. package/dist/api/resources/embed/exports.d.ts +2 -0
  52. package/dist/api/resources/embed/exports.js +3 -0
  53. package/dist/api/resources/embed/index.d.ts +2 -0
  54. package/dist/api/resources/embed/index.js +2 -0
  55. package/dist/api/resources/embed/types/CreateEmbedTokenResponse.d.ts +6 -0
  56. package/dist/api/resources/embed/types/CreateEmbedTokenResponse.js +2 -0
  57. package/dist/api/resources/embed/types/index.d.ts +1 -0
  58. package/dist/api/resources/embed/types/index.js +1 -0
  59. package/dist/api/resources/flows/client/Client.d.ts +2 -0
  60. package/dist/api/resources/flows/client/Client.js +13 -1
  61. package/dist/api/resources/flows/client/requests/ListFlowsRequest.d.ts +13 -0
  62. package/dist/api/resources/flows/types/ListFlowsRequestSort.d.ts +6 -0
  63. package/dist/api/resources/flows/types/ListFlowsRequestSort.js +6 -0
  64. package/dist/api/resources/flows/types/ListFlowsResponse.d.ts +4 -0
  65. package/dist/api/resources/flows/types/index.d.ts +1 -0
  66. package/dist/api/resources/flows/types/index.js +1 -0
  67. package/dist/api/resources/groups/client/Client.d.ts +2 -0
  68. package/dist/api/resources/groups/client/Client.js +13 -1
  69. package/dist/api/resources/groups/client/requests/ListGroupsRequest.d.ts +13 -0
  70. package/dist/api/resources/groups/types/ListGroupsRequestSort.d.ts +6 -0
  71. package/dist/api/resources/groups/types/ListGroupsRequestSort.js +6 -0
  72. package/dist/api/resources/groups/types/ListGroupsResponse.d.ts +4 -0
  73. package/dist/api/resources/groups/types/index.d.ts +1 -0
  74. package/dist/api/resources/groups/types/index.js +1 -0
  75. package/dist/api/resources/index.d.ts +3 -0
  76. package/dist/api/resources/index.js +3 -0
  77. package/dist/api/resources/links/client/Client.d.ts +6 -1
  78. package/dist/api/resources/links/client/Client.js +23 -2
  79. package/dist/api/resources/links/client/requests/CreateLinkRequest.d.ts +2 -2
  80. package/dist/api/resources/links/client/requests/ListLinksRequest.d.ts +13 -0
  81. package/dist/api/resources/links/types/ListLinksRequestSort.d.ts +6 -0
  82. package/dist/api/resources/links/types/ListLinksRequestSort.js +6 -0
  83. package/dist/api/resources/links/types/ListLinksResponse.d.ts +4 -0
  84. package/dist/api/resources/links/types/index.d.ts +1 -0
  85. package/dist/api/resources/links/types/index.js +1 -0
  86. package/dist/api/resources/partners/client/Client.d.ts +85 -0
  87. package/dist/api/resources/partners/client/Client.js +273 -1
  88. package/dist/api/resources/partners/client/requests/BulkApprovePartnersRequest.d.ts +10 -0
  89. package/dist/api/resources/partners/client/requests/BulkApprovePartnersRequest.js +2 -0
  90. package/dist/api/resources/partners/client/requests/BulkRejectPartnersRequest.d.ts +11 -0
  91. package/dist/api/resources/partners/client/requests/BulkRejectPartnersRequest.js +2 -0
  92. package/dist/api/resources/partners/client/requests/CreatePartnerRequest.d.ts +41 -0
  93. package/dist/api/resources/partners/client/requests/CreatePartnerRequest.js +8 -0
  94. package/dist/api/resources/partners/client/requests/ListPartnersRequest.d.ts +13 -0
  95. package/dist/api/resources/partners/client/requests/RejectPartnerRequest.d.ts +1 -1
  96. package/dist/api/resources/partners/client/requests/SuspendPartnerRequest.d.ts +1 -1
  97. package/dist/api/resources/partners/client/requests/UpdatePartnerRequest.d.ts +16 -0
  98. package/dist/api/resources/partners/client/requests/UpdatePartnerRequest.js +2 -0
  99. package/dist/api/resources/partners/client/requests/index.d.ts +4 -0
  100. package/dist/api/resources/partners/client/requests/index.js +1 -1
  101. package/dist/api/resources/partners/types/BulkApprovePartnersResponse.d.ts +6 -0
  102. package/dist/api/resources/partners/types/BulkApprovePartnersResponse.js +2 -0
  103. package/dist/api/resources/partners/types/BulkRejectPartnersResponse.d.ts +6 -0
  104. package/dist/api/resources/partners/types/BulkRejectPartnersResponse.js +2 -0
  105. package/dist/api/resources/partners/types/CreatePartnerResponse.d.ts +6 -0
  106. package/dist/api/resources/partners/types/CreatePartnerResponse.js +2 -0
  107. package/dist/api/resources/partners/types/ListPartnersRequestSort.d.ts +6 -0
  108. package/dist/api/resources/partners/types/ListPartnersRequestSort.js +6 -0
  109. package/dist/api/resources/partners/types/ListPartnersResponse.d.ts +4 -0
  110. package/dist/api/resources/partners/types/UpdatePartnerResponse.d.ts +6 -0
  111. package/dist/api/resources/partners/types/UpdatePartnerResponse.js +2 -0
  112. package/dist/api/resources/partners/types/index.d.ts +5 -0
  113. package/dist/api/resources/partners/types/index.js +5 -0
  114. package/dist/api/resources/programs/client/Client.d.ts +2 -0
  115. package/dist/api/resources/programs/client/Client.js +13 -1
  116. package/dist/api/resources/programs/client/requests/ListProgramsRequest.d.ts +13 -0
  117. package/dist/api/resources/programs/types/ListProgramsRequestSort.d.ts +6 -0
  118. package/dist/api/resources/programs/types/ListProgramsRequestSort.js +6 -0
  119. package/dist/api/resources/programs/types/ListProgramsResponse.d.ts +4 -0
  120. package/dist/api/resources/programs/types/index.d.ts +1 -0
  121. package/dist/api/resources/programs/types/index.js +1 -0
  122. package/dist/api/resources/promotionCodes/client/Client.d.ts +6 -1
  123. package/dist/api/resources/promotionCodes/client/Client.js +23 -2
  124. package/dist/api/resources/promotionCodes/client/requests/CreatePromotionCodeRequest.d.ts +2 -2
  125. package/dist/api/resources/promotionCodes/client/requests/ListPromotionCodesRequest.d.ts +13 -0
  126. package/dist/api/resources/promotionCodes/types/ListPromotionCodesRequestSort.d.ts +6 -0
  127. package/dist/api/resources/promotionCodes/types/ListPromotionCodesRequestSort.js +6 -0
  128. package/dist/api/resources/promotionCodes/types/ListPromotionCodesResponse.d.ts +4 -0
  129. package/dist/api/resources/promotionCodes/types/index.d.ts +1 -0
  130. package/dist/api/resources/promotionCodes/types/index.js +1 -0
  131. package/dist/api/resources/reports/client/Client.d.ts +61 -2
  132. package/dist/api/resources/reports/client/Client.js +264 -2
  133. package/dist/api/resources/reports/client/requests/ReportsCustomerStatsRequest.d.ts +9 -0
  134. package/dist/api/resources/reports/client/requests/ReportsCustomerStatsRequest.js +2 -0
  135. package/dist/api/resources/reports/client/requests/ReportsLinksRequest.d.ts +14 -0
  136. package/dist/api/resources/reports/client/requests/ReportsLinksRequest.js +2 -0
  137. package/dist/api/resources/reports/client/requests/ReportsPartnersRequest.d.ts +14 -0
  138. package/dist/api/resources/reports/client/requests/ReportsPartnersRequest.js +2 -0
  139. package/dist/api/resources/reports/client/requests/ReportsTimeseriesRequest.d.ts +11 -0
  140. package/dist/api/resources/reports/client/requests/ReportsTimeseriesRequest.js +2 -0
  141. package/dist/api/resources/reports/client/requests/index.d.ts +4 -0
  142. package/dist/api/resources/reports/types/ReportsCustomerStatsResponse.d.ts +6 -0
  143. package/dist/api/resources/reports/types/ReportsCustomerStatsResponse.js +2 -0
  144. package/dist/api/resources/reports/types/ReportsLinksRequestOrder.d.ts +5 -0
  145. package/dist/api/resources/{clicks/types/ListClicksRequestOrder.js → reports/types/ReportsLinksRequestOrder.js} +1 -1
  146. package/dist/api/resources/reports/types/ReportsLinksRequestSort.d.ts +7 -0
  147. package/dist/api/resources/reports/types/ReportsLinksRequestSort.js +7 -0
  148. package/dist/api/resources/{clicks/types/ListClicksResponse.d.ts → reports/types/ReportsLinksResponse.d.ts} +2 -2
  149. package/dist/api/resources/reports/types/ReportsLinksResponse.js +2 -0
  150. package/dist/api/resources/reports/types/ReportsPartnersRequestOrder.d.ts +5 -0
  151. package/dist/api/resources/reports/types/ReportsPartnersRequestOrder.js +5 -0
  152. package/dist/api/resources/reports/types/ReportsPartnersRequestSort.d.ts +7 -0
  153. package/dist/api/resources/reports/types/ReportsPartnersRequestSort.js +7 -0
  154. package/dist/api/resources/reports/types/ReportsPartnersResponse.d.ts +7 -0
  155. package/dist/api/resources/reports/types/ReportsPartnersResponse.js +2 -0
  156. package/dist/api/resources/reports/types/ReportsTimeseriesRequestGranularity.d.ts +6 -0
  157. package/dist/api/resources/reports/types/ReportsTimeseriesRequestGranularity.js +6 -0
  158. package/dist/api/resources/reports/types/ReportsTimeseriesResponse.d.ts +6 -0
  159. package/dist/api/resources/reports/types/ReportsTimeseriesResponse.js +2 -0
  160. package/dist/api/resources/reports/types/index.d.ts +9 -0
  161. package/dist/api/resources/reports/types/index.js +9 -0
  162. package/dist/api/resources/transactions/client/Client.d.ts +8 -1
  163. package/dist/api/resources/transactions/client/Client.js +29 -2
  164. package/dist/api/resources/transactions/client/requests/CreateTransactionRequest.d.ts +5 -5
  165. package/dist/api/resources/transactions/client/requests/ListTransactionsRequest.d.ts +13 -0
  166. package/dist/api/resources/transactions/client/requests/UpdateTransactionRequest.d.ts +4 -4
  167. package/dist/api/resources/transactions/types/ListTransactionsRequestSort.d.ts +6 -0
  168. package/dist/api/resources/transactions/types/ListTransactionsRequestSort.js +6 -0
  169. package/dist/api/resources/transactions/types/ListTransactionsResponse.d.ts +4 -0
  170. package/dist/api/resources/transactions/types/index.d.ts +1 -0
  171. package/dist/api/resources/transactions/types/index.js +1 -0
  172. package/dist/api/types/BulkResult.d.ts +24 -0
  173. package/dist/api/types/BulkResult.js +14 -0
  174. package/dist/api/types/Click.d.ts +5 -5
  175. package/dist/api/types/Commission.d.ts +13 -13
  176. package/dist/api/types/CreatedPartner.d.ts +19 -0
  177. package/dist/api/types/CreatedPartner.js +2 -0
  178. package/dist/api/types/Customer.d.ts +11 -11
  179. package/dist/api/types/EmbedToken.d.ts +4 -0
  180. package/dist/api/types/EmbedToken.js +2 -0
  181. package/dist/api/types/Error_.d.ts +34 -0
  182. package/dist/api/types/Error_.js +21 -1
  183. package/dist/api/types/Flow.d.ts +8 -8
  184. package/dist/api/types/Group.d.ts +9 -9
  185. package/dist/api/types/Link.d.ts +5 -5
  186. package/dist/api/types/Partner.d.ts +12 -8
  187. package/dist/api/types/Program.d.ts +8 -8
  188. package/dist/api/types/PromotionCode.d.ts +8 -8
  189. package/dist/api/types/ReportsCustomerStats.d.ts +6 -0
  190. package/dist/api/types/ReportsCustomerStats.js +2 -0
  191. package/dist/api/types/ReportsLinkRow.d.ts +12 -0
  192. package/dist/api/types/ReportsLinkRow.js +2 -0
  193. package/dist/api/types/ReportsOverview.d.ts +5 -5
  194. package/dist/api/types/ReportsPartnerRow.d.ts +15 -0
  195. package/dist/api/types/ReportsPartnerRow.js +2 -0
  196. package/dist/api/types/ReportsTimeseriesPoint.d.ts +10 -0
  197. package/dist/api/types/ReportsTimeseriesPoint.js +2 -0
  198. package/dist/api/types/Transaction.d.ts +17 -17
  199. package/dist/api/types/index.d.ts +7 -0
  200. package/dist/api/types/index.js +7 -0
  201. package/dist/environments.d.ts +1 -1
  202. package/dist/environments.js +1 -1
  203. package/package.json +1 -1
  204. package/dist/api/resources/clicks/client/requests/ListClicksRequest.d.ts +0 -16
  205. package/dist/api/resources/clicks/types/ListClicksRequestOrder.d.ts +0 -5
  206. package/dist/api/resources/customers/types/CreateCustomerRequest.d.ts +0 -1
  207. /package/dist/api/resources/clicks/{client/requests/ListClicksRequest.js → types/CreateClickRequest.js} +0 -0
  208. /package/dist/api/resources/clicks/types/{ListClicksResponse.js → CreateClickResponse.js} +0 -0
  209. /package/dist/api/resources/{customers/types/CreateCustomerRequest.js → commissions/client/requests/BulkApproveCommissionsRequest.js} +0 -0
@@ -11,12 +11,133 @@ export class PartnersClient {
11
11
  constructor(options) {
12
12
  this._options = normalizeClientOptionsWithAuth(options);
13
13
  }
14
+ /**
15
+ * Approves up to 100 partners. Each id is processed on its own and the response reports the outcome per id, so one refused partner does not fail the request.
16
+ *
17
+ * @param {ToltApi.BulkApprovePartnersRequest} request
18
+ * @param {PartnersClient.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.partners.bulkApprovePartners({
28
+ * ids: ["part_9fQ2xLL", "part_3RtV9k"]
29
+ * })
30
+ */
31
+ bulkApprovePartners(request, requestOptions) {
32
+ return core.HttpResponsePromise.fromPromise(this.__bulkApprovePartners(request, requestOptions));
33
+ }
34
+ async __bulkApprovePartners(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/partners/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 { data: _response.body, rawResponse: _response.rawResponse };
55
+ }
56
+ if (_response.error.reason === "status-code") {
57
+ switch (_response.error.statusCode) {
58
+ case 400:
59
+ throw new ToltApi.BadRequestError(_response.error.body, _response.rawResponse);
60
+ case 401:
61
+ throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
62
+ case 429:
63
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
64
+ default:
65
+ throw new errors.ToltApiError({
66
+ statusCode: _response.error.statusCode,
67
+ body: _response.error.body,
68
+ rawResponse: _response.rawResponse,
69
+ });
70
+ }
71
+ }
72
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v2/partners/bulk/approve");
73
+ }
74
+ /**
75
+ * Rejects up to 100 partners with an optional shared rejection note. Each id is processed on its own and the response reports the outcome per id.
76
+ *
77
+ * @param {ToltApi.BulkRejectPartnersRequest} request
78
+ * @param {PartnersClient.RequestOptions} requestOptions - Request-specific configuration.
79
+ *
80
+ * @throws {@link ToltApi.BadRequestError}
81
+ * @throws {@link ToltApi.UnauthorizedError}
82
+ * @throws {@link ToltApi.TooManyRequestsError}
83
+ * @throws {@link errors.ToltApiError}
84
+ * @throws {@link errors.ToltApiTimeoutError}
85
+ *
86
+ * @example
87
+ * await client.partners.bulkRejectPartners({
88
+ * ids: ["part_9fQ2xLL", "part_3RtV9k"]
89
+ * })
90
+ */
91
+ bulkRejectPartners(request, requestOptions) {
92
+ return core.HttpResponsePromise.fromPromise(this.__bulkRejectPartners(request, requestOptions));
93
+ }
94
+ async __bulkRejectPartners(request, requestOptions) {
95
+ const _authRequest = await this._options.authProvider.getAuthRequest();
96
+ const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
97
+ const _response = await core.fetcher({
98
+ url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
99
+ (await core.Supplier.get(this._options.environment)) ??
100
+ environments.ToltApiEnvironment.Production, "v2/partners/bulk/reject"),
101
+ method: "POST",
102
+ headers: _headers,
103
+ contentType: "application/json",
104
+ queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
105
+ requestType: "json",
106
+ body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters),
107
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
108
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
109
+ abortSignal: requestOptions?.abortSignal,
110
+ fetchFn: this._options?.fetch,
111
+ logging: this._options.logging,
112
+ });
113
+ if (_response.ok) {
114
+ return { data: _response.body, rawResponse: _response.rawResponse };
115
+ }
116
+ if (_response.error.reason === "status-code") {
117
+ switch (_response.error.statusCode) {
118
+ case 400:
119
+ throw new ToltApi.BadRequestError(_response.error.body, _response.rawResponse);
120
+ case 401:
121
+ throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
122
+ case 429:
123
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
124
+ default:
125
+ throw new errors.ToltApiError({
126
+ statusCode: _response.error.statusCode,
127
+ body: _response.error.body,
128
+ rawResponse: _response.rawResponse,
129
+ });
130
+ }
131
+ }
132
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v2/partners/bulk/reject");
133
+ }
14
134
  /**
15
135
  * @param {ToltApi.ListPartnersRequest} request
16
136
  * @param {PartnersClient.RequestOptions} requestOptions - Request-specific configuration.
17
137
  *
18
138
  * @throws {@link ToltApi.BadRequestError}
19
139
  * @throws {@link ToltApi.UnauthorizedError}
140
+ * @throws {@link ToltApi.TooManyRequestsError}
20
141
  * @throws {@link errors.ToltApiError}
21
142
  * @throws {@link errors.ToltApiTimeoutError}
22
143
  *
@@ -27,11 +148,17 @@ export class PartnersClient {
27
148
  return core.HttpResponsePromise.fromPromise(this.__listPartners(request, requestOptions));
28
149
  }
29
150
  async __listPartners(request = {}, requestOptions) {
30
- const { limit, order, starting_after: startingAfter, status, program_id: programId, group_id: groupId, search, } = request;
151
+ 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, search, } = request;
31
152
  const _queryParams = {
32
153
  limit,
33
154
  order: order != null ? order : undefined,
155
+ sort: sort != null ? sort : undefined,
34
156
  starting_after: startingAfter,
157
+ ending_before: endingBefore,
158
+ created_after: createdAfter != null ? createdAfter : undefined,
159
+ created_before: createdBefore != null ? createdBefore : undefined,
160
+ updated_after: updatedAfter != null ? updatedAfter : undefined,
161
+ updated_before: updatedBefore != null ? updatedBefore : undefined,
35
162
  status: status != null ? status : undefined,
36
163
  program_id: programId,
37
164
  group_id: groupId,
@@ -65,6 +192,8 @@ export class PartnersClient {
65
192
  throw new ToltApi.BadRequestError(_response.error.body, _response.rawResponse);
66
193
  case 401:
67
194
  throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
195
+ case 429:
196
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
68
197
  default:
69
198
  throw new errors.ToltApiError({
70
199
  statusCode: _response.error.statusCode,
@@ -75,12 +204,77 @@ export class PartnersClient {
75
204
  }
76
205
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v2/partners");
77
206
  }
207
+ /**
208
+ * Creates an onboarded partner together with their referral link. The link value defaults to a slug of the partner's name or email and the parameter to the program's first link parameter. Omit group_id to place the partner in the program's default group.
209
+ *
210
+ * @param {ToltApi.CreatePartnerRequest} request
211
+ * @param {PartnersClient.RequestOptions} requestOptions - Request-specific configuration.
212
+ *
213
+ * @throws {@link ToltApi.BadRequestError}
214
+ * @throws {@link ToltApi.UnauthorizedError}
215
+ * @throws {@link ToltApi.ConflictError}
216
+ * @throws {@link ToltApi.TooManyRequestsError}
217
+ * @throws {@link errors.ToltApiError}
218
+ * @throws {@link errors.ToltApiTimeoutError}
219
+ *
220
+ * @example
221
+ * await client.partners.createPartner({
222
+ * email: "sam@acme.com",
223
+ * program_id: "prg_YRsbPDAK"
224
+ * })
225
+ */
226
+ createPartner(request, requestOptions) {
227
+ return core.HttpResponsePromise.fromPromise(this.__createPartner(request, requestOptions));
228
+ }
229
+ async __createPartner(request, requestOptions) {
230
+ const _authRequest = await this._options.authProvider.getAuthRequest();
231
+ const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
232
+ const _response = await core.fetcher({
233
+ url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
234
+ (await core.Supplier.get(this._options.environment)) ??
235
+ environments.ToltApiEnvironment.Production, "v2/partners"),
236
+ method: "POST",
237
+ headers: _headers,
238
+ contentType: "application/json",
239
+ queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
240
+ requestType: "json",
241
+ body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters),
242
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
243
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
244
+ abortSignal: requestOptions?.abortSignal,
245
+ fetchFn: this._options?.fetch,
246
+ logging: this._options.logging,
247
+ });
248
+ if (_response.ok) {
249
+ return { data: _response.body, rawResponse: _response.rawResponse };
250
+ }
251
+ if (_response.error.reason === "status-code") {
252
+ switch (_response.error.statusCode) {
253
+ case 400:
254
+ throw new ToltApi.BadRequestError(_response.error.body, _response.rawResponse);
255
+ case 401:
256
+ throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
257
+ case 409:
258
+ throw new ToltApi.ConflictError(_response.error.body, _response.rawResponse);
259
+ case 429:
260
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
261
+ default:
262
+ throw new errors.ToltApiError({
263
+ statusCode: _response.error.statusCode,
264
+ body: _response.error.body,
265
+ rawResponse: _response.rawResponse,
266
+ });
267
+ }
268
+ }
269
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v2/partners");
270
+ }
78
271
  /**
79
272
  * @param {ToltApi.GetPartnerRequest} request
80
273
  * @param {PartnersClient.RequestOptions} requestOptions - Request-specific configuration.
81
274
  *
82
275
  * @throws {@link ToltApi.UnauthorizedError}
83
276
  * @throws {@link ToltApi.NotFoundError}
277
+ * @throws {@link ToltApi.TooManyRequestsError}
84
278
  * @throws {@link errors.ToltApiError}
85
279
  * @throws {@link errors.ToltApiTimeoutError}
86
280
  *
@@ -118,6 +312,8 @@ export class PartnersClient {
118
312
  throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
119
313
  case 404:
120
314
  throw new ToltApi.NotFoundError(_response.error.body, _response.rawResponse);
315
+ case 429:
316
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
121
317
  default:
122
318
  throw new errors.ToltApiError({
123
319
  statusCode: _response.error.statusCode,
@@ -128,12 +324,80 @@ export class PartnersClient {
128
324
  }
129
325
  return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v2/partners/{id}");
130
326
  }
327
+ /**
328
+ * Edits profile fields and group membership. Status changes go through the approve, reject and suspend actions.
329
+ *
330
+ * @param {ToltApi.UpdatePartnerRequest} request
331
+ * @param {PartnersClient.RequestOptions} requestOptions - Request-specific configuration.
332
+ *
333
+ * @throws {@link ToltApi.BadRequestError}
334
+ * @throws {@link ToltApi.UnauthorizedError}
335
+ * @throws {@link ToltApi.NotFoundError}
336
+ * @throws {@link ToltApi.ConflictError}
337
+ * @throws {@link ToltApi.TooManyRequestsError}
338
+ * @throws {@link errors.ToltApiError}
339
+ * @throws {@link errors.ToltApiTimeoutError}
340
+ *
341
+ * @example
342
+ * await client.partners.updatePartner({
343
+ * id: "id"
344
+ * })
345
+ */
346
+ updatePartner(request, requestOptions) {
347
+ return core.HttpResponsePromise.fromPromise(this.__updatePartner(request, requestOptions));
348
+ }
349
+ async __updatePartner(request, requestOptions) {
350
+ const { id, ..._body } = request;
351
+ const _authRequest = await this._options.authProvider.getAuthRequest();
352
+ const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
353
+ const _response = await core.fetcher({
354
+ url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
355
+ (await core.Supplier.get(this._options.environment)) ??
356
+ environments.ToltApiEnvironment.Production, `v2/partners/${core.url.encodePathParam(id)}`),
357
+ method: "PUT",
358
+ headers: _headers,
359
+ contentType: "application/json",
360
+ queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
361
+ requestType: "json",
362
+ body: mergeAdditionalBodyParameters(_body, requestOptions?.additionalBodyParameters),
363
+ timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
364
+ maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
365
+ abortSignal: requestOptions?.abortSignal,
366
+ fetchFn: this._options?.fetch,
367
+ logging: this._options.logging,
368
+ });
369
+ if (_response.ok) {
370
+ return { data: _response.body, rawResponse: _response.rawResponse };
371
+ }
372
+ if (_response.error.reason === "status-code") {
373
+ switch (_response.error.statusCode) {
374
+ case 400:
375
+ throw new ToltApi.BadRequestError(_response.error.body, _response.rawResponse);
376
+ case 401:
377
+ throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
378
+ case 404:
379
+ throw new ToltApi.NotFoundError(_response.error.body, _response.rawResponse);
380
+ case 409:
381
+ throw new ToltApi.ConflictError(_response.error.body, _response.rawResponse);
382
+ case 429:
383
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
384
+ default:
385
+ throw new errors.ToltApiError({
386
+ statusCode: _response.error.statusCode,
387
+ body: _response.error.body,
388
+ rawResponse: _response.rawResponse,
389
+ });
390
+ }
391
+ }
392
+ return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v2/partners/{id}");
393
+ }
131
394
  /**
132
395
  * @param {ToltApi.ApprovePartnerRequest} request
133
396
  * @param {PartnersClient.RequestOptions} requestOptions - Request-specific configuration.
134
397
  *
135
398
  * @throws {@link ToltApi.UnauthorizedError}
136
399
  * @throws {@link ToltApi.NotFoundError}
400
+ * @throws {@link ToltApi.TooManyRequestsError}
137
401
  * @throws {@link errors.ToltApiError}
138
402
  * @throws {@link errors.ToltApiTimeoutError}
139
403
  *
@@ -171,6 +435,8 @@ export class PartnersClient {
171
435
  throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
172
436
  case 404:
173
437
  throw new ToltApi.NotFoundError(_response.error.body, _response.rawResponse);
438
+ case 429:
439
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
174
440
  default:
175
441
  throw new errors.ToltApiError({
176
442
  statusCode: _response.error.statusCode,
@@ -188,6 +454,7 @@ export class PartnersClient {
188
454
  * @throws {@link ToltApi.BadRequestError}
189
455
  * @throws {@link ToltApi.UnauthorizedError}
190
456
  * @throws {@link ToltApi.NotFoundError}
457
+ * @throws {@link ToltApi.TooManyRequestsError}
191
458
  * @throws {@link errors.ToltApiError}
192
459
  * @throws {@link errors.ToltApiTimeoutError}
193
460
  *
@@ -230,6 +497,8 @@ export class PartnersClient {
230
497
  throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
231
498
  case 404:
232
499
  throw new ToltApi.NotFoundError(_response.error.body, _response.rawResponse);
500
+ case 429:
501
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
233
502
  default:
234
503
  throw new errors.ToltApiError({
235
504
  statusCode: _response.error.statusCode,
@@ -247,6 +516,7 @@ export class PartnersClient {
247
516
  * @throws {@link ToltApi.BadRequestError}
248
517
  * @throws {@link ToltApi.UnauthorizedError}
249
518
  * @throws {@link ToltApi.NotFoundError}
519
+ * @throws {@link ToltApi.TooManyRequestsError}
250
520
  * @throws {@link errors.ToltApiError}
251
521
  * @throws {@link errors.ToltApiTimeoutError}
252
522
  *
@@ -289,6 +559,8 @@ export class PartnersClient {
289
559
  throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
290
560
  case 404:
291
561
  throw new ToltApi.NotFoundError(_response.error.body, _response.rawResponse);
562
+ case 429:
563
+ throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
292
564
  default:
293
565
  throw new errors.ToltApiError({
294
566
  statusCode: _response.error.statusCode,
@@ -0,0 +1,10 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * ids: ["part_9fQ2xLL", "part_3RtV9k"]
5
+ * }
6
+ */
7
+ export interface BulkApprovePartnersRequest {
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,11 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * ids: ["part_9fQ2xLL", "part_3RtV9k"]
5
+ * }
6
+ */
7
+ export interface BulkRejectPartnersRequest {
8
+ /** Up to 100 ids. Duplicates are processed once. */
9
+ ids: string[];
10
+ rejection_note?: string | null;
11
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,41 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * email: "sam@acme.com",
5
+ * program_id: "prg_YRsbPDAK"
6
+ * }
7
+ */
8
+ export interface CreatePartnerRequest {
9
+ /** Unique within the program, compared case-insensitively. */
10
+ email: string;
11
+ program_id: string;
12
+ first_name?: string;
13
+ last_name?: string;
14
+ company_name?: string;
15
+ /** Two-letter ISO country code. */
16
+ country_code?: string;
17
+ website_url?: string;
18
+ /** Group in the program. Defaults to the program's default group. */
19
+ group_id?: string;
20
+ status?: CreatePartnerRequest.Status;
21
+ /** The referral link created with the partner. Defaults to a slug of the name or email. */
22
+ link?: CreatePartnerRequest.Link;
23
+ /** Send the partner the program's welcome email. Only goes out when the program's welcome email is enabled and the partner is active. */
24
+ notify_partner?: boolean;
25
+ }
26
+ export declare namespace CreatePartnerRequest {
27
+ const Status: {
28
+ readonly Active: "active";
29
+ readonly Pending: "pending";
30
+ };
31
+ type Status = (typeof Status)[keyof typeof Status];
32
+ /**
33
+ * The referral link created with the partner. Defaults to a slug of the name or email.
34
+ */
35
+ interface Link {
36
+ /** The slug after the parameter, e.g. `sam` in `?ref=sam`. */
37
+ value: string;
38
+ /** Defaults to the program's first link parameter. */
39
+ param?: string | undefined;
40
+ }
41
+ }
@@ -0,0 +1,8 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export var CreatePartnerRequest;
3
+ (function (CreatePartnerRequest) {
4
+ CreatePartnerRequest.Status = {
5
+ Active: "active",
6
+ Pending: "pending",
7
+ };
8
+ })(CreatePartnerRequest || (CreatePartnerRequest = {}));
@@ -6,7 +6,20 @@ import type * as ToltApi from "../../../../index.js";
6
6
  export interface ListPartnersRequest {
7
7
  limit?: number;
8
8
  order?: ToltApi.ListPartnersRequestOrder;
9
+ /** Column the list is ordered and paged by. */
10
+ sort?: ToltApi.ListPartnersRequestSort;
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
  status?: ToltApi.ListPartnersRequestStatus;
11
24
  program_id?: string;
12
25
  group_id?: string;
@@ -6,5 +6,5 @@
6
6
  */
7
7
  export interface RejectPartnerRequest {
8
8
  id: string;
9
- rejectionNote?: string | null;
9
+ rejection_note?: string | null;
10
10
  }
@@ -6,5 +6,5 @@
6
6
  */
7
7
  export interface SuspendPartnerRequest {
8
8
  id: string;
9
- suspensionReason?: string | null;
9
+ suspension_reason?: string | null;
10
10
  }
@@ -0,0 +1,16 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * id: "id"
5
+ * }
6
+ */
7
+ export interface UpdatePartnerRequest {
8
+ id: string;
9
+ email?: string;
10
+ first_name?: string | null;
11
+ last_name?: string | null;
12
+ company_name?: string | null;
13
+ country_code?: string | null;
14
+ website_url?: string | null;
15
+ group_id?: string | null;
16
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -1,5 +1,9 @@
1
1
  export type { ApprovePartnerRequest } from "./ApprovePartnerRequest.js";
2
+ export type { BulkApprovePartnersRequest } from "./BulkApprovePartnersRequest.js";
3
+ export type { BulkRejectPartnersRequest } from "./BulkRejectPartnersRequest.js";
4
+ export { CreatePartnerRequest } from "./CreatePartnerRequest.js";
2
5
  export type { GetPartnerRequest } from "./GetPartnerRequest.js";
3
6
  export type { ListPartnersRequest } from "./ListPartnersRequest.js";
4
7
  export type { RejectPartnerRequest } from "./RejectPartnerRequest.js";
5
8
  export type { SuspendPartnerRequest } from "./SuspendPartnerRequest.js";
9
+ export type { UpdatePartnerRequest } from "./UpdatePartnerRequest.js";
@@ -1 +1 @@
1
- export {};
1
+ export { CreatePartnerRequest } from "./CreatePartnerRequest.js";
@@ -0,0 +1,6 @@
1
+ import type * as ToltApi from "../../../index.js";
2
+ export interface BulkApprovePartnersResponse {
3
+ success: boolean;
4
+ message: string;
5
+ data: ToltApi.BulkResult;
6
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,6 @@
1
+ import type * as ToltApi from "../../../index.js";
2
+ export interface BulkRejectPartnersResponse {
3
+ success: boolean;
4
+ message: string;
5
+ data: ToltApi.BulkResult;
6
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,6 @@
1
+ import type * as ToltApi from "../../../index.js";
2
+ export interface CreatePartnerResponse {
3
+ success: boolean;
4
+ message: string;
5
+ data: ToltApi.CreatedPartner;
6
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,6 @@
1
+ /** Column the list is ordered and paged by. */
2
+ export declare const ListPartnersRequestSort: {
3
+ readonly CreatedAt: "created_at";
4
+ readonly UpdatedAt: "updated_at";
5
+ };
6
+ export type ListPartnersRequestSort = (typeof ListPartnersRequestSort)[keyof typeof ListPartnersRequestSort];
@@ -0,0 +1,6 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ /** Column the list is ordered and paged by. */
3
+ export const ListPartnersRequestSort = {
4
+ CreatedAt: "created_at",
5
+ UpdatedAt: "updated_at",
6
+ };
@@ -4,4 +4,8 @@ export interface ListPartnersResponse {
4
4
  message: string;
5
5
  data: ToltApi.Partner[];
6
6
  has_more: boolean;
7
+ /** Opaque cursor marking the last item on this page. Pass it as starting_after to continue. Null when the page is empty. */
8
+ next_cursor: string | null;
9
+ /** Opaque cursor marking the first item on this page. Pass it as ending_before to page backward. Null when the page is empty. */
10
+ prev_cursor: string | null;
7
11
  }
@@ -0,0 +1,6 @@
1
+ import type * as ToltApi from "../../../index.js";
2
+ export interface UpdatePartnerResponse {
3
+ success: boolean;
4
+ message: string;
5
+ data: ToltApi.Partner;
6
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -1,7 +1,12 @@
1
1
  export * from "./ApprovePartnerResponse.js";
2
+ export * from "./BulkApprovePartnersResponse.js";
3
+ export * from "./BulkRejectPartnersResponse.js";
4
+ export * from "./CreatePartnerResponse.js";
2
5
  export * from "./GetPartnerResponse.js";
3
6
  export * from "./ListPartnersRequestOrder.js";
7
+ export * from "./ListPartnersRequestSort.js";
4
8
  export * from "./ListPartnersRequestStatus.js";
5
9
  export * from "./ListPartnersResponse.js";
6
10
  export * from "./RejectPartnerResponse.js";
7
11
  export * from "./SuspendPartnerResponse.js";
12
+ export * from "./UpdatePartnerResponse.js";
@@ -1,7 +1,12 @@
1
1
  export * from "./ApprovePartnerResponse.js";
2
+ export * from "./BulkApprovePartnersResponse.js";
3
+ export * from "./BulkRejectPartnersResponse.js";
4
+ export * from "./CreatePartnerResponse.js";
2
5
  export * from "./GetPartnerResponse.js";
3
6
  export * from "./ListPartnersRequestOrder.js";
7
+ export * from "./ListPartnersRequestSort.js";
4
8
  export * from "./ListPartnersRequestStatus.js";
5
9
  export * from "./ListPartnersResponse.js";
6
10
  export * from "./RejectPartnerResponse.js";
7
11
  export * from "./SuspendPartnerResponse.js";
12
+ export * from "./UpdatePartnerResponse.js";
@@ -16,6 +16,7 @@ export declare class ProgramsClient {
16
16
  *
17
17
  * @throws {@link ToltApi.BadRequestError}
18
18
  * @throws {@link ToltApi.UnauthorizedError}
19
+ * @throws {@link ToltApi.TooManyRequestsError}
19
20
  * @throws {@link errors.ToltApiError}
20
21
  * @throws {@link errors.ToltApiTimeoutError}
21
22
  *
@@ -30,6 +31,7 @@ export declare class ProgramsClient {
30
31
  *
31
32
  * @throws {@link ToltApi.UnauthorizedError}
32
33
  * @throws {@link ToltApi.NotFoundError}
34
+ * @throws {@link ToltApi.TooManyRequestsError}
33
35
  * @throws {@link errors.ToltApiError}
34
36
  * @throws {@link errors.ToltApiTimeoutError}
35
37
  *