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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (156) hide show
  1. package/dist/cjs/BaseClient.d.ts +4 -17
  2. package/dist/cjs/BaseClient.js +0 -59
  3. package/dist/cjs/Client.d.ts +28 -28
  4. package/dist/cjs/Client.js +52 -11
  5. package/dist/cjs/api/errors/BadRequestError.js +1 -5
  6. package/dist/cjs/api/errors/ForbiddenError.js +1 -5
  7. package/dist/cjs/api/errors/InternalServerError.js +1 -5
  8. package/dist/cjs/api/errors/NotFoundError.js +1 -5
  9. package/dist/cjs/api/resources/agents/client/Client.d.ts +23 -22
  10. package/dist/cjs/api/resources/agents/client/Client.js +158 -55
  11. package/dist/cjs/api/resources/contacts/client/Client.d.ts +19 -18
  12. package/dist/cjs/api/resources/contacts/client/Client.js +122 -43
  13. package/dist/cjs/api/resources/customers/client/Client.d.ts +37 -36
  14. package/dist/cjs/api/resources/customers/client/Client.js +315 -113
  15. package/dist/cjs/api/resources/orders/client/Client.d.ts +28 -27
  16. package/dist/cjs/api/resources/orders/client/Client.js +177 -62
  17. package/dist/cjs/api/resources/orders/resources/lines/client/Client.d.ts +9 -8
  18. package/dist/cjs/api/resources/orders/resources/lines/client/Client.js +32 -13
  19. package/dist/cjs/api/resources/plans/client/Client.d.ts +13 -12
  20. package/dist/cjs/api/resources/plans/client/Client.js +82 -32
  21. package/dist/cjs/api/resources/products/client/Client.d.ts +23 -22
  22. package/dist/cjs/api/resources/products/client/Client.js +158 -55
  23. package/dist/cjs/api/resources/products/client/requests/index.d.ts +1 -1
  24. package/dist/cjs/api/resources/products/client/requests/index.js +0 -3
  25. package/dist/cjs/api/resources/traces/client/Client.d.ts +9 -8
  26. package/dist/cjs/api/resources/traces/client/Client.js +57 -23
  27. package/dist/cjs/api/resources/usage/client/Client.d.ts +13 -12
  28. package/dist/cjs/api/resources/usage/client/Client.js +68 -25
  29. package/dist/cjs/core/auth/AuthProvider.d.ts +1 -4
  30. package/dist/cjs/core/auth/BearerToken.d.ts +1 -3
  31. package/dist/cjs/core/auth/BearerToken.js +6 -7
  32. package/dist/cjs/core/auth/index.d.ts +0 -1
  33. package/dist/cjs/core/auth/index.js +1 -3
  34. package/dist/cjs/core/fetcher/BinaryResponse.d.ts +7 -6
  35. package/dist/cjs/core/fetcher/EndpointSupplier.d.ts +2 -2
  36. package/dist/cjs/core/fetcher/Fetcher.d.ts +4 -10
  37. package/dist/cjs/core/fetcher/Fetcher.js +10 -204
  38. package/dist/cjs/core/fetcher/ResponseWithBody.d.ts +4 -0
  39. package/dist/cjs/core/fetcher/ResponseWithBody.js +6 -0
  40. package/dist/cjs/core/fetcher/getRequestBody.d.ts +1 -1
  41. package/dist/cjs/core/fetcher/getRequestBody.js +0 -4
  42. package/dist/cjs/core/fetcher/getResponseBody.js +4 -18
  43. package/dist/cjs/core/fetcher/makeRequest.d.ts +1 -1
  44. package/dist/cjs/core/fetcher/makeRequest.js +2 -0
  45. package/dist/cjs/core/fetcher/requestWithRetries.js +9 -0
  46. package/dist/cjs/core/fetcher/signals.d.ts +7 -1
  47. package/dist/cjs/core/fetcher/signals.js +12 -0
  48. package/dist/cjs/core/headers.d.ts +2 -2
  49. package/dist/cjs/core/headers.js +4 -6
  50. package/dist/cjs/core/index.d.ts +0 -1
  51. package/dist/cjs/core/index.js +1 -2
  52. package/dist/cjs/core/runtime/runtime.js +10 -11
  53. package/dist/cjs/core/url/join.js +1 -0
  54. package/dist/cjs/errors/PaidError.js +1 -5
  55. package/dist/cjs/errors/PaidTimeoutError.js +1 -5
  56. package/dist/cjs/index.d.ts +0 -1
  57. package/dist/cjs/index.js +0 -4
  58. package/dist/cjs/version.d.ts +1 -1
  59. package/dist/cjs/version.js +1 -1
  60. package/dist/esm/BaseClient.d.mts +4 -17
  61. package/dist/esm/BaseClient.mjs +1 -24
  62. package/dist/esm/Client.d.mts +28 -28
  63. package/dist/esm/Client.mjs +27 -19
  64. package/dist/esm/api/errors/BadRequestError.mjs +1 -5
  65. package/dist/esm/api/errors/ForbiddenError.mjs +1 -5
  66. package/dist/esm/api/errors/InternalServerError.mjs +1 -5
  67. package/dist/esm/api/errors/NotFoundError.mjs +1 -5
  68. package/dist/esm/api/resources/agents/client/Client.d.mts +23 -22
  69. package/dist/esm/api/resources/agents/client/Client.mjs +157 -54
  70. package/dist/esm/api/resources/contacts/client/Client.d.mts +19 -18
  71. package/dist/esm/api/resources/contacts/client/Client.mjs +121 -42
  72. package/dist/esm/api/resources/customers/client/Client.d.mts +37 -36
  73. package/dist/esm/api/resources/customers/client/Client.mjs +314 -112
  74. package/dist/esm/api/resources/orders/client/Client.d.mts +28 -27
  75. package/dist/esm/api/resources/orders/client/Client.mjs +177 -62
  76. package/dist/esm/api/resources/orders/resources/lines/client/Client.d.mts +9 -8
  77. package/dist/esm/api/resources/orders/resources/lines/client/Client.mjs +31 -12
  78. package/dist/esm/api/resources/plans/client/Client.d.mts +13 -12
  79. package/dist/esm/api/resources/plans/client/Client.mjs +81 -31
  80. package/dist/esm/api/resources/products/client/Client.d.mts +23 -22
  81. package/dist/esm/api/resources/products/client/Client.mjs +157 -54
  82. package/dist/esm/api/resources/products/client/requests/index.d.mts +1 -1
  83. package/dist/esm/api/resources/products/client/requests/index.mjs +1 -1
  84. package/dist/esm/api/resources/traces/client/Client.d.mts +9 -8
  85. package/dist/esm/api/resources/traces/client/Client.mjs +56 -22
  86. package/dist/esm/api/resources/usage/client/Client.d.mts +13 -12
  87. package/dist/esm/api/resources/usage/client/Client.mjs +67 -24
  88. package/dist/esm/core/auth/AuthProvider.d.mts +1 -4
  89. package/dist/esm/core/auth/BearerToken.d.mts +1 -3
  90. package/dist/esm/core/auth/BearerToken.mjs +6 -7
  91. package/dist/esm/core/auth/index.d.mts +0 -1
  92. package/dist/esm/core/auth/index.mjs +0 -1
  93. package/dist/esm/core/fetcher/BinaryResponse.d.mts +7 -6
  94. package/dist/esm/core/fetcher/EndpointSupplier.d.mts +2 -2
  95. package/dist/esm/core/fetcher/Fetcher.d.mts +4 -10
  96. package/dist/esm/core/fetcher/Fetcher.mjs +10 -204
  97. package/dist/esm/core/fetcher/ResponseWithBody.d.mts +4 -0
  98. package/dist/esm/core/fetcher/ResponseWithBody.mjs +3 -0
  99. package/dist/esm/core/fetcher/getRequestBody.d.mts +1 -1
  100. package/dist/esm/core/fetcher/getRequestBody.mjs +0 -4
  101. package/dist/esm/core/fetcher/getResponseBody.mjs +4 -18
  102. package/dist/esm/core/fetcher/makeRequest.d.mts +1 -1
  103. package/dist/esm/core/fetcher/makeRequest.mjs +2 -0
  104. package/dist/esm/core/fetcher/requestWithRetries.mjs +9 -0
  105. package/dist/esm/core/fetcher/signals.d.mts +7 -1
  106. package/dist/esm/core/fetcher/signals.mjs +12 -0
  107. package/dist/esm/core/headers.d.mts +2 -2
  108. package/dist/esm/core/headers.mjs +4 -6
  109. package/dist/esm/core/index.d.mts +0 -1
  110. package/dist/esm/core/index.mjs +0 -1
  111. package/dist/esm/core/runtime/runtime.mjs +10 -11
  112. package/dist/esm/core/url/join.mjs +1 -0
  113. package/dist/esm/errors/PaidError.mjs +1 -5
  114. package/dist/esm/errors/PaidTimeoutError.mjs +1 -5
  115. package/dist/esm/index.d.mts +0 -1
  116. package/dist/esm/index.mjs +0 -1
  117. package/dist/esm/version.d.mts +1 -1
  118. package/dist/esm/version.mjs +1 -1
  119. package/package.json +3 -6
  120. package/reference.md +54 -54
  121. package/dist/cjs/auth/BearerAuthProvider.d.ts +0 -20
  122. package/dist/cjs/auth/BearerAuthProvider.js +0 -79
  123. package/dist/cjs/auth/index.d.ts +0 -1
  124. package/dist/cjs/auth/index.js +0 -5
  125. package/dist/cjs/core/auth/NoOpAuthProvider.d.ts +0 -5
  126. package/dist/cjs/core/auth/NoOpAuthProvider.js +0 -9
  127. package/dist/cjs/core/exports.d.ts +0 -1
  128. package/dist/cjs/core/exports.js +0 -17
  129. package/dist/cjs/core/logging/exports.d.ts +0 -18
  130. package/dist/cjs/core/logging/exports.js +0 -45
  131. package/dist/cjs/core/logging/index.d.ts +0 -1
  132. package/dist/cjs/core/logging/index.js +0 -17
  133. package/dist/cjs/core/logging/logger.d.ts +0 -126
  134. package/dist/cjs/core/logging/logger.js +0 -144
  135. package/dist/cjs/errors/handleNonStatusCodeError.d.ts +0 -2
  136. package/dist/cjs/errors/handleNonStatusCodeError.js +0 -65
  137. package/dist/cjs/exports.d.ts +0 -1
  138. package/dist/cjs/exports.js +0 -17
  139. package/dist/esm/auth/BearerAuthProvider.d.mts +0 -20
  140. package/dist/esm/auth/BearerAuthProvider.mjs +0 -42
  141. package/dist/esm/auth/index.d.mts +0 -1
  142. package/dist/esm/auth/index.mjs +0 -1
  143. package/dist/esm/core/auth/NoOpAuthProvider.d.mts +0 -5
  144. package/dist/esm/core/auth/NoOpAuthProvider.mjs +0 -5
  145. package/dist/esm/core/exports.d.mts +0 -1
  146. package/dist/esm/core/exports.mjs +0 -1
  147. package/dist/esm/core/logging/exports.d.mts +0 -18
  148. package/dist/esm/core/logging/exports.mjs +0 -9
  149. package/dist/esm/core/logging/index.d.mts +0 -1
  150. package/dist/esm/core/logging/index.mjs +0 -1
  151. package/dist/esm/core/logging/logger.d.mts +0 -126
  152. package/dist/esm/core/logging/logger.mjs +0 -138
  153. package/dist/esm/errors/handleNonStatusCodeError.d.mts +0 -2
  154. package/dist/esm/errors/handleNonStatusCodeError.mjs +0 -29
  155. package/dist/esm/exports.d.mts +0 -1
  156. package/dist/esm/exports.mjs +0 -1
@@ -1,29 +1,29 @@
1
1
  import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
2
- import { type NormalizedClientOptions } from "../../../../BaseClient.js";
3
2
  import * as core from "../../../../core/index.js";
4
3
  import * as Paid from "../../../index.js";
5
- import { LinesClient } from "../resources/lines/client/Client.js";
6
- export declare namespace OrdersClient {
7
- type Options = BaseClientOptions;
4
+ import { Lines } from "../resources/lines/client/Client.js";
5
+ export declare namespace Orders {
6
+ interface Options extends BaseClientOptions {
7
+ }
8
8
  interface RequestOptions extends BaseRequestOptions {
9
9
  }
10
10
  }
11
- export declare class OrdersClient {
12
- protected readonly _options: NormalizedClientOptions<OrdersClient.Options>;
13
- protected _lines: LinesClient | undefined;
14
- constructor(options?: OrdersClient.Options);
15
- get lines(): LinesClient;
11
+ export declare class Orders {
12
+ protected readonly _options: Orders.Options;
13
+ protected _lines: Lines | undefined;
14
+ constructor(_options?: Orders.Options);
15
+ get lines(): Lines;
16
16
  /**
17
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
17
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
18
18
  *
19
19
  * @example
20
20
  * await client.orders.list()
21
21
  */
22
- list(requestOptions?: OrdersClient.RequestOptions): core.HttpResponsePromise<Paid.Order[]>;
22
+ list(requestOptions?: Orders.RequestOptions): core.HttpResponsePromise<Paid.Order[]>;
23
23
  private __list;
24
24
  /**
25
25
  * @param {Paid.OrderCreate} request
26
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
26
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
27
27
  *
28
28
  * @example
29
29
  * await client.orders.create({
@@ -45,41 +45,41 @@ export declare class OrdersClient {
45
45
  * currency: "USD"
46
46
  * })
47
47
  */
48
- create(request: Paid.OrderCreate, requestOptions?: OrdersClient.RequestOptions): core.HttpResponsePromise<Paid.Order>;
48
+ create(request: Paid.OrderCreate, requestOptions?: Orders.RequestOptions): core.HttpResponsePromise<Paid.Order>;
49
49
  private __create;
50
50
  /**
51
51
  * @param {string} orderId
52
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
52
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
53
53
  *
54
54
  * @example
55
55
  * await client.orders.get("orderId")
56
56
  */
57
- get(orderId: string, requestOptions?: OrdersClient.RequestOptions): core.HttpResponsePromise<Paid.Order>;
57
+ get(orderId: string, requestOptions?: Orders.RequestOptions): core.HttpResponsePromise<Paid.Order>;
58
58
  private __get;
59
59
  /**
60
60
  * @param {string} orderId
61
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
61
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
62
62
  *
63
63
  * @example
64
64
  * await client.orders.delete("orderId")
65
65
  */
66
- delete(orderId: string, requestOptions?: OrdersClient.RequestOptions): core.HttpResponsePromise<void>;
66
+ delete(orderId: string, requestOptions?: Orders.RequestOptions): core.HttpResponsePromise<void>;
67
67
  private __delete;
68
68
  /**
69
69
  * @param {string} orderId
70
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
70
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
71
71
  *
72
72
  * @example
73
73
  * await client.orders.activate("orderId")
74
74
  */
75
- activate(orderId: string, requestOptions?: OrdersClient.RequestOptions): core.HttpResponsePromise<Paid.Order>;
75
+ activate(orderId: string, requestOptions?: Orders.RequestOptions): core.HttpResponsePromise<Paid.Order>;
76
76
  private __activate;
77
77
  /**
78
78
  * Activates the order and processes the initial payment using the provided Stripe confirmation token.
79
79
  *
80
80
  * @param {string} orderId - The order ID (can be internal ID or display ID)
81
81
  * @param {Paid.OrdersActivateAndPayRequest} request
82
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
82
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
83
83
  *
84
84
  * @throws {@link Paid.BadRequestError}
85
85
  * @throws {@link Paid.ForbiddenError}
@@ -91,14 +91,14 @@ export declare class OrdersClient {
91
91
  * returnUrl: "https://example.com/payment-complete"
92
92
  * })
93
93
  */
94
- activateAndPay(orderId: string, request: Paid.OrdersActivateAndPayRequest, requestOptions?: OrdersClient.RequestOptions): core.HttpResponsePromise<Paid.Order>;
94
+ activateAndPay(orderId: string, request: Paid.OrdersActivateAndPayRequest, requestOptions?: Orders.RequestOptions): core.HttpResponsePromise<Paid.Order>;
95
95
  private __activateAndPay;
96
96
  /**
97
97
  * Schedules the cancellation of an order's renewal from a specified date. The order will remain active until the cancellation date.
98
98
  *
99
99
  * @param {string} orderId - The order ID (can be internal ID or display ID)
100
100
  * @param {Paid.CancelRenewalRequest} request
101
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
101
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
102
102
  *
103
103
  * @throws {@link Paid.BadRequestError}
104
104
  * @throws {@link Paid.ForbiddenError}
@@ -110,14 +110,14 @@ export declare class OrdersClient {
110
110
  * cancelFromDate: "2025-12-31T00:00:00Z"
111
111
  * })
112
112
  */
113
- cancelRenewal(orderId: string, request: Paid.CancelRenewalRequest, requestOptions?: OrdersClient.RequestOptions): core.HttpResponsePromise<Paid.CancelRenewalResponse>;
113
+ cancelRenewal(orderId: string, request: Paid.CancelRenewalRequest, requestOptions?: Orders.RequestOptions): core.HttpResponsePromise<Paid.CancelRenewalResponse>;
114
114
  private __cancelRenewal;
115
115
  /**
116
116
  * Schedules a plan upgrade or downgrade for an order with automatic proration calculation. Credits are applied for the unused portion of the current billing period.
117
117
  *
118
118
  * @param {string} orderId - The order ID (can be internal ID or display ID)
119
119
  * @param {Paid.ProrationUpgradeRequest} request
120
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
120
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
121
121
  *
122
122
  * @throws {@link Paid.BadRequestError}
123
123
  * @throws {@link Paid.ForbiddenError}
@@ -137,13 +137,13 @@ export declare class OrdersClient {
137
137
  * }]
138
138
  * })
139
139
  */
140
- schedulePlanChange(orderId: string, request: Paid.ProrationUpgradeRequest, requestOptions?: OrdersClient.RequestOptions): core.HttpResponsePromise<Paid.ProrationUpgradeResponse>;
140
+ schedulePlanChange(orderId: string, request: Paid.ProrationUpgradeRequest, requestOptions?: Orders.RequestOptions): core.HttpResponsePromise<Paid.ProrationUpgradeResponse>;
141
141
  private __schedulePlanChange;
142
142
  /**
143
143
  * Retrieves all invoices associated with a specific order.
144
144
  *
145
145
  * @param {string} orderId - The order ID (can be internal ID or display ID)
146
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
146
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
147
147
  *
148
148
  * @throws {@link Paid.ForbiddenError}
149
149
  * @throws {@link Paid.NotFoundError}
@@ -151,6 +151,7 @@ export declare class OrdersClient {
151
151
  * @example
152
152
  * await client.orders.getInvoices("orderId")
153
153
  */
154
- getInvoices(orderId: string, requestOptions?: OrdersClient.RequestOptions): core.HttpResponsePromise<Paid.Invoice[]>;
154
+ getInvoices(orderId: string, requestOptions?: Orders.RequestOptions): core.HttpResponsePromise<Paid.Invoice[]>;
155
155
  private __getInvoices;
156
+ protected _getAuthorizationHeader(): Promise<string | undefined>;
156
157
  }
@@ -43,25 +43,23 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
43
43
  });
44
44
  };
45
45
  Object.defineProperty(exports, "__esModule", { value: true });
46
- exports.OrdersClient = void 0;
47
- const BaseClient_js_1 = require("../../../../BaseClient.js");
46
+ exports.Orders = void 0;
48
47
  const headers_js_1 = require("../../../../core/headers.js");
49
48
  const core = __importStar(require("../../../../core/index.js"));
50
49
  const environments = __importStar(require("../../../../environments.js"));
51
- const handleNonStatusCodeError_js_1 = require("../../../../errors/handleNonStatusCodeError.js");
52
50
  const errors = __importStar(require("../../../../errors/index.js"));
53
51
  const Paid = __importStar(require("../../../index.js"));
54
52
  const Client_js_1 = require("../resources/lines/client/Client.js");
55
- class OrdersClient {
56
- constructor(options = {}) {
57
- this._options = (0, BaseClient_js_1.normalizeClientOptions)(options);
53
+ class Orders {
54
+ constructor(_options = {}) {
55
+ this._options = _options;
58
56
  }
59
57
  get lines() {
60
58
  var _a;
61
- return ((_a = this._lines) !== null && _a !== void 0 ? _a : (this._lines = new Client_js_1.LinesClient(this._options)));
59
+ return ((_a = this._lines) !== null && _a !== void 0 ? _a : (this._lines = new Client_js_1.Lines(this._options)));
62
60
  }
63
61
  /**
64
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
62
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
65
63
  *
66
64
  * @example
67
65
  * await client.orders.list()
@@ -71,8 +69,8 @@ class OrdersClient {
71
69
  }
72
70
  __list(requestOptions) {
73
71
  return __awaiter(this, void 0, void 0, function* () {
74
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
75
- 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);
72
+ var _a, _b, _c, _d, _e, _f, _g, _h;
73
+ 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);
76
74
  const _response = yield core.fetcher({
77
75
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Production, "orders"),
78
76
  method: "GET",
@@ -81,8 +79,6 @@ class OrdersClient {
81
79
  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,
82
80
  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,
83
81
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
84
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
85
- logging: this._options.logging,
86
82
  });
87
83
  if (_response.ok) {
88
84
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -94,12 +90,26 @@ class OrdersClient {
94
90
  rawResponse: _response.rawResponse,
95
91
  });
96
92
  }
97
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/orders");
93
+ switch (_response.error.reason) {
94
+ case "non-json":
95
+ throw new errors.PaidError({
96
+ statusCode: _response.error.statusCode,
97
+ body: _response.error.rawBody,
98
+ rawResponse: _response.rawResponse,
99
+ });
100
+ case "timeout":
101
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /orders.");
102
+ case "unknown":
103
+ throw new errors.PaidError({
104
+ message: _response.error.errorMessage,
105
+ rawResponse: _response.rawResponse,
106
+ });
107
+ }
98
108
  });
99
109
  }
100
110
  /**
101
111
  * @param {Paid.OrderCreate} request
102
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
112
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
103
113
  *
104
114
  * @example
105
115
  * await client.orders.create({
@@ -126,8 +136,8 @@ class OrdersClient {
126
136
  }
127
137
  __create(request, requestOptions) {
128
138
  return __awaiter(this, void 0, void 0, function* () {
129
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
130
- 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);
139
+ var _a, _b, _c, _d, _e, _f, _g, _h;
140
+ 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);
131
141
  const _response = yield core.fetcher({
132
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, "orders"),
133
143
  method: "POST",
@@ -139,8 +149,6 @@ class OrdersClient {
139
149
  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,
140
150
  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,
141
151
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
142
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
143
- logging: this._options.logging,
144
152
  });
145
153
  if (_response.ok) {
146
154
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -152,12 +160,26 @@ class OrdersClient {
152
160
  rawResponse: _response.rawResponse,
153
161
  });
154
162
  }
155
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/orders");
163
+ switch (_response.error.reason) {
164
+ case "non-json":
165
+ throw new errors.PaidError({
166
+ statusCode: _response.error.statusCode,
167
+ body: _response.error.rawBody,
168
+ rawResponse: _response.rawResponse,
169
+ });
170
+ case "timeout":
171
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /orders.");
172
+ case "unknown":
173
+ throw new errors.PaidError({
174
+ message: _response.error.errorMessage,
175
+ rawResponse: _response.rawResponse,
176
+ });
177
+ }
156
178
  });
157
179
  }
158
180
  /**
159
181
  * @param {string} orderId
160
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
182
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
161
183
  *
162
184
  * @example
163
185
  * await client.orders.get("orderId")
@@ -167,8 +189,8 @@ class OrdersClient {
167
189
  }
168
190
  __get(orderId, requestOptions) {
169
191
  return __awaiter(this, void 0, void 0, function* () {
170
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
171
- 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);
192
+ var _a, _b, _c, _d, _e, _f, _g, _h;
193
+ 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);
172
194
  const _response = yield core.fetcher({
173
195
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Production, `orders/${core.url.encodePathParam(orderId)}`),
174
196
  method: "GET",
@@ -177,8 +199,6 @@ class OrdersClient {
177
199
  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,
178
200
  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,
179
201
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
180
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
181
- logging: this._options.logging,
182
202
  });
183
203
  if (_response.ok) {
184
204
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -190,12 +210,26 @@ class OrdersClient {
190
210
  rawResponse: _response.rawResponse,
191
211
  });
192
212
  }
193
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/orders/{orderId}");
213
+ switch (_response.error.reason) {
214
+ case "non-json":
215
+ throw new errors.PaidError({
216
+ statusCode: _response.error.statusCode,
217
+ body: _response.error.rawBody,
218
+ rawResponse: _response.rawResponse,
219
+ });
220
+ case "timeout":
221
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /orders/{orderId}.");
222
+ case "unknown":
223
+ throw new errors.PaidError({
224
+ message: _response.error.errorMessage,
225
+ rawResponse: _response.rawResponse,
226
+ });
227
+ }
194
228
  });
195
229
  }
196
230
  /**
197
231
  * @param {string} orderId
198
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
232
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
199
233
  *
200
234
  * @example
201
235
  * await client.orders.delete("orderId")
@@ -205,8 +239,8 @@ class OrdersClient {
205
239
  }
206
240
  __delete(orderId, requestOptions) {
207
241
  return __awaiter(this, void 0, void 0, function* () {
208
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
209
- const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
242
+ var _a, _b, _c, _d, _e, _f, _g, _h;
243
+ const _headers = (0, headers_js_1.mergeHeaders)((_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ Authorization: yield this._getAuthorizationHeader() }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
210
244
  const _response = yield core.fetcher({
211
245
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Production, `orders/${core.url.encodePathParam(orderId)}`),
212
246
  method: "DELETE",
@@ -215,8 +249,6 @@ class OrdersClient {
215
249
  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,
216
250
  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,
217
251
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
218
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
219
- logging: this._options.logging,
220
252
  });
221
253
  if (_response.ok) {
222
254
  return { data: undefined, rawResponse: _response.rawResponse };
@@ -228,12 +260,26 @@ class OrdersClient {
228
260
  rawResponse: _response.rawResponse,
229
261
  });
230
262
  }
231
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "DELETE", "/orders/{orderId}");
263
+ switch (_response.error.reason) {
264
+ case "non-json":
265
+ throw new errors.PaidError({
266
+ statusCode: _response.error.statusCode,
267
+ body: _response.error.rawBody,
268
+ rawResponse: _response.rawResponse,
269
+ });
270
+ case "timeout":
271
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling DELETE /orders/{orderId}.");
272
+ case "unknown":
273
+ throw new errors.PaidError({
274
+ message: _response.error.errorMessage,
275
+ rawResponse: _response.rawResponse,
276
+ });
277
+ }
232
278
  });
233
279
  }
234
280
  /**
235
281
  * @param {string} orderId
236
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
282
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
237
283
  *
238
284
  * @example
239
285
  * await client.orders.activate("orderId")
@@ -243,8 +289,8 @@ class OrdersClient {
243
289
  }
244
290
  __activate(orderId, requestOptions) {
245
291
  return __awaiter(this, void 0, void 0, function* () {
246
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
247
- 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);
292
+ var _a, _b, _c, _d, _e, _f, _g, _h;
293
+ 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);
248
294
  const _response = yield core.fetcher({
249
295
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Production, `orders/${core.url.encodePathParam(orderId)}/activate`),
250
296
  method: "POST",
@@ -253,8 +299,6 @@ class OrdersClient {
253
299
  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,
254
300
  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,
255
301
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
256
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
257
- logging: this._options.logging,
258
302
  });
259
303
  if (_response.ok) {
260
304
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -266,7 +310,21 @@ class OrdersClient {
266
310
  rawResponse: _response.rawResponse,
267
311
  });
268
312
  }
269
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/orders/{orderId}/activate");
313
+ switch (_response.error.reason) {
314
+ case "non-json":
315
+ throw new errors.PaidError({
316
+ statusCode: _response.error.statusCode,
317
+ body: _response.error.rawBody,
318
+ rawResponse: _response.rawResponse,
319
+ });
320
+ case "timeout":
321
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /orders/{orderId}/activate.");
322
+ case "unknown":
323
+ throw new errors.PaidError({
324
+ message: _response.error.errorMessage,
325
+ rawResponse: _response.rawResponse,
326
+ });
327
+ }
270
328
  });
271
329
  }
272
330
  /**
@@ -274,7 +332,7 @@ class OrdersClient {
274
332
  *
275
333
  * @param {string} orderId - The order ID (can be internal ID or display ID)
276
334
  * @param {Paid.OrdersActivateAndPayRequest} request
277
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
335
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
278
336
  *
279
337
  * @throws {@link Paid.BadRequestError}
280
338
  * @throws {@link Paid.ForbiddenError}
@@ -291,8 +349,8 @@ class OrdersClient {
291
349
  }
292
350
  __activateAndPay(orderId, request, requestOptions) {
293
351
  return __awaiter(this, void 0, void 0, function* () {
294
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
295
- 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);
352
+ var _a, _b, _c, _d, _e, _f, _g, _h;
353
+ 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);
296
354
  const _response = yield core.fetcher({
297
355
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Production, `orders/${core.url.encodePathParam(orderId)}/activate-and-pay`),
298
356
  method: "POST",
@@ -304,8 +362,6 @@ class OrdersClient {
304
362
  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,
305
363
  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,
306
364
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
307
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
308
- logging: this._options.logging,
309
365
  });
310
366
  if (_response.ok) {
311
367
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -326,7 +382,21 @@ class OrdersClient {
326
382
  });
327
383
  }
328
384
  }
329
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/orders/{orderId}/activate-and-pay");
385
+ switch (_response.error.reason) {
386
+ case "non-json":
387
+ throw new errors.PaidError({
388
+ statusCode: _response.error.statusCode,
389
+ body: _response.error.rawBody,
390
+ rawResponse: _response.rawResponse,
391
+ });
392
+ case "timeout":
393
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /orders/{orderId}/activate-and-pay.");
394
+ case "unknown":
395
+ throw new errors.PaidError({
396
+ message: _response.error.errorMessage,
397
+ rawResponse: _response.rawResponse,
398
+ });
399
+ }
330
400
  });
331
401
  }
332
402
  /**
@@ -334,7 +404,7 @@ class OrdersClient {
334
404
  *
335
405
  * @param {string} orderId - The order ID (can be internal ID or display ID)
336
406
  * @param {Paid.CancelRenewalRequest} request
337
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
407
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
338
408
  *
339
409
  * @throws {@link Paid.BadRequestError}
340
410
  * @throws {@link Paid.ForbiddenError}
@@ -351,8 +421,8 @@ class OrdersClient {
351
421
  }
352
422
  __cancelRenewal(orderId, request, requestOptions) {
353
423
  return __awaiter(this, void 0, void 0, function* () {
354
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
355
- 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);
424
+ var _a, _b, _c, _d, _e, _f, _g, _h;
425
+ 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);
356
426
  const _response = yield core.fetcher({
357
427
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Production, `orders/${core.url.encodePathParam(orderId)}/cancel`),
358
428
  method: "POST",
@@ -364,8 +434,6 @@ class OrdersClient {
364
434
  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,
365
435
  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,
366
436
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
367
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
368
- logging: this._options.logging,
369
437
  });
370
438
  if (_response.ok) {
371
439
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -386,7 +454,21 @@ class OrdersClient {
386
454
  });
387
455
  }
388
456
  }
389
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/orders/{orderId}/cancel");
457
+ switch (_response.error.reason) {
458
+ case "non-json":
459
+ throw new errors.PaidError({
460
+ statusCode: _response.error.statusCode,
461
+ body: _response.error.rawBody,
462
+ rawResponse: _response.rawResponse,
463
+ });
464
+ case "timeout":
465
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /orders/{orderId}/cancel.");
466
+ case "unknown":
467
+ throw new errors.PaidError({
468
+ message: _response.error.errorMessage,
469
+ rawResponse: _response.rawResponse,
470
+ });
471
+ }
390
472
  });
391
473
  }
392
474
  /**
@@ -394,7 +476,7 @@ class OrdersClient {
394
476
  *
395
477
  * @param {string} orderId - The order ID (can be internal ID or display ID)
396
478
  * @param {Paid.ProrationUpgradeRequest} request
397
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
479
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
398
480
  *
399
481
  * @throws {@link Paid.BadRequestError}
400
482
  * @throws {@link Paid.ForbiddenError}
@@ -419,8 +501,8 @@ class OrdersClient {
419
501
  }
420
502
  __schedulePlanChange(orderId, request, requestOptions) {
421
503
  return __awaiter(this, void 0, void 0, function* () {
422
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
423
- 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);
504
+ var _a, _b, _c, _d, _e, _f, _g, _h;
505
+ 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);
424
506
  const _response = yield core.fetcher({
425
507
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Production, `orders/${core.url.encodePathParam(orderId)}/schedule-plan-change`),
426
508
  method: "POST",
@@ -432,8 +514,6 @@ class OrdersClient {
432
514
  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,
433
515
  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,
434
516
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
435
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
436
- logging: this._options.logging,
437
517
  });
438
518
  if (_response.ok) {
439
519
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -454,14 +534,28 @@ class OrdersClient {
454
534
  });
455
535
  }
456
536
  }
457
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "POST", "/orders/{orderId}/schedule-plan-change");
537
+ switch (_response.error.reason) {
538
+ case "non-json":
539
+ throw new errors.PaidError({
540
+ statusCode: _response.error.statusCode,
541
+ body: _response.error.rawBody,
542
+ rawResponse: _response.rawResponse,
543
+ });
544
+ case "timeout":
545
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /orders/{orderId}/schedule-plan-change.");
546
+ case "unknown":
547
+ throw new errors.PaidError({
548
+ message: _response.error.errorMessage,
549
+ rawResponse: _response.rawResponse,
550
+ });
551
+ }
458
552
  });
459
553
  }
460
554
  /**
461
555
  * Retrieves all invoices associated with a specific order.
462
556
  *
463
557
  * @param {string} orderId - The order ID (can be internal ID or display ID)
464
- * @param {OrdersClient.RequestOptions} requestOptions - Request-specific configuration.
558
+ * @param {Orders.RequestOptions} requestOptions - Request-specific configuration.
465
559
  *
466
560
  * @throws {@link Paid.ForbiddenError}
467
561
  * @throws {@link Paid.NotFoundError}
@@ -474,8 +568,8 @@ class OrdersClient {
474
568
  }
475
569
  __getInvoices(orderId, requestOptions) {
476
570
  return __awaiter(this, void 0, void 0, function* () {
477
- var _a, _b, _c, _d, _e, _f, _g, _h, _j;
478
- 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);
571
+ var _a, _b, _c, _d, _e, _f, _g, _h;
572
+ 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);
479
573
  const _response = yield core.fetcher({
480
574
  url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Production, `orders/${core.url.encodePathParam(orderId)}/invoices`),
481
575
  method: "GET",
@@ -484,8 +578,6 @@ class OrdersClient {
484
578
  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,
485
579
  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,
486
580
  abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
487
- fetchFn: (_j = this._options) === null || _j === void 0 ? void 0 : _j.fetch,
488
- logging: this._options.logging,
489
581
  });
490
582
  if (_response.ok) {
491
583
  return { data: _response.body, rawResponse: _response.rawResponse };
@@ -504,8 +596,31 @@ class OrdersClient {
504
596
  });
505
597
  }
506
598
  }
507
- return (0, handleNonStatusCodeError_js_1.handleNonStatusCodeError)(_response.error, _response.rawResponse, "GET", "/orders/{orderId}/invoices");
599
+ switch (_response.error.reason) {
600
+ case "non-json":
601
+ throw new errors.PaidError({
602
+ statusCode: _response.error.statusCode,
603
+ body: _response.error.rawBody,
604
+ rawResponse: _response.rawResponse,
605
+ });
606
+ case "timeout":
607
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /orders/{orderId}/invoices.");
608
+ case "unknown":
609
+ throw new errors.PaidError({
610
+ message: _response.error.errorMessage,
611
+ rawResponse: _response.rawResponse,
612
+ });
613
+ }
614
+ });
615
+ }
616
+ _getAuthorizationHeader() {
617
+ return __awaiter(this, void 0, void 0, function* () {
618
+ const bearer = yield core.Supplier.get(this._options.token);
619
+ if (bearer != null) {
620
+ return `Bearer ${bearer}`;
621
+ }
622
+ return undefined;
508
623
  });
509
624
  }
510
625
  }
511
- exports.OrdersClient = OrdersClient;
626
+ exports.Orders = Orders;