@tolt/api 1.1.0 → 1.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.
- package/README.md +43 -15
- package/dist/BaseClient.js +1 -1
- package/dist/Client.d.ts +3 -0
- package/dist/Client.js +4 -0
- package/dist/api/resources/embedTokens/client/Client.d.ts +1 -1
- package/dist/api/resources/embedTokens/client/Client.js +1 -1
- package/dist/api/resources/embedTokens/client/requests/CreateEmbedTokenRequest.d.ts +8 -2
- package/dist/api/resources/index.d.ts +3 -0
- package/dist/api/resources/index.js +3 -0
- package/dist/api/resources/partnerTags/client/Client.d.ts +118 -0
- package/dist/api/resources/partnerTags/client/Client.js +352 -0
- package/dist/api/resources/partnerTags/client/index.d.ts +1 -0
- package/dist/api/resources/partnerTags/client/index.js +1 -0
- package/dist/api/resources/partnerTags/client/requests/CreatePartnerTagRequest.d.ts +16 -0
- package/dist/api/resources/partnerTags/client/requests/CreatePartnerTagRequest.js +2 -0
- package/dist/api/resources/partnerTags/client/requests/DeletePartnerTagRequest.d.ts +9 -0
- package/dist/api/resources/partnerTags/client/requests/DeletePartnerTagRequest.js +2 -0
- package/dist/api/resources/partnerTags/client/requests/GetPartnerTagRequest.d.ts +9 -0
- package/dist/api/resources/partnerTags/client/requests/GetPartnerTagRequest.js +2 -0
- package/dist/api/resources/partnerTags/client/requests/ListPartnerTagsRequest.d.ts +29 -0
- package/dist/api/resources/partnerTags/client/requests/ListPartnerTagsRequest.js +2 -0
- package/dist/api/resources/partnerTags/client/requests/UpdatePartnerTagRequest.d.ts +15 -0
- package/dist/api/resources/partnerTags/client/requests/UpdatePartnerTagRequest.js +2 -0
- package/dist/api/resources/partnerTags/client/requests/index.d.ts +5 -0
- package/dist/api/resources/partnerTags/client/requests/index.js +1 -0
- package/dist/api/resources/partnerTags/exports.d.ts +2 -0
- package/dist/api/resources/partnerTags/exports.js +3 -0
- package/dist/api/resources/partnerTags/index.d.ts +2 -0
- package/dist/api/resources/partnerTags/index.js +2 -0
- package/dist/api/resources/partnerTags/types/CreatePartnerTagResponse.d.ts +6 -0
- package/dist/api/resources/partnerTags/types/CreatePartnerTagResponse.js +2 -0
- package/dist/api/resources/partnerTags/types/DeletePartnerTagResponse.d.ts +6 -0
- package/dist/api/resources/partnerTags/types/DeletePartnerTagResponse.js +2 -0
- package/dist/api/resources/partnerTags/types/GetPartnerTagResponse.d.ts +6 -0
- package/dist/api/resources/partnerTags/types/GetPartnerTagResponse.js +2 -0
- package/dist/api/resources/partnerTags/types/ListPartnerTagsRequestOrder.d.ts +6 -0
- package/dist/api/resources/partnerTags/types/ListPartnerTagsRequestOrder.js +6 -0
- package/dist/api/resources/partnerTags/types/ListPartnerTagsRequestSort.d.ts +6 -0
- package/dist/api/resources/partnerTags/types/ListPartnerTagsRequestSort.js +6 -0
- package/dist/api/resources/partnerTags/types/ListPartnerTagsResponse.d.ts +11 -0
- package/dist/api/resources/partnerTags/types/ListPartnerTagsResponse.js +2 -0
- package/dist/api/resources/partnerTags/types/UpdatePartnerTagResponse.d.ts +6 -0
- package/dist/api/resources/partnerTags/types/UpdatePartnerTagResponse.js +2 -0
- package/dist/api/resources/partnerTags/types/index.d.ts +7 -0
- package/dist/api/resources/partnerTags/types/index.js +7 -0
- package/dist/api/resources/partners/client/Client.d.ts +43 -0
- package/dist/api/resources/partners/client/Client.js +132 -1
- package/dist/api/resources/partners/client/requests/AddPartnerTagsRequest.d.ts +12 -0
- package/dist/api/resources/partners/client/requests/AddPartnerTagsRequest.js +2 -0
- package/dist/api/resources/partners/client/requests/ListPartnersRequest.d.ts +2 -0
- package/dist/api/resources/partners/client/requests/RemovePartnerTagRequest.d.ts +11 -0
- package/dist/api/resources/partners/client/requests/RemovePartnerTagRequest.js +2 -0
- package/dist/api/resources/partners/client/requests/index.d.ts +2 -0
- package/dist/api/resources/partners/types/AddPartnerTagsResponse.d.ts +6 -0
- package/dist/api/resources/partners/types/AddPartnerTagsResponse.js +2 -0
- package/dist/api/resources/partners/types/RemovePartnerTagResponse.d.ts +6 -0
- package/dist/api/resources/partners/types/RemovePartnerTagResponse.js +2 -0
- package/dist/api/resources/partners/types/index.d.ts +2 -0
- package/dist/api/resources/partners/types/index.js +2 -0
- package/dist/api/resources/transactions/client/requests/CreateTransactionRequest.d.ts +1 -1
- package/dist/api/types/EmbedToken.d.ts +2 -0
- package/dist/api/types/PartnerDetails.d.ts +2 -0
- package/dist/api/types/PartnerTag.d.ts +11 -0
- package/dist/api/types/PartnerTag.js +2 -0
- package/dist/api/types/PartnerTagSummary.d.ts +5 -0
- package/dist/api/types/PartnerTagSummary.js +2 -0
- package/dist/api/types/index.d.ts +2 -0
- package/dist/api/types/index.js +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
import { normalizeClientOptionsWithAuth } from "../../../../BaseClient.js";
|
|
3
|
+
import { mergeHeaders } from "../../../../core/headers.js";
|
|
4
|
+
import * as core from "../../../../core/index.js";
|
|
5
|
+
import { mergeAdditionalBodyParameters } from "../../../../core/requestBody.js";
|
|
6
|
+
import * as environments from "../../../../environments.js";
|
|
7
|
+
import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.js";
|
|
8
|
+
import * as errors from "../../../../errors/index.js";
|
|
9
|
+
import * as ToltApi from "../../../index.js";
|
|
10
|
+
export class PartnerTagsClient {
|
|
11
|
+
constructor(options) {
|
|
12
|
+
this._options = normalizeClientOptionsWithAuth(options);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Lists the tags you can put on partners. Filter by program, search by name, and page with cursors.
|
|
16
|
+
*
|
|
17
|
+
* @param {ToltApi.ListPartnerTagsRequest} request
|
|
18
|
+
* @param {PartnerTagsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
19
|
+
*
|
|
20
|
+
* @throws {@link ToltApi.BadRequestError}
|
|
21
|
+
* @throws {@link ToltApi.UnauthorizedError}
|
|
22
|
+
* @throws {@link ToltApi.ContentTooLargeError}
|
|
23
|
+
* @throws {@link ToltApi.TooManyRequestsError}
|
|
24
|
+
* @throws {@link errors.ToltApiError}
|
|
25
|
+
* @throws {@link errors.ToltApiTimeoutError}
|
|
26
|
+
*
|
|
27
|
+
* @example
|
|
28
|
+
* await client.partnerTags.listPartnerTags()
|
|
29
|
+
*/
|
|
30
|
+
listPartnerTags(request = {}, requestOptions) {
|
|
31
|
+
return core.HttpResponsePromise.fromPromise(this.__listPartnerTags(request, requestOptions));
|
|
32
|
+
}
|
|
33
|
+
async __listPartnerTags(request = {}, requestOptions) {
|
|
34
|
+
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, search, } = request;
|
|
35
|
+
const _queryParams = {
|
|
36
|
+
limit,
|
|
37
|
+
order: order != null ? order : undefined,
|
|
38
|
+
sort: sort != null ? sort : undefined,
|
|
39
|
+
starting_after: startingAfter,
|
|
40
|
+
ending_before: endingBefore,
|
|
41
|
+
created_after: createdAfter != null ? createdAfter : undefined,
|
|
42
|
+
created_before: createdBefore != null ? createdBefore : undefined,
|
|
43
|
+
updated_after: updatedAfter != null ? updatedAfter : undefined,
|
|
44
|
+
updated_before: updatedBefore != null ? updatedBefore : undefined,
|
|
45
|
+
program_id: programId,
|
|
46
|
+
search,
|
|
47
|
+
};
|
|
48
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
49
|
+
const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
50
|
+
const _response = await core.fetcher({
|
|
51
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
52
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
53
|
+
environments.ToltApiEnvironment.Default, "v2/partner-tags"),
|
|
54
|
+
method: "GET",
|
|
55
|
+
headers: _headers,
|
|
56
|
+
queryString: core.url
|
|
57
|
+
.queryBuilder()
|
|
58
|
+
.addMany(_queryParams)
|
|
59
|
+
.mergeAdditional(requestOptions?.queryParams)
|
|
60
|
+
.build(),
|
|
61
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
62
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
63
|
+
abortSignal: requestOptions?.abortSignal,
|
|
64
|
+
fetchFn: this._options?.fetch,
|
|
65
|
+
logging: this._options.logging,
|
|
66
|
+
});
|
|
67
|
+
if (_response.ok) {
|
|
68
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
69
|
+
}
|
|
70
|
+
if (_response.error.reason === "status-code") {
|
|
71
|
+
switch (_response.error.statusCode) {
|
|
72
|
+
case 400:
|
|
73
|
+
throw new ToltApi.BadRequestError(_response.error.body, _response.rawResponse);
|
|
74
|
+
case 401:
|
|
75
|
+
throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
76
|
+
case 413:
|
|
77
|
+
throw new ToltApi.ContentTooLargeError(_response.error.body, _response.rawResponse);
|
|
78
|
+
case 429:
|
|
79
|
+
throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
80
|
+
default:
|
|
81
|
+
throw new errors.ToltApiError({
|
|
82
|
+
statusCode: _response.error.statusCode,
|
|
83
|
+
body: _response.error.body,
|
|
84
|
+
rawResponse: _response.rawResponse,
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v2/partner-tags");
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Creates a tag in a program. Put it on partners with POST /v2/partners/{id}/tags.
|
|
92
|
+
*
|
|
93
|
+
* @param {ToltApi.CreatePartnerTagRequest} request
|
|
94
|
+
* @param {PartnerTagsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
95
|
+
*
|
|
96
|
+
* @throws {@link ToltApi.BadRequestError}
|
|
97
|
+
* @throws {@link ToltApi.UnauthorizedError}
|
|
98
|
+
* @throws {@link ToltApi.ConflictError}
|
|
99
|
+
* @throws {@link ToltApi.ContentTooLargeError}
|
|
100
|
+
* @throws {@link ToltApi.TooManyRequestsError}
|
|
101
|
+
* @throws {@link errors.ToltApiError}
|
|
102
|
+
* @throws {@link errors.ToltApiTimeoutError}
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* await client.partnerTags.createPartnerTag({
|
|
106
|
+
* program_id: "prg_T6z8aRW3XCmvFWP972RKxpAd",
|
|
107
|
+
* name: "VIP",
|
|
108
|
+
* color: "#2457D6"
|
|
109
|
+
* })
|
|
110
|
+
*/
|
|
111
|
+
createPartnerTag(request, requestOptions) {
|
|
112
|
+
return core.HttpResponsePromise.fromPromise(this.__createPartnerTag(request, requestOptions));
|
|
113
|
+
}
|
|
114
|
+
async __createPartnerTag(request, requestOptions) {
|
|
115
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
116
|
+
const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
117
|
+
const _response = await core.fetcher({
|
|
118
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
119
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
120
|
+
environments.ToltApiEnvironment.Default, "v2/partner-tags"),
|
|
121
|
+
method: "POST",
|
|
122
|
+
headers: _headers,
|
|
123
|
+
contentType: "application/json",
|
|
124
|
+
queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
125
|
+
requestType: "json",
|
|
126
|
+
body: mergeAdditionalBodyParameters(request, requestOptions?.additionalBodyParameters),
|
|
127
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
128
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
129
|
+
abortSignal: requestOptions?.abortSignal,
|
|
130
|
+
fetchFn: this._options?.fetch,
|
|
131
|
+
logging: this._options.logging,
|
|
132
|
+
});
|
|
133
|
+
if (_response.ok) {
|
|
134
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
135
|
+
}
|
|
136
|
+
if (_response.error.reason === "status-code") {
|
|
137
|
+
switch (_response.error.statusCode) {
|
|
138
|
+
case 400:
|
|
139
|
+
throw new ToltApi.BadRequestError(_response.error.body, _response.rawResponse);
|
|
140
|
+
case 401:
|
|
141
|
+
throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
142
|
+
case 409:
|
|
143
|
+
throw new ToltApi.ConflictError(_response.error.body, _response.rawResponse);
|
|
144
|
+
case 413:
|
|
145
|
+
throw new ToltApi.ContentTooLargeError(_response.error.body, _response.rawResponse);
|
|
146
|
+
case 429:
|
|
147
|
+
throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
148
|
+
default:
|
|
149
|
+
throw new errors.ToltApiError({
|
|
150
|
+
statusCode: _response.error.statusCode,
|
|
151
|
+
body: _response.error.body,
|
|
152
|
+
rawResponse: _response.rawResponse,
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v2/partner-tags");
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Gets a partner tag by ID, with how many partners have it.
|
|
160
|
+
*
|
|
161
|
+
* @param {ToltApi.GetPartnerTagRequest} request
|
|
162
|
+
* @param {PartnerTagsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
163
|
+
*
|
|
164
|
+
* @throws {@link ToltApi.UnauthorizedError}
|
|
165
|
+
* @throws {@link ToltApi.NotFoundError}
|
|
166
|
+
* @throws {@link ToltApi.ContentTooLargeError}
|
|
167
|
+
* @throws {@link ToltApi.TooManyRequestsError}
|
|
168
|
+
* @throws {@link errors.ToltApiError}
|
|
169
|
+
* @throws {@link errors.ToltApiTimeoutError}
|
|
170
|
+
*
|
|
171
|
+
* @example
|
|
172
|
+
* await client.partnerTags.getPartnerTag({
|
|
173
|
+
* id: "ptag_zDEcdqNuNBPcokarWxBnk9gB"
|
|
174
|
+
* })
|
|
175
|
+
*/
|
|
176
|
+
getPartnerTag(request, requestOptions) {
|
|
177
|
+
return core.HttpResponsePromise.fromPromise(this.__getPartnerTag(request, requestOptions));
|
|
178
|
+
}
|
|
179
|
+
async __getPartnerTag(request, requestOptions) {
|
|
180
|
+
const { id } = request;
|
|
181
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
182
|
+
const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
183
|
+
const _response = await core.fetcher({
|
|
184
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
185
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
186
|
+
environments.ToltApiEnvironment.Default, `v2/partner-tags/${core.url.encodePathParam(id, errors.ToltApiError)}`),
|
|
187
|
+
method: "GET",
|
|
188
|
+
headers: _headers,
|
|
189
|
+
queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
190
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
191
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
192
|
+
abortSignal: requestOptions?.abortSignal,
|
|
193
|
+
fetchFn: this._options?.fetch,
|
|
194
|
+
logging: this._options.logging,
|
|
195
|
+
});
|
|
196
|
+
if (_response.ok) {
|
|
197
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
198
|
+
}
|
|
199
|
+
if (_response.error.reason === "status-code") {
|
|
200
|
+
switch (_response.error.statusCode) {
|
|
201
|
+
case 401:
|
|
202
|
+
throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
203
|
+
case 404:
|
|
204
|
+
throw new ToltApi.NotFoundError(_response.error.body, _response.rawResponse);
|
|
205
|
+
case 413:
|
|
206
|
+
throw new ToltApi.ContentTooLargeError(_response.error.body, _response.rawResponse);
|
|
207
|
+
case 429:
|
|
208
|
+
throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
209
|
+
default:
|
|
210
|
+
throw new errors.ToltApiError({
|
|
211
|
+
statusCode: _response.error.statusCode,
|
|
212
|
+
body: _response.error.body,
|
|
213
|
+
rawResponse: _response.rawResponse,
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v2/partner-tags/{id}");
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Renames a tag or changes its color. Partners who have the tag keep it.
|
|
221
|
+
*
|
|
222
|
+
* @param {ToltApi.UpdatePartnerTagRequest} request
|
|
223
|
+
* @param {PartnerTagsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
224
|
+
*
|
|
225
|
+
* @throws {@link ToltApi.BadRequestError}
|
|
226
|
+
* @throws {@link ToltApi.UnauthorizedError}
|
|
227
|
+
* @throws {@link ToltApi.NotFoundError}
|
|
228
|
+
* @throws {@link ToltApi.ConflictError}
|
|
229
|
+
* @throws {@link ToltApi.ContentTooLargeError}
|
|
230
|
+
* @throws {@link ToltApi.TooManyRequestsError}
|
|
231
|
+
* @throws {@link errors.ToltApiError}
|
|
232
|
+
* @throws {@link errors.ToltApiTimeoutError}
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* await client.partnerTags.updatePartnerTag({
|
|
236
|
+
* id: "ptag_zDEcdqNuNBPcokarWxBnk9gB",
|
|
237
|
+
* name: "VIP",
|
|
238
|
+
* color: "#2457D6"
|
|
239
|
+
* })
|
|
240
|
+
*/
|
|
241
|
+
updatePartnerTag(request, requestOptions) {
|
|
242
|
+
return core.HttpResponsePromise.fromPromise(this.__updatePartnerTag(request, requestOptions));
|
|
243
|
+
}
|
|
244
|
+
async __updatePartnerTag(request, requestOptions) {
|
|
245
|
+
const { id, ..._body } = request;
|
|
246
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
247
|
+
const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
248
|
+
const _response = await core.fetcher({
|
|
249
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
250
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
251
|
+
environments.ToltApiEnvironment.Default, `v2/partner-tags/${core.url.encodePathParam(id, errors.ToltApiError)}`),
|
|
252
|
+
method: "PUT",
|
|
253
|
+
headers: _headers,
|
|
254
|
+
contentType: "application/json",
|
|
255
|
+
queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
256
|
+
requestType: "json",
|
|
257
|
+
body: mergeAdditionalBodyParameters(_body, requestOptions?.additionalBodyParameters),
|
|
258
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
259
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
260
|
+
abortSignal: requestOptions?.abortSignal,
|
|
261
|
+
fetchFn: this._options?.fetch,
|
|
262
|
+
logging: this._options.logging,
|
|
263
|
+
});
|
|
264
|
+
if (_response.ok) {
|
|
265
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
266
|
+
}
|
|
267
|
+
if (_response.error.reason === "status-code") {
|
|
268
|
+
switch (_response.error.statusCode) {
|
|
269
|
+
case 400:
|
|
270
|
+
throw new ToltApi.BadRequestError(_response.error.body, _response.rawResponse);
|
|
271
|
+
case 401:
|
|
272
|
+
throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
273
|
+
case 404:
|
|
274
|
+
throw new ToltApi.NotFoundError(_response.error.body, _response.rawResponse);
|
|
275
|
+
case 409:
|
|
276
|
+
throw new ToltApi.ConflictError(_response.error.body, _response.rawResponse);
|
|
277
|
+
case 413:
|
|
278
|
+
throw new ToltApi.ContentTooLargeError(_response.error.body, _response.rawResponse);
|
|
279
|
+
case 429:
|
|
280
|
+
throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
281
|
+
default:
|
|
282
|
+
throw new errors.ToltApiError({
|
|
283
|
+
statusCode: _response.error.statusCode,
|
|
284
|
+
body: _response.error.body,
|
|
285
|
+
rawResponse: _response.rawResponse,
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/v2/partner-tags/{id}");
|
|
290
|
+
}
|
|
291
|
+
/**
|
|
292
|
+
* Deletes a tag and removes it from every partner who has it.
|
|
293
|
+
*
|
|
294
|
+
* @param {ToltApi.DeletePartnerTagRequest} request
|
|
295
|
+
* @param {PartnerTagsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
296
|
+
*
|
|
297
|
+
* @throws {@link ToltApi.UnauthorizedError}
|
|
298
|
+
* @throws {@link ToltApi.NotFoundError}
|
|
299
|
+
* @throws {@link ToltApi.ContentTooLargeError}
|
|
300
|
+
* @throws {@link ToltApi.TooManyRequestsError}
|
|
301
|
+
* @throws {@link errors.ToltApiError}
|
|
302
|
+
* @throws {@link errors.ToltApiTimeoutError}
|
|
303
|
+
*
|
|
304
|
+
* @example
|
|
305
|
+
* await client.partnerTags.deletePartnerTag({
|
|
306
|
+
* id: "ptag_zDEcdqNuNBPcokarWxBnk9gB"
|
|
307
|
+
* })
|
|
308
|
+
*/
|
|
309
|
+
deletePartnerTag(request, requestOptions) {
|
|
310
|
+
return core.HttpResponsePromise.fromPromise(this.__deletePartnerTag(request, requestOptions));
|
|
311
|
+
}
|
|
312
|
+
async __deletePartnerTag(request, requestOptions) {
|
|
313
|
+
const { id } = request;
|
|
314
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
315
|
+
const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
316
|
+
const _response = await core.fetcher({
|
|
317
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
318
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
319
|
+
environments.ToltApiEnvironment.Default, `v2/partner-tags/${core.url.encodePathParam(id, errors.ToltApiError)}`),
|
|
320
|
+
method: "DELETE",
|
|
321
|
+
headers: _headers,
|
|
322
|
+
queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
323
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
324
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
325
|
+
abortSignal: requestOptions?.abortSignal,
|
|
326
|
+
fetchFn: this._options?.fetch,
|
|
327
|
+
logging: this._options.logging,
|
|
328
|
+
});
|
|
329
|
+
if (_response.ok) {
|
|
330
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
331
|
+
}
|
|
332
|
+
if (_response.error.reason === "status-code") {
|
|
333
|
+
switch (_response.error.statusCode) {
|
|
334
|
+
case 401:
|
|
335
|
+
throw new ToltApi.UnauthorizedError(_response.error.body, _response.rawResponse);
|
|
336
|
+
case 404:
|
|
337
|
+
throw new ToltApi.NotFoundError(_response.error.body, _response.rawResponse);
|
|
338
|
+
case 413:
|
|
339
|
+
throw new ToltApi.ContentTooLargeError(_response.error.body, _response.rawResponse);
|
|
340
|
+
case 429:
|
|
341
|
+
throw new ToltApi.TooManyRequestsError(_response.error.body, _response.rawResponse);
|
|
342
|
+
default:
|
|
343
|
+
throw new errors.ToltApiError({
|
|
344
|
+
statusCode: _response.error.statusCode,
|
|
345
|
+
body: _response.error.body,
|
|
346
|
+
rawResponse: _response.rawResponse,
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/v2/partner-tags/{id}");
|
|
351
|
+
}
|
|
352
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests/index.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests/index.js";
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @example
|
|
3
|
+
* {
|
|
4
|
+
* program_id: "prg_T6z8aRW3XCmvFWP972RKxpAd",
|
|
5
|
+
* name: "VIP",
|
|
6
|
+
* color: "#2457D6"
|
|
7
|
+
* }
|
|
8
|
+
*/
|
|
9
|
+
export interface CreatePartnerTagRequest {
|
|
10
|
+
/** Id of the program the tag belongs to (prg_...), as returned when listing programs. Only partners in that program can have the tag. */
|
|
11
|
+
program_id: string;
|
|
12
|
+
/** Label shown on the partner in the dashboard, up to 50 characters. A program cannot have two tags with the same name, ignoring case. */
|
|
13
|
+
name: string;
|
|
14
|
+
/** Color of the tag in the dashboard, as a hex code like #2457D6. Defaults to one of the dashboard's tag colors. */
|
|
15
|
+
color?: string;
|
|
16
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type * as ToltApi from "../../../../index.js";
|
|
2
|
+
/**
|
|
3
|
+
* @example
|
|
4
|
+
* {}
|
|
5
|
+
*/
|
|
6
|
+
export interface ListPartnerTagsRequest {
|
|
7
|
+
/** How many rows to return in one page. */
|
|
8
|
+
limit?: number;
|
|
9
|
+
/** Ranking direction: desc puts the most recently created or updated rows first. */
|
|
10
|
+
order?: ToltApi.ListPartnerTagsRequestOrder;
|
|
11
|
+
/** Timestamp to order and page by: created_at follows creation order, updated_at follows each item's most recent change. */
|
|
12
|
+
sort?: ToltApi.ListPartnerTagsRequestSort;
|
|
13
|
+
/** 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. */
|
|
14
|
+
starting_after?: string;
|
|
15
|
+
/** 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. */
|
|
16
|
+
ending_before?: string;
|
|
17
|
+
/** Start of a window on when items were created: items created at this time or later are included, for example 2026-01-01T00:00:00Z. Leave it out for no lower bound. */
|
|
18
|
+
created_after?: string;
|
|
19
|
+
/** End of a window on when items were created: only items created before this time are included. Leave it out for no upper bound. */
|
|
20
|
+
created_before?: string;
|
|
21
|
+
/** Only items last changed at or after this moment; with sort=updated_at, use it to fetch what changed since a previous sync. */
|
|
22
|
+
updated_after?: string;
|
|
23
|
+
/** Only items last changed before this moment; pair it with updated_after to fetch what changed in a period. */
|
|
24
|
+
updated_before?: string;
|
|
25
|
+
/** Limit to one program, by its id (prg_...) as returned when listing programs. */
|
|
26
|
+
program_id?: string;
|
|
27
|
+
/** Text matched anywhere in the tag name, ignoring case. */
|
|
28
|
+
search?: string;
|
|
29
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @example
|
|
3
|
+
* {
|
|
4
|
+
* id: "ptag_zDEcdqNuNBPcokarWxBnk9gB",
|
|
5
|
+
* name: "VIP",
|
|
6
|
+
* color: "#2457D6"
|
|
7
|
+
* }
|
|
8
|
+
*/
|
|
9
|
+
export interface UpdatePartnerTagRequest {
|
|
10
|
+
id: string;
|
|
11
|
+
/** Label shown on the partner in the dashboard, up to 50 characters. A program cannot have two tags with the same name, ignoring case. */
|
|
12
|
+
name?: string;
|
|
13
|
+
/** Color of the tag in the dashboard, as a hex code like #2457D6. */
|
|
14
|
+
color?: string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { CreatePartnerTagRequest } from "./CreatePartnerTagRequest.js";
|
|
2
|
+
export type { DeletePartnerTagRequest } from "./DeletePartnerTagRequest.js";
|
|
3
|
+
export type { GetPartnerTagRequest } from "./GetPartnerTagRequest.js";
|
|
4
|
+
export type { ListPartnerTagsRequest } from "./ListPartnerTagsRequest.js";
|
|
5
|
+
export type { UpdatePartnerTagRequest } from "./UpdatePartnerTagRequest.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Ranking direction: desc puts the most recently created or updated rows first. */
|
|
2
|
+
export declare const ListPartnerTagsRequestOrder: {
|
|
3
|
+
readonly Asc: "asc";
|
|
4
|
+
readonly Desc: "desc";
|
|
5
|
+
};
|
|
6
|
+
export type ListPartnerTagsRequestOrder = (typeof ListPartnerTagsRequestOrder)[keyof typeof ListPartnerTagsRequestOrder];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Timestamp to order and page by: created_at follows creation order, updated_at follows each item's most recent change. */
|
|
2
|
+
export declare const ListPartnerTagsRequestSort: {
|
|
3
|
+
readonly CreatedAt: "created_at";
|
|
4
|
+
readonly UpdatedAt: "updated_at";
|
|
5
|
+
};
|
|
6
|
+
export type ListPartnerTagsRequestSort = (typeof ListPartnerTagsRequestSort)[keyof typeof ListPartnerTagsRequestSort];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
/** Timestamp to order and page by: created_at follows creation order, updated_at follows each item's most recent change. */
|
|
3
|
+
export const ListPartnerTagsRequestSort = {
|
|
4
|
+
CreatedAt: "created_at",
|
|
5
|
+
UpdatedAt: "updated_at",
|
|
6
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type * as ToltApi from "../../../index.js";
|
|
2
|
+
export interface ListPartnerTagsResponse {
|
|
3
|
+
success: boolean;
|
|
4
|
+
message: string;
|
|
5
|
+
data: ToltApi.PartnerTag[];
|
|
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;
|
|
11
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./CreatePartnerTagResponse.js";
|
|
2
|
+
export * from "./DeletePartnerTagResponse.js";
|
|
3
|
+
export * from "./GetPartnerTagResponse.js";
|
|
4
|
+
export * from "./ListPartnerTagsRequestOrder.js";
|
|
5
|
+
export * from "./ListPartnerTagsRequestSort.js";
|
|
6
|
+
export * from "./ListPartnerTagsResponse.js";
|
|
7
|
+
export * from "./UpdatePartnerTagResponse.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./CreatePartnerTagResponse.js";
|
|
2
|
+
export * from "./DeletePartnerTagResponse.js";
|
|
3
|
+
export * from "./GetPartnerTagResponse.js";
|
|
4
|
+
export * from "./ListPartnerTagsRequestOrder.js";
|
|
5
|
+
export * from "./ListPartnerTagsRequestSort.js";
|
|
6
|
+
export * from "./ListPartnerTagsResponse.js";
|
|
7
|
+
export * from "./UpdatePartnerTagResponse.js";
|