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

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 (196) 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 +25 -12
  20. package/dist/cjs/api/resources/plans/client/Client.js +143 -33
  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 +16 -15
  28. package/dist/cjs/api/resources/usage/client/Client.js +71 -28
  29. package/dist/cjs/api/resources/usage/client/requests/UsageRecordBulkV2Request.d.ts +3 -3
  30. package/dist/cjs/api/types/PlanWithFeatures.d.ts +34 -0
  31. package/dist/cjs/api/types/PlanWithFeatures.js +3 -0
  32. package/dist/cjs/api/types/SignalV2.d.ts +5 -5
  33. package/dist/cjs/api/types/index.d.ts +1 -0
  34. package/dist/cjs/api/types/index.js +1 -0
  35. package/dist/cjs/core/auth/AuthProvider.d.ts +1 -4
  36. package/dist/cjs/core/auth/BearerToken.d.ts +1 -3
  37. package/dist/cjs/core/auth/BearerToken.js +6 -7
  38. package/dist/cjs/core/auth/index.d.ts +0 -1
  39. package/dist/cjs/core/auth/index.js +1 -3
  40. package/dist/cjs/core/fetcher/BinaryResponse.d.ts +7 -6
  41. package/dist/cjs/core/fetcher/EndpointSupplier.d.ts +2 -2
  42. package/dist/cjs/core/fetcher/Fetcher.d.ts +4 -10
  43. package/dist/cjs/core/fetcher/Fetcher.js +10 -204
  44. package/dist/cjs/core/fetcher/ResponseWithBody.d.ts +4 -0
  45. package/dist/cjs/core/fetcher/ResponseWithBody.js +6 -0
  46. package/dist/cjs/core/fetcher/getRequestBody.d.ts +1 -1
  47. package/dist/cjs/core/fetcher/getRequestBody.js +0 -4
  48. package/dist/cjs/core/fetcher/getResponseBody.js +4 -18
  49. package/dist/cjs/core/fetcher/makeRequest.d.ts +1 -1
  50. package/dist/cjs/core/fetcher/makeRequest.js +2 -0
  51. package/dist/cjs/core/fetcher/requestWithRetries.js +9 -0
  52. package/dist/cjs/core/fetcher/signals.d.ts +7 -1
  53. package/dist/cjs/core/fetcher/signals.js +12 -0
  54. package/dist/cjs/core/headers.d.ts +2 -2
  55. package/dist/cjs/core/headers.js +4 -6
  56. package/dist/cjs/core/index.d.ts +0 -1
  57. package/dist/cjs/core/index.js +1 -2
  58. package/dist/cjs/core/runtime/runtime.js +10 -11
  59. package/dist/cjs/core/url/join.js +1 -0
  60. package/dist/cjs/errors/PaidError.js +1 -5
  61. package/dist/cjs/errors/PaidTimeoutError.js +1 -5
  62. package/dist/cjs/index.d.ts +0 -1
  63. package/dist/cjs/index.js +0 -4
  64. package/dist/cjs/integrations/adapters/expressjs/index.d.ts +2 -2
  65. package/dist/cjs/integrations/adapters/expressjs/index.js +2 -1
  66. package/dist/cjs/integrations/adapters/expressjs/routes.d.ts +16 -0
  67. package/dist/cjs/integrations/adapters/expressjs/routes.js +28 -0
  68. package/dist/cjs/integrations/adapters/nextjs/index.d.ts +1 -1
  69. package/dist/cjs/integrations/adapters/nextjs/index.js +2 -1
  70. package/dist/cjs/integrations/adapters/nextjs/routes.d.ts +15 -0
  71. package/dist/cjs/integrations/adapters/nextjs/routes.js +21 -0
  72. package/dist/cjs/integrations/controllers/index.d.ts +1 -0
  73. package/dist/cjs/integrations/controllers/index.js +3 -1
  74. package/dist/cjs/integrations/controllers/orders.js +52 -17
  75. package/dist/cjs/integrations/controllers/plans.d.ts +50 -0
  76. package/dist/cjs/integrations/controllers/plans.js +88 -0
  77. package/dist/cjs/integrations/types.d.ts +5 -2
  78. package/dist/cjs/version.d.ts +1 -1
  79. package/dist/cjs/version.js +1 -1
  80. package/dist/esm/BaseClient.d.mts +4 -17
  81. package/dist/esm/BaseClient.mjs +1 -24
  82. package/dist/esm/Client.d.mts +28 -28
  83. package/dist/esm/Client.mjs +27 -19
  84. package/dist/esm/api/errors/BadRequestError.mjs +1 -5
  85. package/dist/esm/api/errors/ForbiddenError.mjs +1 -5
  86. package/dist/esm/api/errors/InternalServerError.mjs +1 -5
  87. package/dist/esm/api/errors/NotFoundError.mjs +1 -5
  88. package/dist/esm/api/resources/agents/client/Client.d.mts +23 -22
  89. package/dist/esm/api/resources/agents/client/Client.mjs +157 -54
  90. package/dist/esm/api/resources/contacts/client/Client.d.mts +19 -18
  91. package/dist/esm/api/resources/contacts/client/Client.mjs +121 -42
  92. package/dist/esm/api/resources/customers/client/Client.d.mts +37 -36
  93. package/dist/esm/api/resources/customers/client/Client.mjs +314 -112
  94. package/dist/esm/api/resources/orders/client/Client.d.mts +28 -27
  95. package/dist/esm/api/resources/orders/client/Client.mjs +177 -62
  96. package/dist/esm/api/resources/orders/resources/lines/client/Client.d.mts +9 -8
  97. package/dist/esm/api/resources/orders/resources/lines/client/Client.mjs +31 -12
  98. package/dist/esm/api/resources/plans/client/Client.d.mts +25 -12
  99. package/dist/esm/api/resources/plans/client/Client.mjs +142 -32
  100. package/dist/esm/api/resources/products/client/Client.d.mts +23 -22
  101. package/dist/esm/api/resources/products/client/Client.mjs +157 -54
  102. package/dist/esm/api/resources/products/client/requests/index.d.mts +1 -1
  103. package/dist/esm/api/resources/products/client/requests/index.mjs +1 -1
  104. package/dist/esm/api/resources/traces/client/Client.d.mts +9 -8
  105. package/dist/esm/api/resources/traces/client/Client.mjs +56 -22
  106. package/dist/esm/api/resources/usage/client/Client.d.mts +16 -15
  107. package/dist/esm/api/resources/usage/client/Client.mjs +70 -27
  108. package/dist/esm/api/resources/usage/client/requests/UsageRecordBulkV2Request.d.mts +3 -3
  109. package/dist/esm/api/types/PlanWithFeatures.d.mts +34 -0
  110. package/dist/esm/api/types/PlanWithFeatures.mjs +2 -0
  111. package/dist/esm/api/types/SignalV2.d.mts +5 -5
  112. package/dist/esm/api/types/index.d.mts +1 -0
  113. package/dist/esm/api/types/index.mjs +1 -0
  114. package/dist/esm/core/auth/AuthProvider.d.mts +1 -4
  115. package/dist/esm/core/auth/BearerToken.d.mts +1 -3
  116. package/dist/esm/core/auth/BearerToken.mjs +6 -7
  117. package/dist/esm/core/auth/index.d.mts +0 -1
  118. package/dist/esm/core/auth/index.mjs +0 -1
  119. package/dist/esm/core/fetcher/BinaryResponse.d.mts +7 -6
  120. package/dist/esm/core/fetcher/EndpointSupplier.d.mts +2 -2
  121. package/dist/esm/core/fetcher/Fetcher.d.mts +4 -10
  122. package/dist/esm/core/fetcher/Fetcher.mjs +10 -204
  123. package/dist/esm/core/fetcher/ResponseWithBody.d.mts +4 -0
  124. package/dist/esm/core/fetcher/ResponseWithBody.mjs +3 -0
  125. package/dist/esm/core/fetcher/getRequestBody.d.mts +1 -1
  126. package/dist/esm/core/fetcher/getRequestBody.mjs +0 -4
  127. package/dist/esm/core/fetcher/getResponseBody.mjs +4 -18
  128. package/dist/esm/core/fetcher/makeRequest.d.mts +1 -1
  129. package/dist/esm/core/fetcher/makeRequest.mjs +2 -0
  130. package/dist/esm/core/fetcher/requestWithRetries.mjs +9 -0
  131. package/dist/esm/core/fetcher/signals.d.mts +7 -1
  132. package/dist/esm/core/fetcher/signals.mjs +12 -0
  133. package/dist/esm/core/headers.d.mts +2 -2
  134. package/dist/esm/core/headers.mjs +4 -6
  135. package/dist/esm/core/index.d.mts +0 -1
  136. package/dist/esm/core/index.mjs +0 -1
  137. package/dist/esm/core/runtime/runtime.mjs +10 -11
  138. package/dist/esm/core/url/join.mjs +1 -0
  139. package/dist/esm/errors/PaidError.mjs +1 -5
  140. package/dist/esm/errors/PaidTimeoutError.mjs +1 -5
  141. package/dist/esm/index.d.mts +0 -1
  142. package/dist/esm/index.mjs +0 -1
  143. package/dist/esm/integrations/adapters/expressjs/index.d.mts +2 -2
  144. package/dist/esm/integrations/adapters/expressjs/index.mjs +2 -2
  145. package/dist/esm/integrations/adapters/expressjs/routes.d.mts +16 -0
  146. package/dist/esm/integrations/adapters/expressjs/routes.mjs +27 -0
  147. package/dist/esm/integrations/adapters/nextjs/index.d.mts +1 -1
  148. package/dist/esm/integrations/adapters/nextjs/index.mjs +1 -1
  149. package/dist/esm/integrations/adapters/nextjs/routes.d.mts +15 -0
  150. package/dist/esm/integrations/adapters/nextjs/routes.mjs +20 -0
  151. package/dist/esm/integrations/controllers/index.d.mts +1 -0
  152. package/dist/esm/integrations/controllers/index.mjs +1 -0
  153. package/dist/esm/integrations/controllers/orders.mjs +52 -17
  154. package/dist/esm/integrations/controllers/plans.d.mts +50 -0
  155. package/dist/esm/integrations/controllers/plans.mjs +84 -0
  156. package/dist/esm/integrations/types.d.mts +5 -2
  157. package/dist/esm/version.d.mts +1 -1
  158. package/dist/esm/version.mjs +1 -1
  159. package/package.json +38 -7
  160. package/reference.md +106 -57
  161. package/dist/cjs/auth/BearerAuthProvider.d.ts +0 -20
  162. package/dist/cjs/auth/BearerAuthProvider.js +0 -79
  163. package/dist/cjs/auth/index.d.ts +0 -1
  164. package/dist/cjs/auth/index.js +0 -5
  165. package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +0 -5
  166. package/dist/cjs/core/auth/NoOpAuthProvider.js +0 -9
  167. package/dist/cjs/core/exports.d.ts +0 -1
  168. package/dist/cjs/core/exports.js +0 -17
  169. package/dist/cjs/core/logging/exports.d.ts +0 -18
  170. package/dist/cjs/core/logging/exports.js +0 -45
  171. package/dist/cjs/core/logging/index.d.ts +0 -1
  172. package/dist/cjs/core/logging/index.js +0 -17
  173. package/dist/cjs/core/logging/logger.d.ts +0 -126
  174. package/dist/cjs/core/logging/logger.js +0 -144
  175. package/dist/cjs/errors/handleNonStatusCodeError.d.ts +0 -2
  176. package/dist/cjs/errors/handleNonStatusCodeError.js +0 -65
  177. package/dist/cjs/exports.d.ts +0 -1
  178. package/dist/cjs/exports.js +0 -17
  179. package/dist/esm/auth/BearerAuthProvider.d.mts +0 -20
  180. package/dist/esm/auth/BearerAuthProvider.mjs +0 -42
  181. package/dist/esm/auth/index.d.mts +0 -1
  182. package/dist/esm/auth/index.mjs +0 -1
  183. package/dist/esm/core/auth/NoOpAuthProvider.d.mts +0 -5
  184. package/dist/esm/core/auth/NoOpAuthProvider.mjs +0 -5
  185. package/dist/esm/core/exports.d.mts +0 -1
  186. package/dist/esm/core/exports.mjs +0 -1
  187. package/dist/esm/core/logging/exports.d.mts +0 -18
  188. package/dist/esm/core/logging/exports.mjs +0 -9
  189. package/dist/esm/core/logging/index.d.mts +0 -1
  190. package/dist/esm/core/logging/index.mjs +0 -1
  191. package/dist/esm/core/logging/logger.d.mts +0 -126
  192. package/dist/esm/core/logging/logger.mjs +0 -138
  193. package/dist/esm/errors/handleNonStatusCodeError.d.mts +0 -2
  194. package/dist/esm/errors/handleNonStatusCodeError.mjs +0 -29
  195. package/dist/esm/exports.d.mts +0 -1
  196. package/dist/esm/exports.mjs +0 -1
@@ -43,20 +43,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
43
43
  });
44
44
  };
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.CustomersClient = void 0;
47
- const BaseClient_js_1 = require("../../../../BaseClient.js");
46
+ exports.Customers = 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 CustomersClient {
55
- constructor(options = {}) {
56
- this._options = (0, BaseClient_js_1.normalizeClientOptions)(options);
52
+ class Customers {
53
+ constructor(_options = {}) {
54
+ this._options = _options;
57
55
  }
58
56
  /**
59
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
57
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
60
58
  *
61
59
  * @example
62
60
  * await client.customers.list()
@@ -66,8 +64,8 @@ class CustomersClient {
66
64
  }
67
65
  __list(requestOptions) {
68
66
  return __awaiter(this, void 0, void 0, function* () {
69
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
70
- 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);
67
+ var _a, _b, _c, _d, _e, _f, _g, _h;
68
+ 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);
71
69
  const _response = yield core.fetcher({
72
70
  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, "customers"),
73
71
  method: "GET",
@@ -76,8 +74,6 @@ class CustomersClient {
76
74
  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,
77
75
  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,
78
76
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
79
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
80
- logging: this._options.logging,
81
77
  });
82
78
  if (_response.ok) {
83
79
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -89,12 +85,26 @@ class CustomersClient {
89
85
  rawResponse: _response.rawResponse,
90
86
  });
91
87
  }
92
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/customers");
88
+ switch (_response.error.reason) {
89
+ case "non-json":
90
+ throw new errors.PaidError({
91
+ statusCode: _response.error.statusCode,
92
+ body: _response.error.rawBody,
93
+ rawResponse: _response.rawResponse,
94
+ });
95
+ case "timeout":
96
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /customers.");
97
+ case "unknown":
98
+ throw new errors.PaidError({
99
+ message: _response.error.errorMessage,
100
+ rawResponse: _response.rawResponse,
101
+ });
102
+ }
93
103
  });
94
104
  }
95
105
  /**
96
106
  * @param {Paid.CustomerCreate} request
97
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
107
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
98
108
  *
99
109
  * @example
100
110
  * await client.customers.create({
@@ -120,8 +130,8 @@ class CustomersClient {
120
130
  }
121
131
  __create(request, requestOptions) {
122
132
  return __awaiter(this, void 0, void 0, function* () {
123
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
124
- 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);
133
+ var _a, _b, _c, _d, _e, _f, _g, _h;
134
+ 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);
125
135
  const _response = yield core.fetcher({
126
136
  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, "customers"),
127
137
  method: "POST",
@@ -133,8 +143,6 @@ class CustomersClient {
133
143
  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,
134
144
  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,
135
145
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
136
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
137
- logging: this._options.logging,
138
146
  });
139
147
  if (_response.ok) {
140
148
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -146,12 +154,26 @@ class CustomersClient {
146
154
  rawResponse: _response.rawResponse,
147
155
  });
148
156
  }
149
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/customers");
157
+ switch (_response.error.reason) {
158
+ case "non-json":
159
+ throw new errors.PaidError({
160
+ statusCode: _response.error.statusCode,
161
+ body: _response.error.rawBody,
162
+ rawResponse: _response.rawResponse,
163
+ });
164
+ case "timeout":
165
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /customers.");
166
+ case "unknown":
167
+ throw new errors.PaidError({
168
+ message: _response.error.errorMessage,
169
+ rawResponse: _response.rawResponse,
170
+ });
171
+ }
150
172
  });
151
173
  }
152
174
  /**
153
175
  * @param {string} customerId
154
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
176
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
155
177
  *
156
178
  * @example
157
179
  * await client.customers.get("customerId")
@@ -161,8 +183,8 @@ class CustomersClient {
161
183
  }
162
184
  __get(customerId, requestOptions) {
163
185
  return __awaiter(this, void 0, void 0, function* () {
164
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
165
- 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);
186
+ var _a, _b, _c, _d, _e, _f, _g, _h;
187
+ 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);
166
188
  const _response = yield core.fetcher({
167
189
  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, `customers/${core.url.encodePathParam(customerId)}`),
168
190
  method: "GET",
@@ -171,8 +193,6 @@ class CustomersClient {
171
193
  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,
172
194
  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,
173
195
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
174
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
175
- logging: this._options.logging,
176
196
  });
177
197
  if (_response.ok) {
178
198
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -184,13 +204,27 @@ class CustomersClient {
184
204
  rawResponse: _response.rawResponse,
185
205
  });
186
206
  }
187
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/customers/{customerId}");
207
+ switch (_response.error.reason) {
208
+ case "non-json":
209
+ throw new errors.PaidError({
210
+ statusCode: _response.error.statusCode,
211
+ body: _response.error.rawBody,
212
+ rawResponse: _response.rawResponse,
213
+ });
214
+ case "timeout":
215
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /customers/{customerId}.");
216
+ case "unknown":
217
+ throw new errors.PaidError({
218
+ message: _response.error.errorMessage,
219
+ rawResponse: _response.rawResponse,
220
+ });
221
+ }
188
222
  });
189
223
  }
190
224
  /**
191
225
  * @param {string} customerId
192
226
  * @param {Paid.CustomerUpdate} request
193
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
227
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
194
228
  *
195
229
  * @example
196
230
  * await client.customers.update("customerId", {
@@ -205,8 +239,8 @@ class CustomersClient {
205
239
  }
206
240
  __update(customerId, request, requestOptions) {
207
241
  return __awaiter(this, void 0, void 0, function* () {
208
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
209
- 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);
242
+ var _a, _b, _c, _d, _e, _f, _g, _h;
243
+ 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);
210
244
  const _response = yield core.fetcher({
211
245
  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, `customers/${core.url.encodePathParam(customerId)}`),
212
246
  method: "PUT",
@@ -218,8 +252,6 @@ class CustomersClient {
218
252
  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,
219
253
  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,
220
254
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
221
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
222
- logging: this._options.logging,
223
255
  });
224
256
  if (_response.ok) {
225
257
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -231,12 +263,26 @@ class CustomersClient {
231
263
  rawResponse: _response.rawResponse,
232
264
  });
233
265
  }
234
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "PUT", "/customers/{customerId}");
266
+ switch (_response.error.reason) {
267
+ case "non-json":
268
+ throw new errors.PaidError({
269
+ statusCode: _response.error.statusCode,
270
+ body: _response.error.rawBody,
271
+ rawResponse: _response.rawResponse,
272
+ });
273
+ case "timeout":
274
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling PUT /customers/{customerId}.");
275
+ case "unknown":
276
+ throw new errors.PaidError({
277
+ message: _response.error.errorMessage,
278
+ rawResponse: _response.rawResponse,
279
+ });
280
+ }
235
281
  });
236
282
  }
237
283
  /**
238
284
  * @param {string} customerId
239
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
285
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
240
286
  *
241
287
  * @example
242
288
  * await client.customers.delete("customerId")
@@ -246,8 +292,8 @@ class CustomersClient {
246
292
  }
247
293
  __delete(customerId, requestOptions) {
248
294
  return __awaiter(this, void 0, void 0, function* () {
249
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
250
- 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);
295
+ var _a, _b, _c, _d, _e, _f, _g, _h;
296
+ 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);
251
297
  const _response = yield core.fetcher({
252
298
  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, `customers/${core.url.encodePathParam(customerId)}`),
253
299
  method: "DELETE",
@@ -256,8 +302,6 @@ class CustomersClient {
256
302
  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,
257
303
  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,
258
304
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
259
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
260
- logging: this._options.logging,
261
305
  });
262
306
  if (_response.ok) {
263
307
  return { data: undefined, rawResponse: _response.rawResponse };
@@ -269,13 +313,27 @@ class CustomersClient {
269
313
  rawResponse: _response.rawResponse,
270
314
  });
271
315
  }
272
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "DELETE", "/customers/{customerId}");
316
+ switch (_response.error.reason) {
317
+ case "non-json":
318
+ throw new errors.PaidError({
319
+ statusCode: _response.error.statusCode,
320
+ body: _response.error.rawBody,
321
+ rawResponse: _response.rawResponse,
322
+ });
323
+ case "timeout":
324
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling DELETE /customers/{customerId}.");
325
+ case "unknown":
326
+ throw new errors.PaidError({
327
+ message: _response.error.errorMessage,
328
+ rawResponse: _response.rawResponse,
329
+ });
330
+ }
273
331
  });
274
332
  }
275
333
  /**
276
334
  * @param {string} customerId - The customer ID
277
335
  * @param {Paid.CustomersCheckEntitlementRequest} request
278
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
336
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
279
337
  *
280
338
  * @throws {@link Paid.BadRequestError}
281
339
  * @throws {@link Paid.NotFoundError}
@@ -291,13 +349,14 @@ class CustomersClient {
291
349
  }
292
350
  __checkEntitlement(customerId, request, requestOptions) {
293
351
  return __awaiter(this, void 0, void 0, function* () {
294
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
352
+ var _a, _b, _c, _d, _e, _f, _g, _h;
295
353
  const { event_name: eventName, view } = request;
296
- const _queryParams = {
297
- event_name: eventName,
298
- view: view != null ? view : undefined,
299
- };
300
- 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);
354
+ const _queryParams = {};
355
+ _queryParams.event_name = eventName;
356
+ if (view != null) {
357
+ _queryParams.view = view;
358
+ }
359
+ 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);
301
360
  const _response = yield core.fetcher({
302
361
  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, `customers/${core.url.encodePathParam(customerId)}/entitlement`),
303
362
  method: "GET",
@@ -306,8 +365,6 @@ class CustomersClient {
306
365
  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,
307
366
  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,
308
367
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
309
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
310
- logging: this._options.logging,
311
368
  });
312
369
  if (_response.ok) {
313
370
  return {
@@ -329,12 +386,26 @@ class CustomersClient {
329
386
  });
330
387
  }
331
388
  }
332
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/customers/{customerId}/entitlement");
389
+ switch (_response.error.reason) {
390
+ case "non-json":
391
+ throw new errors.PaidError({
392
+ statusCode: _response.error.statusCode,
393
+ body: _response.error.rawBody,
394
+ rawResponse: _response.rawResponse,
395
+ });
396
+ case "timeout":
397
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /customers/{customerId}/entitlement.");
398
+ case "unknown":
399
+ throw new errors.PaidError({
400
+ message: _response.error.errorMessage,
401
+ rawResponse: _response.rawResponse,
402
+ });
403
+ }
333
404
  });
334
405
  }
335
406
  /**
336
407
  * @param {string} customerId - The customer ID
337
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
408
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
338
409
  *
339
410
  * @throws {@link Paid.ForbiddenError}
340
411
  *
@@ -346,8 +417,8 @@ class CustomersClient {
346
417
  }
347
418
  __getEntitlements(customerId, requestOptions) {
348
419
  return __awaiter(this, void 0, void 0, function* () {
349
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
350
- 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);
420
+ var _a, _b, _c, _d, _e, _f, _g, _h;
421
+ 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);
351
422
  const _response = yield core.fetcher({
352
423
  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, `customers/${core.url.encodePathParam(customerId)}/credit-bundles`),
353
424
  method: "GET",
@@ -356,8 +427,6 @@ class CustomersClient {
356
427
  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,
357
428
  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,
358
429
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
359
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
360
- logging: this._options.logging,
361
430
  });
362
431
  if (_response.ok) {
363
432
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -374,12 +443,26 @@ class CustomersClient {
374
443
  });
375
444
  }
376
445
  }
377
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/customers/{customerId}/credit-bundles");
446
+ switch (_response.error.reason) {
447
+ case "non-json":
448
+ throw new errors.PaidError({
449
+ statusCode: _response.error.statusCode,
450
+ body: _response.error.rawBody,
451
+ rawResponse: _response.rawResponse,
452
+ });
453
+ case "timeout":
454
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /customers/{customerId}/credit-bundles.");
455
+ case "unknown":
456
+ throw new errors.PaidError({
457
+ message: _response.error.errorMessage,
458
+ rawResponse: _response.rawResponse,
459
+ });
460
+ }
378
461
  });
379
462
  }
380
463
  /**
381
464
  * @param {string} externalId
382
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
465
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
383
466
  *
384
467
  * @example
385
468
  * await client.customers.getByExternalId("externalId")
@@ -389,8 +472,8 @@ class CustomersClient {
389
472
  }
390
473
  __getByExternalId(externalId, requestOptions) {
391
474
  return __awaiter(this, void 0, void 0, function* () {
392
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
393
- 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);
475
+ var _a, _b, _c, _d, _e, _f, _g, _h;
476
+ 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);
394
477
  const _response = yield core.fetcher({
395
478
  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, `customers/external/${core.url.encodePathParam(externalId)}`),
396
479
  method: "GET",
@@ -399,8 +482,6 @@ class CustomersClient {
399
482
  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,
400
483
  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,
401
484
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
402
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
403
- logging: this._options.logging,
404
485
  });
405
486
  if (_response.ok) {
406
487
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -412,13 +493,27 @@ class CustomersClient {
412
493
  rawResponse: _response.rawResponse,
413
494
  });
414
495
  }
415
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/customers/external/{externalId}");
496
+ switch (_response.error.reason) {
497
+ case "non-json":
498
+ throw new errors.PaidError({
499
+ statusCode: _response.error.statusCode,
500
+ body: _response.error.rawBody,
501
+ rawResponse: _response.rawResponse,
502
+ });
503
+ case "timeout":
504
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /customers/external/{externalId}.");
505
+ case "unknown":
506
+ throw new errors.PaidError({
507
+ message: _response.error.errorMessage,
508
+ rawResponse: _response.rawResponse,
509
+ });
510
+ }
416
511
  });
417
512
  }
418
513
  /**
419
514
  * @param {string} externalId
420
515
  * @param {Paid.CustomerUpdate} request
421
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
516
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
422
517
  *
423
518
  * @example
424
519
  * await client.customers.updateByExternalId("externalId", {})
@@ -428,8 +523,8 @@ class CustomersClient {
428
523
  }
429
524
  __updateByExternalId(externalId, request, requestOptions) {
430
525
  return __awaiter(this, void 0, void 0, function* () {
431
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
432
- 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);
526
+ var _a, _b, _c, _d, _e, _f, _g, _h;
527
+ 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);
433
528
  const _response = yield core.fetcher({
434
529
  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, `customers/external/${core.url.encodePathParam(externalId)}`),
435
530
  method: "PUT",
@@ -441,8 +536,6 @@ class CustomersClient {
441
536
  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,
442
537
  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,
443
538
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
444
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
445
- logging: this._options.logging,
446
539
  });
447
540
  if (_response.ok) {
448
541
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -454,12 +547,26 @@ class CustomersClient {
454
547
  rawResponse: _response.rawResponse,
455
548
  });
456
549
  }
457
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "PUT", "/customers/external/{externalId}");
550
+ switch (_response.error.reason) {
551
+ case "non-json":
552
+ throw new errors.PaidError({
553
+ statusCode: _response.error.statusCode,
554
+ body: _response.error.rawBody,
555
+ rawResponse: _response.rawResponse,
556
+ });
557
+ case "timeout":
558
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling PUT /customers/external/{externalId}.");
559
+ case "unknown":
560
+ throw new errors.PaidError({
561
+ message: _response.error.errorMessage,
562
+ rawResponse: _response.rawResponse,
563
+ });
564
+ }
458
565
  });
459
566
  }
460
567
  /**
461
568
  * @param {string} externalId
462
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
569
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
463
570
  *
464
571
  * @example
465
572
  * await client.customers.deleteByExternalId("externalId")
@@ -469,8 +576,8 @@ class CustomersClient {
469
576
  }
470
577
  __deleteByExternalId(externalId, requestOptions) {
471
578
  return __awaiter(this, void 0, void 0, function* () {
472
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
473
- 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);
579
+ var _a, _b, _c, _d, _e, _f, _g, _h;
580
+ 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);
474
581
  const _response = yield core.fetcher({
475
582
  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, `customers/external/${core.url.encodePathParam(externalId)}`),
476
583
  method: "DELETE",
@@ -479,8 +586,6 @@ class CustomersClient {
479
586
  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,
480
587
  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,
481
588
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
482
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
483
- logging: this._options.logging,
484
589
  });
485
590
  if (_response.ok) {
486
591
  return { data: undefined, rawResponse: _response.rawResponse };
@@ -492,13 +597,27 @@ class CustomersClient {
492
597
  rawResponse: _response.rawResponse,
493
598
  });
494
599
  }
495
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "DELETE", "/customers/external/{externalId}");
600
+ switch (_response.error.reason) {
601
+ case "non-json":
602
+ throw new errors.PaidError({
603
+ statusCode: _response.error.statusCode,
604
+ body: _response.error.rawBody,
605
+ rawResponse: _response.rawResponse,
606
+ });
607
+ case "timeout":
608
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling DELETE /customers/external/{externalId}.");
609
+ case "unknown":
610
+ throw new errors.PaidError({
611
+ message: _response.error.errorMessage,
612
+ rawResponse: _response.rawResponse,
613
+ });
614
+ }
496
615
  });
497
616
  }
498
617
  /**
499
618
  * @param {string} externalId - The external ID of the customer
500
619
  * @param {Paid.CustomersGetCostsByExternalIdRequest} request
501
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
620
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
502
621
  *
503
622
  * @throws {@link Paid.BadRequestError}
504
623
  * @throws {@link Paid.ForbiddenError}
@@ -517,15 +636,22 @@ class CustomersClient {
517
636
  }
518
637
  __getCostsByExternalId(externalId_1) {
519
638
  return __awaiter(this, arguments, void 0, function* (externalId, request = {}, requestOptions) {
520
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
639
+ var _a, _b, _c, _d, _e, _f, _g, _h;
521
640
  const { limit, offset, startTime, endTime } = request;
522
- const _queryParams = {
523
- limit,
524
- offset,
525
- startTime,
526
- endTime,
527
- };
528
- 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);
641
+ const _queryParams = {};
642
+ if (limit != null) {
643
+ _queryParams.limit = limit.toString();
644
+ }
645
+ if (offset != null) {
646
+ _queryParams.offset = offset.toString();
647
+ }
648
+ if (startTime != null) {
649
+ _queryParams.startTime = startTime;
650
+ }
651
+ if (endTime != null) {
652
+ _queryParams.endTime = endTime;
653
+ }
654
+ 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);
529
655
  const _response = yield core.fetcher({
530
656
  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, `customers/external/${core.url.encodePathParam(externalId)}/costs`),
531
657
  method: "GET",
@@ -534,8 +660,6 @@ class CustomersClient {
534
660
  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,
535
661
  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,
536
662
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
537
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
538
- logging: this._options.logging,
539
663
  });
540
664
  if (_response.ok) {
541
665
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -556,13 +680,27 @@ class CustomersClient {
556
680
  });
557
681
  }
558
682
  }
559
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/customers/external/{externalId}/costs");
683
+ switch (_response.error.reason) {
684
+ case "non-json":
685
+ throw new errors.PaidError({
686
+ statusCode: _response.error.statusCode,
687
+ body: _response.error.rawBody,
688
+ rawResponse: _response.rawResponse,
689
+ });
690
+ case "timeout":
691
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /customers/external/{externalId}/costs.");
692
+ case "unknown":
693
+ throw new errors.PaidError({
694
+ message: _response.error.errorMessage,
695
+ rawResponse: _response.rawResponse,
696
+ });
697
+ }
560
698
  });
561
699
  }
562
700
  /**
563
701
  * @param {string} externalId - The external ID of the customer
564
702
  * @param {Paid.CustomersGetUsageByExternalIdRequest} request
565
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
703
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
566
704
  *
567
705
  * @throws {@link Paid.BadRequestError}
568
706
  * @throws {@link Paid.ForbiddenError}
@@ -581,15 +719,22 @@ class CustomersClient {
581
719
  }
582
720
  __getUsageByExternalId(externalId_1) {
583
721
  return __awaiter(this, arguments, void 0, function* (externalId, request = {}, requestOptions) {
584
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
722
+ var _a, _b, _c, _d, _e, _f, _g, _h;
585
723
  const { limit, offset, startTime, endTime } = request;
586
- const _queryParams = {
587
- limit,
588
- offset,
589
- startTime,
590
- endTime,
591
- };
592
- 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);
724
+ const _queryParams = {};
725
+ if (limit != null) {
726
+ _queryParams.limit = limit.toString();
727
+ }
728
+ if (offset != null) {
729
+ _queryParams.offset = offset.toString();
730
+ }
731
+ if (startTime != null) {
732
+ _queryParams.startTime = startTime;
733
+ }
734
+ if (endTime != null) {
735
+ _queryParams.endTime = endTime;
736
+ }
737
+ 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);
593
738
  const _response = yield core.fetcher({
594
739
  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, `customers/external/${core.url.encodePathParam(externalId)}/usage`),
595
740
  method: "GET",
@@ -598,8 +743,6 @@ class CustomersClient {
598
743
  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,
599
744
  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,
600
745
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
601
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
602
- logging: this._options.logging,
603
746
  });
604
747
  if (_response.ok) {
605
748
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -620,14 +763,28 @@ class CustomersClient {
620
763
  });
621
764
  }
622
765
  }
623
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/customers/external/{externalId}/usage");
766
+ switch (_response.error.reason) {
767
+ case "non-json":
768
+ throw new errors.PaidError({
769
+ statusCode: _response.error.statusCode,
770
+ body: _response.error.rawBody,
771
+ rawResponse: _response.rawResponse,
772
+ });
773
+ case "timeout":
774
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /customers/external/{externalId}/usage.");
775
+ case "unknown":
776
+ throw new errors.PaidError({
777
+ message: _response.error.errorMessage,
778
+ rawResponse: _response.rawResponse,
779
+ });
780
+ }
624
781
  });
625
782
  }
626
783
  /**
627
784
  * Retrieves all payment methods associated with a customer identified by their external ID.
628
785
  *
629
786
  * @param {string} externalId - The external ID of the customer
630
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
787
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
631
788
  *
632
789
  * @throws {@link Paid.ForbiddenError}
633
790
  * @throws {@link Paid.NotFoundError}
@@ -640,8 +797,8 @@ class CustomersClient {
640
797
  }
641
798
  __listPaymentMethods(externalId, requestOptions) {
642
799
  return __awaiter(this, void 0, void 0, function* () {
643
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
644
- 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);
800
+ var _a, _b, _c, _d, _e, _f, _g, _h;
801
+ 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);
645
802
  const _response = yield core.fetcher({
646
803
  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, `customers/external/${core.url.encodePathParam(externalId)}/payment-methods`),
647
804
  method: "GET",
@@ -650,8 +807,6 @@ class CustomersClient {
650
807
  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,
651
808
  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,
652
809
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
653
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
654
- logging: this._options.logging,
655
810
  });
656
811
  if (_response.ok) {
657
812
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -670,7 +825,21 @@ class CustomersClient {
670
825
  });
671
826
  }
672
827
  }
673
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/customers/external/{externalId}/payment-methods");
828
+ switch (_response.error.reason) {
829
+ case "non-json":
830
+ throw new errors.PaidError({
831
+ statusCode: _response.error.statusCode,
832
+ body: _response.error.rawBody,
833
+ rawResponse: _response.rawResponse,
834
+ });
835
+ case "timeout":
836
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /customers/external/{externalId}/payment-methods.");
837
+ case "unknown":
838
+ throw new errors.PaidError({
839
+ message: _response.error.errorMessage,
840
+ rawResponse: _response.rawResponse,
841
+ });
842
+ }
674
843
  });
675
844
  }
676
845
  /**
@@ -678,7 +847,7 @@ class CustomersClient {
678
847
  *
679
848
  * @param {string} externalId - The external ID of the customer
680
849
  * @param {Paid.CustomersCreatePaymentMethodRequest} request
681
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
850
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
682
851
  *
683
852
  * @throws {@link Paid.BadRequestError}
684
853
  * @throws {@link Paid.ForbiddenError}
@@ -698,8 +867,8 @@ class CustomersClient {
698
867
  }
699
868
  __createPaymentMethod(externalId, request, requestOptions) {
700
869
  return __awaiter(this, void 0, void 0, function* () {
701
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
702
- 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);
870
+ var _a, _b, _c, _d, _e, _f, _g, _h;
871
+ 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);
703
872
  const _response = yield core.fetcher({
704
873
  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, `customers/external/${core.url.encodePathParam(externalId)}/payment-methods`),
705
874
  method: "POST",
@@ -711,8 +880,6 @@ class CustomersClient {
711
880
  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,
712
881
  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,
713
882
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
714
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
715
- logging: this._options.logging,
716
883
  });
717
884
  if (_response.ok) {
718
885
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -733,7 +900,21 @@ class CustomersClient {
733
900
  });
734
901
  }
735
902
  }
736
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/customers/external/{externalId}/payment-methods");
903
+ switch (_response.error.reason) {
904
+ case "non-json":
905
+ throw new errors.PaidError({
906
+ statusCode: _response.error.statusCode,
907
+ body: _response.error.rawBody,
908
+ rawResponse: _response.rawResponse,
909
+ });
910
+ case "timeout":
911
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /customers/external/{externalId}/payment-methods.");
912
+ case "unknown":
913
+ throw new errors.PaidError({
914
+ message: _response.error.errorMessage,
915
+ rawResponse: _response.rawResponse,
916
+ });
917
+ }
737
918
  });
738
919
  }
739
920
  /**
@@ -741,7 +922,7 @@ class CustomersClient {
741
922
  *
742
923
  * @param {string} externalId - The external ID of the customer
743
924
  * @param {string} paymentMethodId - The ID of the payment method to delete
744
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
925
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
745
926
  *
746
927
  * @throws {@link Paid.ForbiddenError}
747
928
  * @throws {@link Paid.NotFoundError}
@@ -754,8 +935,8 @@ class CustomersClient {
754
935
  }
755
936
  __deletePaymentMethod(externalId, paymentMethodId, requestOptions) {
756
937
  return __awaiter(this, void 0, void 0, function* () {
757
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
758
- 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);
938
+ var _a, _b, _c, _d, _e, _f, _g, _h;
939
+ 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);
759
940
  const _response = yield core.fetcher({
760
941
  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, `customers/external/${core.url.encodePathParam(externalId)}/payment-methods/${core.url.encodePathParam(paymentMethodId)}`),
761
942
  method: "DELETE",
@@ -764,8 +945,6 @@ class CustomersClient {
764
945
  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,
765
946
  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,
766
947
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
767
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
768
- logging: this._options.logging,
769
948
  });
770
949
  if (_response.ok) {
771
950
  return { data: undefined, rawResponse: _response.rawResponse };
@@ -784,8 +963,31 @@ class CustomersClient {
784
963
  });
785
964
  }
786
965
  }
787
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "DELETE", "/customers/external/{externalId}/payment-methods/{paymentMethodId}");
966
+ switch (_response.error.reason) {
967
+ case "non-json":
968
+ throw new errors.PaidError({
969
+ statusCode: _response.error.statusCode,
970
+ body: _response.error.rawBody,
971
+ rawResponse: _response.rawResponse,
972
+ });
973
+ case "timeout":
974
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling DELETE /customers/external/{externalId}/payment-methods/{paymentMethodId}.");
975
+ case "unknown":
976
+ throw new errors.PaidError({
977
+ message: _response.error.errorMessage,
978
+ rawResponse: _response.rawResponse,
979
+ });
980
+ }
981
+ });
982
+ }
983
+ _getAuthorizationHeader() {
984
+ return __awaiter(this, void 0, void 0, function* () {
985
+ const bearer = yield core.Supplier.get(this._options.token);
986
+ if (bearer != null) {
987
+ return `Bearer ${bearer}`;
988
+ }
989
+ return undefined;
788
990
  });
789
991
  }
790
992
  }
791
- exports.CustomersClient = CustomersClient;
993
+ exports.Customers = Customers;