@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
@@ -345,6 +345,7 @@ class Customers {
345
345
  * @param {Paid.DeleteCustomerByIdRequest} request
346
346
  * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
347
347
  *
348
+ * @throws {@link Paid.BadRequestError}
348
349
  * @throws {@link Paid.ForbiddenError}
349
350
  * @throws {@link Paid.NotFoundError}
350
351
  * @throws {@link Paid.InternalServerError}
@@ -376,6 +377,8 @@ class Customers {
376
377
  }
377
378
  if (_response.error.reason === "status-code") {
378
379
  switch (_response.error.statusCode) {
380
+ case 400:
381
+ throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
379
382
  case 403:
380
383
  throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
381
384
  case 404:
@@ -556,6 +559,7 @@ class Customers {
556
559
  * @param {Paid.DeleteCustomerByExternalIdRequest} request
557
560
  * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
558
561
  *
562
+ * @throws {@link Paid.BadRequestError}
559
563
  * @throws {@link Paid.ForbiddenError}
560
564
  * @throws {@link Paid.NotFoundError}
561
565
  * @throws {@link Paid.InternalServerError}
@@ -587,6 +591,8 @@ class Customers {
587
591
  }
588
592
  if (_response.error.reason === "status-code") {
589
593
  switch (_response.error.statusCode) {
594
+ case 400:
595
+ throw new Paid.BadRequestError(_response.error.body, _response.rawResponse);
590
596
  case 403:
591
597
  throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
592
598
  case 404:
@@ -618,6 +624,142 @@ class Customers {
618
624
  }
619
625
  });
620
626
  }
627
+ /**
628
+ * Get current customer credit balances grouped by currency
629
+ *
630
+ * @param {Paid.GetCustomerCreditBalancesRequest} request
631
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
632
+ *
633
+ * @throws {@link Paid.ForbiddenError}
634
+ * @throws {@link Paid.NotFoundError}
635
+ * @throws {@link Paid.InternalServerError}
636
+ *
637
+ * @example
638
+ * await client.customers.getCustomerCreditBalances({
639
+ * id: "id"
640
+ * })
641
+ */
642
+ getCustomerCreditBalances(request, requestOptions) {
643
+ return core.HttpResponsePromise.fromPromise(this.__getCustomerCreditBalances(request, requestOptions));
644
+ }
645
+ __getCustomerCreditBalances(request, requestOptions) {
646
+ return __awaiter(this, void 0, void 0, function* () {
647
+ var _a, _b, _c, _d, _e, _f, _g, _h;
648
+ const { id } = request;
649
+ 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);
650
+ const _response = yield core.fetcher({
651
+ 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, `customers/${core.url.encodePathParam(id)}/credits/balances`),
652
+ method: "GET",
653
+ headers: _headers,
654
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
655
+ 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,
656
+ 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,
657
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
658
+ });
659
+ if (_response.ok) {
660
+ return { data: _response.body, rawResponse: _response.rawResponse };
661
+ }
662
+ if (_response.error.reason === "status-code") {
663
+ switch (_response.error.statusCode) {
664
+ case 403:
665
+ throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
666
+ case 404:
667
+ throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
668
+ case 500:
669
+ throw new Paid.InternalServerError(_response.error.body, _response.rawResponse);
670
+ default:
671
+ throw new errors.PaidError({
672
+ statusCode: _response.error.statusCode,
673
+ body: _response.error.body,
674
+ rawResponse: _response.rawResponse,
675
+ });
676
+ }
677
+ }
678
+ switch (_response.error.reason) {
679
+ case "non-json":
680
+ throw new errors.PaidError({
681
+ statusCode: _response.error.statusCode,
682
+ body: _response.error.rawBody,
683
+ rawResponse: _response.rawResponse,
684
+ });
685
+ case "timeout":
686
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /customers/{id}/credits/balances.");
687
+ case "unknown":
688
+ throw new errors.PaidError({
689
+ message: _response.error.errorMessage,
690
+ rawResponse: _response.rawResponse,
691
+ });
692
+ }
693
+ });
694
+ }
695
+ /**
696
+ * Get current customer credit balances grouped by currency, looked up by external ID
697
+ *
698
+ * @param {Paid.GetCustomerCreditBalancesByExternalIdRequest} request
699
+ * @param {Customers.RequestOptions} requestOptions - Request-specific configuration.
700
+ *
701
+ * @throws {@link Paid.ForbiddenError}
702
+ * @throws {@link Paid.NotFoundError}
703
+ * @throws {@link Paid.InternalServerError}
704
+ *
705
+ * @example
706
+ * await client.customers.getCustomerCreditBalancesByExternalId({
707
+ * externalId: "externalId"
708
+ * })
709
+ */
710
+ getCustomerCreditBalancesByExternalId(request, requestOptions) {
711
+ return core.HttpResponsePromise.fromPromise(this.__getCustomerCreditBalancesByExternalId(request, requestOptions));
712
+ }
713
+ __getCustomerCreditBalancesByExternalId(request, requestOptions) {
714
+ return __awaiter(this, void 0, void 0, function* () {
715
+ var _a, _b, _c, _d, _e, _f, _g, _h;
716
+ const { externalId } = request;
717
+ 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);
718
+ const _response = yield core.fetcher({
719
+ 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, `customers/external/${core.url.encodePathParam(externalId)}/credits/balances`),
720
+ method: "GET",
721
+ headers: _headers,
722
+ queryParameters: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.queryParams,
723
+ 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,
724
+ 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,
725
+ abortSignal: requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.abortSignal,
726
+ });
727
+ if (_response.ok) {
728
+ return { data: _response.body, rawResponse: _response.rawResponse };
729
+ }
730
+ if (_response.error.reason === "status-code") {
731
+ switch (_response.error.statusCode) {
732
+ case 403:
733
+ throw new Paid.ForbiddenError(_response.error.body, _response.rawResponse);
734
+ case 404:
735
+ throw new Paid.NotFoundError(_response.error.body, _response.rawResponse);
736
+ case 500:
737
+ throw new Paid.InternalServerError(_response.error.body, _response.rawResponse);
738
+ default:
739
+ throw new errors.PaidError({
740
+ statusCode: _response.error.statusCode,
741
+ body: _response.error.body,
742
+ rawResponse: _response.rawResponse,
743
+ });
744
+ }
745
+ }
746
+ switch (_response.error.reason) {
747
+ case "non-json":
748
+ throw new errors.PaidError({
749
+ statusCode: _response.error.statusCode,
750
+ body: _response.error.rawBody,
751
+ rawResponse: _response.rawResponse,
752
+ });
753
+ case "timeout":
754
+ throw new errors.PaidTimeoutError("Timeout exceeded when calling GET /customers/external/{externalId}/credits/balances.");
755
+ case "unknown":
756
+ throw new errors.PaidError({
757
+ message: _response.error.errorMessage,
758
+ rawResponse: _response.rawResponse,
759
+ });
760
+ }
761
+ });
762
+ }
621
763
  _getAuthorizationHeader() {
622
764
  return __awaiter(this, void 0, void 0, function* () {
623
765
  return `Bearer ${yield core.Supplier.get(this._options.token)}`;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * externalId: "externalId"
5
+ * }
6
+ */
7
+ export interface GetCustomerCreditBalancesByExternalIdRequest {
8
+ externalId: string;
9
+ }
@@ -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,9 @@
1
+ /**
2
+ * @example
3
+ * {
4
+ * id: "id"
5
+ * }
6
+ */
7
+ export interface GetCustomerCreditBalancesRequest {
8
+ id: string;
9
+ }
@@ -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 });
@@ -3,6 +3,8 @@ export type { DeleteCustomerByExternalIdRequest } from "./DeleteCustomerByExtern
3
3
  export type { DeleteCustomerByIdRequest } from "./DeleteCustomerByIdRequest.js";
4
4
  export type { GetCustomerByExternalIdRequest } from "./GetCustomerByExternalIdRequest.js";
5
5
  export type { GetCustomerByIdRequest } from "./GetCustomerByIdRequest.js";
6
+ export type { GetCustomerCreditBalancesByExternalIdRequest } from "./GetCustomerCreditBalancesByExternalIdRequest.js";
7
+ export type { GetCustomerCreditBalancesRequest } from "./GetCustomerCreditBalancesRequest.js";
6
8
  export type { ListCustomersRequest } from "./ListCustomersRequest.js";
7
9
  export type { UpdateCustomerByExternalIdRequest } from "./UpdateCustomerByExternalIdRequest.js";
8
10
  export type { UpdateCustomerByIdRequest } from "./UpdateCustomerByIdRequest.js";
@@ -1,5 +1,11 @@
1
+ export * from "./checkouts/client/requests/index.js";
2
+ export * as checkouts from "./checkouts/index.js";
3
+ export * from "./checkouts/types/index.js";
1
4
  export * from "./contacts/client/requests/index.js";
2
5
  export * as contacts from "./contacts/index.js";
6
+ export * as credits from "./credits/index.js";
7
+ export * from "./customerPortals/client/requests/index.js";
8
+ export * as customerPortals from "./customerPortals/index.js";
3
9
  export * from "./customers/client/requests/index.js";
4
10
  export * as customers from "./customers/index.js";
5
11
  export * from "./invoices/client/requests/index.js";
@@ -10,3 +16,5 @@ export * from "./products/client/requests/index.js";
10
16
  export * as products from "./products/index.js";
11
17
  export * from "./signals/client/requests/index.js";
12
18
  export * as signals from "./signals/index.js";
19
+ export * from "./valueReceipts/client/requests/index.js";
20
+ export * as valueReceipts from "./valueReceipts/index.js";
@@ -36,9 +36,15 @@ var __importStar = (this && this.__importStar) || (function () {
36
36
  };
37
37
  })();
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.signals = exports.products = exports.orders = exports.invoices = exports.customers = exports.contacts = void 0;
39
+ exports.valueReceipts = exports.signals = exports.products = exports.orders = exports.invoices = exports.customers = exports.customerPortals = exports.credits = exports.contacts = exports.checkouts = void 0;
40
+ __exportStar(require("./checkouts/client/requests/index.js"), exports);
41
+ exports.checkouts = __importStar(require("./checkouts/index.js"));
42
+ __exportStar(require("./checkouts/types/index.js"), exports);
40
43
  __exportStar(require("./contacts/client/requests/index.js"), exports);
41
44
  exports.contacts = __importStar(require("./contacts/index.js"));
45
+ exports.credits = __importStar(require("./credits/index.js"));
46
+ __exportStar(require("./customerPortals/client/requests/index.js"), exports);
47
+ exports.customerPortals = __importStar(require("./customerPortals/index.js"));
42
48
  __exportStar(require("./customers/client/requests/index.js"), exports);
43
49
  exports.customers = __importStar(require("./customers/index.js"));
44
50
  __exportStar(require("./invoices/client/requests/index.js"), exports);
@@ -49,3 +55,5 @@ __exportStar(require("./products/client/requests/index.js"), exports);
49
55
  exports.products = __importStar(require("./products/index.js"));
50
56
  __exportStar(require("./signals/client/requests/index.js"), exports);
51
57
  exports.signals = __importStar(require("./signals/index.js"));
58
+ __exportStar(require("./valueReceipts/client/requests/index.js"), exports);
59
+ exports.valueReceipts = __importStar(require("./valueReceipts/index.js"));
@@ -7,17 +7,21 @@ import type * as Paid from "../../../../index.js";
7
7
  */
8
8
  export interface CreateOrderRequest {
9
9
  customerId: string;
10
- billingCustomerId?: string | null;
10
+ billingCustomerId?: string;
11
11
  billingContactIds?: string[];
12
12
  name?: string;
13
13
  startDate?: string;
14
- endDate?: string | null;
15
- subscriptionTerms?: number | null;
14
+ endDate?: string;
15
+ subscriptionTerms?: number;
16
16
  creationState?: Paid.OrderCreationState;
17
17
  /** Day of month for billing anchor (1-31). Defaults to start date day if not provided. */
18
- billingAnchor?: number | null;
19
- paymentTerms?: string | null;
20
- externalId?: string | null;
21
- metadata?: Record<string, unknown> | null;
18
+ billingAnchor?: number;
19
+ paymentTerms?: string;
20
+ externalId?: string;
21
+ metadata?: Record<string, unknown>;
22
+ currency?: string;
23
+ autoPostInvoices?: boolean;
24
+ autoSendBillingEmails?: boolean;
25
+ autoSendPaymentEmails?: boolean;
22
26
  lines?: Paid.CreateOrderLineRequest[];
23
27
  }
@@ -9,14 +9,17 @@ export interface UpdateOrderRequest {
9
9
  id: string;
10
10
  name?: string;
11
11
  startDate?: string;
12
- endDate?: string | null;
13
- subscriptionTerms?: number | null;
12
+ endDate?: string;
13
+ subscriptionTerms?: number;
14
14
  creationState?: Paid.OrderCreationState;
15
15
  /** Day of month for billing anchor (1-31). Defaults to start date day if not provided. */
16
- billingAnchor?: number | null;
17
- paymentTerms?: string | null;
18
- externalId?: string | null;
19
- metadata?: Record<string, unknown> | null;
20
- billingCustomerId?: string | null;
16
+ billingAnchor?: number;
17
+ paymentTerms?: string;
18
+ externalId?: string;
19
+ metadata?: Record<string, unknown>;
20
+ billingCustomerId?: string;
21
21
  billingContactIds?: string[];
22
+ autoPostInvoices?: boolean;
23
+ autoSendBillingEmails?: boolean;
24
+ autoSendPaymentEmails?: boolean;
22
25
  }
@@ -0,0 +1,75 @@
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 ValueReceipts {
5
+ interface Options extends BaseClientOptions {
6
+ }
7
+ interface RequestOptions extends BaseRequestOptions {
8
+ }
9
+ }
10
+ export declare class ValueReceipts {
11
+ protected readonly _options: ValueReceipts.Options;
12
+ constructor(_options: ValueReceipts.Options);
13
+ /**
14
+ * List value receipts for the organization
15
+ *
16
+ * @param {Paid.ListValueReceiptsRequest} request
17
+ * @param {ValueReceipts.RequestOptions} requestOptions - Request-specific configuration.
18
+ *
19
+ * @throws {@link Paid.InternalServerError}
20
+ *
21
+ * @example
22
+ * await client.valueReceipts.listValueReceipts()
23
+ */
24
+ listValueReceipts(request?: Paid.ListValueReceiptsRequest, requestOptions?: ValueReceipts.RequestOptions): core.HttpResponsePromise<Paid.ValueReceiptListResponse>;
25
+ private __listValueReceipts;
26
+ /**
27
+ * Get a value receipt by ID, including its publish/share state.
28
+ *
29
+ * @param {Paid.GetValueReceiptByIdRequest} request
30
+ * @param {ValueReceipts.RequestOptions} requestOptions - Request-specific configuration.
31
+ *
32
+ * @throws {@link Paid.NotFoundError}
33
+ * @throws {@link Paid.InternalServerError}
34
+ *
35
+ * @example
36
+ * await client.valueReceipts.getValueReceiptById({
37
+ * id: "id"
38
+ * })
39
+ */
40
+ getValueReceiptById(request: Paid.GetValueReceiptByIdRequest, requestOptions?: ValueReceipts.RequestOptions): core.HttpResponsePromise<Paid.ValueReceiptDetail>;
41
+ private __getValueReceiptById;
42
+ /**
43
+ * Make a value receipt publicly accessible via URL.
44
+ *
45
+ * @param {Paid.PublishValueReceiptBody} request
46
+ * @param {ValueReceipts.RequestOptions} requestOptions - Request-specific configuration.
47
+ *
48
+ * @throws {@link Paid.NotFoundError}
49
+ * @throws {@link Paid.InternalServerError}
50
+ *
51
+ * @example
52
+ * await client.valueReceipts.publishValueReceipt({
53
+ * id: "id"
54
+ * })
55
+ */
56
+ publishValueReceipt(request: Paid.PublishValueReceiptBody, requestOptions?: ValueReceipts.RequestOptions): core.HttpResponsePromise<Paid.ValueReceiptDetail>;
57
+ private __publishValueReceipt;
58
+ /**
59
+ * Revoke public access to a value receipt.
60
+ *
61
+ * @param {Paid.UnpublishValueReceiptRequest} request
62
+ * @param {ValueReceipts.RequestOptions} requestOptions - Request-specific configuration.
63
+ *
64
+ * @throws {@link Paid.NotFoundError}
65
+ * @throws {@link Paid.InternalServerError}
66
+ *
67
+ * @example
68
+ * await client.valueReceipts.unpublishValueReceipt({
69
+ * id: "id"
70
+ * })
71
+ */
72
+ unpublishValueReceipt(request: Paid.UnpublishValueReceiptRequest, requestOptions?: ValueReceipts.RequestOptions): core.HttpResponsePromise<Paid.ValueReceiptDetail>;
73
+ private __unpublishValueReceipt;
74
+ protected _getAuthorizationHeader(): Promise<string>;
75
+ }