@gr4vy/sdk 2.2.0 → 2.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (61) hide show
  1. package/README.md +7 -0
  2. package/funcs/transactionsCapturesGet.d.ts +18 -0
  3. package/funcs/transactionsCapturesGet.d.ts.map +1 -0
  4. package/funcs/transactionsCapturesGet.js +145 -0
  5. package/funcs/transactionsCapturesGet.js.map +1 -0
  6. package/funcs/transactionsCapturesList.d.ts +18 -0
  7. package/funcs/transactionsCapturesList.d.ts.map +1 -0
  8. package/funcs/transactionsCapturesList.js +140 -0
  9. package/funcs/transactionsCapturesList.js.map +1 -0
  10. package/jsr.json +1 -1
  11. package/lib/config.d.ts +2 -2
  12. package/lib/config.js +2 -2
  13. package/models/components/capture.d.ts +84 -0
  14. package/models/components/capture.d.ts.map +1 -0
  15. package/models/components/capture.js +86 -0
  16. package/models/components/capture.js.map +1 -0
  17. package/models/components/capturecollection.d.ts +26 -0
  18. package/models/components/capturecollection.d.ts.map +1 -0
  19. package/models/components/capturecollection.js +60 -0
  20. package/models/components/capturecollection.js.map +1 -0
  21. package/models/components/index.d.ts +2 -0
  22. package/models/components/index.d.ts.map +1 -1
  23. package/models/components/index.js +2 -0
  24. package/models/components/index.js.map +1 -1
  25. package/models/components/transactioncapturecreate.d.ts +10 -0
  26. package/models/components/transactioncapturecreate.d.ts.map +1 -1
  27. package/models/components/transactioncapturecreate.js +3 -0
  28. package/models/components/transactioncapturecreate.js.map +1 -1
  29. package/models/operations/gettransactioncapture.d.ts +28 -0
  30. package/models/operations/gettransactioncapture.d.ts.map +1 -0
  31. package/models/operations/gettransactioncapture.js +57 -0
  32. package/models/operations/gettransactioncapture.js.map +1 -0
  33. package/models/operations/index.d.ts +2 -0
  34. package/models/operations/index.d.ts.map +1 -1
  35. package/models/operations/index.js +2 -0
  36. package/models/operations/index.js.map +1 -1
  37. package/models/operations/listtransactioncaptures.d.ts +23 -0
  38. package/models/operations/listtransactioncaptures.d.ts.map +1 -0
  39. package/models/operations/listtransactioncaptures.js +55 -0
  40. package/models/operations/listtransactioncaptures.js.map +1 -0
  41. package/package.json +1 -1
  42. package/sdk/captures.d.ts +19 -0
  43. package/sdk/captures.d.ts.map +1 -0
  44. package/sdk/captures.js +32 -0
  45. package/sdk/captures.js.map +1 -0
  46. package/sdk/transactions.d.ts +3 -0
  47. package/sdk/transactions.d.ts.map +1 -1
  48. package/sdk/transactions.js +4 -0
  49. package/sdk/transactions.js.map +1 -1
  50. package/src/funcs/transactionsCapturesGet.ts +255 -0
  51. package/src/funcs/transactionsCapturesList.ts +247 -0
  52. package/src/lib/config.ts +2 -2
  53. package/src/models/components/capture.ts +142 -0
  54. package/src/models/components/capturecollection.ts +56 -0
  55. package/src/models/components/index.ts +2 -0
  56. package/src/models/components/transactioncapturecreate.ts +13 -0
  57. package/src/models/operations/gettransactioncapture.ts +58 -0
  58. package/src/models/operations/index.ts +2 -0
  59. package/src/models/operations/listtransactioncaptures.ts +51 -0
  60. package/src/sdk/captures.ts +51 -0
  61. package/src/sdk/transactions.ts +6 -0
@@ -0,0 +1,255 @@
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 capture
32
+ *
33
+ * @remarks
34
+ * Retrieve a specific capture for a transaction by its unique identifier.
35
+ */
36
+ export function transactionsCapturesGet(
37
+ client: Gr4vyCore,
38
+ transactionId: string,
39
+ captureId: string,
40
+ merchantAccountId?: string | null | undefined,
41
+ options?: RequestOptions,
42
+ ): APIPromise<
43
+ Result<
44
+ components.Capture,
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
+ captureId,
71
+ merchantAccountId,
72
+ options,
73
+ ));
74
+ }
75
+
76
+ async function $do(
77
+ client: Gr4vyCore,
78
+ transactionId: string,
79
+ captureId: string,
80
+ merchantAccountId?: string | null | undefined,
81
+ options?: RequestOptions,
82
+ ): Promise<
83
+ [
84
+ Result<
85
+ components.Capture,
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.GetTransactionCaptureRequest = {
111
+ transactionId: transactionId,
112
+ captureId: captureId,
113
+ merchantAccountId: merchantAccountId,
114
+ };
115
+
116
+ const parsed = safeParse(
117
+ input,
118
+ (value) =>
119
+ operations.GetTransactionCaptureRequest$outboundSchema.parse(value),
120
+ "Input validation failed",
121
+ );
122
+ if (!parsed.ok) {
123
+ return [parsed, { status: "invalid" }];
124
+ }
125
+ const payload = parsed.value;
126
+ const body = null;
127
+
128
+ const pathParams = {
129
+ capture_id: encodeSimple("capture_id", payload.capture_id, {
130
+ explode: false,
131
+ charEncoding: "percent",
132
+ }),
133
+ transaction_id: encodeSimple("transaction_id", payload.transaction_id, {
134
+ explode: false,
135
+ charEncoding: "percent",
136
+ }),
137
+ };
138
+ const path = pathToFunc(
139
+ "/transactions/{transaction_id}/captures/{capture_id}",
140
+ )(pathParams);
141
+
142
+ const headers = new Headers(compactMap({
143
+ Accept: "application/json",
144
+ "x-gr4vy-merchant-account-id": encodeSimple(
145
+ "x-gr4vy-merchant-account-id",
146
+ payload.merchantAccountId ?? client._options.merchantAccountId,
147
+ { explode: false, charEncoding: "none" },
148
+ ),
149
+ }));
150
+
151
+ const secConfig = await extractSecurity(client._options.bearerAuth);
152
+ const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
153
+ const requestSecurity = resolveGlobalSecurity(securityInput);
154
+
155
+ const context = {
156
+ options: client._options,
157
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
158
+ operationID: "get_transaction_capture",
159
+ oAuth2Scopes: null,
160
+
161
+ resolvedSecurity: requestSecurity,
162
+
163
+ securitySource: client._options.bearerAuth,
164
+ retryConfig: options?.retries
165
+ || client._options.retryConfig
166
+ || {
167
+ strategy: "backoff",
168
+ backoff: {
169
+ initialInterval: 200,
170
+ maxInterval: 200,
171
+ exponent: 1,
172
+ maxElapsedTime: 1000,
173
+ },
174
+ retryConnectionErrors: true,
175
+ }
176
+ || { strategy: "none" },
177
+ retryCodes: options?.retryCodes || ["5XX"],
178
+ };
179
+
180
+ const requestRes = client._createRequest(context, {
181
+ security: requestSecurity,
182
+ method: "GET",
183
+ baseURL: options?.serverURL,
184
+ path: path,
185
+ headers: headers,
186
+ body: body,
187
+ userAgent: client._options.userAgent,
188
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
189
+ }, options);
190
+ if (!requestRes.ok) {
191
+ return [requestRes, { status: "invalid" }];
192
+ }
193
+ const req = requestRes.value;
194
+
195
+ const doResult = await client._do(req, {
196
+ context,
197
+ isErrorStatusCode: (statusCode: number) =>
198
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
199
+ retryConfig: context.retryConfig,
200
+ retryCodes: context.retryCodes,
201
+ });
202
+ if (!doResult.ok) {
203
+ return [doResult, { status: "request-error", request: req }];
204
+ }
205
+ const response = doResult.value;
206
+
207
+ const responseFields = {
208
+ HttpMeta: { Response: response, Request: req },
209
+ };
210
+
211
+ const [result] = await M.match<
212
+ components.Capture,
213
+ | errors.Error400
214
+ | errors.Error401
215
+ | errors.Error403
216
+ | errors.Error404
217
+ | errors.Error405
218
+ | errors.Error409
219
+ | errors.HTTPValidationError
220
+ | errors.Error425
221
+ | errors.Error429
222
+ | errors.Error500
223
+ | errors.Error502
224
+ | errors.Error504
225
+ | Gr4vyError
226
+ | ResponseValidationError
227
+ | ConnectionError
228
+ | RequestAbortedError
229
+ | RequestTimeoutError
230
+ | InvalidRequestError
231
+ | UnexpectedClientError
232
+ | SDKValidationError
233
+ >(
234
+ M.json(200, components.Capture$inboundSchema),
235
+ M.jsonErr(400, errors.Error400$inboundSchema),
236
+ M.jsonErr(401, errors.Error401$inboundSchema),
237
+ M.jsonErr(403, errors.Error403$inboundSchema),
238
+ M.jsonErr(404, errors.Error404$inboundSchema),
239
+ M.jsonErr(405, errors.Error405$inboundSchema),
240
+ M.jsonErr(409, errors.Error409$inboundSchema),
241
+ M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
242
+ M.jsonErr(425, errors.Error425$inboundSchema),
243
+ M.jsonErr(429, errors.Error429$inboundSchema),
244
+ M.jsonErr(500, errors.Error500$inboundSchema),
245
+ M.jsonErr(502, errors.Error502$inboundSchema),
246
+ M.jsonErr(504, errors.Error504$inboundSchema),
247
+ M.fail("4XX"),
248
+ M.fail("5XX"),
249
+ )(response, req, { extraFields: responseFields });
250
+ if (!result.ok) {
251
+ return [result, { status: "complete", request: req, response }];
252
+ }
253
+
254
+ return [result, { status: "complete", request: req, response }];
255
+ }
@@ -0,0 +1,247 @@
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 captures
32
+ *
33
+ * @remarks
34
+ * List all captures for a specific transaction.
35
+ */
36
+ export function transactionsCapturesList(
37
+ client: Gr4vyCore,
38
+ transactionId: string,
39
+ merchantAccountId?: string | null | undefined,
40
+ options?: RequestOptions,
41
+ ): APIPromise<
42
+ Result<
43
+ components.CaptureCollection,
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.CaptureCollection,
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.ListTransactionCapturesRequest = {
108
+ transactionId: transactionId,
109
+ merchantAccountId: merchantAccountId,
110
+ };
111
+
112
+ const parsed = safeParse(
113
+ input,
114
+ (value) =>
115
+ operations.ListTransactionCapturesRequest$outboundSchema.parse(value),
116
+ "Input validation failed",
117
+ );
118
+ if (!parsed.ok) {
119
+ return [parsed, { status: "invalid" }];
120
+ }
121
+ const payload = parsed.value;
122
+ const body = null;
123
+
124
+ const pathParams = {
125
+ transaction_id: encodeSimple("transaction_id", payload.transaction_id, {
126
+ explode: false,
127
+ charEncoding: "percent",
128
+ }),
129
+ };
130
+ const path = pathToFunc("/transactions/{transaction_id}/captures")(
131
+ pathParams,
132
+ );
133
+
134
+ const headers = new Headers(compactMap({
135
+ Accept: "application/json",
136
+ "x-gr4vy-merchant-account-id": encodeSimple(
137
+ "x-gr4vy-merchant-account-id",
138
+ payload.merchantAccountId ?? client._options.merchantAccountId,
139
+ { explode: false, charEncoding: "none" },
140
+ ),
141
+ }));
142
+
143
+ const secConfig = await extractSecurity(client._options.bearerAuth);
144
+ const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
145
+ const requestSecurity = resolveGlobalSecurity(securityInput);
146
+
147
+ const context = {
148
+ options: client._options,
149
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
150
+ operationID: "list_transaction_captures",
151
+ oAuth2Scopes: null,
152
+
153
+ resolvedSecurity: requestSecurity,
154
+
155
+ securitySource: client._options.bearerAuth,
156
+ retryConfig: options?.retries
157
+ || client._options.retryConfig
158
+ || {
159
+ strategy: "backoff",
160
+ backoff: {
161
+ initialInterval: 200,
162
+ maxInterval: 200,
163
+ exponent: 1,
164
+ maxElapsedTime: 1000,
165
+ },
166
+ retryConnectionErrors: true,
167
+ }
168
+ || { strategy: "none" },
169
+ retryCodes: options?.retryCodes || ["5XX"],
170
+ };
171
+
172
+ const requestRes = client._createRequest(context, {
173
+ security: requestSecurity,
174
+ method: "GET",
175
+ baseURL: options?.serverURL,
176
+ path: path,
177
+ headers: headers,
178
+ body: body,
179
+ userAgent: client._options.userAgent,
180
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
181
+ }, options);
182
+ if (!requestRes.ok) {
183
+ return [requestRes, { status: "invalid" }];
184
+ }
185
+ const req = requestRes.value;
186
+
187
+ const doResult = await client._do(req, {
188
+ context,
189
+ isErrorStatusCode: (statusCode: number) =>
190
+ matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
191
+ retryConfig: context.retryConfig,
192
+ retryCodes: context.retryCodes,
193
+ });
194
+ if (!doResult.ok) {
195
+ return [doResult, { status: "request-error", request: req }];
196
+ }
197
+ const response = doResult.value;
198
+
199
+ const responseFields = {
200
+ HttpMeta: { Response: response, Request: req },
201
+ };
202
+
203
+ const [result] = await M.match<
204
+ components.CaptureCollection,
205
+ | errors.Error400
206
+ | errors.Error401
207
+ | errors.Error403
208
+ | errors.Error404
209
+ | errors.Error405
210
+ | errors.Error409
211
+ | errors.HTTPValidationError
212
+ | errors.Error425
213
+ | errors.Error429
214
+ | errors.Error500
215
+ | errors.Error502
216
+ | errors.Error504
217
+ | Gr4vyError
218
+ | ResponseValidationError
219
+ | ConnectionError
220
+ | RequestAbortedError
221
+ | RequestTimeoutError
222
+ | InvalidRequestError
223
+ | UnexpectedClientError
224
+ | SDKValidationError
225
+ >(
226
+ M.json(200, components.CaptureCollection$inboundSchema),
227
+ M.jsonErr(400, errors.Error400$inboundSchema),
228
+ M.jsonErr(401, errors.Error401$inboundSchema),
229
+ M.jsonErr(403, errors.Error403$inboundSchema),
230
+ M.jsonErr(404, errors.Error404$inboundSchema),
231
+ M.jsonErr(405, errors.Error405$inboundSchema),
232
+ M.jsonErr(409, errors.Error409$inboundSchema),
233
+ M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
234
+ M.jsonErr(425, errors.Error425$inboundSchema),
235
+ M.jsonErr(429, errors.Error429$inboundSchema),
236
+ M.jsonErr(500, errors.Error500$inboundSchema),
237
+ M.jsonErr(502, errors.Error502$inboundSchema),
238
+ M.jsonErr(504, errors.Error504$inboundSchema),
239
+ M.fail("4XX"),
240
+ M.fail("5XX"),
241
+ )(response, req, { extraFields: responseFields });
242
+ if (!result.ok) {
243
+ return [result, { status: "complete", request: req, response }];
244
+ }
245
+
246
+ return [result, { status: "complete", request: req, response }];
247
+ }
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.2.0",
80
+ sdkVersion: "2.2.1",
81
81
  genVersion: "2.900.1",
82
- userAgent: "speakeasy-sdk/typescript 2.2.0 2.900.1 1.0.0 @gr4vy/sdk",
82
+ userAgent: "speakeasy-sdk/typescript 2.2.1 2.900.1 1.0.0 @gr4vy/sdk",
83
83
  } as const;
@@ -0,0 +1,142 @@
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
+ import { CaptureStatus, CaptureStatus$inboundSchema } from "./capturestatus.js";
11
+ import { CartItem, CartItem$inboundSchema } from "./cartitem.js";
12
+
13
+ export type Capture = {
14
+ /**
15
+ * Always `capture`.
16
+ */
17
+ type: "capture";
18
+ /**
19
+ * The unique identifier for the capture.
20
+ */
21
+ id: string;
22
+ /**
23
+ * The merchant account this capture belongs to.
24
+ */
25
+ merchantAccountId: string;
26
+ /**
27
+ * The ID of the transaction associated with this capture.
28
+ */
29
+ transactionId: string;
30
+ /**
31
+ * The payment service's unique ID for the capture.
32
+ */
33
+ xid?: string | null | undefined;
34
+ /**
35
+ * The ISO 4217 currency code for this capture.
36
+ */
37
+ currency: string;
38
+ /**
39
+ * The capture amount in the smallest currency unit.
40
+ */
41
+ amount: number;
42
+ status: CaptureStatus;
43
+ /**
44
+ * Whether this is marked as the final capture for the associated transaction.
45
+ */
46
+ final: boolean;
47
+ /**
48
+ * The date and time this capture was created.
49
+ */
50
+ createdAt: Date;
51
+ /**
52
+ * The date and time this capture was last updated.
53
+ */
54
+ updatedAt: Date;
55
+ /**
56
+ * The date and time the capture was completed.
57
+ */
58
+ capturedAt?: Date | null | undefined;
59
+ /**
60
+ * An external identifier that can be used to match the capture against your own records.
61
+ */
62
+ externalIdentifier?: string | null | undefined;
63
+ /**
64
+ * The standardized error code set by Gr4vy.
65
+ */
66
+ errorCode?: string | null | undefined;
67
+ /**
68
+ * The ISO response code.
69
+ */
70
+ isoResponseCode?: string | null | undefined;
71
+ /**
72
+ * This is the response code received from the payment service. This can be set to any value and is not standardized across different payment services.
73
+ */
74
+ rawResponseCode?: string | null | undefined;
75
+ /**
76
+ * This is the response description received from the payment service. This can be set to any value and is not standardized across different payment services.
77
+ */
78
+ rawResponseDescription?: string | null | undefined;
79
+ /**
80
+ * The external identifier of the associated transaction.
81
+ */
82
+ transactionExternalIdentifier?: string | null | undefined;
83
+ /**
84
+ * An array of cart items that represents the line items of this capture.
85
+ */
86
+ cartItems?: Array<CartItem> | null | undefined;
87
+ };
88
+
89
+ /** @internal */
90
+ export const Capture$inboundSchema: z.ZodType<Capture, z.ZodTypeDef, unknown> =
91
+ z.object({
92
+ type: z.literal("capture").default("capture"),
93
+ id: z.string(),
94
+ merchant_account_id: z.string(),
95
+ transaction_id: z.string(),
96
+ xid: z.nullable(z.string()).optional(),
97
+ currency: z.string(),
98
+ amount: z.number().int(),
99
+ status: CaptureStatus$inboundSchema,
100
+ final: z.boolean(),
101
+ created_at: z.string().datetime({ offset: true }).transform(v =>
102
+ new Date(v)
103
+ ),
104
+ updated_at: z.string().datetime({ offset: true }).transform(v =>
105
+ new Date(v)
106
+ ),
107
+ captured_at: z.nullable(
108
+ z.string().datetime({ offset: true }).transform(v => new Date(v)),
109
+ ).optional(),
110
+ external_identifier: z.nullable(z.string()).optional(),
111
+ error_code: z.nullable(z.string()).optional(),
112
+ iso_response_code: z.nullable(z.string()).optional(),
113
+ raw_response_code: z.nullable(z.string()).optional(),
114
+ raw_response_description: z.nullable(z.string()).optional(),
115
+ transaction_external_identifier: z.nullable(z.string()).optional(),
116
+ cart_items: z.nullable(z.array(CartItem$inboundSchema)).optional(),
117
+ }).transform((v) => {
118
+ return remap$(v, {
119
+ "merchant_account_id": "merchantAccountId",
120
+ "transaction_id": "transactionId",
121
+ "created_at": "createdAt",
122
+ "updated_at": "updatedAt",
123
+ "captured_at": "capturedAt",
124
+ "external_identifier": "externalIdentifier",
125
+ "error_code": "errorCode",
126
+ "iso_response_code": "isoResponseCode",
127
+ "raw_response_code": "rawResponseCode",
128
+ "raw_response_description": "rawResponseDescription",
129
+ "transaction_external_identifier": "transactionExternalIdentifier",
130
+ "cart_items": "cartItems",
131
+ });
132
+ });
133
+
134
+ export function captureFromJSON(
135
+ jsonString: string,
136
+ ): SafeParseResult<Capture, SDKValidationError> {
137
+ return safeParse(
138
+ jsonString,
139
+ (x) => Capture$inboundSchema.parse(JSON.parse(x)),
140
+ `Failed to parse 'Capture' from JSON`,
141
+ );
142
+ }
@@ -0,0 +1,56 @@
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
+ import { Capture, Capture$inboundSchema } from "./capture.js";
11
+
12
+ export type CaptureCollection = {
13
+ /**
14
+ * A list of items returned for this request.
15
+ */
16
+ items: Array<Capture>;
17
+ /**
18
+ * The number of items for this page.
19
+ */
20
+ limit: number;
21
+ /**
22
+ * The cursor pointing at the next page of items.
23
+ */
24
+ nextCursor?: string | null | undefined;
25
+ /**
26
+ * The cursor pointing at the previous page of items.
27
+ */
28
+ previousCursor?: string | null | undefined;
29
+ };
30
+
31
+ /** @internal */
32
+ export const CaptureCollection$inboundSchema: z.ZodType<
33
+ CaptureCollection,
34
+ z.ZodTypeDef,
35
+ unknown
36
+ > = z.object({
37
+ items: z.array(Capture$inboundSchema),
38
+ limit: z.number().int().default(20),
39
+ next_cursor: z.nullable(z.string()).optional(),
40
+ previous_cursor: z.nullable(z.string()).optional(),
41
+ }).transform((v) => {
42
+ return remap$(v, {
43
+ "next_cursor": "nextCursor",
44
+ "previous_cursor": "previousCursor",
45
+ });
46
+ });
47
+
48
+ export function captureCollectionFromJSON(
49
+ jsonString: string,
50
+ ): SafeParseResult<CaptureCollection, SDKValidationError> {
51
+ return safeParse(
52
+ jsonString,
53
+ (x) => CaptureCollection$inboundSchema.parse(JSON.parse(x)),
54
+ `Failed to parse 'CaptureCollection' from JSON`,
55
+ );
56
+ }