@leaflow/sdk 0.129.2 → 0.130.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 (156) hide show
  1. package/dist/billing/type/order/v1/generated/models.d.ts +241 -85
  2. package/dist/billing/type/order/v1/generated/models.js +19 -4
  3. package/dist/billing/type/order/v1/generated/validators/paymentResult.zod.d.ts +1 -0
  4. package/dist/billing/type/order/v1/generated/validators/refund.zod.d.ts +1 -0
  5. package/dist/billing/type/order/v1/generated/validators/refundList.zod.d.ts +1 -0
  6. package/dist/billing/type/order/v1/generated/validators/transaction.zod.d.ts +1 -0
  7. package/dist/billing/type/order/v1/generated/validators/transactionList.zod.d.ts +1 -0
  8. package/dist/billing/type/order/v1/generated/validators/transactionType.zod.d.ts +1 -0
  9. package/dist/billing/type/order/v1/generated/validators/transactionType.zod.js +1 -1
  10. package/dist/billing/type/order/v1/generated/validators/withdrawal.zod.d.ts +40 -0
  11. package/dist/billing/type/order/v1/generated/validators/withdrawal.zod.js +43 -0
  12. package/dist/billing/type/order/v1/generated/validators/withdrawalAllocation.zod.d.ts +19 -0
  13. package/dist/billing/type/order/v1/generated/validators/withdrawalAllocation.zod.js +17 -0
  14. package/dist/billing/type/order/v1/generated/validators/withdrawalCreate.zod.d.ts +25 -0
  15. package/dist/billing/type/order/v1/generated/validators/withdrawalCreate.zod.js +19 -0
  16. package/dist/billing/type/order/v1/generated/validators/withdrawalItem.zod.d.ts +46 -0
  17. package/dist/billing/type/order/v1/generated/validators/withdrawalItem.zod.js +37 -0
  18. package/dist/billing/type/order/v1/generated/validators/withdrawalItemList.zod.d.ts +48 -0
  19. package/dist/billing/type/order/v1/generated/validators/withdrawalItemList.zod.js +14 -0
  20. package/dist/billing/type/order/v1/generated/validators/withdrawalList.zod.d.ts +39 -0
  21. package/dist/billing/type/order/v1/generated/validators/withdrawalList.zod.js +14 -0
  22. package/dist/billing/type/order/v1/generated/validators/withdrawalPreview.zod.d.ts +40 -0
  23. package/dist/billing/type/order/v1/generated/validators/withdrawalPreview.zod.js +25 -0
  24. package/dist/billing/type/order/v1/generated/validators/withdrawalPreviewItem.zod.d.ts +28 -0
  25. package/dist/billing/type/order/v1/generated/validators/withdrawalPreviewItem.zod.js +19 -0
  26. package/dist/billing/type/order/v1/generated/validators/withdrawalPreviewRequest.zod.d.ts +15 -0
  27. package/dist/billing/type/order/v1/generated/validators/withdrawalPreviewRequest.zod.js +13 -0
  28. package/dist/billing/type/order/v1/generated/validators/withdrawalSource.zod.d.ts +23 -0
  29. package/dist/billing/type/order/v1/generated/validators/withdrawalSource.zod.js +23 -0
  30. package/dist/billing/v1/generated/functions.d.ts +106 -1
  31. package/dist/billing/v1/generated/functions.js +132 -0
  32. package/dist/billing/v1/generated/models.d.ts +194 -9
  33. package/dist/billing/v1/generated/models.js +15 -0
  34. package/dist/billing/v1/generated/schemas.zod.d.ts +59 -0
  35. package/dist/billing/v1/generated/schemas.zod.js +67 -0
  36. package/dist/billing/v1/generated/validators/listWithdrawalItemsParams.zod.d.ts +18 -0
  37. package/dist/billing/v1/generated/validators/listWithdrawalItemsParams.zod.js +24 -0
  38. package/dist/billing/v1/generated/validators/listWithdrawalsParams.zod.d.ts +19 -0
  39. package/dist/billing/v1/generated/validators/listWithdrawalsParams.zod.js +25 -0
  40. package/dist/billing/v1/generated/validators/paymentResult.zod.d.ts +1 -0
  41. package/dist/billing/v1/generated/validators/refund.zod.d.ts +1 -0
  42. package/dist/billing/v1/generated/validators/refundList.zod.d.ts +1 -0
  43. package/dist/billing/v1/generated/validators/transaction.zod.d.ts +1 -0
  44. package/dist/billing/v1/generated/validators/transactionList.zod.d.ts +1 -0
  45. package/dist/billing/v1/generated/validators/transactionType.zod.d.ts +1 -0
  46. package/dist/billing/v1/generated/validators/transactionType.zod.js +1 -1
  47. package/dist/billing/v1/generated/validators/withdrawal.zod.d.ts +40 -0
  48. package/dist/billing/v1/generated/validators/withdrawal.zod.js +43 -0
  49. package/dist/billing/v1/generated/validators/withdrawalAllocation.zod.d.ts +19 -0
  50. package/dist/billing/v1/generated/validators/withdrawalAllocation.zod.js +17 -0
  51. package/dist/billing/v1/generated/validators/withdrawalCreate.zod.d.ts +25 -0
  52. package/dist/billing/v1/generated/validators/withdrawalCreate.zod.js +19 -0
  53. package/dist/billing/v1/generated/validators/withdrawalItem.zod.d.ts +46 -0
  54. package/dist/billing/v1/generated/validators/withdrawalItem.zod.js +37 -0
  55. package/dist/billing/v1/generated/validators/withdrawalItemList.zod.d.ts +48 -0
  56. package/dist/billing/v1/generated/validators/withdrawalItemList.zod.js +14 -0
  57. package/dist/billing/v1/generated/validators/withdrawalList.zod.d.ts +39 -0
  58. package/dist/billing/v1/generated/validators/withdrawalList.zod.js +14 -0
  59. package/dist/billing/v1/generated/validators/withdrawalPreview.zod.d.ts +40 -0
  60. package/dist/billing/v1/generated/validators/withdrawalPreview.zod.js +25 -0
  61. package/dist/billing/v1/generated/validators/withdrawalPreviewItem.zod.d.ts +28 -0
  62. package/dist/billing/v1/generated/validators/withdrawalPreviewItem.zod.js +19 -0
  63. package/dist/billing/v1/generated/validators/withdrawalPreviewRequest.zod.d.ts +15 -0
  64. package/dist/billing/v1/generated/validators/withdrawalPreviewRequest.zod.js +13 -0
  65. package/dist/billing/v1/generated/validators/withdrawalSource.zod.d.ts +23 -0
  66. package/dist/billing/v1/generated/validators/withdrawalSource.zod.js +23 -0
  67. package/dist/canopy/v1/generated/models.d.ts +241 -85
  68. package/dist/canopy/v1/generated/models.js +19 -4
  69. package/dist/canopy/v1/generated/validators/paymentResult.zod.d.ts +1 -0
  70. package/dist/canopy/v1/generated/validators/refund.zod.d.ts +1 -0
  71. package/dist/canopy/v1/generated/validators/refundList.zod.d.ts +1 -0
  72. package/dist/canopy/v1/generated/validators/transaction.zod.d.ts +1 -0
  73. package/dist/canopy/v1/generated/validators/transactionList.zod.d.ts +1 -0
  74. package/dist/canopy/v1/generated/validators/transactionType.zod.d.ts +1 -0
  75. package/dist/canopy/v1/generated/validators/transactionType.zod.js +1 -1
  76. package/dist/canopy/v1/generated/validators/withdrawal.zod.d.ts +63 -0
  77. package/dist/canopy/v1/generated/validators/withdrawal.zod.js +66 -0
  78. package/dist/canopy/v1/generated/validators/withdrawalAllocation.zod.d.ts +42 -0
  79. package/dist/canopy/v1/generated/validators/withdrawalAllocation.zod.js +40 -0
  80. package/dist/canopy/v1/generated/validators/withdrawalCreate.zod.d.ts +48 -0
  81. package/dist/canopy/v1/generated/validators/withdrawalCreate.zod.js +42 -0
  82. package/dist/canopy/v1/generated/validators/withdrawalItem.zod.d.ts +69 -0
  83. package/dist/canopy/v1/generated/validators/withdrawalItem.zod.js +60 -0
  84. package/dist/canopy/v1/generated/validators/withdrawalItemList.zod.d.ts +71 -0
  85. package/dist/canopy/v1/generated/validators/withdrawalItemList.zod.js +37 -0
  86. package/dist/canopy/v1/generated/validators/withdrawalList.zod.d.ts +62 -0
  87. package/dist/canopy/v1/generated/validators/withdrawalList.zod.js +37 -0
  88. package/dist/canopy/v1/generated/validators/withdrawalPreview.zod.d.ts +63 -0
  89. package/dist/canopy/v1/generated/validators/withdrawalPreview.zod.js +48 -0
  90. package/dist/canopy/v1/generated/validators/withdrawalPreviewItem.zod.d.ts +51 -0
  91. package/dist/canopy/v1/generated/validators/withdrawalPreviewItem.zod.js +42 -0
  92. package/dist/canopy/v1/generated/validators/withdrawalPreviewRequest.zod.d.ts +38 -0
  93. package/dist/canopy/v1/generated/validators/withdrawalPreviewRequest.zod.js +36 -0
  94. package/dist/canopy/v1/generated/validators/withdrawalSource.zod.d.ts +46 -0
  95. package/dist/canopy/v1/generated/validators/withdrawalSource.zod.js +46 -0
  96. package/dist/compute/v1/generated/models.d.ts +241 -85
  97. package/dist/compute/v1/generated/models.js +19 -4
  98. package/dist/compute/v1/generated/validators/paymentResult.zod.d.ts +1 -0
  99. package/dist/compute/v1/generated/validators/refund.zod.d.ts +1 -0
  100. package/dist/compute/v1/generated/validators/refundList.zod.d.ts +1 -0
  101. package/dist/compute/v1/generated/validators/transaction.zod.d.ts +1 -0
  102. package/dist/compute/v1/generated/validators/transactionList.zod.d.ts +1 -0
  103. package/dist/compute/v1/generated/validators/transactionType.zod.d.ts +1 -0
  104. package/dist/compute/v1/generated/validators/transactionType.zod.js +1 -1
  105. package/dist/compute/v1/generated/validators/withdrawal.zod.d.ts +56 -0
  106. package/dist/compute/v1/generated/validators/withdrawal.zod.js +59 -0
  107. package/dist/compute/v1/generated/validators/withdrawalAllocation.zod.d.ts +35 -0
  108. package/dist/compute/v1/generated/validators/withdrawalAllocation.zod.js +33 -0
  109. package/dist/compute/v1/generated/validators/withdrawalCreate.zod.d.ts +41 -0
  110. package/dist/compute/v1/generated/validators/withdrawalCreate.zod.js +35 -0
  111. package/dist/compute/v1/generated/validators/withdrawalItem.zod.d.ts +62 -0
  112. package/dist/compute/v1/generated/validators/withdrawalItem.zod.js +53 -0
  113. package/dist/compute/v1/generated/validators/withdrawalItemList.zod.d.ts +64 -0
  114. package/dist/compute/v1/generated/validators/withdrawalItemList.zod.js +30 -0
  115. package/dist/compute/v1/generated/validators/withdrawalList.zod.d.ts +55 -0
  116. package/dist/compute/v1/generated/validators/withdrawalList.zod.js +30 -0
  117. package/dist/compute/v1/generated/validators/withdrawalPreview.zod.d.ts +56 -0
  118. package/dist/compute/v1/generated/validators/withdrawalPreview.zod.js +41 -0
  119. package/dist/compute/v1/generated/validators/withdrawalPreviewItem.zod.d.ts +44 -0
  120. package/dist/compute/v1/generated/validators/withdrawalPreviewItem.zod.js +35 -0
  121. package/dist/compute/v1/generated/validators/withdrawalPreviewRequest.zod.d.ts +31 -0
  122. package/dist/compute/v1/generated/validators/withdrawalPreviewRequest.zod.js +29 -0
  123. package/dist/compute/v1/generated/validators/withdrawalSource.zod.d.ts +39 -0
  124. package/dist/compute/v1/generated/validators/withdrawalSource.zod.js +39 -0
  125. package/dist/membership/v1/generated/models.d.ts +241 -85
  126. package/dist/membership/v1/generated/models.js +19 -4
  127. package/dist/membership/v1/generated/validators/paymentResult.zod.d.ts +1 -0
  128. package/dist/membership/v1/generated/validators/refund.zod.d.ts +1 -0
  129. package/dist/membership/v1/generated/validators/refundList.zod.d.ts +1 -0
  130. package/dist/membership/v1/generated/validators/transaction.zod.d.ts +1 -0
  131. package/dist/membership/v1/generated/validators/transactionList.zod.d.ts +1 -0
  132. package/dist/membership/v1/generated/validators/transactionType.zod.d.ts +1 -0
  133. package/dist/membership/v1/generated/validators/transactionType.zod.js +1 -1
  134. package/dist/membership/v1/generated/validators/withdrawal.zod.d.ts +40 -0
  135. package/dist/membership/v1/generated/validators/withdrawal.zod.js +43 -0
  136. package/dist/membership/v1/generated/validators/withdrawalAllocation.zod.d.ts +19 -0
  137. package/dist/membership/v1/generated/validators/withdrawalAllocation.zod.js +17 -0
  138. package/dist/membership/v1/generated/validators/withdrawalCreate.zod.d.ts +25 -0
  139. package/dist/membership/v1/generated/validators/withdrawalCreate.zod.js +19 -0
  140. package/dist/membership/v1/generated/validators/withdrawalItem.zod.d.ts +46 -0
  141. package/dist/membership/v1/generated/validators/withdrawalItem.zod.js +37 -0
  142. package/dist/membership/v1/generated/validators/withdrawalItemList.zod.d.ts +48 -0
  143. package/dist/membership/v1/generated/validators/withdrawalItemList.zod.js +14 -0
  144. package/dist/membership/v1/generated/validators/withdrawalList.zod.d.ts +39 -0
  145. package/dist/membership/v1/generated/validators/withdrawalList.zod.js +14 -0
  146. package/dist/membership/v1/generated/validators/withdrawalPreview.zod.d.ts +40 -0
  147. package/dist/membership/v1/generated/validators/withdrawalPreview.zod.js +25 -0
  148. package/dist/membership/v1/generated/validators/withdrawalPreviewItem.zod.d.ts +28 -0
  149. package/dist/membership/v1/generated/validators/withdrawalPreviewItem.zod.js +19 -0
  150. package/dist/membership/v1/generated/validators/withdrawalPreviewRequest.zod.d.ts +15 -0
  151. package/dist/membership/v1/generated/validators/withdrawalPreviewRequest.zod.js +13 -0
  152. package/dist/membership/v1/generated/validators/withdrawalSource.zod.d.ts +23 -0
  153. package/dist/membership/v1/generated/validators/withdrawalSource.zod.js +23 -0
  154. package/dist/routes.d.ts +40 -0
  155. package/dist/routes.js +45 -0
  156. package/package.json +1 -1
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Billing Order Types
5
+ * The Billing order a product purchase placed. Types only; this document declares no operations.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export declare const withdrawalItemAmountRegExp: RegExp;
10
+ export declare const withdrawalItemFeeAmountRegExp: RegExp;
11
+ export declare const withdrawalItemRefundAmountRegExp: RegExp;
12
+ export declare const withdrawalItemCurrencyMin = 3;
13
+ export declare const withdrawalItemCurrencyMax = 3;
14
+ export declare const WithdrawalItem: zod.ZodObject<{
15
+ source_transaction_id: zod.ZodUUID;
16
+ amount: zod.ZodString;
17
+ fee_amount: zod.ZodString;
18
+ refund_amount: zod.ZodString;
19
+ id: zod.ZodUUID;
20
+ withdrawal_id: zod.ZodUUID;
21
+ billing_account_id: zod.ZodInt;
22
+ currency: zod.ZodString;
23
+ refund_id: zod.ZodUUID;
24
+ fee_transaction_id: zod.ZodOptional<zod.ZodUUID>;
25
+ status: zod.ZodEnum<{
26
+ pending: "pending";
27
+ failed: "failed";
28
+ succeeded: "succeeded";
29
+ reversed: "reversed";
30
+ }>;
31
+ completed_at: zod.ZodOptional<zod.z.ZodISODateTime>;
32
+ payment_gateway: zod.ZodString;
33
+ method_type: zod.ZodString;
34
+ source: zod.ZodObject<{
35
+ amount: zod.ZodString;
36
+ currency: zod.ZodString;
37
+ received_at: zod.z.ZodISODateTime;
38
+ payment_gateway: zod.ZodString;
39
+ method_type: zod.ZodString;
40
+ card_brand: zod.ZodOptional<zod.ZodString>;
41
+ card_last4: zod.ZodOptional<zod.ZodString>;
42
+ }, zod.z.core.$strict>;
43
+ failure_code: zod.ZodOptional<zod.ZodString>;
44
+ }, zod.z.core.$strict>;
45
+ export type WithdrawalItem = zod.input<typeof WithdrawalItem>;
46
+ export type WithdrawalItemOutput = zod.output<typeof WithdrawalItem>;
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Billing Order Types
5
+ * The Billing order a product purchase placed. Types only; this document declares no operations.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ import { WithdrawalSource } from "./withdrawalSource.zod.js";
10
+ export const withdrawalItemAmountRegExp = new RegExp("^[0-9]{1,15}([.][0-9]{1,10})?$");
11
+ export const withdrawalItemFeeAmountRegExp = new RegExp("^[0-9]{1,15}([.][0-9]{1,10})?$");
12
+ export const withdrawalItemRefundAmountRegExp = new RegExp("^[0-9]{1,15}([.][0-9]{1,10})?$");
13
+ export const withdrawalItemCurrencyMin = 3;
14
+ export const withdrawalItemCurrencyMax = 3;
15
+ export const WithdrawalItem = zod
16
+ .strictObject({
17
+ source_transaction_id: zod.uuid(),
18
+ amount: zod.string().regex(withdrawalItemAmountRegExp),
19
+ fee_amount: zod.string().regex(withdrawalItemFeeAmountRegExp),
20
+ refund_amount: zod.string().regex(withdrawalItemRefundAmountRegExp),
21
+ id: zod.uuid(),
22
+ withdrawal_id: zod.uuid(),
23
+ billing_account_id: zod.int(),
24
+ currency: zod.string().min(withdrawalItemCurrencyMin).max(withdrawalItemCurrencyMax),
25
+ refund_id: zod.uuid(),
26
+ fee_transaction_id: zod.uuid().optional(),
27
+ status: zod.enum(["pending", "succeeded", "failed", "reversed"]),
28
+ completed_at: zod.iso.datetime({ offset: true }).optional(),
29
+ payment_gateway: zod.string(),
30
+ method_type: zod.string(),
31
+ source: WithdrawalSource,
32
+ failure_code: zod
33
+ .string()
34
+ .optional()
35
+ .describe("The original gateway failure code when a refund failed, or refund_reversed when a completed refund was reversed. Absent while pending or successful."),
36
+ })
37
+ .describe("The fixed principal deduction, withdrawal fee and exact refund obligation for one original top-up. Each item has its own refund; payment_gateway and method_type identify the original route.");
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Billing Order Types
5
+ * The Billing order a product purchase placed. Types only; this document declares no operations.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export declare const WithdrawalItemList: zod.ZodObject<{
10
+ items: zod.ZodArray<zod.ZodObject<{
11
+ source_transaction_id: zod.ZodUUID;
12
+ amount: zod.ZodString;
13
+ fee_amount: zod.ZodString;
14
+ refund_amount: zod.ZodString;
15
+ id: zod.ZodUUID;
16
+ withdrawal_id: zod.ZodUUID;
17
+ billing_account_id: zod.ZodInt;
18
+ currency: zod.ZodString;
19
+ refund_id: zod.ZodUUID;
20
+ fee_transaction_id: zod.ZodOptional<zod.ZodUUID>;
21
+ status: zod.ZodEnum<{
22
+ pending: "pending";
23
+ failed: "failed";
24
+ succeeded: "succeeded";
25
+ reversed: "reversed";
26
+ }>;
27
+ completed_at: zod.ZodOptional<zod.z.ZodISODateTime>;
28
+ payment_gateway: zod.ZodString;
29
+ method_type: zod.ZodString;
30
+ source: zod.ZodObject<{
31
+ amount: zod.ZodString;
32
+ currency: zod.ZodString;
33
+ received_at: zod.z.ZodISODateTime;
34
+ payment_gateway: zod.ZodString;
35
+ method_type: zod.ZodString;
36
+ card_brand: zod.ZodOptional<zod.ZodString>;
37
+ card_last4: zod.ZodOptional<zod.ZodString>;
38
+ }, zod.z.core.$strict>;
39
+ failure_code: zod.ZodOptional<zod.ZodString>;
40
+ }, zod.z.core.$strict>>;
41
+ pagination: zod.ZodObject<{
42
+ page: zod.ZodInt;
43
+ page_size: zod.ZodInt;
44
+ total_count: zod.ZodOptional<zod.ZodInt>;
45
+ }, zod.z.core.$strict>;
46
+ }, zod.z.core.$strict>;
47
+ export type WithdrawalItemList = zod.input<typeof WithdrawalItemList>;
48
+ export type WithdrawalItemListOutput = zod.output<typeof WithdrawalItemList>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Billing Order Types
5
+ * The Billing order a product purchase placed. Types only; this document declares no operations.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ import { OffsetPagination } from "./offsetPagination.zod.js";
10
+ import { WithdrawalItem } from "./withdrawalItem.zod.js";
11
+ export const WithdrawalItemList = zod.strictObject({
12
+ items: zod.array(WithdrawalItem),
13
+ pagination: OffsetPagination,
14
+ });
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Billing Order Types
5
+ * The Billing order a product purchase placed. Types only; this document declares no operations.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export declare const WithdrawalList: zod.ZodObject<{
10
+ items: zod.ZodArray<zod.ZodObject<{
11
+ id: zod.ZodUUID;
12
+ billing_account_id: zod.ZodInt;
13
+ currency: zod.ZodString;
14
+ amount: zod.ZodString;
15
+ fee_amount: zod.ZodString;
16
+ refund_amount: zod.ZodString;
17
+ deducted_amount: zod.ZodString;
18
+ settled_amount: zod.ZodString;
19
+ charged_fee_amount: zod.ZodString;
20
+ status: zod.ZodEnum<{
21
+ pending: "pending";
22
+ failed: "failed";
23
+ succeeded: "succeeded";
24
+ processing: "processing";
25
+ partially_completed: "partially_completed";
26
+ reversed: "reversed";
27
+ }>;
28
+ created_at: zod.z.ZodISODateTime;
29
+ completed_at: zod.ZodOptional<zod.z.ZodISODateTime>;
30
+ created_by: zod.ZodOptional<zod.ZodString>;
31
+ }, zod.z.core.$strict>>;
32
+ pagination: zod.ZodObject<{
33
+ page: zod.ZodInt;
34
+ page_size: zod.ZodInt;
35
+ total_count: zod.ZodOptional<zod.ZodInt>;
36
+ }, zod.z.core.$strict>;
37
+ }, zod.z.core.$strict>;
38
+ export type WithdrawalList = zod.input<typeof WithdrawalList>;
39
+ export type WithdrawalListOutput = zod.output<typeof WithdrawalList>;
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Billing Order Types
5
+ * The Billing order a product purchase placed. Types only; this document declares no operations.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ import { OffsetPagination } from "./offsetPagination.zod.js";
10
+ import { Withdrawal } from "./withdrawal.zod.js";
11
+ export const WithdrawalList = zod.strictObject({
12
+ items: zod.array(Withdrawal),
13
+ pagination: OffsetPagination,
14
+ });
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Billing Order Types
5
+ * The Billing order a product purchase placed. Types only; this document declares no operations.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export declare const withdrawalPreviewCurrencyMin = 3;
10
+ export declare const withdrawalPreviewCurrencyMax = 3;
11
+ export declare const withdrawalPreviewAvailableAmountRegExp: RegExp;
12
+ export declare const withdrawalPreviewAmountRegExp: RegExp;
13
+ export declare const withdrawalPreviewFeeAmountRegExp: RegExp;
14
+ export declare const withdrawalPreviewRefundAmountRegExp: RegExp;
15
+ export declare const withdrawalPreviewItemsMax = 200;
16
+ export declare const WithdrawalPreview: zod.ZodObject<{
17
+ billing_account_id: zod.ZodInt;
18
+ currency: zod.ZodString;
19
+ available_amount: zod.ZodString;
20
+ amount: zod.ZodString;
21
+ fee_amount: zod.ZodString;
22
+ refund_amount: zod.ZodString;
23
+ items: zod.ZodArray<zod.ZodObject<{
24
+ source_transaction_id: zod.ZodUUID;
25
+ amount: zod.ZodString;
26
+ fee_amount: zod.ZodString;
27
+ refund_amount: zod.ZodString;
28
+ source: zod.ZodObject<{
29
+ amount: zod.ZodString;
30
+ currency: zod.ZodString;
31
+ received_at: zod.z.ZodISODateTime;
32
+ payment_gateway: zod.ZodString;
33
+ method_type: zod.ZodString;
34
+ card_brand: zod.ZodOptional<zod.ZodString>;
35
+ card_last4: zod.ZodOptional<zod.ZodString>;
36
+ }, zod.z.core.$strict>;
37
+ }, zod.z.core.$strict>>;
38
+ }, zod.z.core.$strict>;
39
+ export type WithdrawalPreview = zod.input<typeof WithdrawalPreview>;
40
+ export type WithdrawalPreviewOutput = zod.output<typeof WithdrawalPreview>;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Billing Order Types
5
+ * The Billing order a product purchase placed. Types only; this document declares no operations.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ import { WithdrawalPreviewItem } from "./withdrawalPreviewItem.zod.js";
10
+ export const withdrawalPreviewCurrencyMin = 3;
11
+ export const withdrawalPreviewCurrencyMax = 3;
12
+ export const withdrawalPreviewAvailableAmountRegExp = new RegExp("^[0-9]{1,15}([.][0-9]{1,10})?$");
13
+ export const withdrawalPreviewAmountRegExp = new RegExp("^[0-9]{1,15}([.][0-9]{1,10})?$");
14
+ export const withdrawalPreviewFeeAmountRegExp = new RegExp("^[0-9]{1,15}([.][0-9]{1,10})?$");
15
+ export const withdrawalPreviewRefundAmountRegExp = new RegExp("^[0-9]{1,15}([.][0-9]{1,10})?$");
16
+ export const withdrawalPreviewItemsMax = 200;
17
+ export const WithdrawalPreview = zod.strictObject({
18
+ billing_account_id: zod.int(),
19
+ currency: zod.string().min(withdrawalPreviewCurrencyMin).max(withdrawalPreviewCurrencyMax),
20
+ available_amount: zod.string().regex(withdrawalPreviewAvailableAmountRegExp),
21
+ amount: zod.string().regex(withdrawalPreviewAmountRegExp),
22
+ fee_amount: zod.string().regex(withdrawalPreviewFeeAmountRegExp),
23
+ refund_amount: zod.string().regex(withdrawalPreviewRefundAmountRegExp),
24
+ items: zod.array(WithdrawalPreviewItem).max(withdrawalPreviewItemsMax),
25
+ });
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Billing Order Types
5
+ * The Billing order a product purchase placed. Types only; this document declares no operations.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export declare const withdrawalPreviewItemAmountRegExp: RegExp;
10
+ export declare const withdrawalPreviewItemFeeAmountRegExp: RegExp;
11
+ export declare const withdrawalPreviewItemRefundAmountRegExp: RegExp;
12
+ export declare const WithdrawalPreviewItem: zod.ZodObject<{
13
+ source_transaction_id: zod.ZodUUID;
14
+ amount: zod.ZodString;
15
+ fee_amount: zod.ZodString;
16
+ refund_amount: zod.ZodString;
17
+ source: zod.ZodObject<{
18
+ amount: zod.ZodString;
19
+ currency: zod.ZodString;
20
+ received_at: zod.z.ZodISODateTime;
21
+ payment_gateway: zod.ZodString;
22
+ method_type: zod.ZodString;
23
+ card_brand: zod.ZodOptional<zod.ZodString>;
24
+ card_last4: zod.ZodOptional<zod.ZodString>;
25
+ }, zod.z.core.$strict>;
26
+ }, zod.z.core.$strict>;
27
+ export type WithdrawalPreviewItem = zod.input<typeof WithdrawalPreviewItem>;
28
+ export type WithdrawalPreviewItemOutput = zod.output<typeof WithdrawalPreviewItem>;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Billing Order Types
5
+ * The Billing order a product purchase placed. Types only; this document declares no operations.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ import { WithdrawalSource } from "./withdrawalSource.zod.js";
10
+ export const withdrawalPreviewItemAmountRegExp = new RegExp("^[0-9]{1,15}([.][0-9]{1,10})?$");
11
+ export const withdrawalPreviewItemFeeAmountRegExp = new RegExp("^[0-9]{1,15}([.][0-9]{1,10})?$");
12
+ export const withdrawalPreviewItemRefundAmountRegExp = new RegExp("^[0-9]{1,15}([.][0-9]{1,10})?$");
13
+ export const WithdrawalPreviewItem = zod.strictObject({
14
+ source_transaction_id: zod.uuid(),
15
+ amount: zod.string().regex(withdrawalPreviewItemAmountRegExp),
16
+ fee_amount: zod.string().regex(withdrawalPreviewItemFeeAmountRegExp),
17
+ refund_amount: zod.string().regex(withdrawalPreviewItemRefundAmountRegExp),
18
+ source: WithdrawalSource,
19
+ });
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Billing Order Types
5
+ * The Billing order a product purchase placed. Types only; this document declares no operations.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export declare const withdrawalPreviewRequestAmountRegExp: RegExp;
10
+ export declare const WithdrawalPreviewRequest: zod.ZodObject<{
11
+ billing_account_id: zod.ZodInt;
12
+ amount: zod.ZodOptional<zod.ZodString>;
13
+ }, zod.z.core.$strict>;
14
+ export type WithdrawalPreviewRequest = zod.input<typeof WithdrawalPreviewRequest>;
15
+ export type WithdrawalPreviewRequestOutput = zod.output<typeof WithdrawalPreviewRequest>;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Billing Order Types
5
+ * The Billing order a product purchase placed. Types only; this document declares no operations.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export const withdrawalPreviewRequestAmountRegExp = new RegExp("^[0-9]{1,15}([.][0-9]{1,10})?$");
10
+ export const WithdrawalPreviewRequest = zod.strictObject({
11
+ billing_account_id: zod.int(),
12
+ amount: zod.string().regex(withdrawalPreviewRequestAmountRegExp).optional(),
13
+ });
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Billing Order Types
5
+ * The Billing order a product purchase placed. Types only; this document declares no operations.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export declare const withdrawalSourceAmountRegExp: RegExp;
10
+ export declare const withdrawalSourceCurrencyMin = 3;
11
+ export declare const withdrawalSourceCurrencyMax = 3;
12
+ export declare const withdrawalSourceCardLast4RegExp: RegExp;
13
+ export declare const WithdrawalSource: zod.ZodObject<{
14
+ amount: zod.ZodString;
15
+ currency: zod.ZodString;
16
+ received_at: zod.z.ZodISODateTime;
17
+ payment_gateway: zod.ZodString;
18
+ method_type: zod.ZodString;
19
+ card_brand: zod.ZodOptional<zod.ZodString>;
20
+ card_last4: zod.ZodOptional<zod.ZodString>;
21
+ }, zod.z.core.$strict>;
22
+ export type WithdrawalSource = zod.input<typeof WithdrawalSource>;
23
+ export type WithdrawalSourceOutput = zod.output<typeof WithdrawalSource>;
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Generated by orval 🍺
3
+ * Do not edit manually.
4
+ * Billing Order Types
5
+ * The Billing order a product purchase placed. Types only; this document declares no operations.
6
+ * OpenAPI spec version: v1
7
+ */
8
+ import * as zod from "zod";
9
+ export const withdrawalSourceAmountRegExp = new RegExp("^[0-9]{1,15}([.][0-9]{1,10})?$");
10
+ export const withdrawalSourceCurrencyMin = 3;
11
+ export const withdrawalSourceCurrencyMax = 3;
12
+ export const withdrawalSourceCardLast4RegExp = new RegExp("^[0-9]{4}$");
13
+ export const WithdrawalSource = zod
14
+ .strictObject({
15
+ amount: zod.string().regex(withdrawalSourceAmountRegExp),
16
+ currency: zod.string().min(withdrawalSourceCurrencyMin).max(withdrawalSourceCurrencyMax),
17
+ received_at: zod.iso.datetime({ offset: true }),
18
+ payment_gateway: zod.string(),
19
+ method_type: zod.string(),
20
+ card_brand: zod.string().optional(),
21
+ card_last4: zod.string().regex(withdrawalSourceCardLast4RegExp).optional(),
22
+ })
23
+ .describe("The original top-up and its refund destination. Card details are included when the original payment method was saved; missing card details do not change the original refund route.");
@@ -5,13 +5,118 @@
5
5
  * Products, prices, orders, subscriptions and account billing. Financial operations require an account access token and billing-account authorization. Public catalogue operations declare no security requirement.
6
6
  * OpenAPI spec version: v1
7
7
  */
8
- import type { AccountBalance, ActiveResourceList, AllowanceList, AutoRenewSet, BillingAccount, BillingAccountCreate, BillingAccountList, BillingAccountUpdate, CancelSubscriptionRequest, Cancellation, CancellationCreate, CancellationList, Contact, ContactCreate, ContactList, ContactUpdate, CreditGrantList, CreditNote, CreditNoteItemList, CreditNoteList, CurrencyList, DiscountList, EntitlementList, Error, ErrorResponse, FeatureGrantList, GetPlanHeaders, GetPriceHeaders, GetProductHeaders, GetStatementUsageParams, Invoice, InvoiceItemList, InvoiceList, ListAccountDiscountsParams, ListActiveResourcesParams, ListAllowancesParams, ListBillingAccountsParams, ListCancellationsParams, ListContactsParams, ListCreditGrantsParams, ListCreditNoteItemsParams, ListCreditNotesParams, ListCurrenciesParams, ListEntitlementsParams, ListFeatureGrantsParams, ListInvoiceItemsParams, ListInvoicesParams, ListMonthlyStatementsParams, ListOrderItemsParams, ListOrdersParams, ListPaymentMethodsParams, ListPaymentOptionsParams, ListPlansHeaders, ListPlansParams, ListPricesByPlanHeaders, ListPricesByPlanParams, ListPricesHeaders, ListPricesParams, ListProductsHeaders, ListProductsParams, ListProjectAssignmentsParams, ListRatesHeaders, ListRatesParams, ListRefundsParams, ListRenewalPricesParams, ListSpendParams, ListStatementsParams, ListSubscriptionsParams, ListTopUpsParams, ListTransactionsParams, ListUsageChargesParams, MonthlyStatementList, NotModifiedResponse, Order, OrderCancel, OrderItemList, OrderList, PayInvoiceRequest, PayTogetherRequest, PaymentMethod, PaymentMethodList, PaymentMethodSetup, PaymentMethodSetupResult, PaymentOptionList, PaymentPreview, PaymentResult, Plan, PlanList, PreviewInvoicePaymentParams, Price, PriceList, Product, ProductID, ProductList, ProjectAssignment, ProjectAssignmentList, Quote, QuoteRequest, RateList, RefundList, RenewRequest, RenewalOrderRequest, RenewalPriceList, SetProjectAssignmentRequest, SpendRowList, Statement, StatementList, StatementSummary, Subscription, SubscriptionList, TopUp, TopUpCreate, TopUpList, TransactionList, UsageChargeList } from "./models.js";
8
+ import type { AccountBalance, ActiveResourceList, AllowanceList, AutoRenewSet, BillingAccount, BillingAccountCreate, BillingAccountList, BillingAccountUpdate, CancelSubscriptionRequest, Cancellation, CancellationCreate, CancellationList, Contact, ContactCreate, ContactList, ContactUpdate, CreditGrantList, CreditNote, CreditNoteItemList, CreditNoteList, CurrencyList, DiscountList, EntitlementList, Error, ErrorResponse, FeatureGrantList, GetPlanHeaders, GetPriceHeaders, GetProductHeaders, GetStatementUsageParams, Invoice, InvoiceItemList, InvoiceList, ListAccountDiscountsParams, ListActiveResourcesParams, ListAllowancesParams, ListBillingAccountsParams, ListCancellationsParams, ListContactsParams, ListCreditGrantsParams, ListCreditNoteItemsParams, ListCreditNotesParams, ListCurrenciesParams, ListEntitlementsParams, ListFeatureGrantsParams, ListInvoiceItemsParams, ListInvoicesParams, ListMonthlyStatementsParams, ListOrderItemsParams, ListOrdersParams, ListPaymentMethodsParams, ListPaymentOptionsParams, ListPlansHeaders, ListPlansParams, ListPricesByPlanHeaders, ListPricesByPlanParams, ListPricesHeaders, ListPricesParams, ListProductsHeaders, ListProductsParams, ListProjectAssignmentsParams, ListRatesHeaders, ListRatesParams, ListRefundsParams, ListRenewalPricesParams, ListSpendParams, ListStatementsParams, ListSubscriptionsParams, ListTopUpsParams, ListTransactionsParams, ListUsageChargesParams, ListWithdrawalItemsParams, ListWithdrawalsParams, MonthlyStatementList, NotModifiedResponse, Order, OrderCancel, OrderItemList, OrderList, PayInvoiceRequest, PayTogetherRequest, PaymentMethod, PaymentMethodList, PaymentMethodSetup, PaymentMethodSetupResult, PaymentOptionList, PaymentPreview, PaymentResult, Plan, PlanList, PreviewInvoicePaymentParams, Price, PriceList, Product, ProductID, ProductList, ProjectAssignment, ProjectAssignmentList, Quote, QuoteRequest, RateList, RefundList, RenewRequest, RenewalOrderRequest, RenewalPriceList, SetProjectAssignmentRequest, SpendRowList, Statement, StatementList, StatementSummary, Subscription, SubscriptionList, TopUp, TopUpCreate, TopUpList, TransactionList, UsageChargeList, Withdrawal, WithdrawalCreate, WithdrawalItemList, WithdrawalList, WithdrawalPreview, WithdrawalPreviewRequest } from "./models.js";
9
9
  export type HTTPStatusCode1xx = 100 | 101 | 102 | 103;
10
10
  export type HTTPStatusCode2xx = 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207;
11
11
  export type HTTPStatusCode3xx = 300 | 301 | 302 | 303 | 304 | 305 | 307 | 308;
12
12
  export type HTTPStatusCode4xx = 400 | 401 | 402 | 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | 419 | 420 | 421 | 422 | 423 | 424 | 426 | 428 | 429 | 431 | 451;
13
13
  export type HTTPStatusCode5xx = 500 | 501 | 502 | 503 | 504 | 505 | 507 | 511;
14
14
  export type HTTPStatusCodes = HTTPStatusCode1xx | HTTPStatusCode2xx | HTTPStatusCode3xx | HTTPStatusCode4xx | HTTPStatusCode5xx;
15
+ export type listWithdrawalItemsResponse200 = {
16
+ data: WithdrawalItemList;
17
+ status: 200;
18
+ };
19
+ export type listWithdrawalItemsResponseDefault = {
20
+ data: ErrorResponse;
21
+ status: Exclude<HTTPStatusCodes, 200>;
22
+ };
23
+ export type listWithdrawalItemsResponseSuccess = listWithdrawalItemsResponse200 & {
24
+ headers: Headers;
25
+ };
26
+ export type listWithdrawalItemsResponseError = listWithdrawalItemsResponseDefault & {
27
+ headers: Headers;
28
+ };
29
+ export type listWithdrawalItemsResponse = listWithdrawalItemsResponseSuccess | listWithdrawalItemsResponseError;
30
+ export declare const getListWithdrawalItemsUrl: (withdrawalId: string, params?: ListWithdrawalItemsParams) => string;
31
+ /**
32
+ * Paginated fixed source allocations and their outcomes. A failed source does not undo refunds already completed through other sources.
33
+ * @summary List withdrawal items
34
+ */
35
+ export declare const listWithdrawalItems: (withdrawalId: string, params?: ListWithdrawalItemsParams, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<listWithdrawalItemsResponse>;
36
+ export type listWithdrawalsResponse200 = {
37
+ data: WithdrawalList;
38
+ status: 200;
39
+ };
40
+ export type listWithdrawalsResponseDefault = {
41
+ data: ErrorResponse;
42
+ status: Exclude<HTTPStatusCodes, 200>;
43
+ };
44
+ export type listWithdrawalsResponseSuccess = listWithdrawalsResponse200 & {
45
+ headers: Headers;
46
+ };
47
+ export type listWithdrawalsResponseError = listWithdrawalsResponseDefault & {
48
+ headers: Headers;
49
+ };
50
+ export type listWithdrawalsResponse = listWithdrawalsResponseSuccess | listWithdrawalsResponseError;
51
+ export declare const getListWithdrawalsUrl: (params?: ListWithdrawalsParams) => string;
52
+ /**
53
+ * Paginated account withdrawal history, newest first. Account authorization applies to every record.
54
+ * @summary List withdrawals
55
+ */
56
+ export declare const listWithdrawals: (params?: ListWithdrawalsParams, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<listWithdrawalsResponse>;
57
+ export type createWithdrawalResponse201 = {
58
+ data: Withdrawal;
59
+ status: 201;
60
+ };
61
+ export type createWithdrawalResponseDefault = {
62
+ data: ErrorResponse;
63
+ status: Exclude<HTTPStatusCodes, 201>;
64
+ };
65
+ export type createWithdrawalResponseSuccess = createWithdrawalResponse201 & {
66
+ headers: Headers;
67
+ };
68
+ export type createWithdrawalResponseError = createWithdrawalResponseDefault & {
69
+ headers: Headers;
70
+ };
71
+ export type createWithdrawalResponse = createWithdrawalResponseSuccess | createWithdrawalResponseError;
72
+ export declare const getCreateWithdrawalUrl: () => string;
73
+ /**
74
+ * Withdraws the requested account balance through the original top-ups in receipt order. Fees are calculated independently per source. expected_items and expected_refund_amount must match the accepted preview. Reusing the same ID with different terms fails. Only successful items collect a fee.
75
+ * @summary Create withdrawal
76
+ */
77
+ export declare const createWithdrawal: (withdrawalCreate: WithdrawalCreate, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<createWithdrawalResponse>;
78
+ export type previewWithdrawalResponse200 = {
79
+ data: WithdrawalPreview;
80
+ status: 200;
81
+ };
82
+ export type previewWithdrawalResponseDefault = {
83
+ data: ErrorResponse;
84
+ status: Exclude<HTTPStatusCodes, 200>;
85
+ };
86
+ export type previewWithdrawalResponseSuccess = previewWithdrawalResponse200 & {
87
+ headers: Headers;
88
+ };
89
+ export type previewWithdrawalResponseError = previewWithdrawalResponseDefault & {
90
+ headers: Headers;
91
+ };
92
+ export type previewWithdrawalResponse = previewWithdrawalResponseSuccess | previewWithdrawalResponseError;
93
+ export declare const getPreviewWithdrawalUrl: () => string;
94
+ /**
95
+ * Previews the available balance deduction, fees and exact refund allocation by original source. Omit amount to preview all available principal. Creates no withdrawal and reserves no funds. Fails if a selected source has no configured refund route or its original processing cost is not yet available.
96
+ * @summary Preview withdrawal
97
+ */
98
+ export declare const previewWithdrawal: (withdrawalPreviewRequest: WithdrawalPreviewRequest, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<previewWithdrawalResponse>;
99
+ export type getWithdrawalResponse200 = {
100
+ data: Withdrawal;
101
+ status: 200;
102
+ };
103
+ export type getWithdrawalResponseDefault = {
104
+ data: ErrorResponse;
105
+ status: Exclude<HTTPStatusCodes, 200>;
106
+ };
107
+ export type getWithdrawalResponseSuccess = getWithdrawalResponse200 & {
108
+ headers: Headers;
109
+ };
110
+ export type getWithdrawalResponseError = getWithdrawalResponseDefault & {
111
+ headers: Headers;
112
+ };
113
+ export type getWithdrawalResponse = getWithdrawalResponseSuccess | getWithdrawalResponseError;
114
+ export declare const getGetWithdrawalUrl: (withdrawalId: string) => string;
115
+ /**
116
+ * Reads the accepted amounts and aggregate outcome of an authorized withdrawal. List its source items for each original-method refund result.
117
+ * @summary Get withdrawal
118
+ */
119
+ export declare const getWithdrawal: (withdrawalId: string, options?: RequestInit, fetchFn?: typeof globalThis.fetch) => Promise<getWithdrawalResponse>;
15
120
  export type listContactsResponse200 = {
16
121
  data: ContactList;
17
122
  status: 200;
@@ -1,3 +1,135 @@
1
+ export const getListWithdrawalItemsUrl = (withdrawalId, params) => {
2
+ const normalizedParams = new URLSearchParams();
3
+ Object.entries(params || {}).forEach(([key, value]) => {
4
+ if (value !== undefined) {
5
+ normalizedParams.append(key, value === null ? "null" : String(value));
6
+ }
7
+ });
8
+ const stringifiedParams = normalizedParams.toString();
9
+ return stringifiedParams.length > 0
10
+ ? `https://billing.leaflow.cloud/api/v1/withdrawals/${encodeURIComponent(String(withdrawalId))}/items?${stringifiedParams}`
11
+ : `https://billing.leaflow.cloud/api/v1/withdrawals/${encodeURIComponent(String(withdrawalId))}/items`;
12
+ };
13
+ /**
14
+ * Paginated fixed source allocations and their outcomes. A failed source does not undo refunds already completed through other sources.
15
+ * @summary List withdrawal items
16
+ */
17
+ export const listWithdrawalItems = async (withdrawalId, params, options, fetchFn) => {
18
+ const res = await (fetchFn ?? fetch)(getListWithdrawalItemsUrl(withdrawalId, params), {
19
+ ...options,
20
+ method: "GET",
21
+ });
22
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
23
+ const data = body ? JSON.parse(body) : {};
24
+ return { data, status: res.status, headers: res.headers };
25
+ };
26
+ export const getListWithdrawalsUrl = (params) => {
27
+ const normalizedParams = new URLSearchParams();
28
+ Object.entries(params || {}).forEach(([key, value]) => {
29
+ if (value !== undefined) {
30
+ normalizedParams.append(key, value === null ? "null" : String(value));
31
+ }
32
+ });
33
+ const stringifiedParams = normalizedParams.toString();
34
+ return stringifiedParams.length > 0
35
+ ? `https://billing.leaflow.cloud/api/v1/withdrawals?${stringifiedParams}`
36
+ : `https://billing.leaflow.cloud/api/v1/withdrawals`;
37
+ };
38
+ /**
39
+ * Paginated account withdrawal history, newest first. Account authorization applies to every record.
40
+ * @summary List withdrawals
41
+ */
42
+ export const listWithdrawals = async (params, options, fetchFn) => {
43
+ const res = await (fetchFn ?? fetch)(getListWithdrawalsUrl(params), {
44
+ ...options,
45
+ method: "GET",
46
+ });
47
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
48
+ const data = body ? JSON.parse(body) : {};
49
+ return { data, status: res.status, headers: res.headers };
50
+ };
51
+ export const getCreateWithdrawalUrl = () => {
52
+ return `https://billing.leaflow.cloud/api/v1/withdrawals`;
53
+ };
54
+ /**
55
+ * Withdraws the requested account balance through the original top-ups in receipt order. Fees are calculated independently per source. expected_items and expected_refund_amount must match the accepted preview. Reusing the same ID with different terms fails. Only successful items collect a fee.
56
+ * @summary Create withdrawal
57
+ */
58
+ export const createWithdrawal = async (withdrawalCreate, options, fetchFn) => {
59
+ const getHeaders = (h) => {
60
+ if (!h)
61
+ return {};
62
+ if (h instanceof Headers)
63
+ return Object.fromEntries(h.entries());
64
+ if (Symbol.iterator in h) {
65
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
66
+ }
67
+ const headers = {};
68
+ for (const [name, value] of Object.entries(h)) {
69
+ if (value !== undefined)
70
+ headers[name] = value;
71
+ }
72
+ return headers;
73
+ };
74
+ const res = await (fetchFn ?? fetch)(getCreateWithdrawalUrl(), {
75
+ ...options,
76
+ method: "POST",
77
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
78
+ body: JSON.stringify(withdrawalCreate),
79
+ });
80
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
81
+ const data = body ? JSON.parse(body) : {};
82
+ return { data, status: res.status, headers: res.headers };
83
+ };
84
+ export const getPreviewWithdrawalUrl = () => {
85
+ return `https://billing.leaflow.cloud/api/v1/withdrawals/preview`;
86
+ };
87
+ /**
88
+ * Previews the available balance deduction, fees and exact refund allocation by original source. Omit amount to preview all available principal. Creates no withdrawal and reserves no funds. Fails if a selected source has no configured refund route or its original processing cost is not yet available.
89
+ * @summary Preview withdrawal
90
+ */
91
+ export const previewWithdrawal = async (withdrawalPreviewRequest, options, fetchFn) => {
92
+ const getHeaders = (h) => {
93
+ if (!h)
94
+ return {};
95
+ if (h instanceof Headers)
96
+ return Object.fromEntries(h.entries());
97
+ if (Symbol.iterator in h) {
98
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
99
+ }
100
+ const headers = {};
101
+ for (const [name, value] of Object.entries(h)) {
102
+ if (value !== undefined)
103
+ headers[name] = value;
104
+ }
105
+ return headers;
106
+ };
107
+ const res = await (fetchFn ?? fetch)(getPreviewWithdrawalUrl(), {
108
+ ...options,
109
+ method: "POST",
110
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
111
+ body: JSON.stringify(withdrawalPreviewRequest),
112
+ });
113
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
114
+ const data = body ? JSON.parse(body) : {};
115
+ return { data, status: res.status, headers: res.headers };
116
+ };
117
+ export const getGetWithdrawalUrl = (withdrawalId) => {
118
+ return `https://billing.leaflow.cloud/api/v1/withdrawals/${encodeURIComponent(String(withdrawalId))}`;
119
+ };
120
+ /**
121
+ * Reads the accepted amounts and aggregate outcome of an authorized withdrawal. List its source items for each original-method refund result.
122
+ * @summary Get withdrawal
123
+ */
124
+ export const getWithdrawal = async (withdrawalId, options, fetchFn) => {
125
+ const res = await (fetchFn ?? fetch)(getGetWithdrawalUrl(withdrawalId), {
126
+ ...options,
127
+ method: "GET",
128
+ });
129
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
130
+ const data = body ? JSON.parse(body) : {};
131
+ return { data, status: res.status, headers: res.headers };
132
+ };
1
133
  export const getListContactsUrl = (accountId, params) => {
2
134
  const normalizedParams = new URLSearchParams();
3
135
  Object.entries(params || {}).forEach(([key, value]) => {