@getivy/node-sdk 0.1.0-alpha.10

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 (256) hide show
  1. package/CHANGELOG.md +130 -0
  2. package/LICENSE +201 -0
  3. package/README.md +303 -0
  4. package/_shims/MultipartBody.d.ts +9 -0
  5. package/_shims/MultipartBody.d.ts.map +1 -0
  6. package/_shims/MultipartBody.js +16 -0
  7. package/_shims/MultipartBody.js.map +1 -0
  8. package/_shims/MultipartBody.mjs +12 -0
  9. package/_shims/MultipartBody.mjs.map +1 -0
  10. package/_shims/README.md +46 -0
  11. package/_shims/auto/runtime-bun.d.ts +5 -0
  12. package/_shims/auto/runtime-bun.d.ts.map +1 -0
  13. package/_shims/auto/runtime-bun.js +21 -0
  14. package/_shims/auto/runtime-bun.js.map +1 -0
  15. package/_shims/auto/runtime-bun.mjs +2 -0
  16. package/_shims/auto/runtime-bun.mjs.map +1 -0
  17. package/_shims/auto/runtime-node.d.ts +5 -0
  18. package/_shims/auto/runtime-node.d.ts.map +1 -0
  19. package/_shims/auto/runtime-node.js +21 -0
  20. package/_shims/auto/runtime-node.js.map +1 -0
  21. package/_shims/auto/runtime-node.mjs +2 -0
  22. package/_shims/auto/runtime-node.mjs.map +1 -0
  23. package/_shims/auto/runtime.d.ts +5 -0
  24. package/_shims/auto/runtime.d.ts.map +1 -0
  25. package/_shims/auto/runtime.js +21 -0
  26. package/_shims/auto/runtime.js.map +1 -0
  27. package/_shims/auto/runtime.mjs +2 -0
  28. package/_shims/auto/runtime.mjs.map +1 -0
  29. package/_shims/auto/types-node.d.ts +5 -0
  30. package/_shims/auto/types-node.d.ts.map +1 -0
  31. package/_shims/auto/types-node.js +21 -0
  32. package/_shims/auto/types-node.js.map +1 -0
  33. package/_shims/auto/types-node.mjs +2 -0
  34. package/_shims/auto/types-node.mjs.map +1 -0
  35. package/_shims/auto/types.d.ts +101 -0
  36. package/_shims/auto/types.js +3 -0
  37. package/_shims/auto/types.mjs +3 -0
  38. package/_shims/bun-runtime.d.ts +6 -0
  39. package/_shims/bun-runtime.d.ts.map +1 -0
  40. package/_shims/bun-runtime.js +14 -0
  41. package/_shims/bun-runtime.js.map +1 -0
  42. package/_shims/bun-runtime.mjs +10 -0
  43. package/_shims/bun-runtime.mjs.map +1 -0
  44. package/_shims/index.d.ts +81 -0
  45. package/_shims/index.js +13 -0
  46. package/_shims/index.mjs +7 -0
  47. package/_shims/manual-types.d.ts +12 -0
  48. package/_shims/manual-types.js +3 -0
  49. package/_shims/manual-types.mjs +3 -0
  50. package/_shims/node-runtime.d.ts +3 -0
  51. package/_shims/node-runtime.d.ts.map +1 -0
  52. package/_shims/node-runtime.js +89 -0
  53. package/_shims/node-runtime.js.map +1 -0
  54. package/_shims/node-runtime.mjs +56 -0
  55. package/_shims/node-runtime.mjs.map +1 -0
  56. package/_shims/node-types.d.ts +42 -0
  57. package/_shims/node-types.js +3 -0
  58. package/_shims/node-types.mjs +3 -0
  59. package/_shims/registry.d.ts +37 -0
  60. package/_shims/registry.d.ts.map +1 -0
  61. package/_shims/registry.js +41 -0
  62. package/_shims/registry.js.map +1 -0
  63. package/_shims/registry.mjs +37 -0
  64. package/_shims/registry.mjs.map +1 -0
  65. package/_shims/web-runtime.d.ts +5 -0
  66. package/_shims/web-runtime.d.ts.map +1 -0
  67. package/_shims/web-runtime.js +78 -0
  68. package/_shims/web-runtime.js.map +1 -0
  69. package/_shims/web-runtime.mjs +71 -0
  70. package/_shims/web-runtime.mjs.map +1 -0
  71. package/_shims/web-types.d.ts +83 -0
  72. package/_shims/web-types.js +3 -0
  73. package/_shims/web-types.mjs +3 -0
  74. package/core.d.ts +241 -0
  75. package/core.d.ts.map +1 -0
  76. package/core.js +915 -0
  77. package/core.js.map +1 -0
  78. package/core.mjs +883 -0
  79. package/core.mjs.map +1 -0
  80. package/error.d.ts +47 -0
  81. package/error.d.ts.map +1 -0
  82. package/error.js +113 -0
  83. package/error.js.map +1 -0
  84. package/error.mjs +97 -0
  85. package/error.mjs.map +1 -0
  86. package/index.d.mts +160 -0
  87. package/index.d.ts +160 -0
  88. package/index.d.ts.map +1 -0
  89. package/index.js +167 -0
  90. package/index.js.map +1 -0
  91. package/index.mjs +124 -0
  92. package/index.mjs.map +1 -0
  93. package/package.json +124 -0
  94. package/resource.d.ts +6 -0
  95. package/resource.d.ts.map +1 -0
  96. package/resource.js +11 -0
  97. package/resource.js.map +1 -0
  98. package/resource.mjs +7 -0
  99. package/resource.mjs.map +1 -0
  100. package/resources/balance.d.ts +34 -0
  101. package/resources/balance.d.ts.map +1 -0
  102. package/resources/balance.js +16 -0
  103. package/resources/balance.js.map +1 -0
  104. package/resources/balance.mjs +12 -0
  105. package/resources/balance.mjs.map +1 -0
  106. package/resources/banks.d.ts +235 -0
  107. package/resources/banks.d.ts.map +1 -0
  108. package/resources/banks.js +30 -0
  109. package/resources/banks.js.map +1 -0
  110. package/resources/banks.mjs +26 -0
  111. package/resources/banks.mjs.map +1 -0
  112. package/resources/capabilities.d.ts +28 -0
  113. package/resources/capabilities.d.ts.map +1 -0
  114. package/resources/capabilities.js +16 -0
  115. package/resources/capabilities.js.map +1 -0
  116. package/resources/capabilities.mjs +12 -0
  117. package/resources/capabilities.mjs.map +1 -0
  118. package/resources/charges.d.ts +73 -0
  119. package/resources/charges.d.ts.map +1 -0
  120. package/resources/charges.js +15 -0
  121. package/resources/charges.js.map +1 -0
  122. package/resources/charges.mjs +11 -0
  123. package/resources/charges.mjs.map +1 -0
  124. package/resources/checkoutsession.d.ts +1504 -0
  125. package/resources/checkoutsession.d.ts.map +1 -0
  126. package/resources/checkoutsession.js +30 -0
  127. package/resources/checkoutsession.js.map +1 -0
  128. package/resources/checkoutsession.mjs +26 -0
  129. package/resources/checkoutsession.mjs.map +1 -0
  130. package/resources/customers.d.ts +82 -0
  131. package/resources/customers.d.ts.map +1 -0
  132. package/resources/customers.js +21 -0
  133. package/resources/customers.js.map +1 -0
  134. package/resources/customers.mjs +17 -0
  135. package/resources/customers.mjs.map +1 -0
  136. package/resources/index.d.ts +14 -0
  137. package/resources/index.d.ts.map +1 -0
  138. package/resources/index.js +31 -0
  139. package/resources/index.js.map +1 -0
  140. package/resources/index.mjs +15 -0
  141. package/resources/index.mjs.map +1 -0
  142. package/resources/mandates.d.ts +91 -0
  143. package/resources/mandates.d.ts.map +1 -0
  144. package/resources/mandates.js +27 -0
  145. package/resources/mandates.js.map +1 -0
  146. package/resources/mandates.mjs +23 -0
  147. package/resources/mandates.mjs.map +1 -0
  148. package/resources/orders.d.ts +1239 -0
  149. package/resources/orders.d.ts.map +1 -0
  150. package/resources/orders.js +23 -0
  151. package/resources/orders.js.map +1 -0
  152. package/resources/orders.mjs +19 -0
  153. package/resources/orders.mjs.map +1 -0
  154. package/resources/payouts.d.ts +224 -0
  155. package/resources/payouts.d.ts.map +1 -0
  156. package/resources/payouts.js +28 -0
  157. package/resources/payouts.js.map +1 -0
  158. package/resources/payouts.mjs +24 -0
  159. package/resources/payouts.mjs.map +1 -0
  160. package/resources/refunds.d.ts +138 -0
  161. package/resources/refunds.d.ts.map +1 -0
  162. package/resources/refunds.js +28 -0
  163. package/resources/refunds.js.map +1 -0
  164. package/resources/refunds.mjs +24 -0
  165. package/resources/refunds.mjs.map +1 -0
  166. package/resources/reports.d.ts +120 -0
  167. package/resources/reports.d.ts.map +1 -0
  168. package/resources/reports.js +31 -0
  169. package/resources/reports.js.map +1 -0
  170. package/resources/reports.mjs +27 -0
  171. package/resources/reports.mjs.map +1 -0
  172. package/resources/subaccounts.d.ts +49 -0
  173. package/resources/subaccounts.d.ts.map +1 -0
  174. package/resources/subaccounts.js +22 -0
  175. package/resources/subaccounts.js.map +1 -0
  176. package/resources/subaccounts.mjs +18 -0
  177. package/resources/subaccounts.mjs.map +1 -0
  178. package/resources/webhooksubscription.d.ts +155 -0
  179. package/resources/webhooksubscription.d.ts.map +1 -0
  180. package/resources/webhooksubscription.js +42 -0
  181. package/resources/webhooksubscription.js.map +1 -0
  182. package/resources/webhooksubscription.mjs +38 -0
  183. package/resources/webhooksubscription.mjs.map +1 -0
  184. package/shims/node.d.ts +30 -0
  185. package/shims/node.d.ts.map +1 -0
  186. package/shims/node.js +31 -0
  187. package/shims/node.js.map +1 -0
  188. package/shims/node.mjs +5 -0
  189. package/shims/node.mjs.map +1 -0
  190. package/shims/web.d.ts +26 -0
  191. package/shims/web.d.ts.map +1 -0
  192. package/shims/web.js +31 -0
  193. package/shims/web.js.map +1 -0
  194. package/shims/web.mjs +5 -0
  195. package/shims/web.mjs.map +1 -0
  196. package/src/_shims/MultipartBody.ts +9 -0
  197. package/src/_shims/README.md +46 -0
  198. package/src/_shims/auto/runtime-bun.ts +4 -0
  199. package/src/_shims/auto/runtime-node.ts +4 -0
  200. package/src/_shims/auto/runtime.ts +4 -0
  201. package/src/_shims/auto/types-node.ts +4 -0
  202. package/src/_shims/auto/types.d.ts +101 -0
  203. package/src/_shims/auto/types.js +3 -0
  204. package/src/_shims/auto/types.mjs +3 -0
  205. package/src/_shims/bun-runtime.ts +14 -0
  206. package/src/_shims/index.d.ts +81 -0
  207. package/src/_shims/index.js +13 -0
  208. package/src/_shims/index.mjs +7 -0
  209. package/src/_shims/manual-types.d.ts +12 -0
  210. package/src/_shims/manual-types.js +3 -0
  211. package/src/_shims/manual-types.mjs +3 -0
  212. package/src/_shims/node-runtime.ts +81 -0
  213. package/src/_shims/node-types.d.ts +42 -0
  214. package/src/_shims/node-types.js +3 -0
  215. package/src/_shims/node-types.mjs +3 -0
  216. package/src/_shims/registry.ts +67 -0
  217. package/src/_shims/web-runtime.ts +103 -0
  218. package/src/_shims/web-types.d.ts +83 -0
  219. package/src/_shims/web-types.js +3 -0
  220. package/src/_shims/web-types.mjs +3 -0
  221. package/src/core.ts +1208 -0
  222. package/src/error.ts +130 -0
  223. package/src/index.ts +422 -0
  224. package/src/lib/.keep +4 -0
  225. package/src/resource.ts +11 -0
  226. package/src/resources/balance.ts +49 -0
  227. package/src/resources/banks.ts +1551 -0
  228. package/src/resources/capabilities.ts +291 -0
  229. package/src/resources/charges.ts +95 -0
  230. package/src/resources/checkoutsession.ts +6935 -0
  231. package/src/resources/customers.ts +111 -0
  232. package/src/resources/index.ts +88 -0
  233. package/src/resources/mandates.ts +135 -0
  234. package/src/resources/orders.ts +3174 -0
  235. package/src/resources/payouts.ts +297 -0
  236. package/src/resources/refunds.ts +183 -0
  237. package/src/resources/reports.ts +172 -0
  238. package/src/resources/subaccounts.ts +73 -0
  239. package/src/resources/webhooksubscription.ts +353 -0
  240. package/src/shims/node.ts +50 -0
  241. package/src/shims/web.ts +50 -0
  242. package/src/tsconfig.json +11 -0
  243. package/src/uploads.ts +255 -0
  244. package/src/version.ts +1 -0
  245. package/uploads.d.ts +75 -0
  246. package/uploads.d.ts.map +1 -0
  247. package/uploads.js +171 -0
  248. package/uploads.js.map +1 -0
  249. package/uploads.mjs +158 -0
  250. package/uploads.mjs.map +1 -0
  251. package/version.d.ts +2 -0
  252. package/version.d.ts.map +1 -0
  253. package/version.js +5 -0
  254. package/version.js.map +1 -0
  255. package/version.mjs +2 -0
  256. package/version.mjs.map +1 -0
package/src/error.ts ADDED
@@ -0,0 +1,130 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { castToError, Headers } from './core';
4
+
5
+ export class IvyError extends Error {}
6
+
7
+ export class APIError<
8
+ TStatus extends number | undefined = number | undefined,
9
+ THeaders extends Headers | undefined = Headers | undefined,
10
+ TError extends Object | undefined = Object | undefined,
11
+ > extends IvyError {
12
+ /** HTTP status for the response that caused the error */
13
+ readonly status: TStatus;
14
+ /** HTTP headers for the response that caused the error */
15
+ readonly headers: THeaders;
16
+ /** JSON body of the response that caused the error */
17
+ readonly error: TError;
18
+
19
+ constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders) {
20
+ super(`${APIError.makeMessage(status, error, message)}`);
21
+ this.status = status;
22
+ this.headers = headers;
23
+ this.error = error;
24
+ }
25
+
26
+ private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
27
+ const msg =
28
+ error?.message ?
29
+ typeof error.message === 'string' ?
30
+ error.message
31
+ : JSON.stringify(error.message)
32
+ : error ? JSON.stringify(error)
33
+ : message;
34
+
35
+ if (status && msg) {
36
+ return `${status} ${msg}`;
37
+ }
38
+ if (status) {
39
+ return `${status} status code (no body)`;
40
+ }
41
+ if (msg) {
42
+ return msg;
43
+ }
44
+ return '(no status code or body)';
45
+ }
46
+
47
+ static generate(
48
+ status: number | undefined,
49
+ errorResponse: Object | undefined,
50
+ message: string | undefined,
51
+ headers: Headers | undefined,
52
+ ): APIError {
53
+ if (!status || !headers) {
54
+ return new APIConnectionError({ message, cause: castToError(errorResponse) });
55
+ }
56
+
57
+ const error = errorResponse as Record<string, any>;
58
+
59
+ if (status === 400) {
60
+ return new BadRequestError(status, error, message, headers);
61
+ }
62
+
63
+ if (status === 401) {
64
+ return new AuthenticationError(status, error, message, headers);
65
+ }
66
+
67
+ if (status === 403) {
68
+ return new PermissionDeniedError(status, error, message, headers);
69
+ }
70
+
71
+ if (status === 404) {
72
+ return new NotFoundError(status, error, message, headers);
73
+ }
74
+
75
+ if (status === 409) {
76
+ return new ConflictError(status, error, message, headers);
77
+ }
78
+
79
+ if (status === 422) {
80
+ return new UnprocessableEntityError(status, error, message, headers);
81
+ }
82
+
83
+ if (status === 429) {
84
+ return new RateLimitError(status, error, message, headers);
85
+ }
86
+
87
+ if (status >= 500) {
88
+ return new InternalServerError(status, error, message, headers);
89
+ }
90
+
91
+ return new APIError(status, error, message, headers);
92
+ }
93
+ }
94
+
95
+ export class APIUserAbortError extends APIError<undefined, undefined, undefined> {
96
+ constructor({ message }: { message?: string } = {}) {
97
+ super(undefined, undefined, message || 'Request was aborted.', undefined);
98
+ }
99
+ }
100
+
101
+ export class APIConnectionError extends APIError<undefined, undefined, undefined> {
102
+ constructor({ message, cause }: { message?: string | undefined; cause?: Error | undefined }) {
103
+ super(undefined, undefined, message || 'Connection error.', undefined);
104
+ // in some environments the 'cause' property is already declared
105
+ // @ts-ignore
106
+ if (cause) this.cause = cause;
107
+ }
108
+ }
109
+
110
+ export class APIConnectionTimeoutError extends APIConnectionError {
111
+ constructor({ message }: { message?: string } = {}) {
112
+ super({ message: message ?? 'Request timed out.' });
113
+ }
114
+ }
115
+
116
+ export class BadRequestError extends APIError<400, Headers> {}
117
+
118
+ export class AuthenticationError extends APIError<401, Headers> {}
119
+
120
+ export class PermissionDeniedError extends APIError<403, Headers> {}
121
+
122
+ export class NotFoundError extends APIError<404, Headers> {}
123
+
124
+ export class ConflictError extends APIError<409, Headers> {}
125
+
126
+ export class UnprocessableEntityError extends APIError<422, Headers> {}
127
+
128
+ export class RateLimitError extends APIError<429, Headers> {}
129
+
130
+ export class InternalServerError extends APIError<number, Headers> {}
package/src/index.ts ADDED
@@ -0,0 +1,422 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { type Agent } from './_shims/index';
4
+ import * as Core from './core';
5
+ import * as Errors from './error';
6
+ import * as Uploads from './uploads';
7
+ import * as API from './resources/index';
8
+ import { Balance, BalanceRetrieveParams, BalanceRetrieveResponse } from './resources/balance';
9
+ import {
10
+ BankListParams,
11
+ BankListResponse,
12
+ BankRetrieveParams,
13
+ BankRetrieveResponse,
14
+ BankSearchParams,
15
+ BankSearchResponse,
16
+ Banks,
17
+ } from './resources/banks';
18
+ import { Capabilities, CapabilityRetrieveParams, CapabilityRetrieveResponse } from './resources/capabilities';
19
+ import { Charge, ChargeCreateParams, Charges } from './resources/charges';
20
+ import {
21
+ Checkoutsession,
22
+ CheckoutsessionCreateParams,
23
+ CheckoutsessionCreateResponse,
24
+ CheckoutsessionExpireParams,
25
+ CheckoutsessionExpireResponse,
26
+ CheckoutsessionRetrieveParams,
27
+ CheckoutsessionRetrieveResponse,
28
+ } from './resources/checkoutsession';
29
+ import {
30
+ CustomerCreateParams,
31
+ CustomerCreateResponse,
32
+ CustomerRetrieveParams,
33
+ CustomerRetrieveResponse,
34
+ Customers,
35
+ } from './resources/customers';
36
+ import {
37
+ MandateLookupParams,
38
+ MandateResponse,
39
+ MandateRetrieveParams,
40
+ MandateRevokeParams,
41
+ MandateRevokeResponse,
42
+ Mandates,
43
+ } from './resources/mandates';
44
+ import {
45
+ OrderRetrieveParams,
46
+ OrderRetrieveResponse,
47
+ OrderUpdateParams,
48
+ OrderUpdateResponse,
49
+ Orders,
50
+ } from './resources/orders';
51
+ import {
52
+ PayoutCreateParams,
53
+ PayoutListParams,
54
+ PayoutListResponse,
55
+ PayoutRetrieveParams,
56
+ Payouts,
57
+ PublicUserPayout,
58
+ } from './resources/payouts';
59
+ import {
60
+ RefundBatchParams,
61
+ RefundBatchResponse,
62
+ RefundCreateParams,
63
+ RefundResponse,
64
+ Refunds,
65
+ } from './resources/refunds';
66
+ import {
67
+ PayoutReport,
68
+ ReportCreateParams,
69
+ ReportCreateResponse,
70
+ ReportDownloadParams,
71
+ ReportRetrieveParams,
72
+ ReportRetrieveResponse,
73
+ Reports,
74
+ } from './resources/reports';
75
+ import {
76
+ Subaccount,
77
+ SubaccountCreateParams,
78
+ SubaccountRetrieveParams,
79
+ Subaccounts,
80
+ } from './resources/subaccounts';
81
+ import {
82
+ Webhooksubscription,
83
+ WebhooksubscriptionCreateParams,
84
+ WebhooksubscriptionCreateResponse,
85
+ WebhooksubscriptionDeleteParams,
86
+ WebhooksubscriptionDeleteResponse,
87
+ WebhooksubscriptionListParams,
88
+ WebhooksubscriptionListResponse,
89
+ WebhooksubscriptionPingParams,
90
+ WebhooksubscriptionPingResponse,
91
+ WebhooksubscriptionUpdateParams,
92
+ WebhooksubscriptionUpdateResponse,
93
+ } from './resources/webhooksubscription';
94
+
95
+ const environments = {
96
+ production: 'https://api.getivy.de',
97
+ sandbox: 'https://api.sand.getivy.de',
98
+ };
99
+ type Environment = keyof typeof environments;
100
+
101
+ export interface ClientOptions {
102
+ /**
103
+ * API key for authentication with Ivy API
104
+ */
105
+ apiKey?: string | undefined;
106
+
107
+ /**
108
+ * Specifies the environment to use for the API.
109
+ *
110
+ * Each environment maps to a different base URL:
111
+ * - `production` corresponds to `https://api.getivy.de`
112
+ * - `sandbox` corresponds to `https://api.sand.getivy.de`
113
+ */
114
+ environment?: Environment | undefined;
115
+
116
+ /**
117
+ * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
118
+ *
119
+ * Defaults to process.env['IVY_BASE_URL'].
120
+ */
121
+ baseURL?: string | null | undefined;
122
+
123
+ /**
124
+ * The maximum amount of time (in milliseconds) that the client should wait for a response
125
+ * from the server before timing out a single request.
126
+ *
127
+ * Note that request timeouts are retried by default, so in a worst-case scenario you may wait
128
+ * much longer than this timeout before the promise succeeds or fails.
129
+ */
130
+ timeout?: number | undefined;
131
+
132
+ /**
133
+ * An HTTP agent used to manage HTTP(S) connections.
134
+ *
135
+ * If not provided, an agent will be constructed by default in the Node.js environment,
136
+ * otherwise no agent is used.
137
+ */
138
+ httpAgent?: Agent | undefined;
139
+
140
+ /**
141
+ * Specify a custom `fetch` function implementation.
142
+ *
143
+ * If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
144
+ * defined globally.
145
+ */
146
+ fetch?: Core.Fetch | undefined;
147
+
148
+ /**
149
+ * The maximum number of times that the client will retry a request in case of a
150
+ * temporary failure, like a network error or a 5XX error from the server.
151
+ *
152
+ * @default 2
153
+ */
154
+ maxRetries?: number | undefined;
155
+
156
+ /**
157
+ * Default headers to include with every request to the API.
158
+ *
159
+ * These can be removed in individual requests by explicitly setting the
160
+ * header to `undefined` or `null` in request options.
161
+ */
162
+ defaultHeaders?: Core.Headers | undefined;
163
+
164
+ /**
165
+ * Default query parameters to include with every request to the API.
166
+ *
167
+ * These can be removed in individual requests by explicitly setting the
168
+ * param to `undefined` in request options.
169
+ */
170
+ defaultQuery?: Core.DefaultQuery | undefined;
171
+ }
172
+
173
+ /**
174
+ * API Client for interfacing with the Ivy API.
175
+ */
176
+ export class Ivy extends Core.APIClient {
177
+ apiKey: string;
178
+
179
+ private _options: ClientOptions;
180
+
181
+ /**
182
+ * API Client for interfacing with the Ivy API.
183
+ *
184
+ * @param {string | undefined} [opts.apiKey=process.env['IVY_API_KEY'] ?? undefined]
185
+ * @param {Environment} [opts.environment=production] - Specifies the environment URL to use for the API.
186
+ * @param {string} [opts.baseURL=process.env['IVY_BASE_URL'] ?? https://api.getivy.de] - Override the default base URL for the API.
187
+ * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
188
+ * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
189
+ * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
190
+ * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
191
+ * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
192
+ * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
193
+ */
194
+ constructor({
195
+ baseURL = Core.readEnv('IVY_BASE_URL'),
196
+ apiKey = Core.readEnv('IVY_API_KEY'),
197
+ ...opts
198
+ }: ClientOptions = {}) {
199
+ if (apiKey === undefined) {
200
+ throw new Errors.IvyError(
201
+ "The IVY_API_KEY environment variable is missing or empty; either provide it, or instantiate the Ivy client with an apiKey option, like new Ivy({ apiKey: 'My API Key' }).",
202
+ );
203
+ }
204
+
205
+ const options: ClientOptions = {
206
+ apiKey,
207
+ ...opts,
208
+ baseURL,
209
+ environment: opts.environment ?? 'production',
210
+ };
211
+
212
+ if (baseURL && opts.environment) {
213
+ throw new Errors.IvyError(
214
+ 'Ambiguous URL; The `baseURL` option (or IVY_BASE_URL env var) and the `environment` option are given. If you want to use the environment you must pass baseURL: null',
215
+ );
216
+ }
217
+
218
+ super({
219
+ baseURL: options.baseURL || environments[options.environment || 'production'],
220
+ timeout: options.timeout ?? 60000 /* 1 minute */,
221
+ httpAgent: options.httpAgent,
222
+ maxRetries: options.maxRetries,
223
+ fetch: options.fetch,
224
+ });
225
+
226
+ this._options = options;
227
+
228
+ this.apiKey = apiKey;
229
+ }
230
+
231
+ banks: API.Banks = new API.Banks(this);
232
+ checkoutsession: API.Checkoutsession = new API.Checkoutsession(this);
233
+ customers: API.Customers = new API.Customers(this);
234
+ orders: API.Orders = new API.Orders(this);
235
+ charges: API.Charges = new API.Charges(this);
236
+ mandates: API.Mandates = new API.Mandates(this);
237
+ capabilities: API.Capabilities = new API.Capabilities(this);
238
+ refunds: API.Refunds = new API.Refunds(this);
239
+ payouts: API.Payouts = new API.Payouts(this);
240
+ reports: API.Reports = new API.Reports(this);
241
+ subaccounts: API.Subaccounts = new API.Subaccounts(this);
242
+ balance: API.Balance = new API.Balance(this);
243
+ webhooksubscription: API.Webhooksubscription = new API.Webhooksubscription(this);
244
+
245
+ protected override defaultQuery(): Core.DefaultQuery | undefined {
246
+ return this._options.defaultQuery;
247
+ }
248
+
249
+ protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers {
250
+ return {
251
+ ...super.defaultHeaders(opts),
252
+ ...this._options.defaultHeaders,
253
+ };
254
+ }
255
+
256
+ protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
257
+ return { 'X-Ivy-Api-Key': this.apiKey };
258
+ }
259
+
260
+ static Ivy = this;
261
+ static DEFAULT_TIMEOUT = 60000; // 1 minute
262
+
263
+ static IvyError = Errors.IvyError;
264
+ static APIError = Errors.APIError;
265
+ static APIConnectionError = Errors.APIConnectionError;
266
+ static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
267
+ static APIUserAbortError = Errors.APIUserAbortError;
268
+ static NotFoundError = Errors.NotFoundError;
269
+ static ConflictError = Errors.ConflictError;
270
+ static RateLimitError = Errors.RateLimitError;
271
+ static BadRequestError = Errors.BadRequestError;
272
+ static AuthenticationError = Errors.AuthenticationError;
273
+ static InternalServerError = Errors.InternalServerError;
274
+ static PermissionDeniedError = Errors.PermissionDeniedError;
275
+ static UnprocessableEntityError = Errors.UnprocessableEntityError;
276
+
277
+ static toFile = Uploads.toFile;
278
+ static fileFromPath = Uploads.fileFromPath;
279
+ }
280
+
281
+ Ivy.Banks = Banks;
282
+ Ivy.Checkoutsession = Checkoutsession;
283
+ Ivy.Customers = Customers;
284
+ Ivy.Orders = Orders;
285
+ Ivy.Charges = Charges;
286
+ Ivy.Mandates = Mandates;
287
+ Ivy.Capabilities = Capabilities;
288
+ Ivy.Refunds = Refunds;
289
+ Ivy.Payouts = Payouts;
290
+ Ivy.Reports = Reports;
291
+ Ivy.Subaccounts = Subaccounts;
292
+ Ivy.Balance = Balance;
293
+ Ivy.Webhooksubscription = Webhooksubscription;
294
+ export declare namespace Ivy {
295
+ export type RequestOptions = Core.RequestOptions;
296
+
297
+ export {
298
+ Banks as Banks,
299
+ type BankRetrieveResponse as BankRetrieveResponse,
300
+ type BankListResponse as BankListResponse,
301
+ type BankSearchResponse as BankSearchResponse,
302
+ type BankRetrieveParams as BankRetrieveParams,
303
+ type BankListParams as BankListParams,
304
+ type BankSearchParams as BankSearchParams,
305
+ };
306
+
307
+ export {
308
+ Checkoutsession as Checkoutsession,
309
+ type CheckoutsessionCreateResponse as CheckoutsessionCreateResponse,
310
+ type CheckoutsessionRetrieveResponse as CheckoutsessionRetrieveResponse,
311
+ type CheckoutsessionExpireResponse as CheckoutsessionExpireResponse,
312
+ type CheckoutsessionCreateParams as CheckoutsessionCreateParams,
313
+ type CheckoutsessionRetrieveParams as CheckoutsessionRetrieveParams,
314
+ type CheckoutsessionExpireParams as CheckoutsessionExpireParams,
315
+ };
316
+
317
+ export {
318
+ Customers as Customers,
319
+ type CustomerCreateResponse as CustomerCreateResponse,
320
+ type CustomerRetrieveResponse as CustomerRetrieveResponse,
321
+ type CustomerCreateParams as CustomerCreateParams,
322
+ type CustomerRetrieveParams as CustomerRetrieveParams,
323
+ };
324
+
325
+ export {
326
+ Orders as Orders,
327
+ type OrderRetrieveResponse as OrderRetrieveResponse,
328
+ type OrderUpdateResponse as OrderUpdateResponse,
329
+ type OrderRetrieveParams as OrderRetrieveParams,
330
+ type OrderUpdateParams as OrderUpdateParams,
331
+ };
332
+
333
+ export { Charges as Charges, type Charge as Charge, type ChargeCreateParams as ChargeCreateParams };
334
+
335
+ export {
336
+ Mandates as Mandates,
337
+ type MandateResponse as MandateResponse,
338
+ type MandateRevokeResponse as MandateRevokeResponse,
339
+ type MandateRetrieveParams as MandateRetrieveParams,
340
+ type MandateLookupParams as MandateLookupParams,
341
+ type MandateRevokeParams as MandateRevokeParams,
342
+ };
343
+
344
+ export {
345
+ Capabilities as Capabilities,
346
+ type CapabilityRetrieveResponse as CapabilityRetrieveResponse,
347
+ type CapabilityRetrieveParams as CapabilityRetrieveParams,
348
+ };
349
+
350
+ export {
351
+ Refunds as Refunds,
352
+ type RefundResponse as RefundResponse,
353
+ type RefundBatchResponse as RefundBatchResponse,
354
+ type RefundCreateParams as RefundCreateParams,
355
+ type RefundBatchParams as RefundBatchParams,
356
+ };
357
+
358
+ export {
359
+ Payouts as Payouts,
360
+ type PublicUserPayout as PublicUserPayout,
361
+ type PayoutListResponse as PayoutListResponse,
362
+ type PayoutCreateParams as PayoutCreateParams,
363
+ type PayoutRetrieveParams as PayoutRetrieveParams,
364
+ type PayoutListParams as PayoutListParams,
365
+ };
366
+
367
+ export {
368
+ Reports as Reports,
369
+ type PayoutReport as PayoutReport,
370
+ type ReportCreateResponse as ReportCreateResponse,
371
+ type ReportRetrieveResponse as ReportRetrieveResponse,
372
+ type ReportCreateParams as ReportCreateParams,
373
+ type ReportRetrieveParams as ReportRetrieveParams,
374
+ type ReportDownloadParams as ReportDownloadParams,
375
+ };
376
+
377
+ export {
378
+ Subaccounts as Subaccounts,
379
+ type Subaccount as Subaccount,
380
+ type SubaccountCreateParams as SubaccountCreateParams,
381
+ type SubaccountRetrieveParams as SubaccountRetrieveParams,
382
+ };
383
+
384
+ export {
385
+ Balance as Balance,
386
+ type BalanceRetrieveResponse as BalanceRetrieveResponse,
387
+ type BalanceRetrieveParams as BalanceRetrieveParams,
388
+ };
389
+
390
+ export {
391
+ Webhooksubscription as Webhooksubscription,
392
+ type WebhooksubscriptionCreateResponse as WebhooksubscriptionCreateResponse,
393
+ type WebhooksubscriptionUpdateResponse as WebhooksubscriptionUpdateResponse,
394
+ type WebhooksubscriptionListResponse as WebhooksubscriptionListResponse,
395
+ type WebhooksubscriptionDeleteResponse as WebhooksubscriptionDeleteResponse,
396
+ type WebhooksubscriptionPingResponse as WebhooksubscriptionPingResponse,
397
+ type WebhooksubscriptionCreateParams as WebhooksubscriptionCreateParams,
398
+ type WebhooksubscriptionUpdateParams as WebhooksubscriptionUpdateParams,
399
+ type WebhooksubscriptionListParams as WebhooksubscriptionListParams,
400
+ type WebhooksubscriptionDeleteParams as WebhooksubscriptionDeleteParams,
401
+ type WebhooksubscriptionPingParams as WebhooksubscriptionPingParams,
402
+ };
403
+ }
404
+
405
+ export { toFile, fileFromPath } from './uploads';
406
+ export {
407
+ IvyError,
408
+ APIError,
409
+ APIConnectionError,
410
+ APIConnectionTimeoutError,
411
+ APIUserAbortError,
412
+ NotFoundError,
413
+ ConflictError,
414
+ RateLimitError,
415
+ BadRequestError,
416
+ AuthenticationError,
417
+ InternalServerError,
418
+ PermissionDeniedError,
419
+ UnprocessableEntityError,
420
+ } from './error';
421
+
422
+ export default Ivy;
package/src/lib/.keep ADDED
@@ -0,0 +1,4 @@
1
+ File generated from our OpenAPI spec by Stainless.
2
+
3
+ This directory can be used to store custom files to expand the SDK.
4
+ It is ignored by Stainless code generation and its content (other than this keep file) won't be touched.
@@ -0,0 +1,11 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import type { Ivy } from './index';
4
+
5
+ export class APIResource {
6
+ protected _client: Ivy;
7
+
8
+ constructor(client: Ivy) {
9
+ this._client = client;
10
+ }
11
+ }
@@ -0,0 +1,49 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../resource';
4
+ import * as Core from '../core';
5
+
6
+ export class Balance extends APIResource {
7
+ /**
8
+ * Retrieve the balance of your Ivy account. The balance is the money currently
9
+ * available on your Ivy account. It is broken down by currency.
10
+ */
11
+ retrieve(
12
+ body: BalanceRetrieveParams,
13
+ options?: Core.RequestOptions,
14
+ ): Core.APIPromise<BalanceRetrieveResponse> {
15
+ return this._client.post('/api/service/balance/retrieve', { body, ...options });
16
+ }
17
+ }
18
+
19
+ /**
20
+ * Returns the Balance of your Ivy account
21
+ */
22
+ export interface BalanceRetrieveResponse {
23
+ balances: Array<BalanceRetrieveResponse.Balance>;
24
+ }
25
+
26
+ export namespace BalanceRetrieveResponse {
27
+ export interface Balance {
28
+ /**
29
+ * The amount of money available on your Ivy account for this currency
30
+ */
31
+ available: number;
32
+
33
+ /**
34
+ * The currency of the balance
35
+ */
36
+ currency: 'EUR' | 'GBP' | 'PLN';
37
+ }
38
+ }
39
+
40
+ export interface BalanceRetrieveParams {
41
+ currency: 'EUR' | 'GBP' | 'PLN';
42
+ }
43
+
44
+ export declare namespace Balance {
45
+ export {
46
+ type BalanceRetrieveResponse as BalanceRetrieveResponse,
47
+ type BalanceRetrieveParams as BalanceRetrieveParams,
48
+ };
49
+ }