priceos 1.0.26 → 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/README.md +7 -7
- package/dist/{chunk-VKNB5K6D.js → chunk-M6XZYMJ4.js} +407 -112
- package/dist/chunk-M6XZYMJ4.js.map +1 -0
- package/dist/client.d.ts +16 -1
- package/dist/embed/pricing-table.global.js +66 -8
- package/dist/gen/openapi.d.ts +2331 -691
- package/dist/index.cjs +406 -111
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/next.cjs +508 -188
- package/dist/next.cjs.map +1 -1
- package/dist/next.d.ts +10 -5
- package/dist/next.js +103 -78
- package/dist/next.js.map +1 -1
- package/dist/react.cjs +488 -155
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.ts +14 -12
- package/dist/react.js +488 -155
- package/dist/react.js.map +1 -1
- package/dist/types.d.ts +27 -7
- package/package.json +6 -1
- package/dist/chunk-VKNB5K6D.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) {
|
|
@@ -301,15 +390,25 @@ var PriceOS = class {
|
|
|
301
390
|
});
|
|
302
391
|
},
|
|
303
392
|
createCheckout: async (customerId, input) => {
|
|
304
|
-
const { data, error, response } = await this.client.POST(
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
393
|
+
const { data, error, response } = await this.client.POST(
|
|
394
|
+
"/v1/customers/{customerId}/checkout",
|
|
395
|
+
{
|
|
396
|
+
params: { path: { customerId }, header: this.header },
|
|
397
|
+
body: input
|
|
398
|
+
}
|
|
399
|
+
);
|
|
308
400
|
if (error) {
|
|
309
|
-
throwRequestError(
|
|
401
|
+
throwRequestError(
|
|
402
|
+
this.log,
|
|
403
|
+
error,
|
|
404
|
+
response,
|
|
405
|
+
"POST /v1/customers/{customerId}/checkout"
|
|
406
|
+
);
|
|
310
407
|
}
|
|
311
408
|
if (response && !response.ok) {
|
|
312
|
-
throw new PriceOSError(response.statusText || "Request failed", {
|
|
409
|
+
throw new PriceOSError(response.statusText || "Request failed", {
|
|
410
|
+
status: response.status
|
|
411
|
+
});
|
|
313
412
|
}
|
|
314
413
|
const result = resolveUrlResponse(data, response);
|
|
315
414
|
if (result) {
|
|
@@ -325,10 +424,14 @@ var PriceOS = class {
|
|
|
325
424
|
}
|
|
326
425
|
};
|
|
327
426
|
const getFeatureAccessForCustomer = async (customerId) => {
|
|
328
|
-
const { data, error, response } = await this.client.GET(
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
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");
|
|
332
435
|
return data;
|
|
333
436
|
};
|
|
334
437
|
async function getFeatureAccess(customerId, featureKey) {
|
|
@@ -337,14 +440,137 @@ var PriceOS = class {
|
|
|
337
440
|
return featureAccess[featureKey];
|
|
338
441
|
}
|
|
339
442
|
this.features = {
|
|
340
|
-
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
|
+
}
|
|
341
517
|
};
|
|
342
518
|
this.products = {
|
|
343
519
|
list: async () => {
|
|
344
|
-
const { data, error, response } = await this.client.GET(
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
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");
|
|
528
|
+
return data;
|
|
529
|
+
},
|
|
530
|
+
get: async (productKey) => {
|
|
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}");
|
|
348
574
|
return data;
|
|
349
575
|
}
|
|
350
576
|
};
|
|
@@ -354,22 +580,39 @@ var PriceOS = class {
|
|
|
354
580
|
...typeof input.customerId === "string" ? { customerId: input.customerId } : {},
|
|
355
581
|
...typeof input.pricingTableKey === "string" ? { pricingTableKey: input.pricingTableKey } : {}
|
|
356
582
|
};
|
|
357
|
-
const { data, error, response } = await this.client.GET(
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
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");
|
|
361
591
|
return data;
|
|
362
592
|
}
|
|
363
593
|
};
|
|
364
594
|
this.checkout = {
|
|
365
595
|
create: async (input) => {
|
|
366
|
-
const {
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
596
|
+
const { customerId, ...body } = input;
|
|
597
|
+
const { data, error, response } = await this.client.POST(
|
|
598
|
+
"/v1/customers/{customerId}/checkout",
|
|
599
|
+
{
|
|
600
|
+
params: { path: { customerId }, header: this.header },
|
|
601
|
+
body
|
|
602
|
+
}
|
|
603
|
+
);
|
|
604
|
+
if (error) {
|
|
605
|
+
throwRequestError(
|
|
606
|
+
this.log,
|
|
607
|
+
error,
|
|
608
|
+
response,
|
|
609
|
+
"POST /v1/customers/{customerId}/checkout"
|
|
610
|
+
);
|
|
611
|
+
}
|
|
371
612
|
if (response && !response.ok) {
|
|
372
|
-
throw new PriceOSError(response.statusText || "Request failed", {
|
|
613
|
+
throw new PriceOSError(response.statusText || "Request failed", {
|
|
614
|
+
status: response.status
|
|
615
|
+
});
|
|
373
616
|
}
|
|
374
617
|
const result = resolveUrlResponse(data, response);
|
|
375
618
|
if (result) {
|
|
@@ -386,34 +629,57 @@ var PriceOS = class {
|
|
|
386
629
|
};
|
|
387
630
|
this.bonuses = {
|
|
388
631
|
create: async (input) => {
|
|
389
|
-
const { data, error, response } = await this.client.POST(
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
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");
|
|
394
641
|
return data;
|
|
395
642
|
},
|
|
396
643
|
list: async (input) => {
|
|
397
644
|
const { data, error, response } = await this.client.GET("/v1/bonuses", {
|
|
398
645
|
params: { header: this.header, query: input }
|
|
399
646
|
});
|
|
400
|
-
if (error)
|
|
647
|
+
if (error)
|
|
648
|
+
throwRequestError(this.log, error, response, "GET /v1/bonuses");
|
|
401
649
|
return data;
|
|
402
650
|
},
|
|
403
651
|
update: async (input) => {
|
|
404
652
|
const { bonusId, ...body } = input;
|
|
405
|
-
const { data, error, response } = await this.client.PUT(
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
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
|
+
);
|
|
410
667
|
return data;
|
|
411
668
|
},
|
|
412
669
|
delete: async (bonusId) => {
|
|
413
|
-
const { data, error, response } = await this.client.DELETE(
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
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
|
+
);
|
|
417
683
|
return data;
|
|
418
684
|
}
|
|
419
685
|
};
|
|
@@ -424,47 +690,68 @@ var PriceOS = class {
|
|
|
424
690
|
params: { header: this.header },
|
|
425
691
|
body
|
|
426
692
|
});
|
|
427
|
-
if (error)
|
|
693
|
+
if (error)
|
|
694
|
+
throwRequestError(this.log, error, response, "POST /v1/usage");
|
|
428
695
|
return data;
|
|
429
696
|
},
|
|
430
697
|
set: async (input) => {
|
|
431
698
|
const body = withEventKey(input);
|
|
432
|
-
const { data, error, response } = await this.client.POST(
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
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");
|
|
437
708
|
return data;
|
|
438
709
|
},
|
|
439
710
|
getEvent: async (eventId) => {
|
|
440
|
-
const { data, error, response } = await this.client.GET(
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
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}");
|
|
444
719
|
return data;
|
|
445
720
|
},
|
|
446
721
|
updateEvent: async (input) => {
|
|
447
722
|
const { id, ...body } = input;
|
|
448
|
-
const { data, error, response } = await this.client.PUT(
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
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}");
|
|
453
732
|
return data;
|
|
454
733
|
},
|
|
455
734
|
deleteEvent: async (eventId) => {
|
|
456
|
-
const { data, error, response } = await this.client.DELETE(
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
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}");
|
|
460
743
|
return data;
|
|
461
744
|
},
|
|
462
745
|
deleteEvents: async (input) => {
|
|
463
|
-
const { data, error, response } = await this.client.POST(
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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");
|
|
468
755
|
return data;
|
|
469
756
|
},
|
|
470
757
|
trackBatch: async (input) => {
|
|
@@ -472,19 +759,27 @@ var PriceOS = class {
|
|
|
472
759
|
...input,
|
|
473
760
|
events: input.events.map((event) => withEventKey(event))
|
|
474
761
|
};
|
|
475
|
-
const { data, error, response } = await this.client.POST(
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
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");
|
|
480
771
|
return data;
|
|
481
772
|
},
|
|
482
773
|
listEvents: async (input) => {
|
|
483
|
-
const { data, error, response } = await this.client.POST(
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
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");
|
|
488
783
|
return data;
|
|
489
784
|
}
|
|
490
785
|
};
|
|
@@ -495,4 +790,4 @@ export {
|
|
|
495
790
|
PriceOSError,
|
|
496
791
|
PriceOS
|
|
497
792
|
};
|
|
498
|
-
//# sourceMappingURL=chunk-
|
|
793
|
+
//# sourceMappingURL=chunk-M6XZYMJ4.js.map
|