@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
@@ -8,20 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- import { normalizeClientOptions } from "../../../../BaseClient.mjs";
12
- import { mergeHeaders } from "../../../../core/headers.mjs";
11
+ import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
13
12
  import * as core from "../../../../core/index.mjs";
14
13
  import * as environments from "../../../../environments.mjs";
15
- import { handleNonStatusCodeError } from "../../../../errors/handleNonStatusCodeError.mjs";
16
14
  import * as errors from "../../../../errors/index.mjs";
17
- export class AgentsClient {
18
- constructor(options = {}) {
19
- this._options = normalizeClientOptions(options);
15
+ export class Agents {
16
+ constructor(_options = {}) {
17
+ this._options = _options;
20
18
  }
21
19
  /**
22
20
  * DEPRECATED: Use /products instead. Agents are now products with type='agent'.
23
21
  *
24
- * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
22
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
25
23
  *
26
24
  * @example
27
25
  * await client.agents.list()
@@ -31,8 +29,8 @@ export class AgentsClient {
31
29
  }
32
30
  __list(requestOptions) {
33
31
  return __awaiter(this, void 0, void 0, function* () {
34
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
35
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
32
+ var _a, _b, _c, _d, _e, _f, _g, _h;
33
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
36
34
  const _response = yield core.fetcher({
37
35
  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"),
38
36
  method: "GET",
@@ -41,8 +39,6 @@ export class AgentsClient {
41
39
  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,
42
40
  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,
43
41
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
44
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
45
- logging: this._options.logging,
46
42
  });
47
43
  if (_response.ok) {
48
44
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -54,14 +50,28 @@ export class AgentsClient {
54
50
  rawResponse: _response.rawResponse,
55
51
  });
56
52
  }
57
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/agents");
53
+ switch (_response.error.reason) {
54
+ case "non-json":
55
+ throw new errors.PaidError({
56
+ statusCode: _response.error.statusCode,
57
+ body: _response.error.rawBody,
58
+ rawResponse: _response.rawResponse,
59
+ });
60
+ case "timeout":
61
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /agents.");
62
+ case "unknown":
63
+ throw new errors.PaidError({
64
+ message: _response.error.errorMessage,
65
+ rawResponse: _response.rawResponse,
66
+ });
67
+ }
58
68
  });
59
69
  }
60
70
  /**
61
71
  * DEPRECATED: Use POST /products instead.
62
72
  *
63
73
  * @param {Paid.AgentCreate} request
64
- * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
74
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
65
75
  *
66
76
  * @example
67
77
  * await client.agents.create({
@@ -75,8 +85,8 @@ export class AgentsClient {
75
85
  }
76
86
  __create(request, requestOptions) {
77
87
  return __awaiter(this, void 0, void 0, function* () {
78
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
79
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
88
+ var _a, _b, _c, _d, _e, _f, _g, _h;
89
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
80
90
  const _response = yield core.fetcher({
81
91
  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"),
82
92
  method: "POST",
@@ -88,8 +98,6 @@ export class AgentsClient {
88
98
  timeoutMs: ((_f = (_d = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.timeoutInSeconds) !== null && _d !== void 0 ? _d : (_e = this._options) === null || _e === void 0 ? void 0 : _e.timeoutInSeconds) !== null && _f !== void 0 ? _f : 60) * 1000,
89
99
  maxRetries: (_g = requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.maxRetries) !== null && _g !== void 0 ? _g : (_h = this._options) === null || _h === void 0 ? void 0 : _h.maxRetries,
90
100
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
91
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
92
- logging: this._options.logging,
93
101
  });
94
102
  if (_response.ok) {
95
103
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -101,14 +109,28 @@ export class AgentsClient {
101
109
  rawResponse: _response.rawResponse,
102
110
  });
103
111
  }
104
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/agents");
112
+ switch (_response.error.reason) {
113
+ case "non-json":
114
+ throw new errors.PaidError({
115
+ statusCode: _response.error.statusCode,
116
+ body: _response.error.rawBody,
117
+ rawResponse: _response.rawResponse,
118
+ });
119
+ case "timeout":
120
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /agents.");
121
+ case "unknown":
122
+ throw new errors.PaidError({
123
+ message: _response.error.errorMessage,
124
+ rawResponse: _response.rawResponse,
125
+ });
126
+ }
105
127
  });
106
128
  }
107
129
  /**
108
130
  * DEPRECATED: Use GET /products/{productId} instead.
109
131
  *
110
132
  * @param {string} agentId
111
- * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
133
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
112
134
  *
113
135
  * @example
114
136
  * await client.agents.get("agentId")
@@ -118,8 +140,8 @@ export class AgentsClient {
118
140
  }
119
141
  __get(agentId, requestOptions) {
120
142
  return __awaiter(this, void 0, void 0, function* () {
121
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
122
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
143
+ var _a, _b, _c, _d, _e, _f, _g, _h;
144
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
123
145
  const _response = yield core.fetcher({
124
146
  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)}`),
125
147
  method: "GET",
@@ -128,8 +150,6 @@ export class AgentsClient {
128
150
  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,
129
151
  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,
130
152
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
131
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
132
- logging: this._options.logging,
133
153
  });
134
154
  if (_response.ok) {
135
155
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -141,7 +161,21 @@ export class AgentsClient {
141
161
  rawResponse: _response.rawResponse,
142
162
  });
143
163
  }
144
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/agents/{agentId}");
164
+ switch (_response.error.reason) {
165
+ case "non-json":
166
+ throw new errors.PaidError({
167
+ statusCode: _response.error.statusCode,
168
+ body: _response.error.rawBody,
169
+ rawResponse: _response.rawResponse,
170
+ });
171
+ case "timeout":
172
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /agents/{agentId}.");
173
+ case "unknown":
174
+ throw new errors.PaidError({
175
+ message: _response.error.errorMessage,
176
+ rawResponse: _response.rawResponse,
177
+ });
178
+ }
145
179
  });
146
180
  }
147
181
  /**
@@ -149,7 +183,7 @@ export class AgentsClient {
149
183
  *
150
184
  * @param {string} agentId
151
185
  * @param {Paid.AgentUpdate} request
152
- * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
186
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
153
187
  *
154
188
  * @example
155
189
  * await client.agents.update("agentId", {
@@ -188,8 +222,8 @@ export class AgentsClient {
188
222
  }
189
223
  __update(agentId, request, requestOptions) {
190
224
  return __awaiter(this, void 0, void 0, function* () {
191
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
192
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
225
+ var _a, _b, _c, _d, _e, _f, _g, _h;
226
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
193
227
  const _response = yield core.fetcher({
194
228
  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)}`),
195
229
  method: "PUT",
@@ -201,8 +235,6 @@ export class AgentsClient {
201
235
  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,
202
236
  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,
203
237
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
204
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
205
- logging: this._options.logging,
206
238
  });
207
239
  if (_response.ok) {
208
240
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -214,14 +246,28 @@ export class AgentsClient {
214
246
  rawResponse: _response.rawResponse,
215
247
  });
216
248
  }
217
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/agents/{agentId}");
249
+ switch (_response.error.reason) {
250
+ case "non-json":
251
+ throw new errors.PaidError({
252
+ statusCode: _response.error.statusCode,
253
+ body: _response.error.rawBody,
254
+ rawResponse: _response.rawResponse,
255
+ });
256
+ case "timeout":
257
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling PUT /agents/{agentId}.");
258
+ case "unknown":
259
+ throw new errors.PaidError({
260
+ message: _response.error.errorMessage,
261
+ rawResponse: _response.rawResponse,
262
+ });
263
+ }
218
264
  });
219
265
  }
220
266
  /**
221
267
  * DEPRECATED: Use DELETE /products/{productId} instead.
222
268
  *
223
269
  * @param {string} agentId
224
- * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
270
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
225
271
  *
226
272
  * @example
227
273
  * await client.agents.delete("agentId")
@@ -231,8 +277,8 @@ export class AgentsClient {
231
277
  }
232
278
  __delete(agentId, requestOptions) {
233
279
  return __awaiter(this, void 0, void 0, function* () {
234
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
235
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
280
+ var _a, _b, _c, _d, _e, _f, _g, _h;
281
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
236
282
  const _response = yield core.fetcher({
237
283
  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)}`),
238
284
  method: "DELETE",
@@ -241,8 +287,6 @@ export class AgentsClient {
241
287
  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,
242
288
  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,
243
289
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
244
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
245
- logging: this._options.logging,
246
290
  });
247
291
  if (_response.ok) {
248
292
  return { data: undefined, rawResponse: _response.rawResponse };
@@ -254,14 +298,28 @@ export class AgentsClient {
254
298
  rawResponse: _response.rawResponse,
255
299
  });
256
300
  }
257
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/agents/{agentId}");
301
+ switch (_response.error.reason) {
302
+ case "non-json":
303
+ throw new errors.PaidError({
304
+ statusCode: _response.error.statusCode,
305
+ body: _response.error.rawBody,
306
+ rawResponse: _response.rawResponse,
307
+ });
308
+ case "timeout":
309
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling DELETE /agents/{agentId}.");
310
+ case "unknown":
311
+ throw new errors.PaidError({
312
+ message: _response.error.errorMessage,
313
+ rawResponse: _response.rawResponse,
314
+ });
315
+ }
258
316
  });
259
317
  }
260
318
  /**
261
319
  * DEPRECATED: Use GET /products/external/{externalId} instead.
262
320
  *
263
321
  * @param {string} externalId
264
- * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
322
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
265
323
  *
266
324
  * @example
267
325
  * await client.agents.getByExternalId("externalId")
@@ -271,8 +329,8 @@ export class AgentsClient {
271
329
  }
272
330
  __getByExternalId(externalId, requestOptions) {
273
331
  return __awaiter(this, void 0, void 0, function* () {
274
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
275
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
332
+ var _a, _b, _c, _d, _e, _f, _g, _h;
333
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
276
334
  const _response = yield core.fetcher({
277
335
  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)}`),
278
336
  method: "GET",
@@ -281,8 +339,6 @@ export class AgentsClient {
281
339
  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,
282
340
  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,
283
341
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
284
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
285
- logging: this._options.logging,
286
342
  });
287
343
  if (_response.ok) {
288
344
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -294,7 +350,21 @@ export class AgentsClient {
294
350
  rawResponse: _response.rawResponse,
295
351
  });
296
352
  }
297
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/agents/external/{externalId}");
353
+ switch (_response.error.reason) {
354
+ case "non-json":
355
+ throw new errors.PaidError({
356
+ statusCode: _response.error.statusCode,
357
+ body: _response.error.rawBody,
358
+ rawResponse: _response.rawResponse,
359
+ });
360
+ case "timeout":
361
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /agents/external/{externalId}.");
362
+ case "unknown":
363
+ throw new errors.PaidError({
364
+ message: _response.error.errorMessage,
365
+ rawResponse: _response.rawResponse,
366
+ });
367
+ }
298
368
  });
299
369
  }
300
370
  /**
@@ -302,7 +372,7 @@ export class AgentsClient {
302
372
  *
303
373
  * @param {string} externalId
304
374
  * @param {Paid.AgentUpdate} request
305
- * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
375
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
306
376
  *
307
377
  * @example
308
378
  * await client.agents.updateByExternalId("externalId", {
@@ -330,8 +400,8 @@ export class AgentsClient {
330
400
  }
331
401
  __updateByExternalId(externalId, request, requestOptions) {
332
402
  return __awaiter(this, void 0, void 0, function* () {
333
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
334
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
403
+ var _a, _b, _c, _d, _e, _f, _g, _h;
404
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
335
405
  const _response = yield core.fetcher({
336
406
  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)}`),
337
407
  method: "PUT",
@@ -343,8 +413,6 @@ export class AgentsClient {
343
413
  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,
344
414
  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,
345
415
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
346
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
347
- logging: this._options.logging,
348
416
  });
349
417
  if (_response.ok) {
350
418
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -356,14 +424,28 @@ export class AgentsClient {
356
424
  rawResponse: _response.rawResponse,
357
425
  });
358
426
  }
359
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "PUT", "/agents/external/{externalId}");
427
+ switch (_response.error.reason) {
428
+ case "non-json":
429
+ throw new errors.PaidError({
430
+ statusCode: _response.error.statusCode,
431
+ body: _response.error.rawBody,
432
+ rawResponse: _response.rawResponse,
433
+ });
434
+ case "timeout":
435
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling PUT /agents/external/{externalId}.");
436
+ case "unknown":
437
+ throw new errors.PaidError({
438
+ message: _response.error.errorMessage,
439
+ rawResponse: _response.rawResponse,
440
+ });
441
+ }
360
442
  });
361
443
  }
362
444
  /**
363
445
  * DEPRECATED: Use DELETE /products/external/{externalId} instead.
364
446
  *
365
447
  * @param {string} externalId
366
- * @param {AgentsClient.RequestOptions} requestOptions - Request-specific configuration.
448
+ * @param {Agents.RequestOptions} requestOptions - Request-specific configuration.
367
449
  *
368
450
  * @example
369
451
  * await client.agents.deleteByExternalId("externalId")
@@ -373,8 +455,8 @@ export class AgentsClient {
373
455
  }
374
456
  __deleteByExternalId(externalId, requestOptions) {
375
457
  return __awaiter(this, void 0, void 0, function* () {
376
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
377
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
458
+ var _a, _b, _c, _d, _e, _f, _g, _h;
459
+ const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, mergeOnlyDefinedHeaders({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
378
460
  const _response = yield core.fetcher({
379
461
  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)}`),
380
462
  method: "DELETE",
@@ -383,8 +465,6 @@ export class AgentsClient {
383
465
  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,
384
466
  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,
385
467
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
386
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
387
- logging: this._options.logging,
388
468
  });
389
469
  if (_response.ok) {
390
470
  return { data: undefined, rawResponse: _response.rawResponse };
@@ -396,7 +476,30 @@ export class AgentsClient {
396
476
  rawResponse: _response.rawResponse,
397
477
  });
398
478
  }
399
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/agents/external/{externalId}");
479
+ switch (_response.error.reason) {
480
+ case "non-json":
481
+ throw new errors.PaidError({
482
+ statusCode: _response.error.statusCode,
483
+ body: _response.error.rawBody,
484
+ rawResponse: _response.rawResponse,
485
+ });
486
+ case "timeout":
487
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling DELETE /agents/external/{externalId}.");
488
+ case "unknown":
489
+ throw new errors.PaidError({
490
+ message: _response.error.errorMessage,
491
+ rawResponse: _response.rawResponse,
492
+ });
493
+ }
494
+ });
495
+ }
496
+ _getAuthorizationHeader() {
497
+ return __awaiter(this, void 0, void 0, function* () {
498
+ const bearer = yield core.Supplier.get(this._options.token);
499
+ if (bearer != null) {
500
+ return `Bearer ${bearer}`;
501
+ }
502
+ return undefined;
400
503
  });
401
504
  }
402
505
  }
@@ -1,26 +1,26 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
2
- import { type NormalizedClientOptions } from "../../../../BaseClient.mjs";
3
2
  import * as core from "../../../../core/index.mjs";
4
3
  import type * as Paid from "../../../index.mjs";
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
  }