@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
@@ -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.AgentsClient = void 0;
47
- const BaseClient_js_1 = require("../../../../BaseClient.js");
46
+ exports.Agents = 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 AgentsClient {
54
- constructor(options = {}) {
55
- this._options = (0, BaseClient_js_1.normalizeClientOptions)(options);
51
+ class Agents {
52
+ constructor(_options = {}) {
53
+ this._options = _options;
56
54
  }
57
55
  /**
58
56
  * DEPRECATED: Use /products instead. Agents are now products with type='agent'.
59
57
  *
60
- * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
58
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
61
59
  *
62
60
  * @example
63
61
  * await client.agents.list()
@@ -67,8 +65,8 @@ class AgentsClient {
67
65
  }
68
66
  __list(requestOptions) {
69
67
  return __awaiter(this, void 0, void 0, function* () {
70
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
71
- 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);
68
+ var _a, _b, _c, _d, _e, _f, _g, _h;
69
+ 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);
72
70
  const _response = yield core.fetcher({
73
71
  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, "agents"),
74
72
  method: "GET",
@@ -77,8 +75,6 @@ class AgentsClient {
77
75
  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,
78
76
  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,
79
77
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
80
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
81
- logging: this._options.logging,
82
78
  });
83
79
  if (_response.ok) {
84
80
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -90,14 +86,28 @@ class AgentsClient {
90
86
  rawResponse: _response.rawResponse,
91
87
  });
92
88
  }
93
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/agents");
89
+ switch (_response.error.reason) {
90
+ case "non-json":
91
+ throw new errors.PaidError({
92
+ statusCode: _response.error.statusCode,
93
+ body: _response.error.rawBody,
94
+ rawResponse: _response.rawResponse,
95
+ });
96
+ case "timeout":
97
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /agents.");
98
+ case "unknown":
99
+ throw new errors.PaidError({
100
+ message: _response.error.errorMessage,
101
+ rawResponse: _response.rawResponse,
102
+ });
103
+ }
94
104
  });
95
105
  }
96
106
  /**
97
107
  * DEPRECATED: Use POST /products instead.
98
108
  *
99
109
  * @param {Paid.AgentCreate} request
100
- * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
110
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
101
111
  *
102
112
  * @example
103
113
  * await client.agents.create({
@@ -111,8 +121,8 @@ class AgentsClient {
111
121
  }
112
122
  __create(request, requestOptions) {
113
123
  return __awaiter(this, void 0, void 0, function* () {
114
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
115
- 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);
124
+ var _a, _b, _c, _d, _e, _f, _g, _h;
125
+ 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);
116
126
  const _response = yield core.fetcher({
117
127
  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, "agents"),
118
128
  method: "POST",
@@ -124,8 +134,6 @@ class AgentsClient {
124
134
  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,
125
135
  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,
126
136
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
127
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
128
- logging: this._options.logging,
129
137
  });
130
138
  if (_response.ok) {
131
139
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -137,14 +145,28 @@ class AgentsClient {
137
145
  rawResponse: _response.rawResponse,
138
146
  });
139
147
  }
140
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/agents");
148
+ switch (_response.error.reason) {
149
+ case "non-json":
150
+ throw new errors.PaidError({
151
+ statusCode: _response.error.statusCode,
152
+ body: _response.error.rawBody,
153
+ rawResponse: _response.rawResponse,
154
+ });
155
+ case "timeout":
156
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /agents.");
157
+ case "unknown":
158
+ throw new errors.PaidError({
159
+ message: _response.error.errorMessage,
160
+ rawResponse: _response.rawResponse,
161
+ });
162
+ }
141
163
  });
142
164
  }
143
165
  /**
144
166
  * DEPRECATED: Use GET /products/{productId} instead.
145
167
  *
146
168
  * @param {string} agentId
147
- * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
169
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
148
170
  *
149
171
  * @example
150
172
  * await client.agents.get("agentId")
@@ -154,8 +176,8 @@ class AgentsClient {
154
176
  }
155
177
  __get(agentId, requestOptions) {
156
178
  return __awaiter(this, void 0, void 0, function* () {
157
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
158
- 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);
179
+ var _a, _b, _c, _d, _e, _f, _g, _h;
180
+ 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);
159
181
  const _response = yield core.fetcher({
160
182
  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, `agents/${core.url.encodePathParam(agentId)}`),
161
183
  method: "GET",
@@ -164,8 +186,6 @@ class AgentsClient {
164
186
  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,
165
187
  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,
166
188
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
167
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
168
- logging: this._options.logging,
169
189
  });
170
190
  if (_response.ok) {
171
191
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -177,7 +197,21 @@ class AgentsClient {
177
197
  rawResponse: _response.rawResponse,
178
198
  });
179
199
  }
180
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/agents/{agentId}");
200
+ switch (_response.error.reason) {
201
+ case "non-json":
202
+ throw new errors.PaidError({
203
+ statusCode: _response.error.statusCode,
204
+ body: _response.error.rawBody,
205
+ rawResponse: _response.rawResponse,
206
+ });
207
+ case "timeout":
208
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /agents/{agentId}.");
209
+ case "unknown":
210
+ throw new errors.PaidError({
211
+ message: _response.error.errorMessage,
212
+ rawResponse: _response.rawResponse,
213
+ });
214
+ }
181
215
  });
182
216
  }
183
217
  /**
@@ -185,7 +219,7 @@ class AgentsClient {
185
219
  *
186
220
  * @param {string} agentId
187
221
  * @param {Paid.AgentUpdate} request
188
- * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
222
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
189
223
  *
190
224
  * @example
191
225
  * await client.agents.update("agentId", {
@@ -224,8 +258,8 @@ class AgentsClient {
224
258
  }
225
259
  __update(agentId, request, requestOptions) {
226
260
  return __awaiter(this, void 0, void 0, function* () {
227
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
228
- 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);
261
+ var _a, _b, _c, _d, _e, _f, _g, _h;
262
+ 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);
229
263
  const _response = yield core.fetcher({
230
264
  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, `agents/${core.url.encodePathParam(agentId)}`),
231
265
  method: "PUT",
@@ -237,8 +271,6 @@ class AgentsClient {
237
271
  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,
238
272
  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,
239
273
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
240
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
241
- logging: this._options.logging,
242
274
  });
243
275
  if (_response.ok) {
244
276
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -250,14 +282,28 @@ class AgentsClient {
250
282
  rawResponse: _response.rawResponse,
251
283
  });
252
284
  }
253
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "PUT", "/agents/{agentId}");
285
+ switch (_response.error.reason) {
286
+ case "non-json":
287
+ throw new errors.PaidError({
288
+ statusCode: _response.error.statusCode,
289
+ body: _response.error.rawBody,
290
+ rawResponse: _response.rawResponse,
291
+ });
292
+ case "timeout":
293
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling PUT /agents/{agentId}.");
294
+ case "unknown":
295
+ throw new errors.PaidError({
296
+ message: _response.error.errorMessage,
297
+ rawResponse: _response.rawResponse,
298
+ });
299
+ }
254
300
  });
255
301
  }
256
302
  /**
257
303
  * DEPRECATED: Use DELETE /products/{productId} instead.
258
304
  *
259
305
  * @param {string} agentId
260
- * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
306
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
261
307
  *
262
308
  * @example
263
309
  * await client.agents.delete("agentId")
@@ -267,8 +313,8 @@ class AgentsClient {
267
313
  }
268
314
  __delete(agentId, requestOptions) {
269
315
  return __awaiter(this, void 0, void 0, function* () {
270
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
271
- 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);
316
+ var _a, _b, _c, _d, _e, _f, _g, _h;
317
+ 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);
272
318
  const _response = yield core.fetcher({
273
319
  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, `agents/${core.url.encodePathParam(agentId)}`),
274
320
  method: "DELETE",
@@ -277,8 +323,6 @@ class AgentsClient {
277
323
  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,
278
324
  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,
279
325
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
280
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
281
- logging: this._options.logging,
282
326
  });
283
327
  if (_response.ok) {
284
328
  return { data: undefined, rawResponse: _response.rawResponse };
@@ -290,14 +334,28 @@ class AgentsClient {
290
334
  rawResponse: _response.rawResponse,
291
335
  });
292
336
  }
293
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "DELETE", "/agents/{agentId}");
337
+ switch (_response.error.reason) {
338
+ case "non-json":
339
+ throw new errors.PaidError({
340
+ statusCode: _response.error.statusCode,
341
+ body: _response.error.rawBody,
342
+ rawResponse: _response.rawResponse,
343
+ });
344
+ case "timeout":
345
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling DELETE /agents/{agentId}.");
346
+ case "unknown":
347
+ throw new errors.PaidError({
348
+ message: _response.error.errorMessage,
349
+ rawResponse: _response.rawResponse,
350
+ });
351
+ }
294
352
  });
295
353
  }
296
354
  /**
297
355
  * DEPRECATED: Use GET /products/external/{externalId} instead.
298
356
  *
299
357
  * @param {string} externalId
300
- * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
358
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
301
359
  *
302
360
  * @example
303
361
  * await client.agents.getByExternalId("externalId")
@@ -307,8 +365,8 @@ class AgentsClient {
307
365
  }
308
366
  __getByExternalId(externalId, requestOptions) {
309
367
  return __awaiter(this, void 0, void 0, function* () {
310
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
311
- 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);
368
+ var _a, _b, _c, _d, _e, _f, _g, _h;
369
+ 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);
312
370
  const _response = yield core.fetcher({
313
371
  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, `agents/external/${core.url.encodePathParam(externalId)}`),
314
372
  method: "GET",
@@ -317,8 +375,6 @@ class AgentsClient {
317
375
  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,
318
376
  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,
319
377
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
320
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
321
- logging: this._options.logging,
322
378
  });
323
379
  if (_response.ok) {
324
380
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -330,7 +386,21 @@ class AgentsClient {
330
386
  rawResponse: _response.rawResponse,
331
387
  });
332
388
  }
333
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/agents/external/{externalId}");
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 /agents/external/{externalId}.");
398
+ case "unknown":
399
+ throw new errors.PaidError({
400
+ message: _response.error.errorMessage,
401
+ rawResponse: _response.rawResponse,
402
+ });
403
+ }
334
404
  });
335
405
  }
336
406
  /**
@@ -338,7 +408,7 @@ class AgentsClient {
338
408
  *
339
409
  * @param {string} externalId
340
410
  * @param {Paid.AgentUpdate} request
341
- * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
411
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
342
412
  *
343
413
  * @example
344
414
  * await client.agents.updateByExternalId("externalId", {
@@ -366,8 +436,8 @@ class AgentsClient {
366
436
  }
367
437
  __updateByExternalId(externalId, request, requestOptions) {
368
438
  return __awaiter(this, void 0, void 0, function* () {
369
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
370
- 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);
439
+ var _a, _b, _c, _d, _e, _f, _g, _h;
440
+ 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);
371
441
  const _response = yield core.fetcher({
372
442
  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, `agents/external/${core.url.encodePathParam(externalId)}`),
373
443
  method: "PUT",
@@ -379,8 +449,6 @@ class AgentsClient {
379
449
  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,
380
450
  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,
381
451
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
382
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
383
- logging: this._options.logging,
384
452
  });
385
453
  if (_response.ok) {
386
454
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -392,14 +460,28 @@ class AgentsClient {
392
460
  rawResponse: _response.rawResponse,
393
461
  });
394
462
  }
395
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "PUT", "/agents/external/{externalId}");
463
+ switch (_response.error.reason) {
464
+ case "non-json":
465
+ throw new errors.PaidError({
466
+ statusCode: _response.error.statusCode,
467
+ body: _response.error.rawBody,
468
+ rawResponse: _response.rawResponse,
469
+ });
470
+ case "timeout":
471
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling PUT /agents/external/{externalId}.");
472
+ case "unknown":
473
+ throw new errors.PaidError({
474
+ message: _response.error.errorMessage,
475
+ rawResponse: _response.rawResponse,
476
+ });
477
+ }
396
478
  });
397
479
  }
398
480
  /**
399
481
  * DEPRECATED: Use DELETE /products/external/{externalId} instead.
400
482
  *
401
483
  * @param {string} externalId
402
- * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
484
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
403
485
  *
404
486
  * @example
405
487
  * await client.agents.deleteByExternalId("externalId")
@@ -409,8 +491,8 @@ class AgentsClient {
409
491
  }
410
492
  __deleteByExternalId(externalId, requestOptions) {
411
493
  return __awaiter(this, void 0, void 0, function* () {
412
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
413
- 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);
494
+ var _a, _b, _c, _d, _e, _f, _g, _h;
495
+ 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);
414
496
  const _response = yield core.fetcher({
415
497
  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, `agents/external/${core.url.encodePathParam(externalId)}`),
416
498
  method: "DELETE",
@@ -419,8 +501,6 @@ class AgentsClient {
419
501
  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,
420
502
  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,
421
503
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
422
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
423
- logging: this._options.logging,
424
504
  });
425
505
  if (_response.ok) {
426
506
  return { data: undefined, rawResponse: _response.rawResponse };
@@ -432,8 +512,31 @@ class AgentsClient {
432
512
  rawResponse: _response.rawResponse,
433
513
  });
434
514
  }
435
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "DELETE", "/agents/external/{externalId}");
515
+ switch (_response.error.reason) {
516
+ case "non-json":
517
+ throw new errors.PaidError({
518
+ statusCode: _response.error.statusCode,
519
+ body: _response.error.rawBody,
520
+ rawResponse: _response.rawResponse,
521
+ });
522
+ case "timeout":
523
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling DELETE /agents/external/{externalId}.");
524
+ case "unknown":
525
+ throw new errors.PaidError({
526
+ message: _response.error.errorMessage,
527
+ rawResponse: _response.rawResponse,
528
+ });
529
+ }
530
+ });
531
+ }
532
+ _getAuthorizationHeader() {
533
+ return __awaiter(this, void 0, void 0, function* () {
534
+ const bearer = yield core.Supplier.get(this._options.token);
535
+ if (bearer != null) {
536
+ return `Bearer ${bearer}`;
537
+ }
538
+ return undefined;
436
539
  });
437
540
  }
438
541
  }
439
- exports.AgentsClient = AgentsClient;
542
+ exports.Agents = Agents;
@@ -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 ContactsClient {
6
- type Options = BaseClientOptions;
4
+ export declare namespace Contacts {
5
+ interface Options extends BaseClientOptions {
6
+ }
7
7
  interface RequestOptions extends BaseRequestOptions {
8
8
  }
9
9
  }
10
- export declare class ContactsClient {
11
- protected readonly _options: NormalizedClientOptions<ContactsClient.Options>;
12
- constructor(options?: ContactsClient.Options);
10
+ export declare class Contacts {
11
+ protected readonly _options: Contacts.Options;
12
+ constructor(_options?: Contacts.Options);
13
13
  /**
14
- * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
14
+ * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
15
15
  *
16
16
  * @example
17
17
  * await client.contacts.list()
18
18
  */
19
- list(requestOptions?: ContactsClient.RequestOptions): core.HttpResponsePromise<Paid.Contact[]>;
19
+ list(requestOptions?: Contacts.RequestOptions): core.HttpResponsePromise<Paid.Contact[]>;
20
20
  private __list;
21
21
  /**
22
22
  * @param {Paid.ContactCreate} request
23
- * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
23
+ * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
24
24
  *
25
25
  * @example
26
26
  * await client.contacts.create({
@@ -31,42 +31,43 @@ export declare class ContactsClient {
31
31
  * email: "john.doe@example.com"
32
32
  * })
33
33
  */
34
- create(request: Paid.ContactCreate, requestOptions?: ContactsClient.RequestOptions): core.HttpResponsePromise<Paid.Contact>;
34
+ create(request: Paid.ContactCreate, requestOptions?: Contacts.RequestOptions): core.HttpResponsePromise<Paid.Contact>;
35
35
  private __create;
36
36
  /**
37
37
  * @param {string} contactId
38
- * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
38
+ * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
39
39
  *
40
40
  * @example
41
41
  * await client.contacts.get("contactId")
42
42
  */
43
- get(contactId: string, requestOptions?: ContactsClient.RequestOptions): core.HttpResponsePromise<Paid.Contact>;
43
+ get(contactId: string, requestOptions?: Contacts.RequestOptions): core.HttpResponsePromise<Paid.Contact>;
44
44
  private __get;
45
45
  /**
46
46
  * @param {string} contactId
47
- * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
47
+ * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
48
48
  *
49
49
  * @example
50
50
  * await client.contacts.delete("contactId")
51
51
  */
52
- delete(contactId: string, requestOptions?: ContactsClient.RequestOptions): core.HttpResponsePromise<void>;
52
+ delete(contactId: string, requestOptions?: Contacts.RequestOptions): core.HttpResponsePromise<void>;
53
53
  private __delete;
54
54
  /**
55
55
  * @param {string} externalId
56
- * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
56
+ * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
57
57
  *
58
58
  * @example
59
59
  * await client.contacts.getByExternalId("externalId")
60
60
  */
61
- getByExternalId(externalId: string, requestOptions?: ContactsClient.RequestOptions): core.HttpResponsePromise<Paid.Contact>;
61
+ getByExternalId(externalId: string, requestOptions?: Contacts.RequestOptions): core.HttpResponsePromise<Paid.Contact>;
62
62
  private __getByExternalId;
63
63
  /**
64
64
  * @param {string} externalId
65
- * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
65
+ * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
66
66
  *
67
67
  * @example
68
68
  * await client.contacts.deleteByExternalId("externalId")
69
69
  */
70
- deleteByExternalId(externalId: string, requestOptions?: ContactsClient.RequestOptions): core.HttpResponsePromise<void>;
70
+ deleteByExternalId(externalId: string, requestOptions?: Contacts.RequestOptions): core.HttpResponsePromise<void>;
71
71
  private __deleteByExternalId;
72
+ protected _getAuthorizationHeader(): Promise<string | undefined>;
72
73
  }