@paid-ai/paid-node 0.5.0-alpha2 → 0.5.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 +118 -36
- package/dist/cjs/Client.d.ts +35 -3
- package/dist/cjs/Client.js +57 -19
- package/dist/cjs/api/errors/InternalServerError.d.ts +9 -0
- package/dist/cjs/api/errors/InternalServerError.js +52 -0
- package/dist/cjs/api/errors/index.d.ts +1 -0
- package/dist/cjs/api/errors/index.js +1 -0
- package/dist/cjs/api/index.d.ts +1 -1
- package/dist/cjs/api/index.js +1 -1
- package/dist/cjs/api/resources/agents/client/Client.d.ts +16 -0
- package/dist/cjs/api/resources/agents/client/Client.js +16 -0
- package/dist/cjs/api/resources/customers/client/Client.d.ts +38 -0
- package/dist/cjs/api/resources/customers/client/Client.js +164 -0
- package/dist/cjs/api/resources/customers/client/requests/CustomerCreate.d.ts +2 -0
- package/dist/cjs/api/resources/customers/client/requests/CustomersGetCostsByExternalIdRequest.d.ts +30 -0
- package/dist/cjs/api/resources/customers/client/requests/CustomersGetUsageByExternalIdRequest.d.ts +30 -0
- package/dist/cjs/api/resources/customers/client/requests/CustomersGetUsageByExternalIdRequest.js +5 -0
- package/dist/cjs/api/resources/customers/client/requests/index.d.ts +2 -0
- package/dist/cjs/api/resources/index.d.ts +8 -1
- package/dist/cjs/api/resources/index.js +9 -2
- package/dist/cjs/api/resources/orders/client/requests/OrderCreate.d.ts +2 -0
- package/dist/cjs/api/resources/orders/resources/lines/client/Client.d.ts +0 -2
- package/dist/cjs/api/resources/orders/resources/lines/client/Client.js +0 -2
- package/dist/cjs/api/resources/orders/resources/lines/client/requests/LinesUpdateRequest.d.ts +0 -2
- package/dist/cjs/api/resources/plans/client/Client.d.ts +75 -0
- package/dist/cjs/api/resources/plans/client/Client.js +272 -0
- package/dist/cjs/api/resources/plans/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/plans/client/index.js +17 -0
- package/dist/cjs/api/resources/plans/client/requests/PlansGetUsageRequest.d.ts +35 -0
- package/dist/cjs/api/resources/plans/client/requests/PlansGetUsageRequest.js +5 -0
- package/dist/cjs/api/resources/plans/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/plans/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/plans/index.d.ts +1 -0
- package/dist/cjs/api/resources/plans/index.js +17 -0
- package/dist/cjs/api/resources/products/client/Client.d.ts +109 -0
- package/dist/cjs/api/resources/products/client/Client.js +470 -0
- package/dist/cjs/api/resources/products/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/products/client/index.js +17 -0
- package/dist/cjs/api/resources/products/client/requests/ProductCreate.d.ts +29 -0
- package/dist/cjs/api/resources/products/client/requests/ProductCreate.js +14 -0
- package/dist/cjs/api/resources/products/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/products/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/products/index.d.ts +1 -0
- package/dist/cjs/api/resources/products/index.js +17 -0
- package/dist/cjs/api/resources/traces/client/Client.d.ts +52 -0
- package/dist/cjs/api/resources/traces/client/Client.js +166 -0
- package/dist/cjs/api/resources/traces/client/index.d.ts +1 -0
- package/dist/cjs/api/resources/traces/client/index.js +17 -0
- package/dist/cjs/api/resources/traces/client/requests/GetTracesRequest.d.ts +50 -0
- package/dist/cjs/api/resources/traces/client/requests/GetTracesRequest.js +5 -0
- package/dist/cjs/api/resources/traces/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/resources/traces/client/requests/index.js +2 -0
- package/dist/cjs/api/resources/traces/index.d.ts +1 -0
- package/dist/cjs/api/resources/traces/index.js +17 -0
- package/dist/cjs/api/resources/usage/client/Client.d.ts +47 -0
- package/dist/cjs/api/resources/usage/client/Client.js +146 -0
- package/dist/cjs/api/resources/usage/client/requests/UsageCheckUsageRequest.d.ts +28 -0
- package/dist/cjs/api/resources/usage/client/requests/UsageCheckUsageRequest.js +5 -0
- package/dist/cjs/api/resources/usage/client/requests/UsageRecordBulkV2Request.d.ts +29 -0
- package/dist/cjs/api/resources/usage/client/requests/UsageRecordBulkV2Request.js +5 -0
- package/dist/cjs/api/resources/usage/client/requests/index.d.ts +2 -0
- package/dist/cjs/api/resources/usage/index.d.ts +1 -0
- package/dist/cjs/api/resources/usage/index.js +1 -0
- package/dist/cjs/api/resources/usage/types/UsageCheckUsageResponse.d.ts +17 -0
- package/dist/cjs/api/resources/usage/types/UsageCheckUsageResponse.js +5 -0
- package/dist/cjs/api/resources/usage/types/index.d.ts +1 -0
- package/dist/cjs/api/resources/usage/types/index.js +17 -0
- package/dist/cjs/api/types/CostAmount.d.ts +12 -0
- package/dist/cjs/api/types/CostAmount.js +5 -0
- package/dist/cjs/api/types/CostTrace.d.ts +22 -0
- package/dist/cjs/api/types/CostTrace.js +5 -0
- package/dist/cjs/api/types/CostTracesResponse.d.ts +11 -0
- package/dist/cjs/api/types/CostTracesResponse.js +5 -0
- package/dist/cjs/api/types/Customer.d.ts +2 -0
- package/dist/cjs/api/types/CustomerUpdate.d.ts +2 -0
- package/dist/cjs/api/types/OrderLineAttributeCreateOne.d.ts +4 -0
- package/dist/cjs/api/types/OrderLineAttributeCreateOne.js +5 -0
- package/dist/cjs/api/types/OrderLineCreate.d.ts +10 -4
- package/dist/cjs/api/types/PaginationMeta.d.ts +28 -0
- package/dist/cjs/api/types/PaginationMeta.js +5 -0
- package/dist/cjs/api/types/Plan.d.ts +58 -0
- package/dist/cjs/api/types/Plan.js +5 -0
- package/dist/cjs/api/types/PlanGroup.d.ts +23 -0
- package/dist/cjs/api/types/PlanGroup.js +5 -0
- package/dist/cjs/api/types/Product.d.ts +36 -0
- package/dist/cjs/api/types/Product.js +14 -0
- package/dist/cjs/api/types/ProductUpdate.d.ts +23 -0
- package/dist/cjs/api/types/ProductUpdate.js +14 -0
- package/dist/cjs/api/types/Signal.d.ts +7 -2
- package/dist/cjs/api/types/SignalV2.d.ts +22 -0
- package/dist/cjs/api/types/SignalV2.js +5 -0
- package/dist/cjs/api/types/Trace.d.ts +26 -0
- package/dist/cjs/api/types/Trace.js +5 -0
- package/dist/cjs/api/types/TracesResponse.d.ts +11 -0
- package/dist/cjs/api/types/TracesResponse.js +5 -0
- package/dist/cjs/api/types/UsagePaginationMeta.d.ts +16 -0
- package/dist/cjs/api/types/UsagePaginationMeta.js +5 -0
- package/dist/cjs/api/types/UsageSummariesResponse.d.ts +11 -0
- package/dist/cjs/api/types/UsageSummariesResponse.js +5 -0
- package/dist/cjs/api/types/UsageSummary.d.ts +58 -0
- package/dist/cjs/api/types/UsageSummary.js +5 -0
- package/dist/cjs/api/types/index.d.ts +15 -1
- package/dist/cjs/api/types/index.js +15 -1
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/integrations/adapters/expressjs/base-adapter.d.ts +17 -0
- package/dist/cjs/integrations/adapters/expressjs/base-adapter.js +71 -0
- package/dist/cjs/integrations/adapters/expressjs/index.d.ts +6 -0
- package/dist/cjs/integrations/adapters/expressjs/index.js +20 -0
- package/dist/cjs/integrations/adapters/expressjs/routes.d.ts +162 -0
- package/dist/cjs/integrations/adapters/expressjs/routes.js +269 -0
- package/dist/cjs/integrations/adapters/nestjs/index.d.ts +7 -0
- package/dist/cjs/integrations/adapters/nestjs/index.js +23 -0
- package/dist/cjs/tracing/autoInstrumentation.d.ts +10 -0
- package/dist/cjs/tracing/autoInstrumentation.js +57 -0
- package/dist/cjs/tracing/index.d.ts +4 -0
- package/dist/cjs/tracing/index.js +12 -0
- package/dist/cjs/tracing/signal.d.ts +18 -1
- package/dist/cjs/tracing/signal.js +29 -13
- package/dist/cjs/tracing/spanProcessor.d.ts +10 -0
- package/dist/cjs/tracing/spanProcessor.js +82 -0
- package/dist/cjs/tracing/tracing.d.ts +12 -6
- package/dist/cjs/tracing/tracing.js +65 -58
- package/dist/cjs/tracing/tracingContext.d.ts +8 -0
- package/dist/cjs/tracing/tracingContext.js +28 -0
- package/dist/cjs/tracing/wrappers/anthropicWrapper.js +11 -7
- package/dist/cjs/tracing/wrappers/langchainCallback.js +11 -7
- package/dist/cjs/tracing/wrappers/mistralWrapper.js +11 -7
- package/dist/cjs/tracing/wrappers/openAiWrapper.js +24 -23
- package/dist/cjs/tracing/wrappers/vercelAIWrapper.js +68 -43
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Client.d.mts +35 -3
- package/dist/esm/Client.mjs +54 -16
- package/dist/esm/api/errors/InternalServerError.d.mts +9 -0
- package/dist/esm/api/errors/InternalServerError.mjs +15 -0
- package/dist/esm/api/errors/index.d.mts +1 -0
- package/dist/esm/api/errors/index.mjs +1 -0
- package/dist/esm/api/index.d.mts +1 -1
- package/dist/esm/api/index.mjs +1 -1
- package/dist/esm/api/resources/agents/client/Client.d.mts +16 -0
- package/dist/esm/api/resources/agents/client/Client.mjs +16 -0
- package/dist/esm/api/resources/customers/client/Client.d.mts +38 -0
- package/dist/esm/api/resources/customers/client/Client.mjs +164 -0
- package/dist/esm/api/resources/customers/client/requests/CustomerCreate.d.mts +2 -0
- package/dist/esm/api/resources/customers/client/requests/CustomersGetCostsByExternalIdRequest.d.mts +30 -0
- package/dist/esm/api/resources/customers/client/requests/CustomersGetUsageByExternalIdRequest.d.mts +30 -0
- package/dist/esm/api/resources/customers/client/requests/CustomersGetUsageByExternalIdRequest.mjs +4 -0
- package/dist/esm/api/resources/customers/client/requests/index.d.mts +2 -0
- package/dist/esm/api/resources/index.d.mts +8 -1
- package/dist/esm/api/resources/index.mjs +8 -1
- package/dist/esm/api/resources/orders/client/requests/OrderCreate.d.mts +2 -0
- package/dist/esm/api/resources/orders/resources/lines/client/Client.d.mts +0 -2
- package/dist/esm/api/resources/orders/resources/lines/client/Client.mjs +0 -2
- package/dist/esm/api/resources/orders/resources/lines/client/requests/LinesUpdateRequest.d.mts +0 -2
- package/dist/esm/api/resources/plans/client/Client.d.mts +75 -0
- package/dist/esm/api/resources/plans/client/Client.mjs +232 -0
- package/dist/esm/api/resources/plans/client/index.d.mts +1 -0
- package/dist/esm/api/resources/plans/client/index.mjs +1 -0
- package/dist/esm/api/resources/plans/client/requests/PlansGetUsageRequest.d.mts +35 -0
- package/dist/esm/api/resources/plans/client/requests/PlansGetUsageRequest.mjs +4 -0
- package/dist/esm/api/resources/plans/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/plans/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/plans/index.d.mts +1 -0
- package/dist/esm/api/resources/plans/index.mjs +1 -0
- package/dist/esm/api/resources/products/client/Client.d.mts +109 -0
- package/dist/esm/api/resources/products/client/Client.mjs +430 -0
- package/dist/esm/api/resources/products/client/index.d.mts +1 -0
- package/dist/esm/api/resources/products/client/index.mjs +1 -0
- package/dist/esm/api/resources/products/client/requests/ProductCreate.d.mts +29 -0
- package/dist/esm/api/resources/products/client/requests/ProductCreate.mjs +11 -0
- package/dist/esm/api/resources/products/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/products/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/products/index.d.mts +1 -0
- package/dist/esm/api/resources/products/index.mjs +1 -0
- package/dist/esm/api/resources/traces/client/Client.d.mts +52 -0
- package/dist/esm/api/resources/traces/client/Client.mjs +126 -0
- package/dist/esm/api/resources/traces/client/index.d.mts +1 -0
- package/dist/esm/api/resources/traces/client/index.mjs +1 -0
- package/dist/esm/api/resources/traces/client/requests/GetTracesRequest.d.mts +50 -0
- package/dist/esm/api/resources/traces/client/requests/GetTracesRequest.mjs +4 -0
- package/dist/esm/api/resources/traces/client/requests/index.d.mts +1 -0
- package/dist/esm/api/resources/traces/client/requests/index.mjs +1 -0
- package/dist/esm/api/resources/traces/index.d.mts +1 -0
- package/dist/esm/api/resources/traces/index.mjs +1 -0
- package/dist/esm/api/resources/usage/client/Client.d.mts +47 -0
- package/dist/esm/api/resources/usage/client/Client.mjs +146 -0
- package/dist/esm/api/resources/usage/client/requests/UsageCheckUsageRequest.d.mts +28 -0
- package/dist/esm/api/resources/usage/client/requests/UsageCheckUsageRequest.mjs +4 -0
- package/dist/esm/api/resources/usage/client/requests/UsageRecordBulkV2Request.d.mts +29 -0
- package/dist/esm/api/resources/usage/client/requests/UsageRecordBulkV2Request.mjs +4 -0
- package/dist/esm/api/resources/usage/client/requests/index.d.mts +2 -0
- package/dist/esm/api/resources/usage/index.d.mts +1 -0
- package/dist/esm/api/resources/usage/index.mjs +1 -0
- package/dist/esm/api/resources/usage/types/UsageCheckUsageResponse.d.mts +17 -0
- package/dist/esm/api/resources/usage/types/UsageCheckUsageResponse.mjs +4 -0
- package/dist/esm/api/resources/usage/types/index.d.mts +1 -0
- package/dist/esm/api/resources/usage/types/index.mjs +1 -0
- package/dist/esm/api/types/CostAmount.d.mts +12 -0
- package/dist/esm/api/types/CostAmount.mjs +4 -0
- package/dist/esm/api/types/CostTrace.d.mts +22 -0
- package/dist/esm/api/types/CostTrace.mjs +4 -0
- package/dist/esm/api/types/CostTracesResponse.d.mts +11 -0
- package/dist/esm/api/types/CostTracesResponse.mjs +4 -0
- package/dist/esm/api/types/Customer.d.mts +2 -0
- package/dist/esm/api/types/CustomerUpdate.d.mts +2 -0
- package/dist/esm/api/types/OrderLineAttributeCreateOne.d.mts +4 -0
- package/dist/esm/api/types/OrderLineAttributeCreateOne.mjs +4 -0
- package/dist/esm/api/types/OrderLineCreate.d.mts +10 -4
- package/dist/esm/api/types/PaginationMeta.d.mts +28 -0
- package/dist/esm/api/types/PaginationMeta.mjs +4 -0
- package/dist/esm/api/types/Plan.d.mts +58 -0
- package/dist/esm/api/types/Plan.mjs +4 -0
- package/dist/esm/api/types/PlanGroup.d.mts +23 -0
- package/dist/esm/api/types/PlanGroup.mjs +4 -0
- package/dist/esm/api/types/Product.d.mts +36 -0
- package/dist/esm/api/types/Product.mjs +11 -0
- package/dist/esm/api/types/ProductUpdate.d.mts +23 -0
- package/dist/esm/api/types/ProductUpdate.mjs +11 -0
- package/dist/esm/api/types/Signal.d.mts +7 -2
- package/dist/esm/api/types/SignalV2.d.mts +22 -0
- package/dist/esm/api/types/SignalV2.mjs +4 -0
- package/dist/esm/api/types/Trace.d.mts +26 -0
- package/dist/esm/api/types/Trace.mjs +4 -0
- package/dist/esm/api/types/TracesResponse.d.mts +11 -0
- package/dist/esm/api/types/TracesResponse.mjs +4 -0
- package/dist/esm/api/types/UsagePaginationMeta.d.mts +16 -0
- package/dist/esm/api/types/UsagePaginationMeta.mjs +4 -0
- package/dist/esm/api/types/UsageSummariesResponse.d.mts +11 -0
- package/dist/esm/api/types/UsageSummariesResponse.mjs +4 -0
- package/dist/esm/api/types/UsageSummary.d.mts +58 -0
- package/dist/esm/api/types/UsageSummary.mjs +4 -0
- package/dist/esm/api/types/index.d.mts +15 -1
- package/dist/esm/api/types/index.mjs +15 -1
- package/dist/esm/index.d.mts +1 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/integrations/adapters/expressjs/base-adapter.d.mts +17 -0
- package/dist/esm/integrations/adapters/expressjs/base-adapter.mjs +67 -0
- package/dist/esm/integrations/adapters/expressjs/index.d.mts +6 -0
- package/dist/esm/integrations/adapters/expressjs/index.mjs +6 -0
- package/dist/esm/integrations/adapters/expressjs/routes.d.mts +162 -0
- package/dist/esm/integrations/adapters/expressjs/routes.mjs +258 -0
- package/dist/esm/integrations/adapters/nestjs/index.d.mts +7 -0
- package/dist/esm/integrations/adapters/nestjs/index.mjs +7 -0
- package/dist/esm/tracing/autoInstrumentation.d.mts +10 -0
- package/dist/esm/tracing/autoInstrumentation.mjs +54 -0
- package/dist/esm/tracing/index.d.mts +4 -0
- package/dist/esm/tracing/index.mjs +4 -0
- package/dist/esm/tracing/signal.d.mts +18 -1
- package/dist/esm/tracing/signal.mjs +28 -12
- package/dist/esm/tracing/spanProcessor.d.mts +10 -0
- package/dist/esm/tracing/spanProcessor.mjs +78 -0
- package/dist/esm/tracing/tracing.d.mts +12 -6
- package/dist/esm/tracing/tracing.mjs +59 -52
- package/dist/esm/tracing/tracingContext.d.mts +8 -0
- package/dist/esm/tracing/tracingContext.mjs +23 -0
- package/dist/esm/tracing/wrappers/anthropicWrapper.mjs +11 -7
- package/dist/esm/tracing/wrappers/langchainCallback.mjs +11 -7
- package/dist/esm/tracing/wrappers/mistralWrapper.mjs +11 -7
- package/dist/esm/tracing/wrappers/openAiWrapper.mjs +24 -23
- package/dist/esm/tracing/wrappers/vercelAIWrapper.mjs +68 -43
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +41 -4
- package/reference.md +1147 -153
- package/dist/cjs/api/types/OrderLineAttributeCreate.d.ts +0 -12
- package/dist/esm/api/types/OrderLineAttributeCreate.d.mts +0 -12
- /package/dist/cjs/api/{types/OrderLineAttributeCreate.js → resources/customers/client/requests/CustomersGetCostsByExternalIdRequest.js} +0 -0
- /package/dist/esm/api/{types/OrderLineAttributeCreate.mjs → resources/customers/client/requests/CustomersGetCostsByExternalIdRequest.mjs} +0 -0
|
@@ -477,6 +477,170 @@ export class Customers {
|
|
|
477
477
|
}
|
|
478
478
|
});
|
|
479
479
|
}
|
|
480
|
+
/**
|
|
481
|
+
* @param {string} externalId - The external ID of the customer
|
|
482
|
+
* @param {Paid.CustomersGetCostsByExternalIdRequest} request
|
|
483
|
+
* @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
|
|
484
|
+
*
|
|
485
|
+
* @throws {@link Paid.BadRequestError}
|
|
486
|
+
* @throws {@link Paid.ForbiddenError}
|
|
487
|
+
* @throws {@link Paid.NotFoundError}
|
|
488
|
+
*
|
|
489
|
+
* @example
|
|
490
|
+
* await client.customers.getCostsByExternalId("externalId", {
|
|
491
|
+
* limit: 1,
|
|
492
|
+
* offset: 1,
|
|
493
|
+
* startTime: "2024-01-15T09:30:00Z",
|
|
494
|
+
* endTime: "2024-01-15T09:30:00Z"
|
|
495
|
+
* })
|
|
496
|
+
*/
|
|
497
|
+
getCostsByExternalId(externalId, request = {}, requestOptions) {
|
|
498
|
+
return core.HttpResponsePromise.fromPromise(this.__getCostsByExternalId(externalId, request, requestOptions));
|
|
499
|
+
}
|
|
500
|
+
__getCostsByExternalId(externalId_1) {
|
|
501
|
+
return __awaiter(this, arguments, void 0, function* (externalId, request = {}, requestOptions) {
|
|
502
|
+
var _a, _b, _c;
|
|
503
|
+
const { limit, offset, startTime, endTime } = request;
|
|
504
|
+
const _queryParams = {};
|
|
505
|
+
if (limit != null) {
|
|
506
|
+
_queryParams["limit"] = limit.toString();
|
|
507
|
+
}
|
|
508
|
+
if (offset != null) {
|
|
509
|
+
_queryParams["offset"] = offset.toString();
|
|
510
|
+
}
|
|
511
|
+
if (startTime != null) {
|
|
512
|
+
_queryParams["startTime"] = startTime;
|
|
513
|
+
}
|
|
514
|
+
if (endTime != null) {
|
|
515
|
+
_queryParams["endTime"] = endTime;
|
|
516
|
+
}
|
|
517
|
+
const _response = yield core.fetcher({
|
|
518
|
+
url: urlJoin((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.PaidEnvironment.Production, `customers/external/${encodeURIComponent(externalId)}/costs`),
|
|
519
|
+
method: "GET",
|
|
520
|
+
headers: mergeHeaders((_c = this._options) === null || _c === void 0 ? void 0 : _c.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
521
|
+
queryParameters: _queryParams,
|
|
522
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
523
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
524
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
525
|
+
});
|
|
526
|
+
if (_response.ok) {
|
|
527
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
528
|
+
}
|
|
529
|
+
if (_response.error.reason === "status-code") {
|
|
530
|
+
switch (_response.error.statusCode) {
|
|
531
|
+
case 400:
|
|
532
|
+
throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
|
|
533
|
+
case 403:
|
|
534
|
+
throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
535
|
+
case 404:
|
|
536
|
+
throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
|
|
537
|
+
default:
|
|
538
|
+
throw new errors.PaidError({
|
|
539
|
+
statusCode: _response.error.statusCode,
|
|
540
|
+
body: _response.error.body,
|
|
541
|
+
rawResponse: _response.rawResponse,
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
switch (_response.error.reason) {
|
|
546
|
+
case "non-json":
|
|
547
|
+
throw new errors.PaidError({
|
|
548
|
+
statusCode: _response.error.statusCode,
|
|
549
|
+
body: _response.error.rawBody,
|
|
550
|
+
rawResponse: _response.rawResponse,
|
|
551
|
+
});
|
|
552
|
+
case "timeout":
|
|
553
|
+
throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /customers/external/{externalId}/costs.");
|
|
554
|
+
case "unknown":
|
|
555
|
+
throw new errors.PaidError({
|
|
556
|
+
message: _response.error.errorMessage,
|
|
557
|
+
rawResponse: _response.rawResponse,
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
}
|
|
562
|
+
/**
|
|
563
|
+
* @param {string} externalId - The external ID of the customer
|
|
564
|
+
* @param {Paid.CustomersGetUsageByExternalIdRequest} request
|
|
565
|
+
* @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
|
|
566
|
+
*
|
|
567
|
+
* @throws {@link Paid.BadRequestError}
|
|
568
|
+
* @throws {@link Paid.ForbiddenError}
|
|
569
|
+
* @throws {@link Paid.NotFoundError}
|
|
570
|
+
*
|
|
571
|
+
* @example
|
|
572
|
+
* await client.customers.getUsageByExternalId("externalId", {
|
|
573
|
+
* limit: 1,
|
|
574
|
+
* offset: 1,
|
|
575
|
+
* startTime: "2024-01-15T09:30:00Z",
|
|
576
|
+
* endTime: "2024-01-15T09:30:00Z"
|
|
577
|
+
* })
|
|
578
|
+
*/
|
|
579
|
+
getUsageByExternalId(externalId, request = {}, requestOptions) {
|
|
580
|
+
return core.HttpResponsePromise.fromPromise(this.__getUsageByExternalId(externalId, request, requestOptions));
|
|
581
|
+
}
|
|
582
|
+
__getUsageByExternalId(externalId_1) {
|
|
583
|
+
return __awaiter(this, arguments, void 0, function* (externalId, request = {}, requestOptions) {
|
|
584
|
+
var _a, _b, _c;
|
|
585
|
+
const { limit, offset, startTime, endTime } = request;
|
|
586
|
+
const _queryParams = {};
|
|
587
|
+
if (limit != null) {
|
|
588
|
+
_queryParams["limit"] = limit.toString();
|
|
589
|
+
}
|
|
590
|
+
if (offset != null) {
|
|
591
|
+
_queryParams["offset"] = offset.toString();
|
|
592
|
+
}
|
|
593
|
+
if (startTime != null) {
|
|
594
|
+
_queryParams["startTime"] = startTime;
|
|
595
|
+
}
|
|
596
|
+
if (endTime != null) {
|
|
597
|
+
_queryParams["endTime"] = endTime;
|
|
598
|
+
}
|
|
599
|
+
const _response = yield core.fetcher({
|
|
600
|
+
url: urlJoin((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.PaidEnvironment.Production, `customers/external/${encodeURIComponent(externalId)}/usage`),
|
|
601
|
+
method: "GET",
|
|
602
|
+
headers: mergeHeaders((_c = this._options) === null || _c === void 0 ? void 0 : _c.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
603
|
+
queryParameters: _queryParams,
|
|
604
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
605
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
606
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
607
|
+
});
|
|
608
|
+
if (_response.ok) {
|
|
609
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
610
|
+
}
|
|
611
|
+
if (_response.error.reason === "status-code") {
|
|
612
|
+
switch (_response.error.statusCode) {
|
|
613
|
+
case 400:
|
|
614
|
+
throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
|
|
615
|
+
case 403:
|
|
616
|
+
throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
617
|
+
case 404:
|
|
618
|
+
throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
|
|
619
|
+
default:
|
|
620
|
+
throw new errors.PaidError({
|
|
621
|
+
statusCode: _response.error.statusCode,
|
|
622
|
+
body: _response.error.body,
|
|
623
|
+
rawResponse: _response.rawResponse,
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
switch (_response.error.reason) {
|
|
628
|
+
case "non-json":
|
|
629
|
+
throw new errors.PaidError({
|
|
630
|
+
statusCode: _response.error.statusCode,
|
|
631
|
+
body: _response.error.rawBody,
|
|
632
|
+
rawResponse: _response.rawResponse,
|
|
633
|
+
});
|
|
634
|
+
case "timeout":
|
|
635
|
+
throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /customers/external/{externalId}/usage.");
|
|
636
|
+
case "unknown":
|
|
637
|
+
throw new errors.PaidError({
|
|
638
|
+
message: _response.error.errorMessage,
|
|
639
|
+
rawResponse: _response.rawResponse,
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
}
|
|
480
644
|
_getAuthorizationHeader() {
|
|
481
645
|
return __awaiter(this, void 0, void 0, function* () {
|
|
482
646
|
const bearer = yield core.Supplier.get(this._options.token);
|
package/dist/esm/api/resources/customers/client/requests/CustomersGetCostsByExternalIdRequest.d.mts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @example
|
|
6
|
+
* {
|
|
7
|
+
* limit: 1,
|
|
8
|
+
* offset: 1,
|
|
9
|
+
* startTime: "2024-01-15T09:30:00Z",
|
|
10
|
+
* endTime: "2024-01-15T09:30:00Z"
|
|
11
|
+
* }
|
|
12
|
+
*/
|
|
13
|
+
export interface CustomersGetCostsByExternalIdRequest {
|
|
14
|
+
/**
|
|
15
|
+
* Maximum number of traces to return (1-1000)
|
|
16
|
+
*/
|
|
17
|
+
limit?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Number of traces to skip for pagination
|
|
20
|
+
*/
|
|
21
|
+
offset?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Filter traces starting from this time (ISO 8601 format)
|
|
24
|
+
*/
|
|
25
|
+
startTime?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Filter traces up to this time (ISO 8601 format)
|
|
28
|
+
*/
|
|
29
|
+
endTime?: string;
|
|
30
|
+
}
|
package/dist/esm/api/resources/customers/client/requests/CustomersGetUsageByExternalIdRequest.d.mts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* @example
|
|
6
|
+
* {
|
|
7
|
+
* limit: 1,
|
|
8
|
+
* offset: 1,
|
|
9
|
+
* startTime: "2024-01-15T09:30:00Z",
|
|
10
|
+
* endTime: "2024-01-15T09:30:00Z"
|
|
11
|
+
* }
|
|
12
|
+
*/
|
|
13
|
+
export interface CustomersGetUsageByExternalIdRequest {
|
|
14
|
+
/**
|
|
15
|
+
* Maximum number of usage summaries to return (1-1000)
|
|
16
|
+
*/
|
|
17
|
+
limit?: number;
|
|
18
|
+
/**
|
|
19
|
+
* Number of usage summaries to skip for pagination
|
|
20
|
+
*/
|
|
21
|
+
offset?: number;
|
|
22
|
+
/**
|
|
23
|
+
* Filter usage summaries starting from this time (ISO 8601 format). Returns summaries that overlap with the time range.
|
|
24
|
+
*/
|
|
25
|
+
startTime?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Filter usage summaries up to this time (ISO 8601 format). Returns summaries that overlap with the time range.
|
|
28
|
+
*/
|
|
29
|
+
endTime?: string;
|
|
30
|
+
}
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
export * as usage from "./usage/index.mjs";
|
|
2
|
+
export * from "./usage/types/index.mjs";
|
|
1
3
|
export * as customers from "./customers/index.mjs";
|
|
2
4
|
export * as agents from "./agents/index.mjs";
|
|
5
|
+
export * as products from "./products/index.mjs";
|
|
3
6
|
export * as contacts from "./contacts/index.mjs";
|
|
4
7
|
export * as orders from "./orders/index.mjs";
|
|
5
|
-
export * as
|
|
8
|
+
export * as plans from "./plans/index.mjs";
|
|
9
|
+
export * as traces from "./traces/index.mjs";
|
|
6
10
|
export * from "./customers/client/requests/index.mjs";
|
|
7
11
|
export * from "./agents/client/requests/index.mjs";
|
|
12
|
+
export * from "./products/client/requests/index.mjs";
|
|
8
13
|
export * from "./contacts/client/requests/index.mjs";
|
|
9
14
|
export * from "./orders/client/requests/index.mjs";
|
|
15
|
+
export * from "./plans/client/requests/index.mjs";
|
|
10
16
|
export * from "./usage/client/requests/index.mjs";
|
|
17
|
+
export * from "./traces/client/requests/index.mjs";
|
|
@@ -1,10 +1,17 @@
|
|
|
1
|
+
export * as usage from "./usage/index.mjs";
|
|
2
|
+
export * from "./usage/types/index.mjs";
|
|
1
3
|
export * as customers from "./customers/index.mjs";
|
|
2
4
|
export * as agents from "./agents/index.mjs";
|
|
5
|
+
export * as products from "./products/index.mjs";
|
|
3
6
|
export * as contacts from "./contacts/index.mjs";
|
|
4
7
|
export * as orders from "./orders/index.mjs";
|
|
5
|
-
export * as
|
|
8
|
+
export * as plans from "./plans/index.mjs";
|
|
9
|
+
export * as traces from "./traces/index.mjs";
|
|
6
10
|
export * from "./customers/client/requests/index.mjs";
|
|
7
11
|
export * from "./agents/client/requests/index.mjs";
|
|
12
|
+
export * from "./products/client/requests/index.mjs";
|
|
8
13
|
export * from "./contacts/client/requests/index.mjs";
|
|
9
14
|
export * from "./orders/client/requests/index.mjs";
|
|
15
|
+
export * from "./plans/client/requests/index.mjs";
|
|
10
16
|
export * from "./usage/client/requests/index.mjs";
|
|
17
|
+
export * from "./traces/client/requests/index.mjs";
|
|
@@ -35,11 +35,9 @@ export declare class Lines {
|
|
|
35
35
|
* @example
|
|
36
36
|
* await client.orders.lines.update("orderId", {
|
|
37
37
|
* lines: [{
|
|
38
|
-
* agentExternalId: "acme-agent",
|
|
39
38
|
* name: "Order Line One",
|
|
40
39
|
* description: "Order Line One is an order line for Acme, Inc."
|
|
41
40
|
* }, {
|
|
42
|
-
* agentExternalId: "acme-agent-2",
|
|
43
41
|
* name: "Order Line Two",
|
|
44
42
|
* description: "Order Line Two is an order line for Acme, Inc."
|
|
45
43
|
* }]
|
|
@@ -27,11 +27,9 @@ export class Lines {
|
|
|
27
27
|
* @example
|
|
28
28
|
* await client.orders.lines.update("orderId", {
|
|
29
29
|
* lines: [{
|
|
30
|
-
* agentExternalId: "acme-agent",
|
|
31
30
|
* name: "Order Line One",
|
|
32
31
|
* description: "Order Line One is an order line for Acme, Inc."
|
|
33
32
|
* }, {
|
|
34
|
-
* agentExternalId: "acme-agent-2",
|
|
35
33
|
* name: "Order Line Two",
|
|
36
34
|
* description: "Order Line Two is an order line for Acme, Inc."
|
|
37
35
|
* }]
|
package/dist/esm/api/resources/orders/resources/lines/client/requests/LinesUpdateRequest.d.mts
CHANGED
|
@@ -6,11 +6,9 @@ import * as Paid from "../../../../../../index.mjs";
|
|
|
6
6
|
* @example
|
|
7
7
|
* {
|
|
8
8
|
* lines: [{
|
|
9
|
-
* agentExternalId: "acme-agent",
|
|
10
9
|
* name: "Order Line One",
|
|
11
10
|
* description: "Order Line One is an order line for Acme, Inc."
|
|
12
11
|
* }, {
|
|
13
|
-
* agentExternalId: "acme-agent-2",
|
|
14
12
|
* name: "Order Line Two",
|
|
15
13
|
* description: "Order Line Two is an order line for Acme, Inc."
|
|
16
14
|
* }]
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
import * as environments from "../../../../environments.mjs";
|
|
5
|
+
import * as core from "../../../../core/index.mjs";
|
|
6
|
+
import * as Paid from "../../../index.mjs";
|
|
7
|
+
export declare namespace Plans {
|
|
8
|
+
interface Options {
|
|
9
|
+
environment?: core.Supplier<environments.PaidEnvironment | string>;
|
|
10
|
+
/** Specify a custom URL to connect the client to. */
|
|
11
|
+
baseUrl?: core.Supplier<string>;
|
|
12
|
+
token?: core.Supplier<core.BearerToken | undefined>;
|
|
13
|
+
/** Additional headers to include in requests. */
|
|
14
|
+
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
|
|
15
|
+
}
|
|
16
|
+
interface RequestOptions {
|
|
17
|
+
/** The maximum time to wait for a response in seconds. */
|
|
18
|
+
timeoutInSeconds?: number;
|
|
19
|
+
/** The number of times to retry the request. Defaults to 2. */
|
|
20
|
+
maxRetries?: number;
|
|
21
|
+
/** A hook to abort the request. */
|
|
22
|
+
abortSignal?: AbortSignal;
|
|
23
|
+
/** Additional headers to include in the request. */
|
|
24
|
+
headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
export declare class Plans {
|
|
28
|
+
protected readonly _options: Plans.Options;
|
|
29
|
+
constructor(_options?: Plans.Options);
|
|
30
|
+
/**
|
|
31
|
+
* @param {string} planId - The ID of the plan
|
|
32
|
+
* @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
|
|
33
|
+
*
|
|
34
|
+
* @throws {@link Paid.ForbiddenError}
|
|
35
|
+
* @throws {@link Paid.NotFoundError}
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* await client.plans.getById("planId")
|
|
39
|
+
*/
|
|
40
|
+
getById(planId: string, requestOptions?: Plans.RequestOptions): core.HttpResponsePromise<Paid.Plan>;
|
|
41
|
+
private __getById;
|
|
42
|
+
/**
|
|
43
|
+
* @param {string} planId - The ID of the plan
|
|
44
|
+
* @param {Paid.PlansGetUsageRequest} request
|
|
45
|
+
* @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
|
|
46
|
+
*
|
|
47
|
+
* @throws {@link Paid.BadRequestError}
|
|
48
|
+
* @throws {@link Paid.ForbiddenError}
|
|
49
|
+
* @throws {@link Paid.NotFoundError}
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* await client.plans.getUsage("planId", {
|
|
53
|
+
* externalId: "externalId",
|
|
54
|
+
* limit: 1,
|
|
55
|
+
* offset: 1,
|
|
56
|
+
* startTime: "2024-01-15T09:30:00Z",
|
|
57
|
+
* endTime: "2024-01-15T09:30:00Z"
|
|
58
|
+
* })
|
|
59
|
+
*/
|
|
60
|
+
getUsage(planId: string, request: Paid.PlansGetUsageRequest, requestOptions?: Plans.RequestOptions): core.HttpResponsePromise<Paid.UsageSummariesResponse>;
|
|
61
|
+
private __getUsage;
|
|
62
|
+
/**
|
|
63
|
+
* @param {string} planGroupId - The ID of the plan group
|
|
64
|
+
* @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
|
|
65
|
+
*
|
|
66
|
+
* @throws {@link Paid.ForbiddenError}
|
|
67
|
+
* @throws {@link Paid.NotFoundError}
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* await client.plans.getGroupById("planGroupId")
|
|
71
|
+
*/
|
|
72
|
+
getGroupById(planGroupId: string, requestOptions?: Plans.RequestOptions): core.HttpResponsePromise<Paid.PlanGroup>;
|
|
73
|
+
private __getGroupById;
|
|
74
|
+
protected _getAuthorizationHeader(): Promise<string | undefined>;
|
|
75
|
+
}
|
|
@@ -0,0 +1,232 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This file was auto-generated by Fern from our API Definition.
|
|
3
|
+
*/
|
|
4
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
5
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
6
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
7
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
8
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
9
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
10
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
11
|
+
});
|
|
12
|
+
};
|
|
13
|
+
import * as environments from "../../../../environments.mjs";
|
|
14
|
+
import * as core from "../../../../core/index.mjs";
|
|
15
|
+
import * as Paid from "../../../index.mjs";
|
|
16
|
+
import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
|
|
17
|
+
import urlJoin from "url-join";
|
|
18
|
+
import * as errors from "../../../../errors/index.mjs";
|
|
19
|
+
export class Plans {
|
|
20
|
+
constructor(_options = {}) {
|
|
21
|
+
this._options = _options;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* @param {string} planId - The ID of the plan
|
|
25
|
+
* @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
|
|
26
|
+
*
|
|
27
|
+
* @throws {@link Paid.ForbiddenError}
|
|
28
|
+
* @throws {@link Paid.NotFoundError}
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* await client.plans.getById("planId")
|
|
32
|
+
*/
|
|
33
|
+
getById(planId, requestOptions) {
|
|
34
|
+
return core.HttpResponsePromise.fromPromise(this.__getById(planId, requestOptions));
|
|
35
|
+
}
|
|
36
|
+
__getById(planId, requestOptions) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
var _a, _b, _c;
|
|
39
|
+
const _response = yield core.fetcher({
|
|
40
|
+
url: urlJoin((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.PaidEnvironment.Production, `plans/${encodeURIComponent(planId)}`),
|
|
41
|
+
method: "GET",
|
|
42
|
+
headers: mergeHeaders((_c = this._options) === null || _c === void 0 ? void 0 : _c.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
43
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
44
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
45
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
46
|
+
});
|
|
47
|
+
if (_response.ok) {
|
|
48
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
49
|
+
}
|
|
50
|
+
if (_response.error.reason === "status-code") {
|
|
51
|
+
switch (_response.error.statusCode) {
|
|
52
|
+
case 403:
|
|
53
|
+
throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
54
|
+
case 404:
|
|
55
|
+
throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
|
|
56
|
+
default:
|
|
57
|
+
throw new errors.PaidError({
|
|
58
|
+
statusCode: _response.error.statusCode,
|
|
59
|
+
body: _response.error.body,
|
|
60
|
+
rawResponse: _response.rawResponse,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
switch (_response.error.reason) {
|
|
65
|
+
case "non-json":
|
|
66
|
+
throw new errors.PaidError({
|
|
67
|
+
statusCode: _response.error.statusCode,
|
|
68
|
+
body: _response.error.rawBody,
|
|
69
|
+
rawResponse: _response.rawResponse,
|
|
70
|
+
});
|
|
71
|
+
case "timeout":
|
|
72
|
+
throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /plans/{planId}.");
|
|
73
|
+
case "unknown":
|
|
74
|
+
throw new errors.PaidError({
|
|
75
|
+
message: _response.error.errorMessage,
|
|
76
|
+
rawResponse: _response.rawResponse,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* @param {string} planId - The ID of the plan
|
|
83
|
+
* @param {Paid.PlansGetUsageRequest} request
|
|
84
|
+
* @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
|
|
85
|
+
*
|
|
86
|
+
* @throws {@link Paid.BadRequestError}
|
|
87
|
+
* @throws {@link Paid.ForbiddenError}
|
|
88
|
+
* @throws {@link Paid.NotFoundError}
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* await client.plans.getUsage("planId", {
|
|
92
|
+
* externalId: "externalId",
|
|
93
|
+
* limit: 1,
|
|
94
|
+
* offset: 1,
|
|
95
|
+
* startTime: "2024-01-15T09:30:00Z",
|
|
96
|
+
* endTime: "2024-01-15T09:30:00Z"
|
|
97
|
+
* })
|
|
98
|
+
*/
|
|
99
|
+
getUsage(planId, request, requestOptions) {
|
|
100
|
+
return core.HttpResponsePromise.fromPromise(this.__getUsage(planId, request, requestOptions));
|
|
101
|
+
}
|
|
102
|
+
__getUsage(planId, request, requestOptions) {
|
|
103
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
104
|
+
var _a, _b, _c;
|
|
105
|
+
const { externalId, limit, offset, startTime, endTime } = request;
|
|
106
|
+
const _queryParams = {};
|
|
107
|
+
_queryParams["externalId"] = externalId;
|
|
108
|
+
if (limit != null) {
|
|
109
|
+
_queryParams["limit"] = limit.toString();
|
|
110
|
+
}
|
|
111
|
+
if (offset != null) {
|
|
112
|
+
_queryParams["offset"] = offset.toString();
|
|
113
|
+
}
|
|
114
|
+
if (startTime != null) {
|
|
115
|
+
_queryParams["startTime"] = startTime;
|
|
116
|
+
}
|
|
117
|
+
if (endTime != null) {
|
|
118
|
+
_queryParams["endTime"] = endTime;
|
|
119
|
+
}
|
|
120
|
+
const _response = yield core.fetcher({
|
|
121
|
+
url: urlJoin((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.PaidEnvironment.Production, `plans/${encodeURIComponent(planId)}/usage`),
|
|
122
|
+
method: "GET",
|
|
123
|
+
headers: mergeHeaders((_c = this._options) === null || _c === void 0 ? void 0 : _c.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
124
|
+
queryParameters: _queryParams,
|
|
125
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
126
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
127
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
128
|
+
});
|
|
129
|
+
if (_response.ok) {
|
|
130
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
131
|
+
}
|
|
132
|
+
if (_response.error.reason === "status-code") {
|
|
133
|
+
switch (_response.error.statusCode) {
|
|
134
|
+
case 400:
|
|
135
|
+
throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
|
|
136
|
+
case 403:
|
|
137
|
+
throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
138
|
+
case 404:
|
|
139
|
+
throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
|
|
140
|
+
default:
|
|
141
|
+
throw new errors.PaidError({
|
|
142
|
+
statusCode: _response.error.statusCode,
|
|
143
|
+
body: _response.error.body,
|
|
144
|
+
rawResponse: _response.rawResponse,
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
switch (_response.error.reason) {
|
|
149
|
+
case "non-json":
|
|
150
|
+
throw new errors.PaidError({
|
|
151
|
+
statusCode: _response.error.statusCode,
|
|
152
|
+
body: _response.error.rawBody,
|
|
153
|
+
rawResponse: _response.rawResponse,
|
|
154
|
+
});
|
|
155
|
+
case "timeout":
|
|
156
|
+
throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /plans/{planId}/usage.");
|
|
157
|
+
case "unknown":
|
|
158
|
+
throw new errors.PaidError({
|
|
159
|
+
message: _response.error.errorMessage,
|
|
160
|
+
rawResponse: _response.rawResponse,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* @param {string} planGroupId - The ID of the plan group
|
|
167
|
+
* @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
|
|
168
|
+
*
|
|
169
|
+
* @throws {@link Paid.ForbiddenError}
|
|
170
|
+
* @throws {@link Paid.NotFoundError}
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* await client.plans.getGroupById("planGroupId")
|
|
174
|
+
*/
|
|
175
|
+
getGroupById(planGroupId, requestOptions) {
|
|
176
|
+
return core.HttpResponsePromise.fromPromise(this.__getGroupById(planGroupId, requestOptions));
|
|
177
|
+
}
|
|
178
|
+
__getGroupById(planGroupId, requestOptions) {
|
|
179
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
180
|
+
var _a, _b, _c;
|
|
181
|
+
const _response = yield core.fetcher({
|
|
182
|
+
url: urlJoin((_b = (_a = (yield core.Supplier.get(this._options.baseUrl))) !== null && _a !== void 0 ? _a : (yield core.Supplier.get(this._options.environment))) !== null && _b !== void 0 ? _b : environments.PaidEnvironment.Production, `plans/group/${encodeURIComponent(planGroupId)}`),
|
|
183
|
+
method: "GET",
|
|
184
|
+
headers: mergeHeaders((_c = this._options) === null || _c === void 0 ? void 0 : _c.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers),
|
|
185
|
+
timeoutMs: (requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) != null ? requestOptions.timeoutInSeconds * 1000 : 60000,
|
|
186
|
+
maxRetries: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries,
|
|
187
|
+
abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
|
|
188
|
+
});
|
|
189
|
+
if (_response.ok) {
|
|
190
|
+
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
191
|
+
}
|
|
192
|
+
if (_response.error.reason === "status-code") {
|
|
193
|
+
switch (_response.error.statusCode) {
|
|
194
|
+
case 403:
|
|
195
|
+
throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
|
|
196
|
+
case 404:
|
|
197
|
+
throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
|
|
198
|
+
default:
|
|
199
|
+
throw new errors.PaidError({
|
|
200
|
+
statusCode: _response.error.statusCode,
|
|
201
|
+
body: _response.error.body,
|
|
202
|
+
rawResponse: _response.rawResponse,
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
switch (_response.error.reason) {
|
|
207
|
+
case "non-json":
|
|
208
|
+
throw new errors.PaidError({
|
|
209
|
+
statusCode: _response.error.statusCode,
|
|
210
|
+
body: _response.error.rawBody,
|
|
211
|
+
rawResponse: _response.rawResponse,
|
|
212
|
+
});
|
|
213
|
+
case "timeout":
|
|
214
|
+
throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /plans/group/{planGroupId}.");
|
|
215
|
+
case "unknown":
|
|
216
|
+
throw new errors.PaidError({
|
|
217
|
+
message: _response.error.errorMessage,
|
|
218
|
+
rawResponse: _response.rawResponse,
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
_getAuthorizationHeader() {
|
|
224
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
225
|
+
const bearer = yield core.Supplier.get(this._options.token);
|
|
226
|
+
if (bearer != null) {
|
|
227
|
+
return `Bearer ${bearer}`;
|
|
228
|
+
}
|
|
229
|
+
return undefined;
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests/index.mjs";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./requests/index.mjs";
|