priceos 1.0.27 → 1.0.30
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/dist/{chunk-HXCSQLYW.js → chunk-M6XZYMJ4.js} +387 -108
- package/dist/chunk-M6XZYMJ4.js.map +1 -0
- package/dist/client.d.ts +15 -1
- package/dist/embed/pricing-table.global.js +19 -19
- package/dist/gen/openapi.d.ts +1827 -447
- package/dist/index.cjs +386 -107
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/next.cjs +386 -107
- package/dist/next.cjs.map +1 -1
- package/dist/next.js +1 -1
- package/dist/react.cjs +88 -27
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +13 -11
- package/dist/react.js +88 -27
- package/dist/react.js.map +1 -1
- package/dist/types.d.ts +21 -5
- package/package.json +3 -1
- package/dist/chunk-HXCSQLYW.js.map +0 -1
|
@@ -62,7 +62,8 @@ var createLogger = (logLevel) => {
|
|
|
62
62
|
};
|
|
63
63
|
var getUpstreamSignal = (input, init) => {
|
|
64
64
|
if (init?.signal) return init.signal;
|
|
65
|
-
if (typeof Request !== "undefined" && input instanceof Request)
|
|
65
|
+
if (typeof Request !== "undefined" && input instanceof Request)
|
|
66
|
+
return input.signal;
|
|
66
67
|
return void 0;
|
|
67
68
|
};
|
|
68
69
|
var stripSignal = (init) => {
|
|
@@ -81,15 +82,27 @@ var prepareRetryRequest = async (input, init, log, method, url) => {
|
|
|
81
82
|
}
|
|
82
83
|
if (input.bodyUsed) {
|
|
83
84
|
log.warning("Request body already used; retries disabled", { method, url });
|
|
84
|
-
return {
|
|
85
|
+
return {
|
|
86
|
+
requestInput: input,
|
|
87
|
+
baseInit: stripSignal(init),
|
|
88
|
+
canRetry: false
|
|
89
|
+
};
|
|
85
90
|
}
|
|
86
91
|
let body = void 0;
|
|
87
92
|
if (method !== "GET" && method !== "HEAD") {
|
|
88
93
|
try {
|
|
89
94
|
body = await input.clone().arrayBuffer();
|
|
90
95
|
} catch (error) {
|
|
91
|
-
log.warning("Unable to clone request body; retries disabled", {
|
|
92
|
-
|
|
96
|
+
log.warning("Unable to clone request body; retries disabled", {
|
|
97
|
+
method,
|
|
98
|
+
url,
|
|
99
|
+
error
|
|
100
|
+
});
|
|
101
|
+
return {
|
|
102
|
+
requestInput: input,
|
|
103
|
+
baseInit: stripSignal(init),
|
|
104
|
+
canRetry: false
|
|
105
|
+
};
|
|
93
106
|
}
|
|
94
107
|
}
|
|
95
108
|
const headers = new Headers(input.headers);
|
|
@@ -98,12 +111,16 @@ var prepareRetryRequest = async (input, init, log, method, url) => {
|
|
|
98
111
|
};
|
|
99
112
|
var getErrorMessage = (error) => {
|
|
100
113
|
const maybeError = error;
|
|
101
|
-
if (maybeError && typeof maybeError.error === "string")
|
|
114
|
+
if (maybeError && typeof maybeError.error === "string")
|
|
115
|
+
return maybeError.error;
|
|
102
116
|
return "Request failed";
|
|
103
117
|
};
|
|
104
118
|
var throwRequestError = (log, error, response, context) => {
|
|
105
119
|
log.error("Request failed", { context, status: response?.status, error });
|
|
106
|
-
throw new PriceOSError(getErrorMessage(error), {
|
|
120
|
+
throw new PriceOSError(getErrorMessage(error), {
|
|
121
|
+
status: response?.status,
|
|
122
|
+
details: error
|
|
123
|
+
});
|
|
107
124
|
};
|
|
108
125
|
var resolveUrlResponse = (data, response) => {
|
|
109
126
|
if (data && typeof data === "object" && !Array.isArray(data)) {
|
|
@@ -134,9 +151,17 @@ var createRetryingFetch = (baseFetch, log) => {
|
|
|
134
151
|
);
|
|
135
152
|
let attempt = 0;
|
|
136
153
|
while (true) {
|
|
137
|
-
log.debug("Request attempt", {
|
|
154
|
+
log.debug("Request attempt", {
|
|
155
|
+
method,
|
|
156
|
+
url,
|
|
157
|
+
attempt: attempt + 1,
|
|
158
|
+
maxRetries: MAX_RETRIES
|
|
159
|
+
});
|
|
138
160
|
const controller = new AbortController();
|
|
139
|
-
const timeoutId = setTimeout(
|
|
161
|
+
const timeoutId = setTimeout(
|
|
162
|
+
() => controller.abort(),
|
|
163
|
+
REQUEST_TIMEOUT_MS
|
|
164
|
+
);
|
|
140
165
|
let removeAbortListener = null;
|
|
141
166
|
if (upstreamSignal) {
|
|
142
167
|
if (upstreamSignal.aborted) {
|
|
@@ -160,11 +185,18 @@ var createRetryingFetch = (baseFetch, log) => {
|
|
|
160
185
|
retryAfter
|
|
161
186
|
});
|
|
162
187
|
if (!canRetry) {
|
|
163
|
-
log.warning("Skipping retry because request body is not replayable", {
|
|
188
|
+
log.warning("Skipping retry because request body is not replayable", {
|
|
189
|
+
method,
|
|
190
|
+
url
|
|
191
|
+
});
|
|
164
192
|
return response;
|
|
165
193
|
}
|
|
166
194
|
if (attempt >= MAX_RETRIES) {
|
|
167
|
-
log.error("Rate limit retries exhausted", {
|
|
195
|
+
log.error("Rate limit retries exhausted", {
|
|
196
|
+
method,
|
|
197
|
+
url,
|
|
198
|
+
attempts: attempt + 1
|
|
199
|
+
});
|
|
168
200
|
return response;
|
|
169
201
|
}
|
|
170
202
|
const delayMs = getRetryDelayMs(attempt + 1);
|
|
@@ -181,7 +213,11 @@ var createRetryingFetch = (baseFetch, log) => {
|
|
|
181
213
|
if (controller.signal.aborted) {
|
|
182
214
|
const abortedByCaller = upstreamSignal?.aborted ?? false;
|
|
183
215
|
if (abortedByCaller) {
|
|
184
|
-
log.warning("Request aborted by caller", {
|
|
216
|
+
log.warning("Request aborted by caller", {
|
|
217
|
+
method,
|
|
218
|
+
url,
|
|
219
|
+
attempt: attempt + 1
|
|
220
|
+
});
|
|
185
221
|
} else {
|
|
186
222
|
log.error("Request timed out", {
|
|
187
223
|
method,
|
|
@@ -191,7 +227,12 @@ var createRetryingFetch = (baseFetch, log) => {
|
|
|
191
227
|
});
|
|
192
228
|
}
|
|
193
229
|
} else {
|
|
194
|
-
log.error("Request failed", {
|
|
230
|
+
log.error("Request failed", {
|
|
231
|
+
method,
|
|
232
|
+
url,
|
|
233
|
+
attempt: attempt + 1,
|
|
234
|
+
error
|
|
235
|
+
});
|
|
195
236
|
}
|
|
196
237
|
throw error;
|
|
197
238
|
} finally {
|
|
@@ -218,6 +259,7 @@ var PriceOS = class {
|
|
|
218
259
|
customers;
|
|
219
260
|
features;
|
|
220
261
|
products;
|
|
262
|
+
customProducts;
|
|
221
263
|
pricing;
|
|
222
264
|
checkout;
|
|
223
265
|
bonuses;
|
|
@@ -237,42 +279,82 @@ var PriceOS = class {
|
|
|
237
279
|
});
|
|
238
280
|
this.customers = {
|
|
239
281
|
get: async (customerId) => {
|
|
240
|
-
const { data, error, response } = await this.client.GET(
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
282
|
+
const { data, error, response } = await this.client.GET(
|
|
283
|
+
"/v1/customers/{customerId}",
|
|
284
|
+
{
|
|
285
|
+
params: { path: { customerId }, header: this.header }
|
|
286
|
+
}
|
|
287
|
+
);
|
|
288
|
+
if (error)
|
|
289
|
+
throwRequestError(
|
|
290
|
+
this.log,
|
|
291
|
+
error,
|
|
292
|
+
response,
|
|
293
|
+
"GET /v1/customers/{customerId}"
|
|
294
|
+
);
|
|
244
295
|
return data ?? null;
|
|
245
296
|
},
|
|
246
297
|
link: async (input) => {
|
|
247
|
-
const { data, error, response } = await this.client.POST(
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
298
|
+
const { data, error, response } = await this.client.POST(
|
|
299
|
+
"/v1/customers/link",
|
|
300
|
+
{
|
|
301
|
+
params: { header: this.header },
|
|
302
|
+
body: input
|
|
303
|
+
}
|
|
304
|
+
);
|
|
305
|
+
if (error)
|
|
306
|
+
throwRequestError(
|
|
307
|
+
this.log,
|
|
308
|
+
error,
|
|
309
|
+
response,
|
|
310
|
+
"POST /v1/customers/link"
|
|
311
|
+
);
|
|
252
312
|
return data ?? null;
|
|
253
313
|
},
|
|
254
314
|
create: async (input) => {
|
|
255
|
-
const { data, error, response } = await this.client.POST(
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
315
|
+
const { data, error, response } = await this.client.POST(
|
|
316
|
+
"/v1/customers",
|
|
317
|
+
{
|
|
318
|
+
params: { header: this.header },
|
|
319
|
+
body: input
|
|
320
|
+
}
|
|
321
|
+
);
|
|
322
|
+
if (error)
|
|
323
|
+
throwRequestError(this.log, error, response, "POST /v1/customers");
|
|
260
324
|
return data;
|
|
261
325
|
},
|
|
262
326
|
update: async (input) => {
|
|
263
327
|
const { customerId, ...body } = input;
|
|
264
|
-
const { data, error, response } = await this.client.PUT(
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
328
|
+
const { data, error, response } = await this.client.PUT(
|
|
329
|
+
"/v1/customers/{customerId}",
|
|
330
|
+
{
|
|
331
|
+
params: { path: { customerId }, header: this.header },
|
|
332
|
+
body
|
|
333
|
+
}
|
|
334
|
+
);
|
|
335
|
+
if (error)
|
|
336
|
+
throwRequestError(
|
|
337
|
+
this.log,
|
|
338
|
+
error,
|
|
339
|
+
response,
|
|
340
|
+
"PUT /v1/customers/{customerId}"
|
|
341
|
+
);
|
|
269
342
|
return data;
|
|
270
343
|
},
|
|
271
344
|
delete: async (customerId) => {
|
|
272
|
-
const { data, error, response } = await this.client.DELETE(
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
345
|
+
const { data, error, response } = await this.client.DELETE(
|
|
346
|
+
"/v1/customers/{customerId}",
|
|
347
|
+
{
|
|
348
|
+
params: { path: { customerId }, header: this.header }
|
|
349
|
+
}
|
|
350
|
+
);
|
|
351
|
+
if (error)
|
|
352
|
+
throwRequestError(
|
|
353
|
+
this.log,
|
|
354
|
+
error,
|
|
355
|
+
response,
|
|
356
|
+
"DELETE /v1/customers/{customerId}"
|
|
357
|
+
);
|
|
276
358
|
return data;
|
|
277
359
|
},
|
|
278
360
|
createPortal: async (customerId) => {
|
|
@@ -283,10 +365,17 @@ var PriceOS = class {
|
|
|
283
365
|
}
|
|
284
366
|
);
|
|
285
367
|
if (error) {
|
|
286
|
-
throwRequestError(
|
|
368
|
+
throwRequestError(
|
|
369
|
+
this.log,
|
|
370
|
+
error,
|
|
371
|
+
response,
|
|
372
|
+
"POST /v1/customers/{customerId}/customer_portal"
|
|
373
|
+
);
|
|
287
374
|
}
|
|
288
375
|
if (response && !response.ok) {
|
|
289
|
-
throw new PriceOSError(response.statusText || "Request failed", {
|
|
376
|
+
throw new PriceOSError(response.statusText || "Request failed", {
|
|
377
|
+
status: response.status
|
|
378
|
+
});
|
|
290
379
|
}
|
|
291
380
|
const result = resolveUrlResponse(data, response);
|
|
292
381
|
if (result) {
|
|
@@ -309,10 +398,17 @@ var PriceOS = class {
|
|
|
309
398
|
}
|
|
310
399
|
);
|
|
311
400
|
if (error) {
|
|
312
|
-
throwRequestError(
|
|
401
|
+
throwRequestError(
|
|
402
|
+
this.log,
|
|
403
|
+
error,
|
|
404
|
+
response,
|
|
405
|
+
"POST /v1/customers/{customerId}/checkout"
|
|
406
|
+
);
|
|
313
407
|
}
|
|
314
408
|
if (response && !response.ok) {
|
|
315
|
-
throw new PriceOSError(response.statusText || "Request failed", {
|
|
409
|
+
throw new PriceOSError(response.statusText || "Request failed", {
|
|
410
|
+
status: response.status
|
|
411
|
+
});
|
|
316
412
|
}
|
|
317
413
|
const result = resolveUrlResponse(data, response);
|
|
318
414
|
if (result) {
|
|
@@ -328,10 +424,14 @@ var PriceOS = class {
|
|
|
328
424
|
}
|
|
329
425
|
};
|
|
330
426
|
const getFeatureAccessForCustomer = async (customerId) => {
|
|
331
|
-
const { data, error, response } = await this.client.GET(
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
427
|
+
const { data, error, response } = await this.client.GET(
|
|
428
|
+
"/v1/feature-access",
|
|
429
|
+
{
|
|
430
|
+
params: { query: { customerId }, header: this.header }
|
|
431
|
+
}
|
|
432
|
+
);
|
|
433
|
+
if (error)
|
|
434
|
+
throwRequestError(this.log, error, response, "GET /v1/feature-access");
|
|
335
435
|
return data;
|
|
336
436
|
};
|
|
337
437
|
async function getFeatureAccess(customerId, featureKey) {
|
|
@@ -340,21 +440,137 @@ var PriceOS = class {
|
|
|
340
440
|
return featureAccess[featureKey];
|
|
341
441
|
}
|
|
342
442
|
this.features = {
|
|
343
|
-
getAccess: getFeatureAccess
|
|
443
|
+
getAccess: getFeatureAccess,
|
|
444
|
+
list: async () => {
|
|
445
|
+
const { data, error, response } = await this.client.GET(
|
|
446
|
+
"/v1/features",
|
|
447
|
+
{
|
|
448
|
+
params: { header: this.header }
|
|
449
|
+
}
|
|
450
|
+
);
|
|
451
|
+
if (error)
|
|
452
|
+
throwRequestError(this.log, error, response, "GET /v1/features");
|
|
453
|
+
return data;
|
|
454
|
+
},
|
|
455
|
+
create: async (input) => {
|
|
456
|
+
const { data, error, response } = await this.client.POST(
|
|
457
|
+
"/v1/features",
|
|
458
|
+
{
|
|
459
|
+
params: { header: this.header },
|
|
460
|
+
body: input
|
|
461
|
+
}
|
|
462
|
+
);
|
|
463
|
+
if (error)
|
|
464
|
+
throwRequestError(this.log, error, response, "POST /v1/features");
|
|
465
|
+
return data;
|
|
466
|
+
},
|
|
467
|
+
update: async (featureKey, input) => {
|
|
468
|
+
const { data, error, response } = await this.client.PUT(
|
|
469
|
+
"/v1/features/{featureKey}",
|
|
470
|
+
{
|
|
471
|
+
params: { path: { featureKey }, header: this.header },
|
|
472
|
+
body: input
|
|
473
|
+
}
|
|
474
|
+
);
|
|
475
|
+
if (error)
|
|
476
|
+
throwRequestError(
|
|
477
|
+
this.log,
|
|
478
|
+
error,
|
|
479
|
+
response,
|
|
480
|
+
"PUT /v1/features/{featureKey}"
|
|
481
|
+
);
|
|
482
|
+
return data;
|
|
483
|
+
},
|
|
484
|
+
archive: async (featureKey, archived = true) => {
|
|
485
|
+
const { data, error, response } = await this.client.POST(
|
|
486
|
+
"/v1/features/{featureKey}/archive",
|
|
487
|
+
{
|
|
488
|
+
params: { path: { featureKey }, header: this.header },
|
|
489
|
+
body: { archived }
|
|
490
|
+
}
|
|
491
|
+
);
|
|
492
|
+
if (error)
|
|
493
|
+
throwRequestError(
|
|
494
|
+
this.log,
|
|
495
|
+
error,
|
|
496
|
+
response,
|
|
497
|
+
"POST /v1/features/{featureKey}/archive"
|
|
498
|
+
);
|
|
499
|
+
return data;
|
|
500
|
+
},
|
|
501
|
+
delete: async (featureKey) => {
|
|
502
|
+
const { data, error, response } = await this.client.DELETE(
|
|
503
|
+
"/v1/features/{featureKey}",
|
|
504
|
+
{
|
|
505
|
+
params: { path: { featureKey }, header: this.header }
|
|
506
|
+
}
|
|
507
|
+
);
|
|
508
|
+
if (error)
|
|
509
|
+
throwRequestError(
|
|
510
|
+
this.log,
|
|
511
|
+
error,
|
|
512
|
+
response,
|
|
513
|
+
"DELETE /v1/features/{featureKey}"
|
|
514
|
+
);
|
|
515
|
+
return data;
|
|
516
|
+
}
|
|
344
517
|
};
|
|
345
518
|
this.products = {
|
|
346
519
|
list: async () => {
|
|
347
|
-
const { data, error, response } = await this.client.GET(
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
520
|
+
const { data, error, response } = await this.client.GET(
|
|
521
|
+
"/v1/products",
|
|
522
|
+
{
|
|
523
|
+
params: { header: this.header }
|
|
524
|
+
}
|
|
525
|
+
);
|
|
526
|
+
if (error)
|
|
527
|
+
throwRequestError(this.log, error, response, "GET /v1/products");
|
|
351
528
|
return data;
|
|
352
529
|
},
|
|
353
530
|
get: async (productKey) => {
|
|
354
|
-
const { data, error, response } = await this.client.GET(
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
531
|
+
const { data, error, response } = await this.client.GET(
|
|
532
|
+
"/v1/products/{productKey}",
|
|
533
|
+
{
|
|
534
|
+
params: { path: { productKey }, header: this.header }
|
|
535
|
+
}
|
|
536
|
+
);
|
|
537
|
+
if (error)
|
|
538
|
+
throwRequestError(
|
|
539
|
+
this.log,
|
|
540
|
+
error,
|
|
541
|
+
response,
|
|
542
|
+
"GET /v1/products/{productKey}"
|
|
543
|
+
);
|
|
544
|
+
return data;
|
|
545
|
+
},
|
|
546
|
+
setFeatureAccess: async (productKey, featureAccess) => {
|
|
547
|
+
const { data, error, response } = await this.client.PUT(
|
|
548
|
+
"/v1/products/{productKey}/feature-access",
|
|
549
|
+
{ params: { path: { productKey }, header: this.header }, body: { featureAccess } }
|
|
550
|
+
);
|
|
551
|
+
if (error) throwRequestError(this.log, error, response, "PUT /v1/products/{productKey}/feature-access");
|
|
552
|
+
return data;
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
this.customProducts = {
|
|
556
|
+
create: async (input) => {
|
|
557
|
+
const { data, error, response } = await this.client.POST("/v1/custom-products", { params: { header: this.header }, body: input });
|
|
558
|
+
if (error) throwRequestError(this.log, error, response, "POST /v1/custom-products");
|
|
559
|
+
return data;
|
|
560
|
+
},
|
|
561
|
+
update: async (productKey, input) => {
|
|
562
|
+
const { data, error, response } = await this.client.PUT("/v1/custom-products/{productKey}", { params: { path: { productKey }, header: this.header }, body: input });
|
|
563
|
+
if (error) throwRequestError(this.log, error, response, "PUT /v1/custom-products/{productKey}");
|
|
564
|
+
return data;
|
|
565
|
+
},
|
|
566
|
+
archive: async (productKey, archived = true) => {
|
|
567
|
+
const { data, error, response } = await this.client.POST("/v1/custom-products/{productKey}/archive", { params: { path: { productKey }, header: this.header }, body: { archived } });
|
|
568
|
+
if (error) throwRequestError(this.log, error, response, "POST /v1/custom-products/{productKey}/archive");
|
|
569
|
+
return data;
|
|
570
|
+
},
|
|
571
|
+
delete: async (productKey) => {
|
|
572
|
+
const { data, error, response } = await this.client.DELETE("/v1/custom-products/{productKey}", { params: { path: { productKey }, header: this.header } });
|
|
573
|
+
if (error) throwRequestError(this.log, error, response, "DELETE /v1/custom-products/{productKey}");
|
|
358
574
|
return data;
|
|
359
575
|
}
|
|
360
576
|
};
|
|
@@ -364,10 +580,14 @@ var PriceOS = class {
|
|
|
364
580
|
...typeof input.customerId === "string" ? { customerId: input.customerId } : {},
|
|
365
581
|
...typeof input.pricingTableKey === "string" ? { pricingTableKey: input.pricingTableKey } : {}
|
|
366
582
|
};
|
|
367
|
-
const { data, error, response } = await this.client.GET(
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
583
|
+
const { data, error, response } = await this.client.GET(
|
|
584
|
+
"/v1/pricing-table",
|
|
585
|
+
{
|
|
586
|
+
params: { query, header: this.header }
|
|
587
|
+
}
|
|
588
|
+
);
|
|
589
|
+
if (error)
|
|
590
|
+
throwRequestError(this.log, error, response, "GET /v1/pricing-table");
|
|
371
591
|
return data;
|
|
372
592
|
}
|
|
373
593
|
};
|
|
@@ -382,10 +602,17 @@ var PriceOS = class {
|
|
|
382
602
|
}
|
|
383
603
|
);
|
|
384
604
|
if (error) {
|
|
385
|
-
throwRequestError(
|
|
605
|
+
throwRequestError(
|
|
606
|
+
this.log,
|
|
607
|
+
error,
|
|
608
|
+
response,
|
|
609
|
+
"POST /v1/customers/{customerId}/checkout"
|
|
610
|
+
);
|
|
386
611
|
}
|
|
387
612
|
if (response && !response.ok) {
|
|
388
|
-
throw new PriceOSError(response.statusText || "Request failed", {
|
|
613
|
+
throw new PriceOSError(response.statusText || "Request failed", {
|
|
614
|
+
status: response.status
|
|
615
|
+
});
|
|
389
616
|
}
|
|
390
617
|
const result = resolveUrlResponse(data, response);
|
|
391
618
|
if (result) {
|
|
@@ -402,34 +629,57 @@ var PriceOS = class {
|
|
|
402
629
|
};
|
|
403
630
|
this.bonuses = {
|
|
404
631
|
create: async (input) => {
|
|
405
|
-
const { data, error, response } = await this.client.POST(
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
632
|
+
const { data, error, response } = await this.client.POST(
|
|
633
|
+
"/v1/bonuses",
|
|
634
|
+
{
|
|
635
|
+
params: { header: this.header },
|
|
636
|
+
body: input
|
|
637
|
+
}
|
|
638
|
+
);
|
|
639
|
+
if (error)
|
|
640
|
+
throwRequestError(this.log, error, response, "POST /v1/bonuses");
|
|
410
641
|
return data;
|
|
411
642
|
},
|
|
412
643
|
list: async (input) => {
|
|
413
644
|
const { data, error, response } = await this.client.GET("/v1/bonuses", {
|
|
414
645
|
params: { header: this.header, query: input }
|
|
415
646
|
});
|
|
416
|
-
if (error)
|
|
647
|
+
if (error)
|
|
648
|
+
throwRequestError(this.log, error, response, "GET /v1/bonuses");
|
|
417
649
|
return data;
|
|
418
650
|
},
|
|
419
651
|
update: async (input) => {
|
|
420
652
|
const { bonusId, ...body } = input;
|
|
421
|
-
const { data, error, response } = await this.client.PUT(
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
653
|
+
const { data, error, response } = await this.client.PUT(
|
|
654
|
+
"/v1/bonuses/{bonusId}",
|
|
655
|
+
{
|
|
656
|
+
params: { header: this.header, path: { bonusId } },
|
|
657
|
+
body
|
|
658
|
+
}
|
|
659
|
+
);
|
|
660
|
+
if (error)
|
|
661
|
+
throwRequestError(
|
|
662
|
+
this.log,
|
|
663
|
+
error,
|
|
664
|
+
response,
|
|
665
|
+
"PUT /v1/bonuses/{bonusId}"
|
|
666
|
+
);
|
|
426
667
|
return data;
|
|
427
668
|
},
|
|
428
669
|
delete: async (bonusId) => {
|
|
429
|
-
const { data, error, response } = await this.client.DELETE(
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
670
|
+
const { data, error, response } = await this.client.DELETE(
|
|
671
|
+
"/v1/bonuses/{bonusId}",
|
|
672
|
+
{
|
|
673
|
+
params: { header: this.header, path: { bonusId } }
|
|
674
|
+
}
|
|
675
|
+
);
|
|
676
|
+
if (error)
|
|
677
|
+
throwRequestError(
|
|
678
|
+
this.log,
|
|
679
|
+
error,
|
|
680
|
+
response,
|
|
681
|
+
"DELETE /v1/bonuses/{bonusId}"
|
|
682
|
+
);
|
|
433
683
|
return data;
|
|
434
684
|
}
|
|
435
685
|
};
|
|
@@ -440,47 +690,68 @@ var PriceOS = class {
|
|
|
440
690
|
params: { header: this.header },
|
|
441
691
|
body
|
|
442
692
|
});
|
|
443
|
-
if (error)
|
|
693
|
+
if (error)
|
|
694
|
+
throwRequestError(this.log, error, response, "POST /v1/usage");
|
|
444
695
|
return data;
|
|
445
696
|
},
|
|
446
697
|
set: async (input) => {
|
|
447
698
|
const body = withEventKey(input);
|
|
448
|
-
const { data, error, response } = await this.client.POST(
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
699
|
+
const { data, error, response } = await this.client.POST(
|
|
700
|
+
"/v1/usage/set",
|
|
701
|
+
{
|
|
702
|
+
params: { header: this.header },
|
|
703
|
+
body
|
|
704
|
+
}
|
|
705
|
+
);
|
|
706
|
+
if (error)
|
|
707
|
+
throwRequestError(this.log, error, response, "POST /v1/usage/set");
|
|
453
708
|
return data;
|
|
454
709
|
},
|
|
455
710
|
getEvent: async (eventId) => {
|
|
456
|
-
const { data, error, response } = await this.client.GET(
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
711
|
+
const { data, error, response } = await this.client.GET(
|
|
712
|
+
"/v1/usage/{id}",
|
|
713
|
+
{
|
|
714
|
+
params: { header: this.header, path: { id: eventId } }
|
|
715
|
+
}
|
|
716
|
+
);
|
|
717
|
+
if (error)
|
|
718
|
+
throwRequestError(this.log, error, response, "GET /v1/usage/{id}");
|
|
460
719
|
return data;
|
|
461
720
|
},
|
|
462
721
|
updateEvent: async (input) => {
|
|
463
722
|
const { id, ...body } = input;
|
|
464
|
-
const { data, error, response } = await this.client.PUT(
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
723
|
+
const { data, error, response } = await this.client.PUT(
|
|
724
|
+
"/v1/usage/{id}",
|
|
725
|
+
{
|
|
726
|
+
params: { header: this.header, path: { id } },
|
|
727
|
+
body
|
|
728
|
+
}
|
|
729
|
+
);
|
|
730
|
+
if (error)
|
|
731
|
+
throwRequestError(this.log, error, response, "PUT /v1/usage/{id}");
|
|
469
732
|
return data;
|
|
470
733
|
},
|
|
471
734
|
deleteEvent: async (eventId) => {
|
|
472
|
-
const { data, error, response } = await this.client.DELETE(
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
735
|
+
const { data, error, response } = await this.client.DELETE(
|
|
736
|
+
"/v1/usage/{id}",
|
|
737
|
+
{
|
|
738
|
+
params: { header: this.header, path: { id: eventId } }
|
|
739
|
+
}
|
|
740
|
+
);
|
|
741
|
+
if (error)
|
|
742
|
+
throwRequestError(this.log, error, response, "DELETE /v1/usage/{id}");
|
|
476
743
|
return data;
|
|
477
744
|
},
|
|
478
745
|
deleteEvents: async (input) => {
|
|
479
|
-
const { data, error, response } = await this.client.POST(
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
746
|
+
const { data, error, response } = await this.client.POST(
|
|
747
|
+
"/v1/usage/delete",
|
|
748
|
+
{
|
|
749
|
+
params: { header: this.header },
|
|
750
|
+
body: input
|
|
751
|
+
}
|
|
752
|
+
);
|
|
753
|
+
if (error)
|
|
754
|
+
throwRequestError(this.log, error, response, "POST /v1/usage/delete");
|
|
484
755
|
return data;
|
|
485
756
|
},
|
|
486
757
|
trackBatch: async (input) => {
|
|
@@ -488,19 +759,27 @@ var PriceOS = class {
|
|
|
488
759
|
...input,
|
|
489
760
|
events: input.events.map((event) => withEventKey(event))
|
|
490
761
|
};
|
|
491
|
-
const { data, error, response } = await this.client.POST(
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
762
|
+
const { data, error, response } = await this.client.POST(
|
|
763
|
+
"/v1/usage/batch",
|
|
764
|
+
{
|
|
765
|
+
params: { header: this.header },
|
|
766
|
+
body
|
|
767
|
+
}
|
|
768
|
+
);
|
|
769
|
+
if (error)
|
|
770
|
+
throwRequestError(this.log, error, response, "POST /v1/usage/batch");
|
|
496
771
|
return data;
|
|
497
772
|
},
|
|
498
773
|
listEvents: async (input) => {
|
|
499
|
-
const { data, error, response } = await this.client.POST(
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
774
|
+
const { data, error, response } = await this.client.POST(
|
|
775
|
+
"/v1/usage/events",
|
|
776
|
+
{
|
|
777
|
+
params: { header: this.header },
|
|
778
|
+
body: input
|
|
779
|
+
}
|
|
780
|
+
);
|
|
781
|
+
if (error)
|
|
782
|
+
throwRequestError(this.log, error, response, "POST /v1/usage/events");
|
|
504
783
|
return data;
|
|
505
784
|
}
|
|
506
785
|
};
|
|
@@ -511,4 +790,4 @@ export {
|
|
|
511
790
|
PriceOSError,
|
|
512
791
|
PriceOS
|
|
513
792
|
};
|
|
514
|
-
//# sourceMappingURL=chunk-
|
|
793
|
+
//# sourceMappingURL=chunk-M6XZYMJ4.js.map
|