@paid-ai/paid-node 1.1.0 → 1.2.1

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 (205) hide show
  1. package/README.md +2 -0
  2. package/dist/cjs/Client.d.ts +12 -0
  3. package/dist/cjs/Client.js +34 -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 +25 -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 +36 -0
  41. package/dist/cjs/api/resources/customers/client/Client.js +142 -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 +8 -0
  48. package/dist/cjs/api/resources/index.js +9 -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/resources/valueReceipts/client/Client.d.ts +75 -0
  52. package/dist/cjs/api/resources/valueReceipts/client/Client.js +347 -0
  53. package/dist/cjs/api/resources/valueReceipts/client/index.d.ts +1 -0
  54. package/dist/cjs/api/resources/valueReceipts/client/index.js +17 -0
  55. package/dist/cjs/api/resources/valueReceipts/client/requests/GetValueReceiptByIdRequest.d.ts +9 -0
  56. package/dist/cjs/api/resources/valueReceipts/client/requests/GetValueReceiptByIdRequest.js +3 -0
  57. package/dist/cjs/api/resources/valueReceipts/client/requests/ListValueReceiptsRequest.d.ts +10 -0
  58. package/dist/cjs/api/resources/valueReceipts/client/requests/ListValueReceiptsRequest.js +3 -0
  59. package/dist/cjs/api/resources/valueReceipts/client/requests/PublishValueReceiptBody.d.ts +10 -0
  60. package/dist/cjs/api/resources/valueReceipts/client/requests/PublishValueReceiptBody.js +3 -0
  61. package/dist/cjs/api/resources/valueReceipts/client/requests/UnpublishValueReceiptRequest.d.ts +9 -0
  62. package/dist/cjs/api/resources/valueReceipts/client/requests/UnpublishValueReceiptRequest.js +3 -0
  63. package/dist/cjs/api/resources/valueReceipts/client/requests/index.d.ts +4 -0
  64. package/dist/cjs/api/resources/valueReceipts/client/requests/index.js +2 -0
  65. package/dist/cjs/api/resources/valueReceipts/index.d.ts +1 -0
  66. package/dist/cjs/api/resources/valueReceipts/index.js +17 -0
  67. package/dist/cjs/api/types/Checkout.d.ts +19 -0
  68. package/dist/cjs/api/types/Checkout.js +3 -0
  69. package/dist/cjs/api/types/CheckoutListResponse.d.ts +5 -0
  70. package/dist/cjs/api/types/CheckoutListResponse.js +3 -0
  71. package/dist/cjs/api/types/CheckoutProduct.d.ts +3 -0
  72. package/dist/cjs/api/types/CheckoutProduct.js +3 -0
  73. package/dist/cjs/api/types/CheckoutProductInput.d.ts +3 -0
  74. package/dist/cjs/api/types/CheckoutProductInput.js +3 -0
  75. package/dist/cjs/api/types/CheckoutStatus.d.ts +7 -0
  76. package/dist/cjs/api/types/CheckoutStatus.js +10 -0
  77. package/dist/cjs/api/types/CreateOrderLineAttributeRequest.d.ts +116 -1
  78. package/dist/cjs/api/types/CreateOrderLineAttributeRequest.js +70 -0
  79. package/dist/cjs/api/types/CreateOrderLineRequest.d.ts +3 -3
  80. package/dist/cjs/api/types/CreditBalance.d.ts +19 -0
  81. package/dist/cjs/api/types/CreditBalance.js +11 -0
  82. package/dist/cjs/api/types/CreditBalanceListResponse.d.ts +4 -0
  83. package/dist/cjs/api/types/CreditBalanceListResponse.js +3 -0
  84. package/dist/cjs/api/types/CreditCurrency.d.ts +9 -0
  85. package/dist/cjs/api/types/CreditCurrency.js +3 -0
  86. package/dist/cjs/api/types/CreditCurrencyListResponse.d.ts +4 -0
  87. package/dist/cjs/api/types/CreditCurrencyListResponse.js +3 -0
  88. package/dist/cjs/api/types/CustomerPortal.d.ts +10 -0
  89. package/dist/cjs/api/types/CustomerPortal.js +3 -0
  90. package/dist/cjs/api/types/CustomerPortalStatus.d.ts +5 -0
  91. package/dist/cjs/api/types/CustomerPortalStatus.js +8 -0
  92. package/dist/cjs/api/types/Order.d.ts +3 -0
  93. package/dist/cjs/api/types/ValueReceiptDetail.d.ts +19 -0
  94. package/dist/cjs/api/types/ValueReceiptDetail.js +3 -0
  95. package/dist/cjs/api/types/ValueReceiptListResponse.d.ts +5 -0
  96. package/dist/cjs/api/types/ValueReceiptListResponse.js +3 -0
  97. package/dist/cjs/api/types/ValueReceiptSummary.d.ts +16 -0
  98. package/dist/cjs/api/types/ValueReceiptSummary.js +3 -0
  99. package/dist/cjs/api/types/index.d.ts +14 -0
  100. package/dist/cjs/api/types/index.js +14 -0
  101. package/dist/cjs/version.d.ts +1 -1
  102. package/dist/cjs/version.js +1 -1
  103. package/dist/esm/Client.d.mts +12 -0
  104. package/dist/esm/Client.mjs +22 -2
  105. package/dist/esm/api/resources/checkouts/client/Client.d.mts +84 -0
  106. package/dist/esm/api/resources/checkouts/client/Client.mjs +313 -0
  107. package/dist/esm/api/resources/checkouts/client/index.d.mts +1 -0
  108. package/dist/esm/api/resources/checkouts/client/index.mjs +1 -0
  109. package/dist/esm/api/resources/checkouts/client/requests/ArchiveCheckoutRequest.d.mts +9 -0
  110. package/dist/esm/api/resources/checkouts/client/requests/ArchiveCheckoutRequest.mjs +2 -0
  111. package/dist/esm/api/resources/checkouts/client/requests/CreateCheckoutRequest.d.mts +25 -0
  112. package/dist/esm/api/resources/checkouts/client/requests/CreateCheckoutRequest.mjs +2 -0
  113. package/dist/esm/api/resources/checkouts/client/requests/GetCheckoutRequest.d.mts +9 -0
  114. package/dist/esm/api/resources/checkouts/client/requests/GetCheckoutRequest.mjs +2 -0
  115. package/dist/esm/api/resources/checkouts/client/requests/ListCheckoutsRequest.d.mts +10 -0
  116. package/dist/esm/api/resources/checkouts/client/requests/ListCheckoutsRequest.mjs +2 -0
  117. package/dist/esm/api/resources/checkouts/client/requests/index.d.mts +4 -0
  118. package/dist/esm/api/resources/checkouts/client/requests/index.mjs +1 -0
  119. package/dist/esm/api/resources/checkouts/index.d.mts +2 -0
  120. package/dist/esm/api/resources/checkouts/index.mjs +2 -0
  121. package/dist/esm/api/resources/checkouts/types/ListCheckoutsRequestStatus.d.mts +6 -0
  122. package/dist/esm/api/resources/checkouts/types/ListCheckoutsRequestStatus.mjs +6 -0
  123. package/dist/esm/api/resources/checkouts/types/index.d.mts +1 -0
  124. package/dist/esm/api/resources/checkouts/types/index.mjs +1 -0
  125. package/dist/esm/api/resources/credits/client/Client.d.mts +27 -0
  126. package/dist/esm/api/resources/credits/client/Client.mjs +86 -0
  127. package/dist/esm/api/resources/credits/client/index.d.mts +1 -0
  128. package/dist/esm/api/resources/credits/client/index.mjs +1 -0
  129. package/dist/esm/api/resources/credits/index.d.mts +1 -0
  130. package/dist/esm/api/resources/credits/index.mjs +1 -0
  131. package/dist/esm/api/resources/customerPortals/client/Client.d.mts +30 -0
  132. package/dist/esm/api/resources/customerPortals/client/Client.mjs +96 -0
  133. package/dist/esm/api/resources/customerPortals/client/index.d.mts +1 -0
  134. package/dist/esm/api/resources/customerPortals/client/index.mjs +1 -0
  135. package/dist/esm/api/resources/customerPortals/client/requests/CreateCustomerPortalRequest.d.mts +12 -0
  136. package/dist/esm/api/resources/customerPortals/client/requests/CreateCustomerPortalRequest.mjs +2 -0
  137. package/dist/esm/api/resources/customerPortals/client/requests/index.d.mts +1 -0
  138. package/dist/esm/api/resources/customerPortals/client/requests/index.mjs +1 -0
  139. package/dist/esm/api/resources/customerPortals/index.d.mts +1 -0
  140. package/dist/esm/api/resources/customerPortals/index.mjs +1 -0
  141. package/dist/esm/api/resources/customers/client/Client.d.mts +36 -0
  142. package/dist/esm/api/resources/customers/client/Client.mjs +142 -0
  143. package/dist/esm/api/resources/customers/client/requests/GetCustomerCreditBalancesByExternalIdRequest.d.mts +9 -0
  144. package/dist/esm/api/resources/customers/client/requests/GetCustomerCreditBalancesByExternalIdRequest.mjs +2 -0
  145. package/dist/esm/api/resources/customers/client/requests/GetCustomerCreditBalancesRequest.d.mts +9 -0
  146. package/dist/esm/api/resources/customers/client/requests/GetCustomerCreditBalancesRequest.mjs +2 -0
  147. package/dist/esm/api/resources/customers/client/requests/index.d.mts +2 -0
  148. package/dist/esm/api/resources/index.d.mts +8 -0
  149. package/dist/esm/api/resources/index.mjs +8 -0
  150. package/dist/esm/api/resources/orders/client/requests/CreateOrderRequest.d.mts +11 -7
  151. package/dist/esm/api/resources/orders/client/requests/UpdateOrderRequest.d.mts +10 -7
  152. package/dist/esm/api/resources/valueReceipts/client/Client.d.mts +75 -0
  153. package/dist/esm/api/resources/valueReceipts/client/Client.mjs +310 -0
  154. package/dist/esm/api/resources/valueReceipts/client/index.d.mts +1 -0
  155. package/dist/esm/api/resources/valueReceipts/client/index.mjs +1 -0
  156. package/dist/esm/api/resources/valueReceipts/client/requests/GetValueReceiptByIdRequest.d.mts +9 -0
  157. package/dist/esm/api/resources/valueReceipts/client/requests/GetValueReceiptByIdRequest.mjs +2 -0
  158. package/dist/esm/api/resources/valueReceipts/client/requests/ListValueReceiptsRequest.d.mts +10 -0
  159. package/dist/esm/api/resources/valueReceipts/client/requests/ListValueReceiptsRequest.mjs +2 -0
  160. package/dist/esm/api/resources/valueReceipts/client/requests/PublishValueReceiptBody.d.mts +10 -0
  161. package/dist/esm/api/resources/valueReceipts/client/requests/PublishValueReceiptBody.mjs +2 -0
  162. package/dist/esm/api/resources/valueReceipts/client/requests/UnpublishValueReceiptRequest.d.mts +9 -0
  163. package/dist/esm/api/resources/valueReceipts/client/requests/UnpublishValueReceiptRequest.mjs +2 -0
  164. package/dist/esm/api/resources/valueReceipts/client/requests/index.d.mts +4 -0
  165. package/dist/esm/api/resources/valueReceipts/client/requests/index.mjs +1 -0
  166. package/dist/esm/api/resources/valueReceipts/index.d.mts +1 -0
  167. package/dist/esm/api/resources/valueReceipts/index.mjs +1 -0
  168. package/dist/esm/api/types/Checkout.d.mts +19 -0
  169. package/dist/esm/api/types/Checkout.mjs +2 -0
  170. package/dist/esm/api/types/CheckoutListResponse.d.mts +5 -0
  171. package/dist/esm/api/types/CheckoutListResponse.mjs +2 -0
  172. package/dist/esm/api/types/CheckoutProduct.d.mts +3 -0
  173. package/dist/esm/api/types/CheckoutProduct.mjs +2 -0
  174. package/dist/esm/api/types/CheckoutProductInput.d.mts +3 -0
  175. package/dist/esm/api/types/CheckoutProductInput.mjs +2 -0
  176. package/dist/esm/api/types/CheckoutStatus.d.mts +7 -0
  177. package/dist/esm/api/types/CheckoutStatus.mjs +7 -0
  178. package/dist/esm/api/types/CreateOrderLineAttributeRequest.d.mts +116 -1
  179. package/dist/esm/api/types/CreateOrderLineAttributeRequest.mjs +69 -1
  180. package/dist/esm/api/types/CreateOrderLineRequest.d.mts +3 -3
  181. package/dist/esm/api/types/CreditBalance.d.mts +19 -0
  182. package/dist/esm/api/types/CreditBalance.mjs +8 -0
  183. package/dist/esm/api/types/CreditBalanceListResponse.d.mts +4 -0
  184. package/dist/esm/api/types/CreditBalanceListResponse.mjs +2 -0
  185. package/dist/esm/api/types/CreditCurrency.d.mts +9 -0
  186. package/dist/esm/api/types/CreditCurrency.mjs +2 -0
  187. package/dist/esm/api/types/CreditCurrencyListResponse.d.mts +4 -0
  188. package/dist/esm/api/types/CreditCurrencyListResponse.mjs +2 -0
  189. package/dist/esm/api/types/CustomerPortal.d.mts +10 -0
  190. package/dist/esm/api/types/CustomerPortal.mjs +2 -0
  191. package/dist/esm/api/types/CustomerPortalStatus.d.mts +5 -0
  192. package/dist/esm/api/types/CustomerPortalStatus.mjs +5 -0
  193. package/dist/esm/api/types/Order.d.mts +3 -0
  194. package/dist/esm/api/types/ValueReceiptDetail.d.mts +19 -0
  195. package/dist/esm/api/types/ValueReceiptDetail.mjs +2 -0
  196. package/dist/esm/api/types/ValueReceiptListResponse.d.mts +5 -0
  197. package/dist/esm/api/types/ValueReceiptListResponse.mjs +2 -0
  198. package/dist/esm/api/types/ValueReceiptSummary.d.mts +16 -0
  199. package/dist/esm/api/types/ValueReceiptSummary.mjs +2 -0
  200. package/dist/esm/api/types/index.d.mts +14 -0
  201. package/dist/esm/api/types/index.mjs +14 -0
  202. package/dist/esm/version.d.mts +1 -1
  203. package/dist/esm/version.mjs +1 -1
  204. package/package.json +3 -3
  205. package/reference.md +771 -0
@@ -0,0 +1,313 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
12
+ import * as core from "../../../../core/index.mjs";
13
+ import * as environments from "../../../../environments.mjs";
14
+ import * as errors from "../../../../errors/index.mjs";
15
+ import * as Paid from "../../../index.mjs";
16
+ export class Checkouts {
17
+ constructor(_options) {
18
+ this._options = _options;
19
+ }
20
+ /**
21
+ * Get a list of checkouts for the organization
22
+ *
23
+ * @param {Paid.ListCheckoutsRequest} request
24
+ * @param {Checkouts.RequestOptions} requestOptions - Request-specific configuration.
25
+ *
26
+ * @throws {@link Paid.BadRequestError}
27
+ * @throws {@link Paid.ForbiddenError}
28
+ * @throws {@link Paid.InternalServerError}
29
+ *
30
+ * @example
31
+ * await client.checkouts.listCheckouts()
32
+ */
33
+ listCheckouts(request = {}, requestOptions) {
34
+ return core.HttpResponsePromise.fromPromise(this.__listCheckouts(request, requestOptions));
35
+ }
36
+ __listCheckouts() {
37
+ return __awaiter(this, arguments, void 0, function* (request = {}, requestOptions) {
38
+ var _a, _b, _c, _d, _e, _f, _g, _h;
39
+ const { limit, offset, status } = request;
40
+ const _queryParams = {};
41
+ if (limit != null) {
42
+ _queryParams.limit = limit.toString();
43
+ }
44
+ if (offset != null) {
45
+ _queryParams.offset = offset.toString();
46
+ }
47
+ if (status != null) {
48
+ _queryParams.status = status;
49
+ }
50
+ 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);
51
+ const _response = yield core.fetcher({
52
+ 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, "checkouts/"),
53
+ method: "GET",
54
+ headers: _headers,
55
+ queryParameters: Object.assign(Object.assign({}, _queryParams), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams),
56
+ 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,
57
+ 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,
58
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
59
+ });
60
+ if (_response.ok) {
61
+ return { data: _response.body, rawResponse: _response.rawResponse };
62
+ }
63
+ if (_response.error.reason === "status-code") {
64
+ switch (_response.error.statusCode) {
65
+ case 400:
66
+ throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
67
+ case 403:
68
+ throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
69
+ case 500:
70
+ throw new Paid.InternalServerError(_response.error.body, _response.rawResponse);
71
+ default:
72
+ throw new errors.PaidError({
73
+ statusCode: _response.error.statusCode,
74
+ body: _response.error.body,
75
+ rawResponse: _response.rawResponse,
76
+ });
77
+ }
78
+ }
79
+ switch (_response.error.reason) {
80
+ case "non-json":
81
+ throw new errors.PaidError({
82
+ statusCode: _response.error.statusCode,
83
+ body: _response.error.rawBody,
84
+ rawResponse: _response.rawResponse,
85
+ });
86
+ case "timeout":
87
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /checkouts/.");
88
+ case "unknown":
89
+ throw new errors.PaidError({
90
+ message: _response.error.errorMessage,
91
+ rawResponse: _response.rawResponse,
92
+ });
93
+ }
94
+ });
95
+ }
96
+ /**
97
+ * Creates a checkout link that generates a URL for a customer to complete a purchase
98
+ *
99
+ * @param {Paid.CreateCheckoutRequest} request
100
+ * @param {Checkouts.RequestOptions} requestOptions - Request-specific configuration.
101
+ *
102
+ * @throws {@link Paid.BadRequestError}
103
+ * @throws {@link Paid.ForbiddenError}
104
+ * @throws {@link Paid.NotFoundError}
105
+ * @throws {@link Paid.InternalServerError}
106
+ *
107
+ * @example
108
+ * await client.checkouts.createCheckout({
109
+ * products: [{
110
+ * id: "id"
111
+ * }],
112
+ * successUrl: "successUrl"
113
+ * })
114
+ */
115
+ createCheckout(request, requestOptions) {
116
+ return core.HttpResponsePromise.fromPromise(this.__createCheckout(request, requestOptions));
117
+ }
118
+ __createCheckout(request, requestOptions) {
119
+ return __awaiter(this, void 0, void 0, function* () {
120
+ var _a, _b, _c, _d, _e, _f, _g, _h;
121
+ 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);
122
+ const _response = yield core.fetcher({
123
+ 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, "checkouts/"),
124
+ method: "POST",
125
+ headers: _headers,
126
+ contentType: "application/json",
127
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
128
+ requestType: "json",
129
+ body: request,
130
+ 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,
131
+ 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,
132
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
133
+ });
134
+ if (_response.ok) {
135
+ return { data: _response.body, rawResponse: _response.rawResponse };
136
+ }
137
+ if (_response.error.reason === "status-code") {
138
+ switch (_response.error.statusCode) {
139
+ case 400:
140
+ throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
141
+ case 403:
142
+ throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
143
+ case 404:
144
+ throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
145
+ case 500:
146
+ throw new Paid.InternalServerError(_response.error.body, _response.rawResponse);
147
+ default:
148
+ throw new errors.PaidError({
149
+ statusCode: _response.error.statusCode,
150
+ body: _response.error.body,
151
+ rawResponse: _response.rawResponse,
152
+ });
153
+ }
154
+ }
155
+ switch (_response.error.reason) {
156
+ case "non-json":
157
+ throw new errors.PaidError({
158
+ statusCode: _response.error.statusCode,
159
+ body: _response.error.rawBody,
160
+ rawResponse: _response.rawResponse,
161
+ });
162
+ case "timeout":
163
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling POST /checkouts/.");
164
+ case "unknown":
165
+ throw new errors.PaidError({
166
+ message: _response.error.errorMessage,
167
+ rawResponse: _response.rawResponse,
168
+ });
169
+ }
170
+ });
171
+ }
172
+ /**
173
+ * Get a checkout by ID
174
+ *
175
+ * @param {Paid.GetCheckoutRequest} request
176
+ * @param {Checkouts.RequestOptions} requestOptions - Request-specific configuration.
177
+ *
178
+ * @throws {@link Paid.ForbiddenError}
179
+ * @throws {@link Paid.NotFoundError}
180
+ * @throws {@link Paid.InternalServerError}
181
+ *
182
+ * @example
183
+ * await client.checkouts.getCheckout({
184
+ * id: "id"
185
+ * })
186
+ */
187
+ getCheckout(request, requestOptions) {
188
+ return core.HttpResponsePromise.fromPromise(this.__getCheckout(request, requestOptions));
189
+ }
190
+ __getCheckout(request, requestOptions) {
191
+ return __awaiter(this, void 0, void 0, function* () {
192
+ var _a, _b, _c, _d, _e, _f, _g, _h;
193
+ const { id } = request;
194
+ 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
+ const _response = yield core.fetcher({
196
+ 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, `checkouts/${core.url.encodePathParam(id)}`),
197
+ method: "GET",
198
+ headers: _headers,
199
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
200
+ 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
+ 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
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
203
+ });
204
+ if (_response.ok) {
205
+ return { data: _response.body, rawResponse: _response.rawResponse };
206
+ }
207
+ if (_response.error.reason === "status-code") {
208
+ switch (_response.error.statusCode) {
209
+ case 403:
210
+ throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
211
+ case 404:
212
+ throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
213
+ case 500:
214
+ throw new Paid.InternalServerError(_response.error.body, _response.rawResponse);
215
+ default:
216
+ throw new errors.PaidError({
217
+ statusCode: _response.error.statusCode,
218
+ body: _response.error.body,
219
+ rawResponse: _response.rawResponse,
220
+ });
221
+ }
222
+ }
223
+ switch (_response.error.reason) {
224
+ case "non-json":
225
+ throw new errors.PaidError({
226
+ statusCode: _response.error.statusCode,
227
+ body: _response.error.rawBody,
228
+ rawResponse: _response.rawResponse,
229
+ });
230
+ case "timeout":
231
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /checkouts/{id}.");
232
+ case "unknown":
233
+ throw new errors.PaidError({
234
+ message: _response.error.errorMessage,
235
+ rawResponse: _response.rawResponse,
236
+ });
237
+ }
238
+ });
239
+ }
240
+ /**
241
+ * Archive a checkout by ID
242
+ *
243
+ * @param {Paid.ArchiveCheckoutRequest} request
244
+ * @param {Checkouts.RequestOptions} requestOptions - Request-specific configuration.
245
+ *
246
+ * @throws {@link Paid.ForbiddenError}
247
+ * @throws {@link Paid.NotFoundError}
248
+ * @throws {@link Paid.InternalServerError}
249
+ *
250
+ * @example
251
+ * await client.checkouts.archiveCheckout({
252
+ * id: "id"
253
+ * })
254
+ */
255
+ archiveCheckout(request, requestOptions) {
256
+ return core.HttpResponsePromise.fromPromise(this.__archiveCheckout(request, requestOptions));
257
+ }
258
+ __archiveCheckout(request, requestOptions) {
259
+ return __awaiter(this, void 0, void 0, function* () {
260
+ var _a, _b, _c, _d, _e, _f, _g, _h;
261
+ const { id } = request;
262
+ 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);
263
+ const _response = yield core.fetcher({
264
+ url: core.url.join((_c = (_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.PaidEnvironment.Default, `checkouts/${core.url.encodePathParam(id)}`),
265
+ method: "DELETE",
266
+ headers: _headers,
267
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
268
+ 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,
269
+ 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,
270
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
271
+ });
272
+ if (_response.ok) {
273
+ return { data: _response.body, rawResponse: _response.rawResponse };
274
+ }
275
+ if (_response.error.reason === "status-code") {
276
+ switch (_response.error.statusCode) {
277
+ case 403:
278
+ throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
279
+ case 404:
280
+ throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
281
+ case 500:
282
+ throw new Paid.InternalServerError(_response.error.body, _response.rawResponse);
283
+ default:
284
+ throw new errors.PaidError({
285
+ statusCode: _response.error.statusCode,
286
+ body: _response.error.body,
287
+ rawResponse: _response.rawResponse,
288
+ });
289
+ }
290
+ }
291
+ switch (_response.error.reason) {
292
+ case "non-json":
293
+ throw new errors.PaidError({
294
+ statusCode: _response.error.statusCode,
295
+ body: _response.error.rawBody,
296
+ rawResponse: _response.rawResponse,
297
+ });
298
+ case "timeout":
299
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling DELETE /checkouts/{id}.");
300
+ case "unknown":
301
+ throw new errors.PaidError({
302
+ message: _response.error.errorMessage,
303
+ rawResponse: _response.rawResponse,
304
+ });
305
+ }
306
+ });
307
+ }
308
+ _getAuthorizationHeader() {
309
+ return __awaiter(this, void 0, void 0, function* () {
310
+ return `Bearer ${yield core.Supplier.get(this._options.token)}`;
311
+ });
312
+ }
313
+ }
@@ -0,0 +1 @@
1
+ export * from "./requests/index.mjs";
@@ -0,0 +1 @@
1
+ export * from "./requests/index.mjs";
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * id: "id"
5
+ * }
6
+ */
7
+ export interface ArchiveCheckoutRequest {
8
+ id: string;
9
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,25 @@
1
+ import type * as Paid from "../../../../index.mjs";
2
+ /**
3
+ * @example
4
+ * {
5
+ * products: [{
6
+ * id: "id"
7
+ * }],
8
+ * successUrl: "successUrl"
9
+ * }
10
+ */
11
+ export interface CreateCheckoutRequest {
12
+ products: Paid.CheckoutProductInput[];
13
+ customerId?: string;
14
+ /** External customer identifier. Creates the customer on first use, resolves to the existing customer on subsequent uses. */
15
+ externalCustomerId?: string;
16
+ successUrl: string;
17
+ cancelUrl?: string;
18
+ expiresAt?: string;
19
+ metadata?: Record<string, unknown>;
20
+ collectAddress?: boolean;
21
+ collectPhone?: boolean;
22
+ singleUse?: boolean;
23
+ /** Lock checkout to a specific currency. Omit to allow all currencies supported by the selected plans. */
24
+ currency?: string;
25
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * id: "id"
5
+ * }
6
+ */
7
+ export interface GetCheckoutRequest {
8
+ id: string;
9
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,10 @@
1
+ import type * as Paid from "../../../../index.mjs";
2
+ /**
3
+ * @example
4
+ * {}
5
+ */
6
+ export interface ListCheckoutsRequest {
7
+ limit?: number;
8
+ offset?: number;
9
+ status?: Paid.ListCheckoutsRequestStatus;
10
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export {};
@@ -0,0 +1,4 @@
1
+ export type { ArchiveCheckoutRequest } from "./ArchiveCheckoutRequest.mjs";
2
+ export type { CreateCheckoutRequest } from "./CreateCheckoutRequest.mjs";
3
+ export type { GetCheckoutRequest } from "./GetCheckoutRequest.mjs";
4
+ export type { ListCheckoutsRequest } from "./ListCheckoutsRequest.mjs";
@@ -0,0 +1,2 @@
1
+ export * from "./client/index.mjs";
2
+ export * from "./types/index.mjs";
@@ -0,0 +1,2 @@
1
+ export * from "./client/index.mjs";
2
+ export * from "./types/index.mjs";
@@ -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,6 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ export const ListCheckoutsRequestStatus = {
3
+ Active: "active",
4
+ Completed: "completed",
5
+ Archived: "archived",
6
+ };
@@ -0,0 +1 @@
1
+ export * from "./ListCheckoutsRequestStatus.mjs";
@@ -0,0 +1 @@
1
+ export * from "./ListCheckoutsRequestStatus.mjs";
@@ -0,0 +1,27 @@
1
+ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
2
+ import * as core from "../../../../core/index.mjs";
3
+ import * as Paid from "../../../index.mjs";
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,86 @@
1
+ // This file was auto-generated by Fern from our API Definition.
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ import { mergeHeaders, mergeOnlyDefinedHeaders } from "../../../../core/headers.mjs";
12
+ import * as core from "../../../../core/index.mjs";
13
+ import * as environments from "../../../../environments.mjs";
14
+ import * as errors from "../../../../errors/index.mjs";
15
+ import * as Paid from "../../../index.mjs";
16
+ export class Credits {
17
+ constructor(_options) {
18
+ this._options = _options;
19
+ }
20
+ /**
21
+ * List credit currencies for the organization
22
+ *
23
+ * @param {Credits.RequestOptions} requestOptions - Request-specific configuration.
24
+ *
25
+ * @throws {@link Paid.ForbiddenError}
26
+ * @throws {@link Paid.InternalServerError}
27
+ *
28
+ * @example
29
+ * await client.credits.listCreditCurrencies()
30
+ */
31
+ listCreditCurrencies(requestOptions) {
32
+ return core.HttpResponsePromise.fromPromise(this.__listCreditCurrencies(requestOptions));
33
+ }
34
+ __listCreditCurrencies(requestOptions) {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ var _a, _b, _c, _d, _e, _f, _g, _h;
37
+ 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);
38
+ const _response = yield core.fetcher({
39
+ 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"),
40
+ method: "GET",
41
+ headers: _headers,
42
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
43
+ 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,
44
+ 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,
45
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
46
+ });
47
+ if (_response.ok) {
48
+ return { data: _response.body, rawResponse: _response.rawResponse };
49
+ }
50
+ if (_response.error.reason === "status-code") {
51
+ switch (_response.error.statusCode) {
52
+ case 403:
53
+ throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
54
+ case 500:
55
+ throw new Paid.InternalServerError(_response.error.body, _response.rawResponse);
56
+ default:
57
+ throw new errors.PaidError({
58
+ statusCode: _response.error.statusCode,
59
+ body: _response.error.body,
60
+ rawResponse: _response.rawResponse,
61
+ });
62
+ }
63
+ }
64
+ switch (_response.error.reason) {
65
+ case "non-json":
66
+ throw new errors.PaidError({
67
+ statusCode: _response.error.statusCode,
68
+ body: _response.error.rawBody,
69
+ rawResponse: _response.rawResponse,
70
+ });
71
+ case "timeout":
72
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /credits/currencies.");
73
+ case "unknown":
74
+ throw new errors.PaidError({
75
+ message: _response.error.errorMessage,
76
+ rawResponse: _response.rawResponse,
77
+ });
78
+ }
79
+ });
80
+ }
81
+ _getAuthorizationHeader() {
82
+ return __awaiter(this, void 0, void 0, function* () {
83
+ return `Bearer ${yield core.Supplier.get(this._options.token)}`;
84
+ });
85
+ }
86
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./client/index.mjs";
@@ -0,0 +1 @@
1
+ export * from "./client/index.mjs";
@@ -0,0 +1,30 @@
1
+ import type { BaseClientOptions, BaseRequestOptions } from "../../../../BaseClient.mjs";
2
+ import * as core from "../../../../core/index.mjs";
3
+ import * as Paid from "../../../index.mjs";
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
+ }