mollie-api-typescript 1.7.0 → 1.7.2

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 (197) hide show
  1. package/README.md +11 -0
  2. package/dist/commonjs/funcs/payoutsCancel.d.ts +22 -0
  3. package/dist/commonjs/funcs/payoutsCancel.d.ts.map +1 -0
  4. package/dist/commonjs/funcs/payoutsCancel.js +147 -0
  5. package/dist/commonjs/funcs/payoutsCancel.js.map +1 -0
  6. package/dist/commonjs/funcs/payoutsCreate.d.ts +54 -0
  7. package/dist/commonjs/funcs/payoutsCreate.d.ts.map +1 -0
  8. package/dist/commonjs/funcs/payoutsCreate.js +174 -0
  9. package/dist/commonjs/funcs/payoutsCreate.js.map +1 -0
  10. package/dist/commonjs/funcs/payoutsGet.d.ts +19 -0
  11. package/dist/commonjs/funcs/payoutsGet.d.ts.map +1 -0
  12. package/dist/commonjs/funcs/payoutsGet.js +144 -0
  13. package/dist/commonjs/funcs/payoutsGet.js.map +1 -0
  14. package/dist/commonjs/funcs/payoutsList.d.ts +29 -0
  15. package/dist/commonjs/funcs/payoutsList.d.ts.map +1 -0
  16. package/dist/commonjs/funcs/payoutsList.js +182 -0
  17. package/dist/commonjs/funcs/payoutsList.js.map +1 -0
  18. package/dist/commonjs/lib/config.d.ts +3 -3
  19. package/dist/commonjs/lib/config.js +3 -3
  20. package/dist/commonjs/models/entitypayoutresponse.d.ts +94 -0
  21. package/dist/commonjs/models/entitypayoutresponse.d.ts.map +1 -0
  22. package/dist/commonjs/models/entitypayoutresponse.js +82 -0
  23. package/dist/commonjs/models/entitypayoutresponse.js.map +1 -0
  24. package/dist/commonjs/models/entitywebhookevent.d.ts +8 -2
  25. package/dist/commonjs/models/entitywebhookevent.d.ts.map +1 -1
  26. package/dist/commonjs/models/entitywebhookevent.js +8 -0
  27. package/dist/commonjs/models/entitywebhookevent.js.map +1 -1
  28. package/dist/commonjs/models/index.d.ts +6 -0
  29. package/dist/commonjs/models/index.d.ts.map +1 -1
  30. package/dist/commonjs/models/index.js +6 -0
  31. package/dist/commonjs/models/index.js.map +1 -1
  32. package/dist/commonjs/models/listentitypayout.d.ts +90 -0
  33. package/dist/commonjs/models/listentitypayout.d.ts.map +1 -0
  34. package/dist/commonjs/models/listentitypayout.js +81 -0
  35. package/dist/commonjs/models/listentitypayout.js.map +1 -0
  36. package/dist/commonjs/models/operations/cancelpayout.d.ts +43 -0
  37. package/dist/commonjs/models/operations/cancelpayout.d.ts.map +1 -0
  38. package/dist/commonjs/models/operations/cancelpayout.js +57 -0
  39. package/dist/commonjs/models/operations/cancelpayout.js.map +1 -0
  40. package/dist/commonjs/models/operations/createpayout.d.ts +41 -0
  41. package/dist/commonjs/models/operations/createpayout.d.ts.map +1 -0
  42. package/dist/commonjs/models/operations/createpayout.js +59 -0
  43. package/dist/commonjs/models/operations/createpayout.js.map +1 -0
  44. package/dist/commonjs/models/operations/getpayout.d.ts +43 -0
  45. package/dist/commonjs/models/operations/getpayout.d.ts.map +1 -0
  46. package/dist/commonjs/models/operations/getpayout.js +57 -0
  47. package/dist/commonjs/models/operations/getpayout.js.map +1 -0
  48. package/dist/commonjs/models/operations/index.d.ts +4 -0
  49. package/dist/commonjs/models/operations/index.d.ts.map +1 -1
  50. package/dist/commonjs/models/operations/index.js +4 -0
  51. package/dist/commonjs/models/operations/index.js.map +1 -1
  52. package/dist/commonjs/models/operations/listpayouts.d.ts +114 -0
  53. package/dist/commonjs/models/operations/listpayouts.d.ts.map +1 -0
  54. package/dist/commonjs/models/operations/listpayouts.js +97 -0
  55. package/dist/commonjs/models/operations/listpayouts.js.map +1 -0
  56. package/dist/commonjs/models/paymentrequest.d.ts +10 -0
  57. package/dist/commonjs/models/paymentrequest.d.ts.map +1 -1
  58. package/dist/commonjs/models/paymentrequest.js +1 -0
  59. package/dist/commonjs/models/paymentrequest.js.map +1 -1
  60. package/dist/commonjs/models/payoutrequest.d.ts +37 -0
  61. package/dist/commonjs/models/payoutrequest.d.ts.map +1 -0
  62. package/dist/commonjs/models/payoutrequest.js +54 -0
  63. package/dist/commonjs/models/payoutrequest.js.map +1 -0
  64. package/dist/commonjs/models/payoutstatus.d.ts +20 -0
  65. package/dist/commonjs/models/payoutstatus.d.ts.map +1 -0
  66. package/dist/commonjs/models/payoutstatus.js +55 -0
  67. package/dist/commonjs/models/payoutstatus.js.map +1 -0
  68. package/dist/commonjs/models/payoutstatusreason.d.ts +21 -0
  69. package/dist/commonjs/models/payoutstatusreason.d.ts.map +1 -0
  70. package/dist/commonjs/models/payoutstatusreason.js +53 -0
  71. package/dist/commonjs/models/payoutstatusreason.js.map +1 -0
  72. package/dist/commonjs/models/payoutstatusreasoncode.d.ts +28 -0
  73. package/dist/commonjs/models/payoutstatusreasoncode.d.ts.map +1 -0
  74. package/dist/commonjs/models/payoutstatusreasoncode.js +63 -0
  75. package/dist/commonjs/models/payoutstatusreasoncode.js.map +1 -0
  76. package/dist/commonjs/models/webhookeventtypes.d.ts +5 -0
  77. package/dist/commonjs/models/webhookeventtypes.d.ts.map +1 -1
  78. package/dist/commonjs/models/webhookeventtypes.js +5 -0
  79. package/dist/commonjs/models/webhookeventtypes.js.map +1 -1
  80. package/dist/commonjs/sdk/payouts.d.ts +81 -0
  81. package/dist/commonjs/sdk/payouts.d.ts.map +1 -0
  82. package/dist/commonjs/sdk/payouts.js +98 -0
  83. package/dist/commonjs/sdk/payouts.js.map +1 -0
  84. package/dist/commonjs/sdk/sdk.d.ts +3 -0
  85. package/dist/commonjs/sdk/sdk.d.ts.map +1 -1
  86. package/dist/commonjs/sdk/sdk.js +4 -0
  87. package/dist/commonjs/sdk/sdk.js.map +1 -1
  88. package/dist/esm/funcs/payoutsCancel.d.ts +22 -0
  89. package/dist/esm/funcs/payoutsCancel.d.ts.map +1 -0
  90. package/dist/esm/funcs/payoutsCancel.js +111 -0
  91. package/dist/esm/funcs/payoutsCancel.js.map +1 -0
  92. package/dist/esm/funcs/payoutsCreate.d.ts +54 -0
  93. package/dist/esm/funcs/payoutsCreate.d.ts.map +1 -0
  94. package/dist/esm/funcs/payoutsCreate.js +138 -0
  95. package/dist/esm/funcs/payoutsCreate.js.map +1 -0
  96. package/dist/esm/funcs/payoutsGet.d.ts +19 -0
  97. package/dist/esm/funcs/payoutsGet.d.ts.map +1 -0
  98. package/dist/esm/funcs/payoutsGet.js +108 -0
  99. package/dist/esm/funcs/payoutsGet.js.map +1 -0
  100. package/dist/esm/funcs/payoutsList.d.ts +29 -0
  101. package/dist/esm/funcs/payoutsList.d.ts.map +1 -0
  102. package/dist/esm/funcs/payoutsList.js +146 -0
  103. package/dist/esm/funcs/payoutsList.js.map +1 -0
  104. package/dist/esm/lib/config.d.ts +3 -3
  105. package/dist/esm/lib/config.js +3 -3
  106. package/dist/esm/models/entitypayoutresponse.d.ts +94 -0
  107. package/dist/esm/models/entitypayoutresponse.d.ts.map +1 -0
  108. package/dist/esm/models/entitypayoutresponse.js +44 -0
  109. package/dist/esm/models/entitypayoutresponse.js.map +1 -0
  110. package/dist/esm/models/entitywebhookevent.d.ts +8 -2
  111. package/dist/esm/models/entitywebhookevent.d.ts.map +1 -1
  112. package/dist/esm/models/entitywebhookevent.js +8 -0
  113. package/dist/esm/models/entitywebhookevent.js.map +1 -1
  114. package/dist/esm/models/index.d.ts +6 -0
  115. package/dist/esm/models/index.d.ts.map +1 -1
  116. package/dist/esm/models/index.js +6 -0
  117. package/dist/esm/models/index.js.map +1 -1
  118. package/dist/esm/models/listentitypayout.d.ts +90 -0
  119. package/dist/esm/models/listentitypayout.d.ts.map +1 -0
  120. package/dist/esm/models/listentitypayout.js +43 -0
  121. package/dist/esm/models/listentitypayout.js.map +1 -0
  122. package/dist/esm/models/operations/cancelpayout.d.ts +43 -0
  123. package/dist/esm/models/operations/cancelpayout.d.ts.map +1 -0
  124. package/dist/esm/models/operations/cancelpayout.js +20 -0
  125. package/dist/esm/models/operations/cancelpayout.js.map +1 -0
  126. package/dist/esm/models/operations/createpayout.d.ts +41 -0
  127. package/dist/esm/models/operations/createpayout.d.ts.map +1 -0
  128. package/dist/esm/models/operations/createpayout.js +22 -0
  129. package/dist/esm/models/operations/createpayout.js.map +1 -0
  130. package/dist/esm/models/operations/getpayout.d.ts +43 -0
  131. package/dist/esm/models/operations/getpayout.d.ts.map +1 -0
  132. package/dist/esm/models/operations/getpayout.js +20 -0
  133. package/dist/esm/models/operations/getpayout.js.map +1 -0
  134. package/dist/esm/models/operations/index.d.ts +4 -0
  135. package/dist/esm/models/operations/index.d.ts.map +1 -1
  136. package/dist/esm/models/operations/index.js +4 -0
  137. package/dist/esm/models/operations/index.js.map +1 -1
  138. package/dist/esm/models/operations/listpayouts.d.ts +114 -0
  139. package/dist/esm/models/operations/listpayouts.d.ts.map +1 -0
  140. package/dist/esm/models/operations/listpayouts.js +57 -0
  141. package/dist/esm/models/operations/listpayouts.js.map +1 -0
  142. package/dist/esm/models/paymentrequest.d.ts +10 -0
  143. package/dist/esm/models/paymentrequest.d.ts.map +1 -1
  144. package/dist/esm/models/paymentrequest.js +1 -0
  145. package/dist/esm/models/paymentrequest.js.map +1 -1
  146. package/dist/esm/models/payoutrequest.d.ts +37 -0
  147. package/dist/esm/models/payoutrequest.d.ts.map +1 -0
  148. package/dist/esm/models/payoutrequest.js +17 -0
  149. package/dist/esm/models/payoutrequest.js.map +1 -0
  150. package/dist/esm/models/payoutstatus.d.ts +20 -0
  151. package/dist/esm/models/payoutstatus.d.ts.map +1 -0
  152. package/dist/esm/models/payoutstatus.js +19 -0
  153. package/dist/esm/models/payoutstatus.js.map +1 -0
  154. package/dist/esm/models/payoutstatusreason.d.ts +21 -0
  155. package/dist/esm/models/payoutstatusreason.d.ts.map +1 -0
  156. package/dist/esm/models/payoutstatusreason.js +16 -0
  157. package/dist/esm/models/payoutstatusreason.js.map +1 -0
  158. package/dist/esm/models/payoutstatusreasoncode.d.ts +28 -0
  159. package/dist/esm/models/payoutstatusreasoncode.d.ts.map +1 -0
  160. package/dist/esm/models/payoutstatusreasoncode.js +27 -0
  161. package/dist/esm/models/payoutstatusreasoncode.js.map +1 -0
  162. package/dist/esm/models/webhookeventtypes.d.ts +5 -0
  163. package/dist/esm/models/webhookeventtypes.d.ts.map +1 -1
  164. package/dist/esm/models/webhookeventtypes.js +5 -0
  165. package/dist/esm/models/webhookeventtypes.js.map +1 -1
  166. package/dist/esm/sdk/payouts.d.ts +81 -0
  167. package/dist/esm/sdk/payouts.d.ts.map +1 -0
  168. package/dist/esm/sdk/payouts.js +94 -0
  169. package/dist/esm/sdk/payouts.js.map +1 -0
  170. package/dist/esm/sdk/sdk.d.ts +3 -0
  171. package/dist/esm/sdk/sdk.d.ts.map +1 -1
  172. package/dist/esm/sdk/sdk.js +4 -0
  173. package/dist/esm/sdk/sdk.js.map +1 -1
  174. package/jsr.json +1 -1
  175. package/package.json +1 -1
  176. package/src/funcs/payoutsCancel.ts +204 -0
  177. package/src/funcs/payoutsCreate.ts +231 -0
  178. package/src/funcs/payoutsGet.ts +201 -0
  179. package/src/funcs/payoutsList.ts +278 -0
  180. package/src/lib/config.ts +3 -3
  181. package/src/models/entitypayoutresponse.ts +157 -0
  182. package/src/models/entitywebhookevent.ts +13 -0
  183. package/src/models/index.ts +6 -0
  184. package/src/models/listentitypayout.ts +152 -0
  185. package/src/models/operations/cancelpayout.ts +71 -0
  186. package/src/models/operations/createpayout.ts +70 -0
  187. package/src/models/operations/getpayout.ts +71 -0
  188. package/src/models/operations/index.ts +4 -0
  189. package/src/models/operations/listpayouts.ts +208 -0
  190. package/src/models/paymentrequest.ts +11 -0
  191. package/src/models/payoutrequest.ts +60 -0
  192. package/src/models/payoutstatus.ts +31 -0
  193. package/src/models/payoutstatusreason.ts +47 -0
  194. package/src/models/payoutstatusreasoncode.ts +39 -0
  195. package/src/models/webhookeventtypes.ts +5 -0
  196. package/src/sdk/payouts.ts +128 -0
  197. package/src/sdk/sdk.ts +6 -0
@@ -0,0 +1,231 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: f0af27f99157
4
+ */
5
+
6
+ import { ClientCore } from "../core.js";
7
+ import { encodeFormQuery, encodeJSON, encodeSimple } from "../lib/encodings.js";
8
+ import { matchStatusCode } from "../lib/http.js";
9
+ import * as M from "../lib/matchers.js";
10
+ import { compactMap } from "../lib/primitives.js";
11
+ import { safeParse } from "../lib/schemas.js";
12
+ import { RequestOptions } from "../lib/sdks.js";
13
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
14
+ import { pathToFunc } from "../lib/url.js";
15
+ import { ClientError } from "../models/errors/clienterror.js";
16
+ import {
17
+ ConnectionError,
18
+ InvalidRequestError,
19
+ RequestAbortedError,
20
+ RequestTimeoutError,
21
+ UnexpectedClientError,
22
+ } from "../models/errors/httpclienterrors.js";
23
+ import * as errors from "../models/errors/index.js";
24
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
25
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
26
+ import * as models from "../models/index.js";
27
+ import * as operations from "../models/operations/index.js";
28
+ import { APICall, APIPromise } from "../types/async.js";
29
+ import { Result } from "../types/fp.js";
30
+
31
+ /**
32
+ * Create payout
33
+ *
34
+ * @remarks
35
+ * Request a payout from one of your balances to the balance's configured bank account.
36
+ *
37
+ * The payout will be executed on the next scheduled business day. If no `amount` is specified, the full available
38
+ * balance minus any configured balance reserve is paid out.
39
+ *
40
+ * Once the payout is created with status `requested`, you can cancel it via the
41
+ * [Cancel payout](cancel-payout) endpoint, up until the payout moves to `initiated`.
42
+ *
43
+ * Creating a payout via the API automatically sets the balance's `transferFrequency` to `never`,
44
+ * pausing any previously configured automatic settlement schedule. To resume automatic settlements,
45
+ * update the transfer frequency via the dashboard.
46
+ *
47
+ * ### Webhooks
48
+ *
49
+ * Subscribe to the following webhook events to track payout status changes. See the
50
+ * [Webhook Subscriptions API](list-webhooks) for details on subscribing.
51
+ *
52
+ * | Event | Description |
53
+ * |---|---|
54
+ * | `payout.initiated` | The payout is being executed and funds are reserved. |
55
+ * | `payout.processing-at-bank` | The payout has been submitted to the bank. |
56
+ * | `payout.completed` | The payout has been sent to the destination bank account. |
57
+ * | `payout.canceled` | The payout was canceled via the API before being submitted to the bank. |
58
+ * | `payout.failed` | The payout failed after creation, including bank rejections and post-submission cancellations. |
59
+ *
60
+ * ### Payout failure reasons
61
+ *
62
+ * A payout request may fail immediately if one of the following conditions applies:
63
+ *
64
+ * - A payout is already scheduled for the next business day for this balance.
65
+ * - The balance has insufficient funds.
66
+ * - The balance is not active.
67
+ * - Payouts are blocked for this organization.
68
+ * - The balance has queued refunds.
69
+ * - One of the organization's balances is below the negative balance threshold.
70
+ * - The payout destination (bank account) is invalid or not configured.
71
+ */
72
+ export function payoutsCreate(
73
+ client: ClientCore,
74
+ request: operations.CreatePayoutRequest,
75
+ options?: RequestOptions,
76
+ ): APIPromise<
77
+ Result<
78
+ models.EntityPayoutResponse,
79
+ | errors.ErrorResponse
80
+ | ClientError
81
+ | ResponseValidationError
82
+ | ConnectionError
83
+ | RequestAbortedError
84
+ | RequestTimeoutError
85
+ | InvalidRequestError
86
+ | UnexpectedClientError
87
+ | SDKValidationError
88
+ >
89
+ > {
90
+ return new APIPromise($do(
91
+ client,
92
+ request,
93
+ options,
94
+ ));
95
+ }
96
+
97
+ async function $do(
98
+ client: ClientCore,
99
+ request: operations.CreatePayoutRequest,
100
+ options?: RequestOptions,
101
+ ): Promise<
102
+ [
103
+ Result<
104
+ models.EntityPayoutResponse,
105
+ | errors.ErrorResponse
106
+ | ClientError
107
+ | ResponseValidationError
108
+ | ConnectionError
109
+ | RequestAbortedError
110
+ | RequestTimeoutError
111
+ | InvalidRequestError
112
+ | UnexpectedClientError
113
+ | SDKValidationError
114
+ >,
115
+ APICall,
116
+ ]
117
+ > {
118
+ const parsed = safeParse(
119
+ request,
120
+ (value) => operations.CreatePayoutRequest$outboundSchema.parse(value),
121
+ "Input validation failed",
122
+ );
123
+ if (!parsed.ok) {
124
+ return [parsed, { status: "invalid" }];
125
+ }
126
+ const payload = parsed.value;
127
+ const body = encodeJSON("body", payload["payout-request"], { explode: true });
128
+
129
+ const path = pathToFunc("/v2/payouts")();
130
+
131
+ const query = encodeFormQuery({
132
+ "testmode": payload.testmode ?? client._options.testmode,
133
+ });
134
+
135
+ const headers = new Headers(compactMap({
136
+ "Content-Type": "application/json",
137
+ Accept: "application/hal+json",
138
+ "idempotency-key": encodeSimple(
139
+ "idempotency-key",
140
+ payload["idempotency-key"],
141
+ { explode: false, charEncoding: "none" },
142
+ ),
143
+ }));
144
+
145
+ const securityInput = await extractSecurity(client._options.security);
146
+ const requestSecurity = resolveGlobalSecurity(securityInput);
147
+
148
+ const context = {
149
+ options: client._options,
150
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
151
+ operationID: "create-payout",
152
+ oAuth2Scopes: null,
153
+
154
+ resolvedSecurity: requestSecurity,
155
+
156
+ securitySource: client._options.security,
157
+ retryConfig: options?.retries
158
+ || client._options.retryConfig
159
+ || {
160
+ strategy: "backoff",
161
+ backoff: {
162
+ initialInterval: 500,
163
+ maxInterval: 5000,
164
+ exponent: 2,
165
+ maxElapsedTime: 7500,
166
+ },
167
+ retryConnectionErrors: true,
168
+ }
169
+ || { strategy: "none" },
170
+ retryCodes: options?.retryCodes || ["5xx"],
171
+ };
172
+
173
+ const requestRes = client._createRequest(context, {
174
+ security: requestSecurity,
175
+ method: "POST",
176
+ baseURL: options?.serverURL,
177
+ path: path,
178
+ headers: headers,
179
+ query: query,
180
+ body: body,
181
+ userAgent: client._options.userAgent,
182
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
183
+ }, options);
184
+ if (!requestRes.ok) {
185
+ return [requestRes, { status: "invalid" }];
186
+ }
187
+ const req = requestRes.value;
188
+
189
+ const doResult = await client._do(req, {
190
+ context,
191
+ isErrorStatusCode: (statusCode: number) =>
192
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
193
+ retryConfig: context.retryConfig,
194
+ retryCodes: context.retryCodes,
195
+ });
196
+ if (!doResult.ok) {
197
+ return [doResult, { status: "request-error", request: req }];
198
+ }
199
+ const response = doResult.value;
200
+
201
+ const responseFields = {
202
+ HttpMeta: { Response: response, Request: req },
203
+ };
204
+
205
+ const [result] = await M.match<
206
+ models.EntityPayoutResponse,
207
+ | errors.ErrorResponse
208
+ | ClientError
209
+ | ResponseValidationError
210
+ | ConnectionError
211
+ | RequestAbortedError
212
+ | RequestTimeoutError
213
+ | InvalidRequestError
214
+ | UnexpectedClientError
215
+ | SDKValidationError
216
+ >(
217
+ M.json(201, models.EntityPayoutResponse$inboundSchema, {
218
+ ctype: "application/hal+json",
219
+ }),
220
+ M.jsonErr(422, errors.ErrorResponse$inboundSchema, {
221
+ ctype: "application/hal+json",
222
+ }),
223
+ M.fail("4XX"),
224
+ M.fail("5XX"),
225
+ )(response, req, { extraFields: responseFields });
226
+ if (!result.ok) {
227
+ return [result, { status: "complete", request: req, response }];
228
+ }
229
+
230
+ return [result, { status: "complete", request: req, response }];
231
+ }
@@ -0,0 +1,201 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: dc969f7d14e9
4
+ */
5
+
6
+ import { ClientCore } from "../core.js";
7
+ import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
8
+ import { matchStatusCode } from "../lib/http.js";
9
+ import * as M from "../lib/matchers.js";
10
+ import { compactMap } from "../lib/primitives.js";
11
+ import { safeParse } from "../lib/schemas.js";
12
+ import { RequestOptions } from "../lib/sdks.js";
13
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
14
+ import { pathToFunc } from "../lib/url.js";
15
+ import { ClientError } from "../models/errors/clienterror.js";
16
+ import {
17
+ ConnectionError,
18
+ InvalidRequestError,
19
+ RequestAbortedError,
20
+ RequestTimeoutError,
21
+ UnexpectedClientError,
22
+ } from "../models/errors/httpclienterrors.js";
23
+ import * as errors from "../models/errors/index.js";
24
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
25
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
26
+ import * as models from "../models/index.js";
27
+ import * as operations from "../models/operations/index.js";
28
+ import { APICall, APIPromise } from "../types/async.js";
29
+ import { Result } from "../types/fp.js";
30
+
31
+ /**
32
+ * Get payout
33
+ *
34
+ * @remarks
35
+ * Retrieve a single payout by its ID.
36
+ */
37
+ export function payoutsGet(
38
+ client: ClientCore,
39
+ request: operations.GetPayoutRequest,
40
+ options?: RequestOptions,
41
+ ): APIPromise<
42
+ Result<
43
+ models.EntityPayoutResponse,
44
+ | errors.ErrorResponse
45
+ | ClientError
46
+ | ResponseValidationError
47
+ | ConnectionError
48
+ | RequestAbortedError
49
+ | RequestTimeoutError
50
+ | InvalidRequestError
51
+ | UnexpectedClientError
52
+ | SDKValidationError
53
+ >
54
+ > {
55
+ return new APIPromise($do(
56
+ client,
57
+ request,
58
+ options,
59
+ ));
60
+ }
61
+
62
+ async function $do(
63
+ client: ClientCore,
64
+ request: operations.GetPayoutRequest,
65
+ options?: RequestOptions,
66
+ ): Promise<
67
+ [
68
+ Result<
69
+ models.EntityPayoutResponse,
70
+ | errors.ErrorResponse
71
+ | ClientError
72
+ | ResponseValidationError
73
+ | ConnectionError
74
+ | RequestAbortedError
75
+ | RequestTimeoutError
76
+ | InvalidRequestError
77
+ | UnexpectedClientError
78
+ | SDKValidationError
79
+ >,
80
+ APICall,
81
+ ]
82
+ > {
83
+ const parsed = safeParse(
84
+ request,
85
+ (value) => operations.GetPayoutRequest$outboundSchema.parse(value),
86
+ "Input validation failed",
87
+ );
88
+ if (!parsed.ok) {
89
+ return [parsed, { status: "invalid" }];
90
+ }
91
+ const payload = parsed.value;
92
+ const body = null;
93
+
94
+ const pathParams = {
95
+ payoutId: encodeSimple("payoutId", payload.payoutId, {
96
+ explode: false,
97
+ charEncoding: "percent",
98
+ }),
99
+ };
100
+ const path = pathToFunc("/v2/payouts/{payoutId}")(pathParams);
101
+
102
+ const query = encodeFormQuery({
103
+ "testmode": payload.testmode ?? client._options.testmode,
104
+ });
105
+
106
+ const headers = new Headers(compactMap({
107
+ Accept: "application/hal+json",
108
+ "idempotency-key": encodeSimple(
109
+ "idempotency-key",
110
+ payload["idempotency-key"],
111
+ { explode: false, charEncoding: "none" },
112
+ ),
113
+ }));
114
+
115
+ const securityInput = await extractSecurity(client._options.security);
116
+ const requestSecurity = resolveGlobalSecurity(securityInput);
117
+
118
+ const context = {
119
+ options: client._options,
120
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
121
+ operationID: "get-payout",
122
+ oAuth2Scopes: null,
123
+
124
+ resolvedSecurity: requestSecurity,
125
+
126
+ securitySource: client._options.security,
127
+ retryConfig: options?.retries
128
+ || client._options.retryConfig
129
+ || {
130
+ strategy: "backoff",
131
+ backoff: {
132
+ initialInterval: 500,
133
+ maxInterval: 5000,
134
+ exponent: 2,
135
+ maxElapsedTime: 7500,
136
+ },
137
+ retryConnectionErrors: true,
138
+ }
139
+ || { strategy: "none" },
140
+ retryCodes: options?.retryCodes || ["5xx"],
141
+ };
142
+
143
+ const requestRes = client._createRequest(context, {
144
+ security: requestSecurity,
145
+ method: "GET",
146
+ baseURL: options?.serverURL,
147
+ path: path,
148
+ headers: headers,
149
+ query: query,
150
+ body: body,
151
+ userAgent: client._options.userAgent,
152
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
153
+ }, options);
154
+ if (!requestRes.ok) {
155
+ return [requestRes, { status: "invalid" }];
156
+ }
157
+ const req = requestRes.value;
158
+
159
+ const doResult = await client._do(req, {
160
+ context,
161
+ isErrorStatusCode: (statusCode: number) =>
162
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
163
+ retryConfig: context.retryConfig,
164
+ retryCodes: context.retryCodes,
165
+ });
166
+ if (!doResult.ok) {
167
+ return [doResult, { status: "request-error", request: req }];
168
+ }
169
+ const response = doResult.value;
170
+
171
+ const responseFields = {
172
+ HttpMeta: { Response: response, Request: req },
173
+ };
174
+
175
+ const [result] = await M.match<
176
+ models.EntityPayoutResponse,
177
+ | errors.ErrorResponse
178
+ | ClientError
179
+ | ResponseValidationError
180
+ | ConnectionError
181
+ | RequestAbortedError
182
+ | RequestTimeoutError
183
+ | InvalidRequestError
184
+ | UnexpectedClientError
185
+ | SDKValidationError
186
+ >(
187
+ M.json(200, models.EntityPayoutResponse$inboundSchema, {
188
+ ctype: "application/hal+json",
189
+ }),
190
+ M.jsonErr(404, errors.ErrorResponse$inboundSchema, {
191
+ ctype: "application/hal+json",
192
+ }),
193
+ M.fail("4XX"),
194
+ M.fail("5XX"),
195
+ )(response, req, { extraFields: responseFields });
196
+ if (!result.ok) {
197
+ return [result, { status: "complete", request: req, response }];
198
+ }
199
+
200
+ return [result, { status: "complete", request: req, response }];
201
+ }
@@ -0,0 +1,278 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ * @generated-id: 9b9d3a48147e
4
+ */
5
+
6
+ import { ClientCore } from "../core.js";
7
+ import { dlv } from "../lib/dlv.js";
8
+ import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
9
+ import { matchStatusCode } from "../lib/http.js";
10
+ import * as M from "../lib/matchers.js";
11
+ import { compactMap } from "../lib/primitives.js";
12
+ import { safeParse } from "../lib/schemas.js";
13
+ import { RequestOptions } from "../lib/sdks.js";
14
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
15
+ import { pathToFunc } from "../lib/url.js";
16
+ import { ClientError } from "../models/errors/clienterror.js";
17
+ import {
18
+ ConnectionError,
19
+ InvalidRequestError,
20
+ RequestAbortedError,
21
+ RequestTimeoutError,
22
+ UnexpectedClientError,
23
+ } from "../models/errors/httpclienterrors.js";
24
+ import * as errors from "../models/errors/index.js";
25
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
26
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
27
+ import * as operations from "../models/operations/index.js";
28
+ import { APICall, APIPromise } from "../types/async.js";
29
+ import { Result } from "../types/fp.js";
30
+ import {
31
+ createPageIterator,
32
+ haltIterator,
33
+ PageIterator,
34
+ Paginator,
35
+ URL_OVERRIDE,
36
+ } from "../types/operations.js";
37
+
38
+ /**
39
+ * List payouts
40
+ *
41
+ * @remarks
42
+ * Retrieve a list of all payouts for your organization, including payouts initiated automatically by the
43
+ * balance's payout schedule and payouts requested via the API or dashboard.
44
+ *
45
+ * Only payouts created on or after April 1st, 2026 are returned.
46
+ *
47
+ * The results are paginated. Use the `from` query parameter together with `_links.next` to iterate through
48
+ * the full result set.
49
+ */
50
+ export function payoutsList(
51
+ client: ClientCore,
52
+ request?: operations.ListPayoutsRequest | undefined,
53
+ options?: RequestOptions & { [URL_OVERRIDE]?: URL },
54
+ ): APIPromise<
55
+ PageIterator<
56
+ Result<
57
+ operations.ListPayoutsResponse,
58
+ | errors.ErrorResponse
59
+ | ClientError
60
+ | ResponseValidationError
61
+ | ConnectionError
62
+ | RequestAbortedError
63
+ | RequestTimeoutError
64
+ | InvalidRequestError
65
+ | UnexpectedClientError
66
+ | SDKValidationError
67
+ >,
68
+ { url: string }
69
+ >
70
+ > {
71
+ return new APIPromise($do(
72
+ client,
73
+ request,
74
+ options,
75
+ ));
76
+ }
77
+
78
+ async function $do(
79
+ client: ClientCore,
80
+ request?: operations.ListPayoutsRequest | undefined,
81
+ options?: RequestOptions & { [URL_OVERRIDE]?: URL },
82
+ ): Promise<
83
+ [
84
+ PageIterator<
85
+ Result<
86
+ operations.ListPayoutsResponse,
87
+ | errors.ErrorResponse
88
+ | ClientError
89
+ | ResponseValidationError
90
+ | ConnectionError
91
+ | RequestAbortedError
92
+ | RequestTimeoutError
93
+ | InvalidRequestError
94
+ | UnexpectedClientError
95
+ | SDKValidationError
96
+ >,
97
+ { url: string }
98
+ >,
99
+ APICall,
100
+ ]
101
+ > {
102
+ const parsed = safeParse(
103
+ request,
104
+ (value) =>
105
+ operations.ListPayoutsRequest$outboundSchema.optional().parse(value),
106
+ "Input validation failed",
107
+ );
108
+ if (!parsed.ok) {
109
+ return [haltIterator(parsed), { status: "invalid" }];
110
+ }
111
+ const payload = parsed.value;
112
+ const body = null;
113
+
114
+ const path = options?.[URL_OVERRIDE]
115
+ ? ""
116
+ : pathToFunc("/v2/payouts")();
117
+
118
+ const query = options?.[URL_OVERRIDE]
119
+ ? options[URL_OVERRIDE].search.substring(1)
120
+ : encodeFormQuery({
121
+ "balanceId": payload?.balanceId,
122
+ "from": payload?.from,
123
+ "limit": payload?.limit,
124
+ "sort": payload?.sort,
125
+ "testmode": payload?.testmode ?? client._options.testmode,
126
+ });
127
+
128
+ const headers = new Headers(compactMap({
129
+ Accept: "application/hal+json",
130
+ "idempotency-key": encodeSimple(
131
+ "idempotency-key",
132
+ payload?.["idempotency-key"],
133
+ { explode: false, charEncoding: "none" },
134
+ ),
135
+ }));
136
+
137
+ const securityInput = await extractSecurity(client._options.security);
138
+ const requestSecurity = resolveGlobalSecurity(securityInput);
139
+
140
+ const context = {
141
+ options: client._options,
142
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
143
+ operationID: "list-payouts",
144
+ oAuth2Scopes: null,
145
+
146
+ resolvedSecurity: requestSecurity,
147
+
148
+ securitySource: client._options.security,
149
+ retryConfig: options?.retries
150
+ || client._options.retryConfig
151
+ || {
152
+ strategy: "backoff",
153
+ backoff: {
154
+ initialInterval: 500,
155
+ maxInterval: 5000,
156
+ exponent: 2,
157
+ maxElapsedTime: 7500,
158
+ },
159
+ retryConnectionErrors: true,
160
+ }
161
+ || { strategy: "none" },
162
+ retryCodes: options?.retryCodes || ["5xx"],
163
+ };
164
+
165
+ const requestRes = client._createRequest(context, {
166
+ security: requestSecurity,
167
+ method: "GET",
168
+ baseURL: options?.[URL_OVERRIDE]?.href || options?.serverURL,
169
+ path: path,
170
+ headers: headers,
171
+ query: query,
172
+ body: body,
173
+ userAgent: client._options.userAgent,
174
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
175
+ }, options);
176
+ if (!requestRes.ok) {
177
+ return [haltIterator(requestRes), { status: "invalid" }];
178
+ }
179
+ const req = requestRes.value;
180
+
181
+ const doResult = await client._do(req, {
182
+ context,
183
+ isErrorStatusCode: (statusCode: number) =>
184
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
185
+ retryConfig: context.retryConfig,
186
+ retryCodes: context.retryCodes,
187
+ });
188
+ if (!doResult.ok) {
189
+ return [haltIterator(doResult), { status: "request-error", request: req }];
190
+ }
191
+ const response = doResult.value;
192
+
193
+ const responseFields = {
194
+ HttpMeta: { Response: response, Request: req },
195
+ };
196
+
197
+ const [result, raw] = await M.match<
198
+ operations.ListPayoutsResponse,
199
+ | errors.ErrorResponse
200
+ | ClientError
201
+ | ResponseValidationError
202
+ | ConnectionError
203
+ | RequestAbortedError
204
+ | RequestTimeoutError
205
+ | InvalidRequestError
206
+ | UnexpectedClientError
207
+ | SDKValidationError
208
+ >(
209
+ M.json(200, operations.ListPayoutsResponse$inboundSchema, {
210
+ ctype: "application/hal+json",
211
+ key: "Result",
212
+ }),
213
+ M.jsonErr(400, errors.ErrorResponse$inboundSchema, {
214
+ ctype: "application/hal+json",
215
+ }),
216
+ M.fail("4XX"),
217
+ M.fail("5XX"),
218
+ )(response, req, { extraFields: responseFields });
219
+ if (!result.ok) {
220
+ return [haltIterator(result), {
221
+ status: "complete",
222
+ request: req,
223
+ response,
224
+ }];
225
+ }
226
+
227
+ const nextFunc = (
228
+ responseData: unknown,
229
+ ): {
230
+ next: Paginator<
231
+ Result<
232
+ operations.ListPayoutsResponse,
233
+ | errors.ErrorResponse
234
+ | ClientError
235
+ | ResponseValidationError
236
+ | ConnectionError
237
+ | RequestAbortedError
238
+ | RequestTimeoutError
239
+ | InvalidRequestError
240
+ | UnexpectedClientError
241
+ | SDKValidationError
242
+ >
243
+ >;
244
+ "~next"?: { url: string };
245
+ } => {
246
+ let nextURL = dlv(responseData, "_links.next.href");
247
+ if (typeof nextURL !== "string") {
248
+ return { next: () => null };
249
+ }
250
+
251
+ try {
252
+ if (nextURL.startsWith("/")) {
253
+ nextURL = new URL(nextURL, client._baseURL ?? "").href;
254
+ }
255
+ new URL(nextURL);
256
+ } catch (_error) {
257
+ return { next: () => null };
258
+ }
259
+
260
+ const nextVal = () =>
261
+ payoutsList(
262
+ client,
263
+ {
264
+ ...request!,
265
+ },
266
+ { ...options, [URL_OVERRIDE]: new URL(nextURL) },
267
+ );
268
+
269
+ return { next: nextVal, "~next": { url: nextURL } };
270
+ };
271
+
272
+ const page = { ...result, ...nextFunc(raw) };
273
+ return [{ ...page, ...createPageIterator(page, (v) => !v.ok) }, {
274
+ status: "complete",
275
+ request: req,
276
+ response,
277
+ }];
278
+ }