@paid-ai/paid-node 1.1.0 → 1.2.0

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 (161) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/Client.d.ts +9 -0
  3. package/dist/cjs/Client.js +29 -14
  4. package/dist/cjs/api/resources/checkouts/client/Client.d.ts +84 -0
  5. package/dist/cjs/api/resources/checkouts/client/Client.js +350 -0
  6. package/dist/cjs/api/resources/checkouts/client/index.d.ts +1 -0
  7. package/dist/cjs/api/resources/checkouts/client/index.js +17 -0
  8. package/dist/cjs/api/resources/checkouts/client/requests/ArchiveCheckoutRequest.d.ts +9 -0
  9. package/dist/cjs/api/resources/checkouts/client/requests/ArchiveCheckoutRequest.js +3 -0
  10. package/dist/cjs/api/resources/checkouts/client/requests/CreateCheckoutRequest.d.ts +23 -0
  11. package/dist/cjs/api/resources/checkouts/client/requests/CreateCheckoutRequest.js +3 -0
  12. package/dist/cjs/api/resources/checkouts/client/requests/GetCheckoutRequest.d.ts +9 -0
  13. package/dist/cjs/api/resources/checkouts/client/requests/GetCheckoutRequest.js +3 -0
  14. package/dist/cjs/api/resources/checkouts/client/requests/ListCheckoutsRequest.d.ts +10 -0
  15. package/dist/cjs/api/resources/checkouts/client/requests/ListCheckoutsRequest.js +3 -0
  16. package/dist/cjs/api/resources/checkouts/client/requests/index.d.ts +4 -0
  17. package/dist/cjs/api/resources/checkouts/client/requests/index.js +2 -0
  18. package/dist/cjs/api/resources/checkouts/index.d.ts +2 -0
  19. package/dist/cjs/api/resources/checkouts/index.js +18 -0
  20. package/dist/cjs/api/resources/checkouts/types/ListCheckoutsRequestStatus.d.ts +6 -0
  21. package/dist/cjs/api/resources/checkouts/types/ListCheckoutsRequestStatus.js +9 -0
  22. package/dist/cjs/api/resources/checkouts/types/index.d.ts +1 -0
  23. package/dist/cjs/api/resources/checkouts/types/index.js +17 -0
  24. package/dist/cjs/api/resources/credits/client/Client.d.ts +27 -0
  25. package/dist/cjs/api/resources/credits/client/Client.js +123 -0
  26. package/dist/cjs/api/resources/credits/client/index.d.ts +1 -0
  27. package/dist/cjs/api/resources/credits/client/index.js +2 -0
  28. package/dist/cjs/api/resources/credits/index.d.ts +1 -0
  29. package/dist/cjs/api/resources/credits/index.js +17 -0
  30. package/dist/cjs/api/resources/customerPortals/client/Client.d.ts +30 -0
  31. package/dist/cjs/api/resources/customerPortals/client/Client.js +133 -0
  32. package/dist/cjs/api/resources/customerPortals/client/index.d.ts +1 -0
  33. package/dist/cjs/api/resources/customerPortals/client/index.js +17 -0
  34. package/dist/cjs/api/resources/customerPortals/client/requests/CreateCustomerPortalRequest.d.ts +12 -0
  35. package/dist/cjs/api/resources/customerPortals/client/requests/CreateCustomerPortalRequest.js +3 -0
  36. package/dist/cjs/api/resources/customerPortals/client/requests/index.d.ts +1 -0
  37. package/dist/cjs/api/resources/customerPortals/client/requests/index.js +2 -0
  38. package/dist/cjs/api/resources/customerPortals/index.d.ts +1 -0
  39. package/dist/cjs/api/resources/customerPortals/index.js +17 -0
  40. package/dist/cjs/api/resources/customers/client/Client.d.ts +34 -0
  41. package/dist/cjs/api/resources/customers/client/Client.js +136 -0
  42. package/dist/cjs/api/resources/customers/client/requests/GetCustomerCreditBalancesByExternalIdRequest.d.ts +9 -0
  43. package/dist/cjs/api/resources/customers/client/requests/GetCustomerCreditBalancesByExternalIdRequest.js +3 -0
  44. package/dist/cjs/api/resources/customers/client/requests/GetCustomerCreditBalancesRequest.d.ts +9 -0
  45. package/dist/cjs/api/resources/customers/client/requests/GetCustomerCreditBalancesRequest.js +3 -0
  46. package/dist/cjs/api/resources/customers/client/requests/index.d.ts +2 -0
  47. package/dist/cjs/api/resources/index.d.ts +6 -0
  48. package/dist/cjs/api/resources/index.js +7 -1
  49. package/dist/cjs/api/resources/orders/client/requests/CreateOrderRequest.d.ts +11 -7
  50. package/dist/cjs/api/resources/orders/client/requests/UpdateOrderRequest.d.ts +10 -7
  51. package/dist/cjs/api/types/Checkout.d.ts +18 -0
  52. package/dist/cjs/api/types/Checkout.js +3 -0
  53. package/dist/cjs/api/types/CheckoutListResponse.d.ts +5 -0
  54. package/dist/cjs/api/types/CheckoutListResponse.js +3 -0
  55. package/dist/cjs/api/types/CheckoutProduct.d.ts +3 -0
  56. package/dist/cjs/api/types/CheckoutProduct.js +3 -0
  57. package/dist/cjs/api/types/CheckoutProductInput.d.ts +3 -0
  58. package/dist/cjs/api/types/CheckoutProductInput.js +3 -0
  59. package/dist/cjs/api/types/CheckoutStatus.d.ts +7 -0
  60. package/dist/cjs/api/types/CheckoutStatus.js +10 -0
  61. package/dist/cjs/api/types/CreateOrderLineAttributeRequest.d.ts +116 -1
  62. package/dist/cjs/api/types/CreateOrderLineAttributeRequest.js +70 -0
  63. package/dist/cjs/api/types/CreateOrderLineRequest.d.ts +3 -3
  64. package/dist/cjs/api/types/CreditBalance.d.ts +19 -0
  65. package/dist/cjs/api/types/CreditBalance.js +11 -0
  66. package/dist/cjs/api/types/CreditBalanceListResponse.d.ts +4 -0
  67. package/dist/cjs/api/types/CreditBalanceListResponse.js +3 -0
  68. package/dist/cjs/api/types/CreditCurrency.d.ts +9 -0
  69. package/dist/cjs/api/types/CreditCurrency.js +3 -0
  70. package/dist/cjs/api/types/CreditCurrencyListResponse.d.ts +4 -0
  71. package/dist/cjs/api/types/CreditCurrencyListResponse.js +3 -0
  72. package/dist/cjs/api/types/CustomerPortal.d.ts +10 -0
  73. package/dist/cjs/api/types/CustomerPortal.js +3 -0
  74. package/dist/cjs/api/types/CustomerPortalStatus.d.ts +5 -0
  75. package/dist/cjs/api/types/CustomerPortalStatus.js +8 -0
  76. package/dist/cjs/api/types/Order.d.ts +3 -0
  77. package/dist/cjs/api/types/index.d.ts +11 -0
  78. package/dist/cjs/api/types/index.js +11 -0
  79. package/dist/cjs/version.d.ts +1 -1
  80. package/dist/cjs/version.js +1 -1
  81. package/dist/esm/Client.d.mts +9 -0
  82. package/dist/esm/Client.mjs +17 -2
  83. package/dist/esm/api/resources/checkouts/client/Client.d.mts +84 -0
  84. package/dist/esm/api/resources/checkouts/client/Client.mjs +313 -0
  85. package/dist/esm/api/resources/checkouts/client/index.d.mts +1 -0
  86. package/dist/esm/api/resources/checkouts/client/index.mjs +1 -0
  87. package/dist/esm/api/resources/checkouts/client/requests/ArchiveCheckoutRequest.d.mts +9 -0
  88. package/dist/esm/api/resources/checkouts/client/requests/ArchiveCheckoutRequest.mjs +2 -0
  89. package/dist/esm/api/resources/checkouts/client/requests/CreateCheckoutRequest.d.mts +23 -0
  90. package/dist/esm/api/resources/checkouts/client/requests/CreateCheckoutRequest.mjs +2 -0
  91. package/dist/esm/api/resources/checkouts/client/requests/GetCheckoutRequest.d.mts +9 -0
  92. package/dist/esm/api/resources/checkouts/client/requests/GetCheckoutRequest.mjs +2 -0
  93. package/dist/esm/api/resources/checkouts/client/requests/ListCheckoutsRequest.d.mts +10 -0
  94. package/dist/esm/api/resources/checkouts/client/requests/ListCheckoutsRequest.mjs +2 -0
  95. package/dist/esm/api/resources/checkouts/client/requests/index.d.mts +4 -0
  96. package/dist/esm/api/resources/checkouts/client/requests/index.mjs +1 -0
  97. package/dist/esm/api/resources/checkouts/index.d.mts +2 -0
  98. package/dist/esm/api/resources/checkouts/index.mjs +2 -0
  99. package/dist/esm/api/resources/checkouts/types/ListCheckoutsRequestStatus.d.mts +6 -0
  100. package/dist/esm/api/resources/checkouts/types/ListCheckoutsRequestStatus.mjs +6 -0
  101. package/dist/esm/api/resources/checkouts/types/index.d.mts +1 -0
  102. package/dist/esm/api/resources/checkouts/types/index.mjs +1 -0
  103. package/dist/esm/api/resources/credits/client/Client.d.mts +27 -0
  104. package/dist/esm/api/resources/credits/client/Client.mjs +86 -0
  105. package/dist/esm/api/resources/credits/client/index.d.mts +1 -0
  106. package/dist/esm/api/resources/credits/client/index.mjs +1 -0
  107. package/dist/esm/api/resources/credits/index.d.mts +1 -0
  108. package/dist/esm/api/resources/credits/index.mjs +1 -0
  109. package/dist/esm/api/resources/customerPortals/client/Client.d.mts +30 -0
  110. package/dist/esm/api/resources/customerPortals/client/Client.mjs +96 -0
  111. package/dist/esm/api/resources/customerPortals/client/index.d.mts +1 -0
  112. package/dist/esm/api/resources/customerPortals/client/index.mjs +1 -0
  113. package/dist/esm/api/resources/customerPortals/client/requests/CreateCustomerPortalRequest.d.mts +12 -0
  114. package/dist/esm/api/resources/customerPortals/client/requests/CreateCustomerPortalRequest.mjs +2 -0
  115. package/dist/esm/api/resources/customerPortals/client/requests/index.d.mts +1 -0
  116. package/dist/esm/api/resources/customerPortals/client/requests/index.mjs +1 -0
  117. package/dist/esm/api/resources/customerPortals/index.d.mts +1 -0
  118. package/dist/esm/api/resources/customerPortals/index.mjs +1 -0
  119. package/dist/esm/api/resources/customers/client/Client.d.mts +34 -0
  120. package/dist/esm/api/resources/customers/client/Client.mjs +136 -0
  121. package/dist/esm/api/resources/customers/client/requests/GetCustomerCreditBalancesByExternalIdRequest.d.mts +9 -0
  122. package/dist/esm/api/resources/customers/client/requests/GetCustomerCreditBalancesByExternalIdRequest.mjs +2 -0
  123. package/dist/esm/api/resources/customers/client/requests/GetCustomerCreditBalancesRequest.d.mts +9 -0
  124. package/dist/esm/api/resources/customers/client/requests/GetCustomerCreditBalancesRequest.mjs +2 -0
  125. package/dist/esm/api/resources/customers/client/requests/index.d.mts +2 -0
  126. package/dist/esm/api/resources/index.d.mts +6 -0
  127. package/dist/esm/api/resources/index.mjs +6 -0
  128. package/dist/esm/api/resources/orders/client/requests/CreateOrderRequest.d.mts +11 -7
  129. package/dist/esm/api/resources/orders/client/requests/UpdateOrderRequest.d.mts +10 -7
  130. package/dist/esm/api/types/Checkout.d.mts +18 -0
  131. package/dist/esm/api/types/Checkout.mjs +2 -0
  132. package/dist/esm/api/types/CheckoutListResponse.d.mts +5 -0
  133. package/dist/esm/api/types/CheckoutListResponse.mjs +2 -0
  134. package/dist/esm/api/types/CheckoutProduct.d.mts +3 -0
  135. package/dist/esm/api/types/CheckoutProduct.mjs +2 -0
  136. package/dist/esm/api/types/CheckoutProductInput.d.mts +3 -0
  137. package/dist/esm/api/types/CheckoutProductInput.mjs +2 -0
  138. package/dist/esm/api/types/CheckoutStatus.d.mts +7 -0
  139. package/dist/esm/api/types/CheckoutStatus.mjs +7 -0
  140. package/dist/esm/api/types/CreateOrderLineAttributeRequest.d.mts +116 -1
  141. package/dist/esm/api/types/CreateOrderLineAttributeRequest.mjs +69 -1
  142. package/dist/esm/api/types/CreateOrderLineRequest.d.mts +3 -3
  143. package/dist/esm/api/types/CreditBalance.d.mts +19 -0
  144. package/dist/esm/api/types/CreditBalance.mjs +8 -0
  145. package/dist/esm/api/types/CreditBalanceListResponse.d.mts +4 -0
  146. package/dist/esm/api/types/CreditBalanceListResponse.mjs +2 -0
  147. package/dist/esm/api/types/CreditCurrency.d.mts +9 -0
  148. package/dist/esm/api/types/CreditCurrency.mjs +2 -0
  149. package/dist/esm/api/types/CreditCurrencyListResponse.d.mts +4 -0
  150. package/dist/esm/api/types/CreditCurrencyListResponse.mjs +2 -0
  151. package/dist/esm/api/types/CustomerPortal.d.mts +10 -0
  152. package/dist/esm/api/types/CustomerPortal.mjs +2 -0
  153. package/dist/esm/api/types/CustomerPortalStatus.d.mts +5 -0
  154. package/dist/esm/api/types/CustomerPortalStatus.mjs +5 -0
  155. package/dist/esm/api/types/Order.d.mts +3 -0
  156. package/dist/esm/api/types/index.d.mts +11 -0
  157. package/dist/esm/api/types/index.mjs +11 -0
  158. package/dist/esm/version.d.mts +1 -1
  159. package/dist/esm/version.mjs +1 -1
  160. package/package.json +3 -3
  161. package/reference.md +512 -0
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,2 @@
1
+ export * from "./client/index.js";
2
+ export * from "./types/index.js";
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./client/index.js"), exports);
18
+ __exportStar(require("./types/index.js"), exports);
@@ -0,0 +1,6 @@
1
+ export declare const ListCheckoutsRequestStatus: {
2
+ readonly Active: "active";
3
+ readonly Completed: "completed";
4
+ readonly Archived: "archived";
5
+ };
6
+ export type ListCheckoutsRequestStatus = (typeof ListCheckoutsRequestStatus)[keyof typeof ListCheckoutsRequestStatus];
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.ListCheckoutsRequestStatus = void 0;
5
+ exports.ListCheckoutsRequestStatus = {
6
+ Active: "active",
7
+ Completed: "completed",
8
+ Archived: "archived",
9
+ };
@@ -0,0 +1 @@
1
+ export * from "./ListCheckoutsRequestStatus.js";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ListCheckoutsRequestStatus.js"), exports);
@@ -0,0 +1,27 @@
1
+ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
2
+ import * as core from "../../../../core/index.js";
3
+ import * as Paid from "../../../index.js";
4
+ export declare namespace Credits {
5
+ interface Options extends BaseClientOptions {
6
+ }
7
+ interface RequestOptions extends BaseRequestOptions {
8
+ }
9
+ }
10
+ export declare class Credits {
11
+ protected readonly _options: Credits.Options;
12
+ constructor(_options: Credits.Options);
13
+ /**
14
+ * List credit currencies for the organization
15
+ *
16
+ * @param {Credits.RequestOptions} requestOptions - Request-specific configuration.
17
+ *
18
+ * @throws {@link Paid.ForbiddenError}
19
+ * @throws {@link Paid.InternalServerError}
20
+ *
21
+ * @example
22
+ * await client.credits.listCreditCurrencies()
23
+ */
24
+ listCreditCurrencies(requestOptions?: Credits.RequestOptions): core.HttpResponsePromise<Paid.CreditCurrencyListResponse>;
25
+ private __listCreditCurrencies;
26
+ protected _getAuthorizationHeader(): Promise<string>;
27
+ }
@@ -0,0 +1,123 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.Credits = void 0;
47
+ const headers_js_1 = require("../../../../core/headers.js");
48
+ const core = __importStar(require("../../../../core/index.js"));
49
+ const environments = __importStar(require("../../../../environments.js"));
50
+ const errors = __importStar(require("../../../../errors/index.js"));
51
+ const Paid = __importStar(require("../../../index.js"));
52
+ class Credits {
53
+ constructor(_options) {
54
+ this._options = _options;
55
+ }
56
+ /**
57
+ * List credit currencies for the organization
58
+ *
59
+ * @param {Credits.RequestOptions} requestOptions - Request-specific configuration.
60
+ *
61
+ * @throws {@link Paid.ForbiddenError}
62
+ * @throws {@link Paid.InternalServerError}
63
+ *
64
+ * @example
65
+ * await client.credits.listCreditCurrencies()
66
+ */
67
+ listCreditCurrencies(requestOptions) {
68
+ return core.HttpResponsePromise.fromPromise(this.__listCreditCurrencies(requestOptions));
69
+ }
70
+ __listCreditCurrencies(requestOptions) {
71
+ return __awaiter(this, void 0, void 0, function* () {
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);
74
+ const _response = yield core.fetcher({
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.Default, "credits/currencies"),
76
+ method: "GET",
77
+ headers: _headers,
78
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
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,
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,
81
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
82
+ });
83
+ if (_response.ok) {
84
+ return { data: _response.body, rawResponse: _response.rawResponse };
85
+ }
86
+ if (_response.error.reason === "status-code") {
87
+ switch (_response.error.statusCode) {
88
+ case 403:
89
+ throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
90
+ case 500:
91
+ throw new Paid.InternalServerError(_response.error.body, _response.rawResponse);
92
+ default:
93
+ throw new errors.PaidError({
94
+ statusCode: _response.error.statusCode,
95
+ body: _response.error.body,
96
+ rawResponse: _response.rawResponse,
97
+ });
98
+ }
99
+ }
100
+ switch (_response.error.reason) {
101
+ case "non-json":
102
+ throw new errors.PaidError({
103
+ statusCode: _response.error.statusCode,
104
+ body: _response.error.rawBody,
105
+ rawResponse: _response.rawResponse,
106
+ });
107
+ case "timeout":
108
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /credits/currencies.");
109
+ case "unknown":
110
+ throw new errors.PaidError({
111
+ message: _response.error.errorMessage,
112
+ rawResponse: _response.rawResponse,
113
+ });
114
+ }
115
+ });
116
+ }
117
+ _getAuthorizationHeader() {
118
+ return __awaiter(this, void 0, void 0, function* () {
119
+ return `Bearer ${yield core.Supplier.get(this._options.token)}`;
120
+ });
121
+ }
122
+ }
123
+ exports.Credits = Credits;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from "./client/index.js";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./client/index.js"), exports);
@@ -0,0 +1,30 @@
1
+ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.js";
2
+ import * as core from "../../../../core/index.js";
3
+ import * as Paid from "../../../index.js";
4
+ export declare namespace CustomerPortals {
5
+ interface Options extends BaseClientOptions {
6
+ }
7
+ interface RequestOptions extends BaseRequestOptions {
8
+ }
9
+ }
10
+ export declare class CustomerPortals {
11
+ protected readonly _options: CustomerPortals.Options;
12
+ constructor(_options: CustomerPortals.Options);
13
+ /**
14
+ * Creates a portal session for the customer. Returns a short-lived URL to the customer portal.
15
+ *
16
+ * @param {Paid.CreateCustomerPortalRequest} request
17
+ * @param {CustomerPortals.RequestOptions} requestOptions - Request-specific configuration.
18
+ *
19
+ * @throws {@link Paid.BadRequestError}
20
+ * @throws {@link Paid.ForbiddenError}
21
+ * @throws {@link Paid.NotFoundError}
22
+ * @throws {@link Paid.InternalServerError}
23
+ *
24
+ * @example
25
+ * await client.customerPortals.createCustomerPortal()
26
+ */
27
+ createCustomerPortal(request?: Paid.CreateCustomerPortalRequest, requestOptions?: CustomerPortals.RequestOptions): core.HttpResponsePromise<Paid.CustomerPortal>;
28
+ private __createCustomerPortal;
29
+ protected _getAuthorizationHeader(): Promise<string>;
30
+ }
@@ -0,0 +1,133 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
37
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
38
+ return new (P || (P = Promise))(function (resolve, reject) {
39
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
40
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
41
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
42
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
43
+ });
44
+ };
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.CustomerPortals = void 0;
47
+ const headers_js_1 = require("../../../../core/headers.js");
48
+ const core = __importStar(require("../../../../core/index.js"));
49
+ const environments = __importStar(require("../../../../environments.js"));
50
+ const errors = __importStar(require("../../../../errors/index.js"));
51
+ const Paid = __importStar(require("../../../index.js"));
52
+ class CustomerPortals {
53
+ constructor(_options) {
54
+ this._options = _options;
55
+ }
56
+ /**
57
+ * Creates a portal session for the customer. Returns a short-lived URL to the customer portal.
58
+ *
59
+ * @param {Paid.CreateCustomerPortalRequest} request
60
+ * @param {CustomerPortals.RequestOptions} requestOptions - Request-specific configuration.
61
+ *
62
+ * @throws {@link Paid.BadRequestError}
63
+ * @throws {@link Paid.ForbiddenError}
64
+ * @throws {@link Paid.NotFoundError}
65
+ * @throws {@link Paid.InternalServerError}
66
+ *
67
+ * @example
68
+ * await client.customerPortals.createCustomerPortal()
69
+ */
70
+ createCustomerPortal(request = {}, requestOptions) {
71
+ return core.HttpResponsePromise.fromPromise(this.__createCustomerPortal(request, requestOptions));
72
+ }
73
+ __createCustomerPortal() {
74
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
75
+ var _a, _b, _c, _d, _e, _f, _g, _h;
76
+ 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);
77
+ const _response = yield core.fetcher({
78
+ 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.Default, "customer-portals/"),
79
+ method: "POST",
80
+ headers: _headers,
81
+ contentType: "application/json",
82
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
83
+ requestType: "json",
84
+ body: request,
85
+ 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,
86
+ 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,
87
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
88
+ });
89
+ if (_response.ok) {
90
+ return { data: _response.body, rawResponse: _response.rawResponse };
91
+ }
92
+ if (_response.error.reason === "status-code") {
93
+ switch (_response.error.statusCode) {
94
+ case 400:
95
+ throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
96
+ case 403:
97
+ throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
98
+ case 404:
99
+ throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
100
+ case 500:
101
+ throw new Paid.InternalServerError(_response.error.body, _response.rawResponse);
102
+ default:
103
+ throw new errors.PaidError({
104
+ statusCode: _response.error.statusCode,
105
+ body: _response.error.body,
106
+ rawResponse: _response.rawResponse,
107
+ });
108
+ }
109
+ }
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 /customer-portals/.");
119
+ case "unknown":
120
+ throw new errors.PaidError({
121
+ message: _response.error.errorMessage,
122
+ rawResponse: _response.rawResponse,
123
+ });
124
+ }
125
+ });
126
+ }
127
+ _getAuthorizationHeader() {
128
+ return __awaiter(this, void 0, void 0, function* () {
129
+ return `Bearer ${yield core.Supplier.get(this._options.token)}`;
130
+ });
131
+ }
132
+ }
133
+ exports.CustomerPortals = CustomerPortals;
@@ -0,0 +1 @@
1
+ export * from "./requests/index.js";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./requests/index.js"), exports);
@@ -0,0 +1,12 @@
1
+ /**
2
+ * @example
3
+ * {}
4
+ */
5
+ export interface CreateCustomerPortalRequest {
6
+ /** The Paid customer ID (display ID or UUID). Either this or externalCustomerId must be provided. */
7
+ customerId?: string;
8
+ /** Your external customer ID. Either this or customerId must be provided. */
9
+ externalCustomerId?: string;
10
+ returnUrl?: string;
11
+ expiresAt?: string;
12
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated by Fern from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export type { CreateCustomerPortalRequest } from "./CreateCustomerPortalRequest.js";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * from "./client/index.js";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./client/index.js"), exports);
@@ -148,5 +148,39 @@ export declare class Customers {
148
148
  */
149
149
  deleteCustomerByExternalId(request: Paid.DeleteCustomerByExternalIdRequest, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.EmptyResponse>;
150
150
  private __deleteCustomerByExternalId;
151
+ /**
152
+ * Get current customer credit balances grouped by currency
153
+ *
154
+ * @param {Paid.GetCustomerCreditBalancesRequest} request
155
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
156
+ *
157
+ * @throws {@link Paid.ForbiddenError}
158
+ * @throws {@link Paid.NotFoundError}
159
+ * @throws {@link Paid.InternalServerError}
160
+ *
161
+ * @example
162
+ * await client.customers.getCustomerCreditBalances({
163
+ * id: "id"
164
+ * })
165
+ */
166
+ getCustomerCreditBalances(request: Paid.GetCustomerCreditBalancesRequest, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.CreditBalanceListResponse>;
167
+ private __getCustomerCreditBalances;
168
+ /**
169
+ * Get current customer credit balances grouped by currency, looked up by external ID
170
+ *
171
+ * @param {Paid.GetCustomerCreditBalancesByExternalIdRequest} request
172
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
173
+ *
174
+ * @throws {@link Paid.ForbiddenError}
175
+ * @throws {@link Paid.NotFoundError}
176
+ * @throws {@link Paid.InternalServerError}
177
+ *
178
+ * @example
179
+ * await client.customers.getCustomerCreditBalancesByExternalId({
180
+ * externalId: "externalId"
181
+ * })
182
+ */
183
+ getCustomerCreditBalancesByExternalId(request: Paid.GetCustomerCreditBalancesByExternalIdRequest, requestOptions?: Customers.RequestOptions): core.HttpResponsePromise<Paid.CreditBalanceListResponse>;
184
+ private __getCustomerCreditBalancesByExternalId;
151
185
  protected _getAuthorizationHeader(): Promise<string>;
152
186
  }