@gr4vy/sdk 2.3.20 → 2.3.22

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 (66) hide show
  1. package/README.md +7 -0
  2. package/funcs/transactionsRefundSettlementsGet.d.ts +18 -0
  3. package/funcs/transactionsRefundSettlementsGet.d.ts.map +1 -0
  4. package/funcs/transactionsRefundSettlementsGet.js +145 -0
  5. package/funcs/transactionsRefundSettlementsGet.js.map +1 -0
  6. package/funcs/transactionsRefundSettlementsList.d.ts +18 -0
  7. package/funcs/transactionsRefundSettlementsList.d.ts.map +1 -0
  8. package/funcs/transactionsRefundSettlementsList.js +140 -0
  9. package/funcs/transactionsRefundSettlementsList.js.map +1 -0
  10. package/jsr.json +1 -1
  11. package/lib/config.d.ts +3 -3
  12. package/lib/config.js +3 -3
  13. package/models/components/giftcarderrorcode.d.ts +4 -0
  14. package/models/components/giftcarderrorcode.d.ts.map +1 -1
  15. package/models/components/giftcarderrorcode.js +4 -0
  16. package/models/components/giftcarderrorcode.js.map +1 -1
  17. package/models/components/index.d.ts +2 -0
  18. package/models/components/index.d.ts.map +1 -1
  19. package/models/components/index.js +2 -0
  20. package/models/components/index.js.map +1 -1
  21. package/models/components/refundsettlement.d.ts +84 -0
  22. package/models/components/refundsettlement.d.ts.map +1 -0
  23. package/models/components/refundsettlement.js +82 -0
  24. package/models/components/refundsettlement.js.map +1 -0
  25. package/models/components/refundsettlements.d.ts +17 -0
  26. package/models/components/refundsettlements.d.ts.map +1 -0
  27. package/models/components/refundsettlements.js +51 -0
  28. package/models/components/refundsettlements.js.map +1 -0
  29. package/models/components/transactioncapturecreate.d.ts +2 -2
  30. package/models/components/transactioncapturecreate.d.ts.map +1 -1
  31. package/models/components/transactioncapturecreate.js +1 -1
  32. package/models/components/transactioncapturecreate.js.map +1 -1
  33. package/models/operations/gettransactionrefundsettlement.d.ts +28 -0
  34. package/models/operations/gettransactionrefundsettlement.d.ts.map +1 -0
  35. package/models/operations/gettransactionrefundsettlement.js +57 -0
  36. package/models/operations/gettransactionrefundsettlement.js.map +1 -0
  37. package/models/operations/index.d.ts +2 -0
  38. package/models/operations/index.d.ts.map +1 -1
  39. package/models/operations/index.js +2 -0
  40. package/models/operations/index.js.map +1 -1
  41. package/models/operations/listtransactionrefundsettlements.d.ts +23 -0
  42. package/models/operations/listtransactionrefundsettlements.d.ts.map +1 -0
  43. package/models/operations/listtransactionrefundsettlements.js +55 -0
  44. package/models/operations/listtransactionrefundsettlements.js.map +1 -0
  45. package/package.json +1 -1
  46. package/sdk/refundsettlements.d.ts +19 -0
  47. package/sdk/refundsettlements.d.ts.map +1 -0
  48. package/sdk/refundsettlements.js +32 -0
  49. package/sdk/refundsettlements.js.map +1 -0
  50. package/sdk/transactions.d.ts +3 -0
  51. package/sdk/transactions.d.ts.map +1 -1
  52. package/sdk/transactions.js +4 -0
  53. package/sdk/transactions.js.map +1 -1
  54. package/src/funcs/transactionsRefundSettlementsGet.ts +257 -0
  55. package/src/funcs/transactionsRefundSettlementsList.ts +249 -0
  56. package/src/lib/config.ts +3 -3
  57. package/src/models/components/giftcarderrorcode.ts +4 -0
  58. package/src/models/components/index.ts +2 -0
  59. package/src/models/components/refundsettlement.ts +139 -0
  60. package/src/models/components/refundsettlements.ts +41 -0
  61. package/src/models/components/transactioncapturecreate.ts +3 -3
  62. package/src/models/operations/gettransactionrefundsettlement.ts +58 -0
  63. package/src/models/operations/index.ts +2 -0
  64. package/src/models/operations/listtransactionrefundsettlements.ts +52 -0
  65. package/src/sdk/refundsettlements.ts +51 -0
  66. package/src/sdk/transactions.ts +6 -0
@@ -0,0 +1,257 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { Gr4vyCore } from "../core.js";
6
+ import { encodeSimple } from "../lib/encodings.js";
7
+ import { matchStatusCode } from "../lib/http.js";
8
+ import * as M from "../lib/matchers.js";
9
+ import { compactMap } from "../lib/primitives.js";
10
+ import { safeParse } from "../lib/schemas.js";
11
+ import { RequestOptions } from "../lib/sdks.js";
12
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
13
+ import { pathToFunc } from "../lib/url.js";
14
+ import * as components from "../models/components/index.js";
15
+ import { Gr4vyError } from "../models/errors/gr4vyerror.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 operations from "../models/operations/index.js";
27
+ import { APICall, APIPromise } from "../types/async.js";
28
+ import { Result } from "../types/fp.js";
29
+
30
+ /**
31
+ * Get transaction refund settlement
32
+ *
33
+ * @remarks
34
+ * Retrieve a specific refund settlement for a transaction by its unique identifier.
35
+ */
36
+ export function transactionsRefundSettlementsGet(
37
+ client: Gr4vyCore,
38
+ transactionId: string,
39
+ settlementId: string,
40
+ merchantAccountId?: string | null | undefined,
41
+ options?: RequestOptions,
42
+ ): APIPromise<
43
+ Result<
44
+ components.RefundSettlement,
45
+ | errors.Error400
46
+ | errors.Error401
47
+ | errors.Error403
48
+ | errors.Error404
49
+ | errors.Error405
50
+ | errors.Error409
51
+ | errors.HTTPValidationError
52
+ | errors.Error425
53
+ | errors.Error429
54
+ | errors.Error500
55
+ | errors.Error502
56
+ | errors.Error504
57
+ | Gr4vyError
58
+ | ResponseValidationError
59
+ | ConnectionError
60
+ | RequestAbortedError
61
+ | RequestTimeoutError
62
+ | InvalidRequestError
63
+ | UnexpectedClientError
64
+ | SDKValidationError
65
+ >
66
+ > {
67
+ return new APIPromise($do(
68
+ client,
69
+ transactionId,
70
+ settlementId,
71
+ merchantAccountId,
72
+ options,
73
+ ));
74
+ }
75
+
76
+ async function $do(
77
+ client: Gr4vyCore,
78
+ transactionId: string,
79
+ settlementId: string,
80
+ merchantAccountId?: string | null | undefined,
81
+ options?: RequestOptions,
82
+ ): Promise<
83
+ [
84
+ Result<
85
+ components.RefundSettlement,
86
+ | errors.Error400
87
+ | errors.Error401
88
+ | errors.Error403
89
+ | errors.Error404
90
+ | errors.Error405
91
+ | errors.Error409
92
+ | errors.HTTPValidationError
93
+ | errors.Error425
94
+ | errors.Error429
95
+ | errors.Error500
96
+ | errors.Error502
97
+ | errors.Error504
98
+ | Gr4vyError
99
+ | ResponseValidationError
100
+ | ConnectionError
101
+ | RequestAbortedError
102
+ | RequestTimeoutError
103
+ | InvalidRequestError
104
+ | UnexpectedClientError
105
+ | SDKValidationError
106
+ >,
107
+ APICall,
108
+ ]
109
+ > {
110
+ const input: operations.GetTransactionRefundSettlementRequest = {
111
+ transactionId: transactionId,
112
+ settlementId: settlementId,
113
+ merchantAccountId: merchantAccountId,
114
+ };
115
+
116
+ const parsed = safeParse(
117
+ input,
118
+ (value) =>
119
+ operations.GetTransactionRefundSettlementRequest$outboundSchema.parse(
120
+ value,
121
+ ),
122
+ "Input validation failed",
123
+ );
124
+ if (!parsed.ok) {
125
+ return [parsed, { status: "invalid" }];
126
+ }
127
+ const payload = parsed.value;
128
+ const body = null;
129
+
130
+ const pathParams = {
131
+ settlement_id: encodeSimple("settlement_id", payload.settlement_id, {
132
+ explode: false,
133
+ charEncoding: "percent",
134
+ }),
135
+ transaction_id: encodeSimple("transaction_id", payload.transaction_id, {
136
+ explode: false,
137
+ charEncoding: "percent",
138
+ }),
139
+ };
140
+ const path = pathToFunc(
141
+ "/transactions/{transaction_id}/refund-settlements/{settlement_id}",
142
+ )(pathParams);
143
+
144
+ const headers = new Headers(compactMap({
145
+ Accept: "application/json",
146
+ "x-gr4vy-merchant-account-id": encodeSimple(
147
+ "x-gr4vy-merchant-account-id",
148
+ payload.merchantAccountId ?? client._options.merchantAccountId,
149
+ { explode: false, charEncoding: "none" },
150
+ ),
151
+ }));
152
+
153
+ const secConfig = await extractSecurity(client._options.bearerAuth);
154
+ const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
155
+ const requestSecurity = resolveGlobalSecurity(securityInput);
156
+
157
+ const context = {
158
+ options: client._options,
159
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
160
+ operationID: "get_transaction_refund_settlement",
161
+ oAuth2Scopes: null,
162
+
163
+ resolvedSecurity: requestSecurity,
164
+
165
+ securitySource: client._options.bearerAuth,
166
+ retryConfig: options?.retries
167
+ || client._options.retryConfig
168
+ || {
169
+ strategy: "backoff",
170
+ backoff: {
171
+ initialInterval: 200,
172
+ maxInterval: 200,
173
+ exponent: 1,
174
+ maxElapsedTime: 1000,
175
+ },
176
+ retryConnectionErrors: true,
177
+ }
178
+ || { strategy: "none" },
179
+ retryCodes: options?.retryCodes || ["5XX"],
180
+ };
181
+
182
+ const requestRes = client._createRequest(context, {
183
+ security: requestSecurity,
184
+ method: "GET",
185
+ baseURL: options?.serverURL,
186
+ path: path,
187
+ headers: headers,
188
+ body: body,
189
+ userAgent: client._options.userAgent,
190
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
191
+ }, options);
192
+ if (!requestRes.ok) {
193
+ return [requestRes, { status: "invalid" }];
194
+ }
195
+ const req = requestRes.value;
196
+
197
+ const doResult = await client._do(req, {
198
+ context,
199
+ isErrorStatusCode: (statusCode: number) =>
200
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
201
+ retryConfig: context.retryConfig,
202
+ retryCodes: context.retryCodes,
203
+ });
204
+ if (!doResult.ok) {
205
+ return [doResult, { status: "request-error", request: req }];
206
+ }
207
+ const response = doResult.value;
208
+
209
+ const responseFields = {
210
+ HttpMeta: { Response: response, Request: req },
211
+ };
212
+
213
+ const [result] = await M.match<
214
+ components.RefundSettlement,
215
+ | errors.Error400
216
+ | errors.Error401
217
+ | errors.Error403
218
+ | errors.Error404
219
+ | errors.Error405
220
+ | errors.Error409
221
+ | errors.HTTPValidationError
222
+ | errors.Error425
223
+ | errors.Error429
224
+ | errors.Error500
225
+ | errors.Error502
226
+ | errors.Error504
227
+ | Gr4vyError
228
+ | ResponseValidationError
229
+ | ConnectionError
230
+ | RequestAbortedError
231
+ | RequestTimeoutError
232
+ | InvalidRequestError
233
+ | UnexpectedClientError
234
+ | SDKValidationError
235
+ >(
236
+ M.json(200, components.RefundSettlement$inboundSchema),
237
+ M.jsonErr(400, errors.Error400$inboundSchema),
238
+ M.jsonErr(401, errors.Error401$inboundSchema),
239
+ M.jsonErr(403, errors.Error403$inboundSchema),
240
+ M.jsonErr(404, errors.Error404$inboundSchema),
241
+ M.jsonErr(405, errors.Error405$inboundSchema),
242
+ M.jsonErr(409, errors.Error409$inboundSchema),
243
+ M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
244
+ M.jsonErr(425, errors.Error425$inboundSchema),
245
+ M.jsonErr(429, errors.Error429$inboundSchema),
246
+ M.jsonErr(500, errors.Error500$inboundSchema),
247
+ M.jsonErr(502, errors.Error502$inboundSchema),
248
+ M.jsonErr(504, errors.Error504$inboundSchema),
249
+ M.fail("4XX"),
250
+ M.fail("5XX"),
251
+ )(response, req, { extraFields: responseFields });
252
+ if (!result.ok) {
253
+ return [result, { status: "complete", request: req, response }];
254
+ }
255
+
256
+ return [result, { status: "complete", request: req, response }];
257
+ }
@@ -0,0 +1,249 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { Gr4vyCore } from "../core.js";
6
+ import { encodeSimple } from "../lib/encodings.js";
7
+ import { matchStatusCode } from "../lib/http.js";
8
+ import * as M from "../lib/matchers.js";
9
+ import { compactMap } from "../lib/primitives.js";
10
+ import { safeParse } from "../lib/schemas.js";
11
+ import { RequestOptions } from "../lib/sdks.js";
12
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
13
+ import { pathToFunc } from "../lib/url.js";
14
+ import * as components from "../models/components/index.js";
15
+ import { Gr4vyError } from "../models/errors/gr4vyerror.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 operations from "../models/operations/index.js";
27
+ import { APICall, APIPromise } from "../types/async.js";
28
+ import { Result } from "../types/fp.js";
29
+
30
+ /**
31
+ * List transaction refund settlements
32
+ *
33
+ * @remarks
34
+ * List all refund settlements for a specific transaction.
35
+ */
36
+ export function transactionsRefundSettlementsList(
37
+ client: Gr4vyCore,
38
+ transactionId: string,
39
+ merchantAccountId?: string | null | undefined,
40
+ options?: RequestOptions,
41
+ ): APIPromise<
42
+ Result<
43
+ components.RefundSettlements,
44
+ | errors.Error400
45
+ | errors.Error401
46
+ | errors.Error403
47
+ | errors.Error404
48
+ | errors.Error405
49
+ | errors.Error409
50
+ | errors.HTTPValidationError
51
+ | errors.Error425
52
+ | errors.Error429
53
+ | errors.Error500
54
+ | errors.Error502
55
+ | errors.Error504
56
+ | Gr4vyError
57
+ | ResponseValidationError
58
+ | ConnectionError
59
+ | RequestAbortedError
60
+ | RequestTimeoutError
61
+ | InvalidRequestError
62
+ | UnexpectedClientError
63
+ | SDKValidationError
64
+ >
65
+ > {
66
+ return new APIPromise($do(
67
+ client,
68
+ transactionId,
69
+ merchantAccountId,
70
+ options,
71
+ ));
72
+ }
73
+
74
+ async function $do(
75
+ client: Gr4vyCore,
76
+ transactionId: string,
77
+ merchantAccountId?: string | null | undefined,
78
+ options?: RequestOptions,
79
+ ): Promise<
80
+ [
81
+ Result<
82
+ components.RefundSettlements,
83
+ | errors.Error400
84
+ | errors.Error401
85
+ | errors.Error403
86
+ | errors.Error404
87
+ | errors.Error405
88
+ | errors.Error409
89
+ | errors.HTTPValidationError
90
+ | errors.Error425
91
+ | errors.Error429
92
+ | errors.Error500
93
+ | errors.Error502
94
+ | errors.Error504
95
+ | Gr4vyError
96
+ | ResponseValidationError
97
+ | ConnectionError
98
+ | RequestAbortedError
99
+ | RequestTimeoutError
100
+ | InvalidRequestError
101
+ | UnexpectedClientError
102
+ | SDKValidationError
103
+ >,
104
+ APICall,
105
+ ]
106
+ > {
107
+ const input: operations.ListTransactionRefundSettlementsRequest = {
108
+ transactionId: transactionId,
109
+ merchantAccountId: merchantAccountId,
110
+ };
111
+
112
+ const parsed = safeParse(
113
+ input,
114
+ (value) =>
115
+ operations.ListTransactionRefundSettlementsRequest$outboundSchema.parse(
116
+ value,
117
+ ),
118
+ "Input validation failed",
119
+ );
120
+ if (!parsed.ok) {
121
+ return [parsed, { status: "invalid" }];
122
+ }
123
+ const payload = parsed.value;
124
+ const body = null;
125
+
126
+ const pathParams = {
127
+ transaction_id: encodeSimple("transaction_id", payload.transaction_id, {
128
+ explode: false,
129
+ charEncoding: "percent",
130
+ }),
131
+ };
132
+ const path = pathToFunc("/transactions/{transaction_id}/refund-settlements")(
133
+ pathParams,
134
+ );
135
+
136
+ const headers = new Headers(compactMap({
137
+ Accept: "application/json",
138
+ "x-gr4vy-merchant-account-id": encodeSimple(
139
+ "x-gr4vy-merchant-account-id",
140
+ payload.merchantAccountId ?? client._options.merchantAccountId,
141
+ { explode: false, charEncoding: "none" },
142
+ ),
143
+ }));
144
+
145
+ const secConfig = await extractSecurity(client._options.bearerAuth);
146
+ const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
147
+ const requestSecurity = resolveGlobalSecurity(securityInput);
148
+
149
+ const context = {
150
+ options: client._options,
151
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
152
+ operationID: "list_transaction_refund_settlements",
153
+ oAuth2Scopes: null,
154
+
155
+ resolvedSecurity: requestSecurity,
156
+
157
+ securitySource: client._options.bearerAuth,
158
+ retryConfig: options?.retries
159
+ || client._options.retryConfig
160
+ || {
161
+ strategy: "backoff",
162
+ backoff: {
163
+ initialInterval: 200,
164
+ maxInterval: 200,
165
+ exponent: 1,
166
+ maxElapsedTime: 1000,
167
+ },
168
+ retryConnectionErrors: true,
169
+ }
170
+ || { strategy: "none" },
171
+ retryCodes: options?.retryCodes || ["5XX"],
172
+ };
173
+
174
+ const requestRes = client._createRequest(context, {
175
+ security: requestSecurity,
176
+ method: "GET",
177
+ baseURL: options?.serverURL,
178
+ path: path,
179
+ headers: headers,
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
+ components.RefundSettlements,
207
+ | errors.Error400
208
+ | errors.Error401
209
+ | errors.Error403
210
+ | errors.Error404
211
+ | errors.Error405
212
+ | errors.Error409
213
+ | errors.HTTPValidationError
214
+ | errors.Error425
215
+ | errors.Error429
216
+ | errors.Error500
217
+ | errors.Error502
218
+ | errors.Error504
219
+ | Gr4vyError
220
+ | ResponseValidationError
221
+ | ConnectionError
222
+ | RequestAbortedError
223
+ | RequestTimeoutError
224
+ | InvalidRequestError
225
+ | UnexpectedClientError
226
+ | SDKValidationError
227
+ >(
228
+ M.json(200, components.RefundSettlements$inboundSchema),
229
+ M.jsonErr(400, errors.Error400$inboundSchema),
230
+ M.jsonErr(401, errors.Error401$inboundSchema),
231
+ M.jsonErr(403, errors.Error403$inboundSchema),
232
+ M.jsonErr(404, errors.Error404$inboundSchema),
233
+ M.jsonErr(405, errors.Error405$inboundSchema),
234
+ M.jsonErr(409, errors.Error409$inboundSchema),
235
+ M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
236
+ M.jsonErr(425, errors.Error425$inboundSchema),
237
+ M.jsonErr(429, errors.Error429$inboundSchema),
238
+ M.jsonErr(500, errors.Error500$inboundSchema),
239
+ M.jsonErr(502, errors.Error502$inboundSchema),
240
+ M.jsonErr(504, errors.Error504$inboundSchema),
241
+ M.fail("4XX"),
242
+ M.fail("5XX"),
243
+ )(response, req, { extraFields: responseFields });
244
+ if (!result.ok) {
245
+ return [result, { status: "complete", request: req, response }];
246
+ }
247
+
248
+ return [result, { status: "complete", request: req, response }];
249
+ }
package/src/lib/config.ts CHANGED
@@ -77,7 +77,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
77
77
  export const SDK_METADATA = {
78
78
  language: "typescript",
79
79
  openapiDocVersion: "1.0.0",
80
- sdkVersion: "2.3.20",
81
- genVersion: "2.916.4",
82
- userAgent: "speakeasy-sdk/typescript 2.3.20 2.916.4 1.0.0 @gr4vy/sdk",
80
+ sdkVersion: "2.3.22",
81
+ genVersion: "2.918.1",
82
+ userAgent: "speakeasy-sdk/typescript 2.3.22 2.918.1 1.0.0 @gr4vy/sdk",
83
83
  } as const;
@@ -31,6 +31,10 @@ export const GiftCardErrorCode = {
31
31
  ServiceNetworkError: "service_network_error",
32
32
  UnknownError: "unknown_error",
33
33
  MaxGiftCardsReached: "max_gift_cards_reached",
34
+ SuspectedFraud: "suspected_fraud",
35
+ CanceledPaymentMethod: "canceled_payment_method",
36
+ DuplicateTransaction: "duplicate_transaction",
37
+ UnexpectedState: "unexpected_state",
34
38
  } as const;
35
39
  /**
36
40
  * Gift card error codes.
@@ -254,6 +254,8 @@ export * from "./recipient.js";
254
254
  export * from "./redirectpaymentmethodcreate.js";
255
255
  export * from "./refund.js";
256
256
  export * from "./refunds.js";
257
+ export * from "./refundsettlement.js";
258
+ export * from "./refundsettlements.js";
257
259
  export * from "./refundstatus.js";
258
260
  export * from "./refundtargettype.js";
259
261
  export * from "./report.js";
@@ -0,0 +1,139 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
+
11
+ /**
12
+ * A settlement record for a refund on a transaction.
13
+ */
14
+ export type RefundSettlement = {
15
+ /**
16
+ * The unique identifier for the record.
17
+ */
18
+ id: string;
19
+ /**
20
+ * The merchant account this record belongs to.
21
+ */
22
+ merchantAccountId: string;
23
+ /**
24
+ * The date and time the record was created, in ISO 8601 format.
25
+ */
26
+ createdAt: Date;
27
+ /**
28
+ * The date and time the record was last updated, in ISO 8601 format.
29
+ */
30
+ updatedAt: Date;
31
+ /**
32
+ * The date and time the record was posted, in ISO 8601 format.
33
+ */
34
+ postedAt: Date;
35
+ /**
36
+ * The date and time the record was ingested, in ISO 8601 format.
37
+ */
38
+ ingestedAt: Date;
39
+ /**
40
+ * ISO 4217 currency code.
41
+ */
42
+ currency: string;
43
+ /**
44
+ * The total amount in the smallest currency unit (e.g. cents).
45
+ */
46
+ amount: number;
47
+ /**
48
+ * The exchange rate, if applicable.
49
+ */
50
+ exchangeRate?: number | null | undefined;
51
+ /**
52
+ * The commission amount deducted in the smallest currency unit.
53
+ */
54
+ commission: number;
55
+ /**
56
+ * The interchange fee, if applicable, in the smallest currency unit.
57
+ */
58
+ interchange?: number | null | undefined;
59
+ /**
60
+ * The markup fee, if applicable, in the smallest currency unit.
61
+ */
62
+ markup?: number | null | undefined;
63
+ /**
64
+ * The scheme fee, if applicable, in the smallest currency unit.
65
+ */
66
+ schemeFee?: number | null | undefined;
67
+ /**
68
+ * The report ID from the payment service.
69
+ */
70
+ paymentServiceReportId: string;
71
+ /**
72
+ * List of file IDs for the payment service report.
73
+ */
74
+ paymentServiceReportFileIds: Array<string>;
75
+ /**
76
+ * The transaction this record is associated with.
77
+ */
78
+ transactionId: string;
79
+ /**
80
+ * Always `refund-settlement`.
81
+ */
82
+ type: "refund-settlement";
83
+ /**
84
+ * The refund this settlement is associated with.
85
+ */
86
+ refundId: string;
87
+ };
88
+
89
+ /** @internal */
90
+ export const RefundSettlement$inboundSchema: z.ZodType<
91
+ RefundSettlement,
92
+ z.ZodTypeDef,
93
+ unknown
94
+ > = z.object({
95
+ id: z.string(),
96
+ merchant_account_id: z.string(),
97
+ created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
98
+ updated_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
99
+ posted_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
100
+ ingested_at: z.string().datetime({ offset: true }).transform(v =>
101
+ new Date(v)
102
+ ),
103
+ currency: z.string(),
104
+ amount: z.number().int(),
105
+ exchange_rate: z.nullable(z.number()).optional(),
106
+ commission: z.number().int(),
107
+ interchange: z.nullable(z.number().int()).optional(),
108
+ markup: z.nullable(z.number().int()).optional(),
109
+ scheme_fee: z.nullable(z.number().int()).optional(),
110
+ payment_service_report_id: z.string(),
111
+ payment_service_report_file_ids: z.array(z.string()),
112
+ transaction_id: z.string(),
113
+ type: z.literal("refund-settlement").default("refund-settlement"),
114
+ refund_id: z.string(),
115
+ }).transform((v) => {
116
+ return remap$(v, {
117
+ "merchant_account_id": "merchantAccountId",
118
+ "created_at": "createdAt",
119
+ "updated_at": "updatedAt",
120
+ "posted_at": "postedAt",
121
+ "ingested_at": "ingestedAt",
122
+ "exchange_rate": "exchangeRate",
123
+ "scheme_fee": "schemeFee",
124
+ "payment_service_report_id": "paymentServiceReportId",
125
+ "payment_service_report_file_ids": "paymentServiceReportFileIds",
126
+ "transaction_id": "transactionId",
127
+ "refund_id": "refundId",
128
+ });
129
+ });
130
+
131
+ export function refundSettlementFromJSON(
132
+ jsonString: string,
133
+ ): SafeParseResult<RefundSettlement, SDKValidationError> {
134
+ return safeParse(
135
+ jsonString,
136
+ (x) => RefundSettlement$inboundSchema.parse(JSON.parse(x)),
137
+ `Failed to parse 'RefundSettlement' from JSON`,
138
+ );
139
+ }