@paid-ai/paid-node 1.0.0 → 1.0.1-alpha0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/dist/cjs/BaseClient.d.ts +4 -17
  2. package/dist/cjs/BaseClient.js +0 -59
  3. package/dist/cjs/Client.d.ts +28 -28
  4. package/dist/cjs/Client.js +52 -11
  5. package/dist/cjs/api/errors/BadRequestError.js +1 -5
  6. package/dist/cjs/api/errors/ForbiddenError.js +1 -5
  7. package/dist/cjs/api/errors/InternalServerError.js +1 -5
  8. package/dist/cjs/api/errors/NotFoundError.js +1 -5
  9. package/dist/cjs/api/resources/agents/client/Client.d.ts +23 -22
  10. package/dist/cjs/api/resources/agents/client/Client.js +158 -55
  11. package/dist/cjs/api/resources/contacts/client/Client.d.ts +19 -18
  12. package/dist/cjs/api/resources/contacts/client/Client.js +122 -43
  13. package/dist/cjs/api/resources/customers/client/Client.d.ts +37 -36
  14. package/dist/cjs/api/resources/customers/client/Client.js +315 -113
  15. package/dist/cjs/api/resources/orders/client/Client.d.ts +28 -27
  16. package/dist/cjs/api/resources/orders/client/Client.js +177 -62
  17. package/dist/cjs/api/resources/orders/resources/lines/client/Client.d.ts +9 -8
  18. package/dist/cjs/api/resources/orders/resources/lines/client/Client.js +32 -13
  19. package/dist/cjs/api/resources/plans/client/Client.d.ts +13 -12
  20. package/dist/cjs/api/resources/plans/client/Client.js +82 -32
  21. package/dist/cjs/api/resources/products/client/Client.d.ts +23 -22
  22. package/dist/cjs/api/resources/products/client/Client.js +158 -55
  23. package/dist/cjs/api/resources/products/client/requests/index.d.ts +1 -1
  24. package/dist/cjs/api/resources/products/client/requests/index.js +0 -3
  25. package/dist/cjs/api/resources/traces/client/Client.d.ts +9 -8
  26. package/dist/cjs/api/resources/traces/client/Client.js +57 -23
  27. package/dist/cjs/api/resources/usage/client/Client.d.ts +13 -12
  28. package/dist/cjs/api/resources/usage/client/Client.js +68 -25
  29. package/dist/cjs/core/auth/AuthProvider.d.ts +1 -4
  30. package/dist/cjs/core/auth/BearerToken.d.ts +1 -3
  31. package/dist/cjs/core/auth/BearerToken.js +6 -7
  32. package/dist/cjs/core/auth/index.d.ts +0 -1
  33. package/dist/cjs/core/auth/index.js +1 -3
  34. package/dist/cjs/core/fetcher/BinaryResponse.d.ts +7 -6
  35. package/dist/cjs/core/fetcher/EndpointSupplier.d.ts +2 -2
  36. package/dist/cjs/core/fetcher/Fetcher.d.ts +4 -10
  37. package/dist/cjs/core/fetcher/Fetcher.js +10 -204
  38. package/dist/cjs/core/fetcher/ResponseWithBody.d.ts +4 -0
  39. package/dist/cjs/core/fetcher/ResponseWithBody.js +6 -0
  40. package/dist/cjs/core/fetcher/getRequestBody.d.ts +1 -1
  41. package/dist/cjs/core/fetcher/getRequestBody.js +0 -4
  42. package/dist/cjs/core/fetcher/getResponseBody.js +4 -18
  43. package/dist/cjs/core/fetcher/makeRequest.d.ts +1 -1
  44. package/dist/cjs/core/fetcher/makeRequest.js +2 -0
  45. package/dist/cjs/core/fetcher/requestWithRetries.js +9 -0
  46. package/dist/cjs/core/fetcher/signals.d.ts +7 -1
  47. package/dist/cjs/core/fetcher/signals.js +12 -0
  48. package/dist/cjs/core/headers.d.ts +2 -2
  49. package/dist/cjs/core/headers.js +4 -6
  50. package/dist/cjs/core/index.d.ts +0 -1
  51. package/dist/cjs/core/index.js +1 -2
  52. package/dist/cjs/core/runtime/runtime.js +10 -11
  53. package/dist/cjs/core/url/join.js +1 -0
  54. package/dist/cjs/errors/PaidError.js +1 -5
  55. package/dist/cjs/errors/PaidTimeoutError.js +1 -5
  56. package/dist/cjs/index.d.ts +0 -1
  57. package/dist/cjs/index.js +0 -4
  58. package/dist/cjs/version.d.ts +1 -1
  59. package/dist/cjs/version.js +1 -1
  60. package/dist/esm/BaseClient.d.mts +4 -17
  61. package/dist/esm/BaseClient.mjs +1 -24
  62. package/dist/esm/Client.d.mts +28 -28
  63. package/dist/esm/Client.mjs +27 -19
  64. package/dist/esm/api/errors/BadRequestError.mjs +1 -5
  65. package/dist/esm/api/errors/ForbiddenError.mjs +1 -5
  66. package/dist/esm/api/errors/InternalServerError.mjs +1 -5
  67. package/dist/esm/api/errors/NotFoundError.mjs +1 -5
  68. package/dist/esm/api/resources/agents/client/Client.d.mts +23 -22
  69. package/dist/esm/api/resources/agents/client/Client.mjs +157 -54
  70. package/dist/esm/api/resources/contacts/client/Client.d.mts +19 -18
  71. package/dist/esm/api/resources/contacts/client/Client.mjs +121 -42
  72. package/dist/esm/api/resources/customers/client/Client.d.mts +37 -36
  73. package/dist/esm/api/resources/customers/client/Client.mjs +314 -112
  74. package/dist/esm/api/resources/orders/client/Client.d.mts +28 -27
  75. package/dist/esm/api/resources/orders/client/Client.mjs +177 -62
  76. package/dist/esm/api/resources/orders/resources/lines/client/Client.d.mts +9 -8
  77. package/dist/esm/api/resources/orders/resources/lines/client/Client.mjs +31 -12
  78. package/dist/esm/api/resources/plans/client/Client.d.mts +13 -12
  79. package/dist/esm/api/resources/plans/client/Client.mjs +81 -31
  80. package/dist/esm/api/resources/products/client/Client.d.mts +23 -22
  81. package/dist/esm/api/resources/products/client/Client.mjs +157 -54
  82. package/dist/esm/api/resources/products/client/requests/index.d.mts +1 -1
  83. package/dist/esm/api/resources/products/client/requests/index.mjs +1 -1
  84. package/dist/esm/api/resources/traces/client/Client.d.mts +9 -8
  85. package/dist/esm/api/resources/traces/client/Client.mjs +56 -22
  86. package/dist/esm/api/resources/usage/client/Client.d.mts +13 -12
  87. package/dist/esm/api/resources/usage/client/Client.mjs +67 -24
  88. package/dist/esm/core/auth/AuthProvider.d.mts +1 -4
  89. package/dist/esm/core/auth/BearerToken.d.mts +1 -3
  90. package/dist/esm/core/auth/BearerToken.mjs +6 -7
  91. package/dist/esm/core/auth/index.d.mts +0 -1
  92. package/dist/esm/core/auth/index.mjs +0 -1
  93. package/dist/esm/core/fetcher/BinaryResponse.d.mts +7 -6
  94. package/dist/esm/core/fetcher/EndpointSupplier.d.mts +2 -2
  95. package/dist/esm/core/fetcher/Fetcher.d.mts +4 -10
  96. package/dist/esm/core/fetcher/Fetcher.mjs +10 -204
  97. package/dist/esm/core/fetcher/ResponseWithBody.d.mts +4 -0
  98. package/dist/esm/core/fetcher/ResponseWithBody.mjs +3 -0
  99. package/dist/esm/core/fetcher/getRequestBody.d.mts +1 -1
  100. package/dist/esm/core/fetcher/getRequestBody.mjs +0 -4
  101. package/dist/esm/core/fetcher/getResponseBody.mjs +4 -18
  102. package/dist/esm/core/fetcher/makeRequest.d.mts +1 -1
  103. package/dist/esm/core/fetcher/makeRequest.mjs +2 -0
  104. package/dist/esm/core/fetcher/requestWithRetries.mjs +9 -0
  105. package/dist/esm/core/fetcher/signals.d.mts +7 -1
  106. package/dist/esm/core/fetcher/signals.mjs +12 -0
  107. package/dist/esm/core/headers.d.mts +2 -2
  108. package/dist/esm/core/headers.mjs +4 -6
  109. package/dist/esm/core/index.d.mts +0 -1
  110. package/dist/esm/core/index.mjs +0 -1
  111. package/dist/esm/core/runtime/runtime.mjs +10 -11
  112. package/dist/esm/core/url/join.mjs +1 -0
  113. package/dist/esm/errors/PaidError.mjs +1 -5
  114. package/dist/esm/errors/PaidTimeoutError.mjs +1 -5
  115. package/dist/esm/index.d.mts +0 -1
  116. package/dist/esm/index.mjs +0 -1
  117. package/dist/esm/version.d.mts +1 -1
  118. package/dist/esm/version.mjs +1 -1
  119. package/package.json +3 -6
  120. package/reference.md +54 -54
  121. package/dist/cjs/auth/BearerAuthProvider.d.ts +0 -20
  122. package/dist/cjs/auth/BearerAuthProvider.js +0 -79
  123. package/dist/cjs/auth/index.d.ts +0 -1
  124. package/dist/cjs/auth/index.js +0 -5
  125. package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +0 -5
  126. package/dist/cjs/core/auth/NoOpAuthProvider.js +0 -9
  127. package/dist/cjs/core/exports.d.ts +0 -1
  128. package/dist/cjs/core/exports.js +0 -17
  129. package/dist/cjs/core/logging/exports.d.ts +0 -18
  130. package/dist/cjs/core/logging/exports.js +0 -45
  131. package/dist/cjs/core/logging/index.d.ts +0 -1
  132. package/dist/cjs/core/logging/index.js +0 -17
  133. package/dist/cjs/core/logging/logger.d.ts +0 -126
  134. package/dist/cjs/core/logging/logger.js +0 -144
  135. package/dist/cjs/errors/handleNonStatusCodeError.d.ts +0 -2
  136. package/dist/cjs/errors/handleNonStatusCodeError.js +0 -65
  137. package/dist/cjs/exports.d.ts +0 -1
  138. package/dist/cjs/exports.js +0 -17
  139. package/dist/esm/auth/BearerAuthProvider.d.mts +0 -20
  140. package/dist/esm/auth/BearerAuthProvider.mjs +0 -42
  141. package/dist/esm/auth/index.d.mts +0 -1
  142. package/dist/esm/auth/index.mjs +0 -1
  143. package/dist/esm/core/auth/NoOpAuthProvider.d.mts +0 -5
  144. package/dist/esm/core/auth/NoOpAuthProvider.mjs +0 -5
  145. package/dist/esm/core/exports.d.mts +0 -1
  146. package/dist/esm/core/exports.mjs +0 -1
  147. package/dist/esm/core/logging/exports.d.mts +0 -18
  148. package/dist/esm/core/logging/exports.mjs +0 -9
  149. package/dist/esm/core/logging/index.d.mts +0 -1
  150. package/dist/esm/core/logging/index.mjs +0 -1
  151. package/dist/esm/core/logging/logger.d.mts +0 -126
  152. package/dist/esm/core/logging/logger.mjs +0 -138
  153. package/dist/esm/errors/handleNonStatusCodeError.d.mts +0 -2
  154. package/dist/esm/errors/handleNonStatusCodeError.mjs +0 -29
  155. package/dist/esm/exports.d.mts +0 -1
  156. package/dist/esm/exports.mjs +0 -1
@@ -1,19 +1,19 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js";
2
- import { type NormalizedClientOptions } from "../../../../../../BaseClient.js";
3
2
  import * as core from "../../../../../../core/index.js";
4
3
  import type * as Paid from "../../../../../index.js";
5
- export declare namespace LinesClient {
6
- type Options = BaseClientOptions;
4
+ export declare namespace Lines {
5
+ interface Options extends BaseClientOptions {
6
+ }
7
7
  interface RequestOptions extends BaseRequestOptions {
8
8
  }
9
9
  }
10
- export declare class LinesClient {
11
- protected readonly _options: NormalizedClientOptions<LinesClient.Options>;
12
- constructor(options?: LinesClient.Options);
10
+ export declare class Lines {
11
+ protected readonly _options: Lines.Options;
12
+ constructor(_options?: Lines.Options);
13
13
  /**
14
14
  * @param {string} orderId
15
15
  * @param {Paid.orders.LinesUpdateRequest} request
16
- * @param {LinesClient.RequestOptions} requestOptions - Request-specific configuration.
16
+ * @param {Lines.RequestOptions} requestOptions - Request-specific configuration.
17
17
  *
18
18
  * @example
19
19
  * await client.orders.lines.update("orderId", {
@@ -26,6 +26,7 @@ export declare class LinesClient {
26
26
  * }]
27
27
  * })
28
28
  */
29
- update(orderId: string, request?: Paid.orders.LinesUpdateRequest, requestOptions?: LinesClient.RequestOptions): core.HttpResponsePromise<Paid.Order>;
29
+ update(orderId: string, request?: Paid.orders.LinesUpdateRequest, requestOptions?: Lines.RequestOptions): core.HttpResponsePromise<Paid.Order>;
30
30
  private __update;
31
+ protected _getAuthorizationHeader(): Promise<string | undefined>;
31
32
  }
@@ -43,21 +43,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
43
43
  });
44
44
  };
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.LinesClient = void 0;
47
- const BaseClient_js_1 = require("../../../../../../BaseClient.js");
46
+ exports.Lines = void 0;
48
47
  const headers_js_1 = require("../../../../../../core/headers.js");
49
48
  const core = __importStar(require("../../../../../../core/index.js"));
50
49
  const environments = __importStar(require("../../../../../../environments.js"));
51
- const handleNonStatusCodeError_js_1 = require("../../../../../../errors/handleNonStatusCodeError.js");
52
50
  const errors = __importStar(require("../../../../../../errors/index.js"));
53
- class LinesClient {
54
- constructor(options = {}) {
55
- this._options = (0, BaseClient_js_1.normalizeClientOptions)(options);
51
+ class Lines {
52
+ constructor(_options = {}) {
53
+ this._options = _options;
56
54
  }
57
55
  /**
58
56
  * @param {string} orderId
59
57
  * @param {Paid.orders.LinesUpdateRequest} request
60
- * @param {LinesClient.RequestOptions} requestOptions - Request-specific configuration.
58
+ * @param {Lines.RequestOptions} requestOptions - Request-specific configuration.
61
59
  *
62
60
  * @example
63
61
  * await client.orders.lines.update("orderId", {
@@ -75,8 +73,8 @@ class LinesClient {
75
73
  }
76
74
  __update(orderId_1) {
77
75
  return __awaiter(this, arguments, void 0, function* (orderId, request = {}, requestOptions) {
78
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
79
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
76
+ var _a, _b, _c, _d, _e, _f, _g, _h;
77
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
80
78
  const _response = yield core.fetcher({
81
79
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Production, `orders/${core.url.encodePathParam(orderId)}/lines`),
82
80
  method: "PUT",
@@ -88,8 +86,6 @@ class LinesClient {
88
86
  timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
89
87
  maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
90
88
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
91
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
92
- logging: this._options.logging,
93
89
  });
94
90
  if (_response.ok) {
95
91
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -101,8 +97,31 @@ class LinesClient {
101
97
  rawResponse: _response.rawResponse,
102
98
  });
103
99
  }
104
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "PUT", "/orders/{orderId}/lines");
100
+ switch (_response.error.reason) {
101
+ case "non-json":
102
+ throw new errors.PaidError({
103
+ statusCode: _response.error.statusCode,
104
+ body: _response.error.rawBody,
105
+ rawResponse: _response.rawResponse,
106
+ });
107
+ case "timeout":
108
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling PUT /orders/{orderId}/lines.");
109
+ case "unknown":
110
+ throw new errors.PaidError({
111
+ message: _response.error.errorMessage,
112
+ rawResponse: _response.rawResponse,
113
+ });
114
+ }
115
+ });
116
+ }
117
+ _getAuthorizationHeader() {
118
+ return __awaiter(this, void 0, void 0, function* () {
119
+ const bearer = yield core.Supplier.get(this._options.token);
120
+ if (bearer != null) {
121
+ return `Bearer ${bearer}`;
122
+ }
123
+ return undefined;
105
124
  });
106
125
  }
107
126
  }
108
- exports.LinesClient = LinesClient;
127
+ exports.Lines = Lines;
@@ -1,18 +1,18 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
2
- import { type NormalizedClientOptions } from "../../../../BaseClient.js";
3
2
  import * as core from "../../../../core/index.js";
4
3
  import * as Paid from "../../../index.js";
5
- export declare namespace PlansClient {
6
- type Options = BaseClientOptions;
4
+ export declare namespace Plans {
5
+ interface Options extends BaseClientOptions {
6
+ }
7
7
  interface RequestOptions extends BaseRequestOptions {
8
8
  }
9
9
  }
10
- export declare class PlansClient {
11
- protected readonly _options: NormalizedClientOptions<PlansClient.Options>;
12
- constructor(options?: PlansClient.Options);
10
+ export declare class Plans {
11
+ protected readonly _options: Plans.Options;
12
+ constructor(_options?: Plans.Options);
13
13
  /**
14
14
  * @param {string} planId - The ID of the plan
15
- * @param {PlansClient.RequestOptions} requestOptions - Request-specific configuration.
15
+ * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
16
16
  *
17
17
  * @throws {@link Paid.ForbiddenError}
18
18
  * @throws {@link Paid.NotFoundError}
@@ -20,12 +20,12 @@ export declare class PlansClient {
20
20
  * @example
21
21
  * await client.plans.getById("planId")
22
22
  */
23
- getById(planId: string, requestOptions?: PlansClient.RequestOptions): core.HttpResponsePromise<Paid.Plan>;
23
+ getById(planId: string, requestOptions?: Plans.RequestOptions): core.HttpResponsePromise<Paid.Plan>;
24
24
  private __getById;
25
25
  /**
26
26
  * @param {string} planId - The ID of the plan
27
27
  * @param {Paid.PlansGetUsageRequest} request
28
- * @param {PlansClient.RequestOptions} requestOptions - Request-specific configuration.
28
+ * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
29
29
  *
30
30
  * @throws {@link Paid.BadRequestError}
31
31
  * @throws {@link Paid.ForbiddenError}
@@ -40,11 +40,11 @@ export declare class PlansClient {
40
40
  * endTime: "2024-01-15T09:30:00Z"
41
41
  * })
42
42
  */
43
- getUsage(planId: string, request: Paid.PlansGetUsageRequest, requestOptions?: PlansClient.RequestOptions): core.HttpResponsePromise<Paid.UsageSummariesResponse>;
43
+ getUsage(planId: string, request: Paid.PlansGetUsageRequest, requestOptions?: Plans.RequestOptions): core.HttpResponsePromise<Paid.UsageSummariesResponse>;
44
44
  private __getUsage;
45
45
  /**
46
46
  * @param {string} planGroupId - The ID of the plan group
47
- * @param {PlansClient.RequestOptions} requestOptions - Request-specific configuration.
47
+ * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
48
48
  *
49
49
  * @throws {@link Paid.ForbiddenError}
50
50
  * @throws {@link Paid.NotFoundError}
@@ -52,6 +52,7 @@ export declare class PlansClient {
52
52
  * @example
53
53
  * await client.plans.getGroupById("planGroupId")
54
54
  */
55
- getGroupById(planGroupId: string, requestOptions?: PlansClient.RequestOptions): core.HttpResponsePromise<Paid.PlanGroup>;
55
+ getGroupById(planGroupId: string, requestOptions?: Plans.RequestOptions): core.HttpResponsePromise<Paid.PlanGroup>;
56
56
  private __getGroupById;
57
+ protected _getAuthorizationHeader(): Promise<string | undefined>;
57
58
  }
@@ -43,21 +43,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
43
43
  });
44
44
  };
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.PlansClient = void 0;
47
- const BaseClient_js_1 = require("../../../../BaseClient.js");
46
+ exports.Plans = void 0;
48
47
  const headers_js_1 = require("../../../../core/headers.js");
49
48
  const core = __importStar(require("../../../../core/index.js"));
50
49
  const environments = __importStar(require("../../../../environments.js"));
51
- const handleNonStatusCodeError_js_1 = require("../../../../errors/handleNonStatusCodeError.js");
52
50
  const errors = __importStar(require("../../../../errors/index.js"));
53
51
  const Paid = __importStar(require("../../../index.js"));
54
- class PlansClient {
55
- constructor(options = {}) {
56
- this._options = (0, BaseClient_js_1.normalizeClientOptions)(options);
52
+ class Plans {
53
+ constructor(_options = {}) {
54
+ this._options = _options;
57
55
  }
58
56
  /**
59
57
  * @param {string} planId - The ID of the plan
60
- * @param {PlansClient.RequestOptions} requestOptions - Request-specific configuration.
58
+ * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
61
59
  *
62
60
  * @throws {@link Paid.ForbiddenError}
63
61
  * @throws {@link Paid.NotFoundError}
@@ -70,8 +68,8 @@ class PlansClient {
70
68
  }
71
69
  __getById(planId, requestOptions) {
72
70
  return __awaiter(this, void 0, void 0, function* () {
73
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
74
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
71
+ var _a, _b, _c, _d, _e, _f, _g, _h;
72
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
75
73
  const _response = yield core.fetcher({
76
74
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Production, `plans/${core.url.encodePathParam(planId)}`),
77
75
  method: "GET",
@@ -80,8 +78,6 @@ class PlansClient {
80
78
  timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
81
79
  maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
82
80
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
83
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
84
- logging: this._options.logging,
85
81
  });
86
82
  if (_response.ok) {
87
83
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -100,13 +96,27 @@ class PlansClient {
100
96
  });
101
97
  }
102
98
  }
103
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/plans/{planId}");
99
+ switch (_response.error.reason) {
100
+ case "non-json":
101
+ throw new errors.PaidError({
102
+ statusCode: _response.error.statusCode,
103
+ body: _response.error.rawBody,
104
+ rawResponse: _response.rawResponse,
105
+ });
106
+ case "timeout":
107
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /plans/{planId}.");
108
+ case "unknown":
109
+ throw new errors.PaidError({
110
+ message: _response.error.errorMessage,
111
+ rawResponse: _response.rawResponse,
112
+ });
113
+ }
104
114
  });
105
115
  }
106
116
  /**
107
117
  * @param {string} planId - The ID of the plan
108
118
  * @param {Paid.PlansGetUsageRequest} request
109
- * @param {PlansClient.RequestOptions} requestOptions - Request-specific configuration.
119
+ * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
110
120
  *
111
121
  * @throws {@link Paid.BadRequestError}
112
122
  * @throws {@link Paid.ForbiddenError}
@@ -126,16 +136,23 @@ class PlansClient {
126
136
  }
127
137
  __getUsage(planId, request, requestOptions) {
128
138
  return __awaiter(this, void 0, void 0, function* () {
129
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
139
+ var _a, _b, _c, _d, _e, _f, _g, _h;
130
140
  const { externalId, limit, offset, startTime, endTime } = request;
131
- const _queryParams = {
132
- externalId,
133
- limit,
134
- offset,
135
- startTime,
136
- endTime,
137
- };
138
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
141
+ const _queryParams = {};
142
+ _queryParams.externalId = externalId;
143
+ if (limit != null) {
144
+ _queryParams.limit = limit.toString();
145
+ }
146
+ if (offset != null) {
147
+ _queryParams.offset = offset.toString();
148
+ }
149
+ if (startTime != null) {
150
+ _queryParams.startTime = startTime;
151
+ }
152
+ if (endTime != null) {
153
+ _queryParams.endTime = endTime;
154
+ }
155
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
139
156
  const _response = yield core.fetcher({
140
157
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Production, `plans/${core.url.encodePathParam(planId)}/usage`),
141
158
  method: "GET",
@@ -144,8 +161,6 @@ class PlansClient {
144
161
  timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
145
162
  maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
146
163
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
147
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
148
- logging: this._options.logging,
149
164
  });
150
165
  if (_response.ok) {
151
166
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -166,12 +181,26 @@ class PlansClient {
166
181
  });
167
182
  }
168
183
  }
169
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/plans/{planId}/usage");
184
+ switch (_response.error.reason) {
185
+ case "non-json":
186
+ throw new errors.PaidError({
187
+ statusCode: _response.error.statusCode,
188
+ body: _response.error.rawBody,
189
+ rawResponse: _response.rawResponse,
190
+ });
191
+ case "timeout":
192
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /plans/{planId}/usage.");
193
+ case "unknown":
194
+ throw new errors.PaidError({
195
+ message: _response.error.errorMessage,
196
+ rawResponse: _response.rawResponse,
197
+ });
198
+ }
170
199
  });
171
200
  }
172
201
  /**
173
202
  * @param {string} planGroupId - The ID of the plan group
174
- * @param {PlansClient.RequestOptions} requestOptions - Request-specific configuration.
203
+ * @param {Plans.RequestOptions} requestOptions - Request-specific configuration.
175
204
  *
176
205
  * @throws {@link Paid.ForbiddenError}
177
206
  * @throws {@link Paid.NotFoundError}
@@ -184,8 +213,8 @@ class PlansClient {
184
213
  }
185
214
  __getGroupById(planGroupId, requestOptions) {
186
215
  return __awaiter(this, void 0, void 0, function* () {
187
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
188
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
216
+ var _a, _b, _c, _d, _e, _f, _g, _h;
217
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
189
218
  const _response = yield core.fetcher({
190
219
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Production, `plans/group/${core.url.encodePathParam(planGroupId)}`),
191
220
  method: "GET",
@@ -194,8 +223,6 @@ class PlansClient {
194
223
  timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
195
224
  maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
196
225
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
197
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
198
- logging: this._options.logging,
199
226
  });
200
227
  if (_response.ok) {
201
228
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -214,8 +241,31 @@ class PlansClient {
214
241
  });
215
242
  }
216
243
  }
217
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/plans/group/{planGroupId}");
244
+ switch (_response.error.reason) {
245
+ case "non-json":
246
+ throw new errors.PaidError({
247
+ statusCode: _response.error.statusCode,
248
+ body: _response.error.rawBody,
249
+ rawResponse: _response.rawResponse,
250
+ });
251
+ case "timeout":
252
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /plans/group/{planGroupId}.");
253
+ case "unknown":
254
+ throw new errors.PaidError({
255
+ message: _response.error.errorMessage,
256
+ rawResponse: _response.rawResponse,
257
+ });
258
+ }
259
+ });
260
+ }
261
+ _getAuthorizationHeader() {
262
+ return __awaiter(this, void 0, void 0, function* () {
263
+ const bearer = yield core.Supplier.get(this._options.token);
264
+ if (bearer != null) {
265
+ return `Bearer ${bearer}`;
266
+ }
267
+ return undefined;
218
268
  });
219
269
  }
220
270
  }
221
- exports.PlansClient = PlansClient;
271
+ exports.Plans = Plans;
@@ -1,26 +1,26 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
2
- import { type NormalizedClientOptions } from "../../../../BaseClient.js";
3
2
  import * as core from "../../../../core/index.js";
4
3
  import type * as Paid from "../../../index.js";
5
- export declare namespace ProductsClient {
6
- type Options = BaseClientOptions;
4
+ export declare namespace Products {
5
+ interface Options extends BaseClientOptions {
6
+ }
7
7
  interface RequestOptions extends BaseRequestOptions {
8
8
  }
9
9
  }
10
- export declare class ProductsClient {
11
- protected readonly _options: NormalizedClientOptions<ProductsClient.Options>;
12
- constructor(options?: ProductsClient.Options);
10
+ export declare class Products {
11
+ protected readonly _options: Products.Options;
12
+ constructor(_options?: Products.Options);
13
13
  /**
14
- * @param {ProductsClient.RequestOptions} requestOptions - Request-specific configuration.
14
+ * @param {Products.RequestOptions} requestOptions - Request-specific configuration.
15
15
  *
16
16
  * @example
17
17
  * await client.products.list()
18
18
  */
19
- list(requestOptions?: ProductsClient.RequestOptions): core.HttpResponsePromise<Paid.Product[]>;
19
+ list(requestOptions?: Products.RequestOptions): core.HttpResponsePromise<Paid.Product[]>;
20
20
  private __list;
21
21
  /**
22
22
  * @param {Paid.ProductCreate} request
23
- * @param {ProductsClient.RequestOptions} requestOptions - Request-specific configuration.
23
+ * @param {Products.RequestOptions} requestOptions - Request-specific configuration.
24
24
  *
25
25
  * @example
26
26
  * await client.products.create({
@@ -30,62 +30,63 @@ export declare class ProductsClient {
30
30
  * type: "product"
31
31
  * })
32
32
  */
33
- create(request: Paid.ProductCreate, requestOptions?: ProductsClient.RequestOptions): core.HttpResponsePromise<Paid.Product>;
33
+ create(request: Paid.ProductCreate, requestOptions?: Products.RequestOptions): core.HttpResponsePromise<Paid.Product>;
34
34
  private __create;
35
35
  /**
36
36
  * @param {string} productId
37
- * @param {ProductsClient.RequestOptions} requestOptions - Request-specific configuration.
37
+ * @param {Products.RequestOptions} requestOptions - Request-specific configuration.
38
38
  *
39
39
  * @example
40
40
  * await client.products.get("productId")
41
41
  */
42
- get(productId: string, requestOptions?: ProductsClient.RequestOptions): core.HttpResponsePromise<Paid.Product>;
42
+ get(productId: string, requestOptions?: Products.RequestOptions): core.HttpResponsePromise<Paid.Product>;
43
43
  private __get;
44
44
  /**
45
45
  * @param {string} productId
46
46
  * @param {Paid.ProductUpdate} request
47
- * @param {ProductsClient.RequestOptions} requestOptions - Request-specific configuration.
47
+ * @param {Products.RequestOptions} requestOptions - Request-specific configuration.
48
48
  *
49
49
  * @example
50
50
  * await client.products.update("productId", {})
51
51
  */
52
- update(productId: string, request: Paid.ProductUpdate, requestOptions?: ProductsClient.RequestOptions): core.HttpResponsePromise<Paid.Product>;
52
+ update(productId: string, request: Paid.ProductUpdate, requestOptions?: Products.RequestOptions): core.HttpResponsePromise<Paid.Product>;
53
53
  private __update;
54
54
  /**
55
55
  * @param {string} productId
56
- * @param {ProductsClient.RequestOptions} requestOptions - Request-specific configuration.
56
+ * @param {Products.RequestOptions} requestOptions - Request-specific configuration.
57
57
  *
58
58
  * @example
59
59
  * await client.products.delete("productId")
60
60
  */
61
- delete(productId: string, requestOptions?: ProductsClient.RequestOptions): core.HttpResponsePromise<void>;
61
+ delete(productId: string, requestOptions?: Products.RequestOptions): core.HttpResponsePromise<void>;
62
62
  private __delete;
63
63
  /**
64
64
  * @param {string} externalId
65
- * @param {ProductsClient.RequestOptions} requestOptions - Request-specific configuration.
65
+ * @param {Products.RequestOptions} requestOptions - Request-specific configuration.
66
66
  *
67
67
  * @example
68
68
  * await client.products.getByExternalId("externalId")
69
69
  */
70
- getByExternalId(externalId: string, requestOptions?: ProductsClient.RequestOptions): core.HttpResponsePromise<Paid.Product>;
70
+ getByExternalId(externalId: string, requestOptions?: Products.RequestOptions): core.HttpResponsePromise<Paid.Product>;
71
71
  private __getByExternalId;
72
72
  /**
73
73
  * @param {string} externalId
74
74
  * @param {Paid.ProductUpdate} request
75
- * @param {ProductsClient.RequestOptions} requestOptions - Request-specific configuration.
75
+ * @param {Products.RequestOptions} requestOptions - Request-specific configuration.
76
76
  *
77
77
  * @example
78
78
  * await client.products.updateByExternalId("externalId", {})
79
79
  */
80
- updateByExternalId(externalId: string, request: Paid.ProductUpdate, requestOptions?: ProductsClient.RequestOptions): core.HttpResponsePromise<Paid.Product>;
80
+ updateByExternalId(externalId: string, request: Paid.ProductUpdate, requestOptions?: Products.RequestOptions): core.HttpResponsePromise<Paid.Product>;
81
81
  private __updateByExternalId;
82
82
  /**
83
83
  * @param {string} externalId
84
- * @param {ProductsClient.RequestOptions} requestOptions - Request-specific configuration.
84
+ * @param {Products.RequestOptions} requestOptions - Request-specific configuration.
85
85
  *
86
86
  * @example
87
87
  * await client.products.deleteByExternalId("externalId")
88
88
  */
89
- deleteByExternalId(externalId: string, requestOptions?: ProductsClient.RequestOptions): core.HttpResponsePromise<void>;
89
+ deleteByExternalId(externalId: string, requestOptions?: Products.RequestOptions): core.HttpResponsePromise<void>;
90
90
  private __deleteByExternalId;
91
+ protected _getAuthorizationHeader(): Promise<string | undefined>;
91
92
  }