@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,18 +8,16 @@ 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 ContactsClient {
18
- constructor(options = {}) {
19
- this._options = normalizeClientOptions(options);
15
+ export class Contacts {
16
+ constructor(_options = {}) {
17
+ this._options = _options;
20
18
  }
21
19
  /**
22
- * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
20
+ * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
23
21
  *
24
22
  * @example
25
23
  * await client.contacts.list()
@@ -29,8 +27,8 @@ export class ContactsClient {
29
27
  }
30
28
  __list(requestOptions) {
31
29
  return __awaiter(this, void 0, void 0, function* () {
32
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
33
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
30
+ var _a, _b, _c, _d, _e, _f, _g, _h;
31
+ 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);
34
32
  const _response = yield core.fetcher({
35
33
  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, "contacts"),
36
34
  method: "GET",
@@ -39,8 +37,6 @@ export class ContactsClient {
39
37
  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,
40
38
  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,
41
39
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
42
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
43
- logging: this._options.logging,
44
40
  });
45
41
  if (_response.ok) {
46
42
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -52,12 +48,26 @@ export class ContactsClient {
52
48
  rawResponse: _response.rawResponse,
53
49
  });
54
50
  }
55
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts");
51
+ switch (_response.error.reason) {
52
+ case "non-json":
53
+ throw new errors.PaidError({
54
+ statusCode: _response.error.statusCode,
55
+ body: _response.error.rawBody,
56
+ rawResponse: _response.rawResponse,
57
+ });
58
+ case "timeout":
59
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /contacts.");
60
+ case "unknown":
61
+ throw new errors.PaidError({
62
+ message: _response.error.errorMessage,
63
+ rawResponse: _response.rawResponse,
64
+ });
65
+ }
56
66
  });
57
67
  }
58
68
  /**
59
69
  * @param {Paid.ContactCreate} request
60
- * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
70
+ * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
61
71
  *
62
72
  * @example
63
73
  * await client.contacts.create({
@@ -73,8 +83,8 @@ export class ContactsClient {
73
83
  }
74
84
  __create(request, requestOptions) {
75
85
  return __awaiter(this, void 0, void 0, function* () {
76
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
77
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
86
+ var _a, _b, _c, _d, _e, _f, _g, _h;
87
+ 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);
78
88
  const _response = yield core.fetcher({
79
89
  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, "contacts"),
80
90
  method: "POST",
@@ -86,8 +96,6 @@ export class ContactsClient {
86
96
  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,
87
97
  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,
88
98
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
89
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
90
- logging: this._options.logging,
91
99
  });
92
100
  if (_response.ok) {
93
101
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -99,12 +107,26 @@ export class ContactsClient {
99
107
  rawResponse: _response.rawResponse,
100
108
  });
101
109
  }
102
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/contacts");
110
+ switch (_response.error.reason) {
111
+ case "non-json":
112
+ throw new errors.PaidError({
113
+ statusCode: _response.error.statusCode,
114
+ body: _response.error.rawBody,
115
+ rawResponse: _response.rawResponse,
116
+ });
117
+ case "timeout":
118
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /contacts.");
119
+ case "unknown":
120
+ throw new errors.PaidError({
121
+ message: _response.error.errorMessage,
122
+ rawResponse: _response.rawResponse,
123
+ });
124
+ }
103
125
  });
104
126
  }
105
127
  /**
106
128
  * @param {string} contactId
107
- * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
129
+ * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
108
130
  *
109
131
  * @example
110
132
  * await client.contacts.get("contactId")
@@ -114,8 +136,8 @@ export class ContactsClient {
114
136
  }
115
137
  __get(contactId, requestOptions) {
116
138
  return __awaiter(this, void 0, void 0, function* () {
117
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
118
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
139
+ var _a, _b, _c, _d, _e, _f, _g, _h;
140
+ 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);
119
141
  const _response = yield core.fetcher({
120
142
  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, `contacts/${core.url.encodePathParam(contactId)}`),
121
143
  method: "GET",
@@ -124,8 +146,6 @@ export class ContactsClient {
124
146
  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
147
  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
148
  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
149
  });
130
150
  if (_response.ok) {
131
151
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -137,12 +157,26 @@ export class ContactsClient {
137
157
  rawResponse: _response.rawResponse,
138
158
  });
139
159
  }
140
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/{contactId}");
160
+ switch (_response.error.reason) {
161
+ case "non-json":
162
+ throw new errors.PaidError({
163
+ statusCode: _response.error.statusCode,
164
+ body: _response.error.rawBody,
165
+ rawResponse: _response.rawResponse,
166
+ });
167
+ case "timeout":
168
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /contacts/{contactId}.");
169
+ case "unknown":
170
+ throw new errors.PaidError({
171
+ message: _response.error.errorMessage,
172
+ rawResponse: _response.rawResponse,
173
+ });
174
+ }
141
175
  });
142
176
  }
143
177
  /**
144
178
  * @param {string} contactId
145
- * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
179
+ * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
146
180
  *
147
181
  * @example
148
182
  * await client.contacts.delete("contactId")
@@ -152,8 +186,8 @@ export class ContactsClient {
152
186
  }
153
187
  __delete(contactId, requestOptions) {
154
188
  return __awaiter(this, void 0, void 0, function* () {
155
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
156
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
189
+ var _a, _b, _c, _d, _e, _f, _g, _h;
190
+ 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);
157
191
  const _response = yield core.fetcher({
158
192
  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, `contacts/${core.url.encodePathParam(contactId)}`),
159
193
  method: "DELETE",
@@ -162,8 +196,6 @@ export class ContactsClient {
162
196
  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,
163
197
  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,
164
198
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
165
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
166
- logging: this._options.logging,
167
199
  });
168
200
  if (_response.ok) {
169
201
  return { data: undefined, rawResponse: _response.rawResponse };
@@ -175,12 +207,26 @@ export class ContactsClient {
175
207
  rawResponse: _response.rawResponse,
176
208
  });
177
209
  }
178
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/contacts/{contactId}");
210
+ switch (_response.error.reason) {
211
+ case "non-json":
212
+ throw new errors.PaidError({
213
+ statusCode: _response.error.statusCode,
214
+ body: _response.error.rawBody,
215
+ rawResponse: _response.rawResponse,
216
+ });
217
+ case "timeout":
218
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling DELETE /contacts/{contactId}.");
219
+ case "unknown":
220
+ throw new errors.PaidError({
221
+ message: _response.error.errorMessage,
222
+ rawResponse: _response.rawResponse,
223
+ });
224
+ }
179
225
  });
180
226
  }
181
227
  /**
182
228
  * @param {string} externalId
183
- * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
229
+ * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
184
230
  *
185
231
  * @example
186
232
  * await client.contacts.getByExternalId("externalId")
@@ -190,8 +236,8 @@ export class ContactsClient {
190
236
  }
191
237
  __getByExternalId(externalId, requestOptions) {
192
238
  return __awaiter(this, void 0, void 0, function* () {
193
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
194
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
239
+ var _a, _b, _c, _d, _e, _f, _g, _h;
240
+ 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);
195
241
  const _response = yield core.fetcher({
196
242
  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, `contacts/external/${core.url.encodePathParam(externalId)}`),
197
243
  method: "GET",
@@ -200,8 +246,6 @@ export class ContactsClient {
200
246
  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,
201
247
  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,
202
248
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
203
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
204
- logging: this._options.logging,
205
249
  });
206
250
  if (_response.ok) {
207
251
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -213,12 +257,26 @@ export class ContactsClient {
213
257
  rawResponse: _response.rawResponse,
214
258
  });
215
259
  }
216
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/contacts/external/{externalId}");
260
+ switch (_response.error.reason) {
261
+ case "non-json":
262
+ throw new errors.PaidError({
263
+ statusCode: _response.error.statusCode,
264
+ body: _response.error.rawBody,
265
+ rawResponse: _response.rawResponse,
266
+ });
267
+ case "timeout":
268
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /contacts/external/{externalId}.");
269
+ case "unknown":
270
+ throw new errors.PaidError({
271
+ message: _response.error.errorMessage,
272
+ rawResponse: _response.rawResponse,
273
+ });
274
+ }
217
275
  });
218
276
  }
219
277
  /**
220
278
  * @param {string} externalId
221
- * @param {ContactsClient.RequestOptions} requestOptions - Request-specific configuration.
279
+ * @param {Contacts.RequestOptions} requestOptions - Request-specific configuration.
222
280
  *
223
281
  * @example
224
282
  * await client.contacts.deleteByExternalId("externalId")
@@ -228,8 +286,8 @@ export class ContactsClient {
228
286
  }
229
287
  __deleteByExternalId(externalId, requestOptions) {
230
288
  return __awaiter(this, void 0, void 0, function* () {
231
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
232
- const _headers = mergeHeaders((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
289
+ var _a, _b, _c, _d, _e, _f, _g, _h;
290
+ 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);
233
291
  const _response = yield core.fetcher({
234
292
  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, `contacts/external/${core.url.encodePathParam(externalId)}`),
235
293
  method: "DELETE",
@@ -238,8 +296,6 @@ export class ContactsClient {
238
296
  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,
239
297
  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,
240
298
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
241
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
242
- logging: this._options.logging,
243
299
  });
244
300
  if (_response.ok) {
245
301
  return { data: undefined, rawResponse: _response.rawResponse };
@@ -251,7 +307,30 @@ export class ContactsClient {
251
307
  rawResponse: _response.rawResponse,
252
308
  });
253
309
  }
254
- return handleNonStatusCodeError(_response.error, _response.rawResponse, "DELETE", "/contacts/external/{externalId}");
310
+ switch (_response.error.reason) {
311
+ case "non-json":
312
+ throw new errors.PaidError({
313
+ statusCode: _response.error.statusCode,
314
+ body: _response.error.rawBody,
315
+ rawResponse: _response.rawResponse,
316
+ });
317
+ case "timeout":
318
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling DELETE /contacts/external/{externalId}.");
319
+ case "unknown":
320
+ throw new errors.PaidError({
321
+ message: _response.error.errorMessage,
322
+ rawResponse: _response.rawResponse,
323
+ });
324
+ }
325
+ });
326
+ }
327
+ _getAuthorizationHeader() {
328
+ return __awaiter(this, void 0, void 0, function* () {
329
+ const bearer = yield core.Supplier.get(this._options.token);
330
+ if (bearer != null) {
331
+ return `Bearer ${bearer}`;
332
+ }
333
+ return undefined;
255
334
  });
256
335
  }
257
336
  }
@@ -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 * as Paid from "../../../index.mjs";
5
- export declare namespace CustomersClient {
6
- type Options = BaseClientOptions;
4
+ export declare namespace Customers {
5
+ interface Options extends BaseClientOptions {
6
+ }
7
7
  interface RequestOptions extends BaseRequestOptions {
8
8
  }
9
9
  }
10
- export declare class CustomersClient {
11
- protected readonly _options: NormalizedClientOptions<CustomersClient.Options>;
12
- constructor(options?: CustomersClient.Options);
10
+ export declare class Customers {
11
+ protected readonly _options: Customers.Options;
12
+ constructor(_options?: Customers.Options);
13
13
  /**
14
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
14
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
15
15
  *
16
16
  * @example
17
17
  * await client.customers.list()
18
18
  */
19
- list(requestOptions?: CustomersClient.RequestOptions): core.HttpResponsePromise<Paid.Customer[]>;
19
+ list(requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.Customer[]>;
20
20
  private __list;
21
21
  /**
22
22
  * @param {Paid.CustomerCreate} request
23
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
23
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
24
24
  *
25
25
  * @example
26
26
  * await client.customers.create({
@@ -41,21 +41,21 @@ export declare class CustomersClient {
41
41
  * }]
42
42
  * })
43
43
  */
44
- create(request: Paid.CustomerCreate, requestOptions?: CustomersClient.RequestOptions): core.HttpResponsePromise<Paid.Customer>;
44
+ create(request: Paid.CustomerCreate, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.Customer>;
45
45
  private __create;
46
46
  /**
47
47
  * @param {string} customerId
48
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
48
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
49
49
  *
50
50
  * @example
51
51
  * await client.customers.get("customerId")
52
52
  */
53
- get(customerId: string, requestOptions?: CustomersClient.RequestOptions): core.HttpResponsePromise<Paid.Customer>;
53
+ get(customerId: string, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.Customer>;
54
54
  private __get;
55
55
  /**
56
56
  * @param {string} customerId
57
57
  * @param {Paid.CustomerUpdate} request
58
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
58
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
59
59
  *
60
60
  * @example
61
61
  * await client.customers.update("customerId", {
@@ -65,21 +65,21 @@ export declare class CustomersClient {
65
65
  * annualRevenue: 1000001
66
66
  * })
67
67
  */
68
- update(customerId: string, request: Paid.CustomerUpdate, requestOptions?: CustomersClient.RequestOptions): core.HttpResponsePromise<Paid.Customer>;
68
+ update(customerId: string, request: Paid.CustomerUpdate, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.Customer>;
69
69
  private __update;
70
70
  /**
71
71
  * @param {string} customerId
72
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
72
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
73
73
  *
74
74
  * @example
75
75
  * await client.customers.delete("customerId")
76
76
  */
77
- delete(customerId: string, requestOptions?: CustomersClient.RequestOptions): core.HttpResponsePromise<void>;
77
+ delete(customerId: string, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<void>;
78
78
  private __delete;
79
79
  /**
80
80
  * @param {string} customerId - The customer ID
81
81
  * @param {Paid.CustomersCheckEntitlementRequest} request
82
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
82
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
83
83
  *
84
84
  * @throws {@link Paid.BadRequestError}
85
85
  * @throws {@link Paid.NotFoundError}
@@ -90,51 +90,51 @@ export declare class CustomersClient {
90
90
  * view: "all"
91
91
  * })
92
92
  */
93
- checkEntitlement(customerId: string, request: Paid.CustomersCheckEntitlementRequest, requestOptions?: CustomersClient.RequestOptions): core.HttpResponsePromise<Paid.CustomersCheckEntitlementResponse>;
93
+ checkEntitlement(customerId: string, request: Paid.CustomersCheckEntitlementRequest, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.CustomersCheckEntitlementResponse>;
94
94
  private __checkEntitlement;
95
95
  /**
96
96
  * @param {string} customerId - The customer ID
97
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
97
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
98
98
  *
99
99
  * @throws {@link Paid.ForbiddenError}
100
100
  *
101
101
  * @example
102
102
  * await client.customers.getEntitlements("customerId")
103
103
  */
104
- getEntitlements(customerId: string, requestOptions?: CustomersClient.RequestOptions): core.HttpResponsePromise<Paid.EntitlementUsage[]>;
104
+ getEntitlements(customerId: string, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.EntitlementUsage[]>;
105
105
  private __getEntitlements;
106
106
  /**
107
107
  * @param {string} externalId
108
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
108
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
109
109
  *
110
110
  * @example
111
111
  * await client.customers.getByExternalId("externalId")
112
112
  */
113
- getByExternalId(externalId: string, requestOptions?: CustomersClient.RequestOptions): core.HttpResponsePromise<Paid.Customer>;
113
+ getByExternalId(externalId: string, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.Customer>;
114
114
  private __getByExternalId;
115
115
  /**
116
116
  * @param {string} externalId
117
117
  * @param {Paid.CustomerUpdate} request
118
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
118
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
119
119
  *
120
120
  * @example
121
121
  * await client.customers.updateByExternalId("externalId", {})
122
122
  */
123
- updateByExternalId(externalId: string, request: Paid.CustomerUpdate, requestOptions?: CustomersClient.RequestOptions): core.HttpResponsePromise<Paid.Customer>;
123
+ updateByExternalId(externalId: string, request: Paid.CustomerUpdate, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.Customer>;
124
124
  private __updateByExternalId;
125
125
  /**
126
126
  * @param {string} externalId
127
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
127
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
128
128
  *
129
129
  * @example
130
130
  * await client.customers.deleteByExternalId("externalId")
131
131
  */
132
- deleteByExternalId(externalId: string, requestOptions?: CustomersClient.RequestOptions): core.HttpResponsePromise<void>;
132
+ deleteByExternalId(externalId: string, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<void>;
133
133
  private __deleteByExternalId;
134
134
  /**
135
135
  * @param {string} externalId - The external ID of the customer
136
136
  * @param {Paid.CustomersGetCostsByExternalIdRequest} request
137
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
137
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
138
138
  *
139
139
  * @throws {@link Paid.BadRequestError}
140
140
  * @throws {@link Paid.ForbiddenError}
@@ -148,12 +148,12 @@ export declare class CustomersClient {
148
148
  * endTime: "2024-01-15T09:30:00Z"
149
149
  * })
150
150
  */
151
- getCostsByExternalId(externalId: string, request?: Paid.CustomersGetCostsByExternalIdRequest, requestOptions?: CustomersClient.RequestOptions): core.HttpResponsePromise<Paid.CostTracesResponse>;
151
+ getCostsByExternalId(externalId: string, request?: Paid.CustomersGetCostsByExternalIdRequest, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.CostTracesResponse>;
152
152
  private __getCostsByExternalId;
153
153
  /**
154
154
  * @param {string} externalId - The external ID of the customer
155
155
  * @param {Paid.CustomersGetUsageByExternalIdRequest} request
156
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
156
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
157
157
  *
158
158
  * @throws {@link Paid.BadRequestError}
159
159
  * @throws {@link Paid.ForbiddenError}
@@ -167,13 +167,13 @@ export declare class CustomersClient {
167
167
  * endTime: "2024-01-15T09:30:00Z"
168
168
  * })
169
169
  */
170
- getUsageByExternalId(externalId: string, request?: Paid.CustomersGetUsageByExternalIdRequest, requestOptions?: CustomersClient.RequestOptions): core.HttpResponsePromise<Paid.UsageSummariesResponse>;
170
+ getUsageByExternalId(externalId: string, request?: Paid.CustomersGetUsageByExternalIdRequest, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.UsageSummariesResponse>;
171
171
  private __getUsageByExternalId;
172
172
  /**
173
173
  * Retrieves all payment methods associated with a customer identified by their external ID.
174
174
  *
175
175
  * @param {string} externalId - The external ID of the customer
176
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
176
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
177
177
  *
178
178
  * @throws {@link Paid.ForbiddenError}
179
179
  * @throws {@link Paid.NotFoundError}
@@ -181,14 +181,14 @@ export declare class CustomersClient {
181
181
  * @example
182
182
  * await client.customers.listPaymentMethods("externalId")
183
183
  */
184
- listPaymentMethods(externalId: string, requestOptions?: CustomersClient.RequestOptions): core.HttpResponsePromise<Paid.PaymentMethod[]>;
184
+ listPaymentMethods(externalId: string, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.PaymentMethod[]>;
185
185
  private __listPaymentMethods;
186
186
  /**
187
187
  * Creates a new payment method for a customer using a Stripe confirmation token.
188
188
  *
189
189
  * @param {string} externalId - The external ID of the customer
190
190
  * @param {Paid.CustomersCreatePaymentMethodRequest} request
191
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
191
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
192
192
  *
193
193
  * @throws {@link Paid.BadRequestError}
194
194
  * @throws {@link Paid.ForbiddenError}
@@ -203,14 +203,14 @@ export declare class CustomersClient {
203
203
  * }
204
204
  * })
205
205
  */
206
- createPaymentMethod(externalId: string, request: Paid.CustomersCreatePaymentMethodRequest, requestOptions?: CustomersClient.RequestOptions): core.HttpResponsePromise<Paid.PaymentMethod>;
206
+ createPaymentMethod(externalId: string, request: Paid.CustomersCreatePaymentMethodRequest, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.PaymentMethod>;
207
207
  private __createPaymentMethod;
208
208
  /**
209
209
  * Deletes a specific payment method from a customer's account.
210
210
  *
211
211
  * @param {string} externalId - The external ID of the customer
212
212
  * @param {string} paymentMethodId - The ID of the payment method to delete
213
- * @param {CustomersClient.RequestOptions} requestOptions - Request-specific configuration.
213
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
214
214
  *
215
215
  * @throws {@link Paid.ForbiddenError}
216
216
  * @throws {@link Paid.NotFoundError}
@@ -218,6 +218,7 @@ export declare class CustomersClient {
218
218
  * @example
219
219
  * await client.customers.deletePaymentMethod("externalId", "paymentMethodId")
220
220
  */
221
- deletePaymentMethod(externalId: string, paymentMethodId: string, requestOptions?: CustomersClient.RequestOptions): core.HttpResponsePromise<void>;
221
+ deletePaymentMethod(externalId: string, paymentMethodId: string, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<void>;
222
222
  private __deletePaymentMethod;
223
+ protected _getAuthorizationHeader(): Promise<string | undefined>;
223
224
  }