@gr4vy/sdk 2.2.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +7 -0
  2. package/funcs/auditLogsList.d.ts.map +1 -1
  3. package/funcs/auditLogsList.js +1 -2
  4. package/funcs/auditLogsList.js.map +1 -1
  5. package/funcs/buyersList.d.ts.map +1 -1
  6. package/funcs/buyersList.js +1 -2
  7. package/funcs/buyersList.js.map +1 -1
  8. package/funcs/giftCardsList.d.ts.map +1 -1
  9. package/funcs/giftCardsList.js +1 -2
  10. package/funcs/giftCardsList.js.map +1 -1
  11. package/funcs/merchantAccountsList.d.ts.map +1 -1
  12. package/funcs/merchantAccountsList.js +1 -2
  13. package/funcs/merchantAccountsList.js.map +1 -1
  14. package/funcs/paymentLinksList.d.ts.map +1 -1
  15. package/funcs/paymentLinksList.js +1 -2
  16. package/funcs/paymentLinksList.js.map +1 -1
  17. package/funcs/paymentMethodsList.d.ts.map +1 -1
  18. package/funcs/paymentMethodsList.js +1 -2
  19. package/funcs/paymentMethodsList.js.map +1 -1
  20. package/funcs/paymentServiceDefinitionsList.d.ts.map +1 -1
  21. package/funcs/paymentServiceDefinitionsList.js +1 -2
  22. package/funcs/paymentServiceDefinitionsList.js.map +1 -1
  23. package/funcs/paymentServicesList.d.ts.map +1 -1
  24. package/funcs/paymentServicesList.js +1 -2
  25. package/funcs/paymentServicesList.js.map +1 -1
  26. package/funcs/payoutsList.d.ts.map +1 -1
  27. package/funcs/payoutsList.js +1 -2
  28. package/funcs/payoutsList.js.map +1 -1
  29. package/funcs/reportExecutionsList.d.ts.map +1 -1
  30. package/funcs/reportExecutionsList.js +1 -2
  31. package/funcs/reportExecutionsList.js.map +1 -1
  32. package/funcs/reportsExecutionsList.d.ts.map +1 -1
  33. package/funcs/reportsExecutionsList.js +1 -2
  34. package/funcs/reportsExecutionsList.js.map +1 -1
  35. package/funcs/reportsList.d.ts.map +1 -1
  36. package/funcs/reportsList.js +1 -2
  37. package/funcs/reportsList.js.map +1 -1
  38. package/funcs/threeDsScenariosList.d.ts.map +1 -1
  39. package/funcs/threeDsScenariosList.js +1 -2
  40. package/funcs/threeDsScenariosList.js.map +1 -1
  41. package/funcs/transactionsCapturesGet.d.ts +18 -0
  42. package/funcs/transactionsCapturesGet.d.ts.map +1 -0
  43. package/funcs/transactionsCapturesGet.js +145 -0
  44. package/funcs/transactionsCapturesGet.js.map +1 -0
  45. package/funcs/transactionsCapturesList.d.ts +18 -0
  46. package/funcs/transactionsCapturesList.d.ts.map +1 -0
  47. package/funcs/transactionsCapturesList.js +140 -0
  48. package/funcs/transactionsCapturesList.js.map +1 -0
  49. package/funcs/transactionsEventsList.d.ts.map +1 -1
  50. package/funcs/transactionsEventsList.js +1 -2
  51. package/funcs/transactionsEventsList.js.map +1 -1
  52. package/funcs/transactionsList.d.ts.map +1 -1
  53. package/funcs/transactionsList.js +1 -2
  54. package/funcs/transactionsList.js.map +1 -1
  55. package/jsr.json +1 -1
  56. package/lib/config.d.ts +3 -3
  57. package/lib/config.js +3 -3
  58. package/lib/encodings.js +12 -12
  59. package/lib/encodings.js.map +1 -1
  60. package/lib/env.d.ts.map +1 -1
  61. package/lib/env.js +3 -3
  62. package/lib/env.js.map +1 -1
  63. package/lib/matchers.js +3 -3
  64. package/lib/matchers.js.map +1 -1
  65. package/lib/primitives.d.ts +1 -0
  66. package/lib/primitives.d.ts.map +1 -1
  67. package/lib/primitives.js +18 -0
  68. package/lib/primitives.js.map +1 -1
  69. package/models/components/capture.d.ts +84 -0
  70. package/models/components/capture.d.ts.map +1 -0
  71. package/models/components/capture.js +86 -0
  72. package/models/components/capture.js.map +1 -0
  73. package/models/components/capturecollection.d.ts +26 -0
  74. package/models/components/capturecollection.d.ts.map +1 -0
  75. package/models/components/capturecollection.js +60 -0
  76. package/models/components/capturecollection.js.map +1 -0
  77. package/models/components/index.d.ts +2 -0
  78. package/models/components/index.d.ts.map +1 -1
  79. package/models/components/index.js +2 -0
  80. package/models/components/index.js.map +1 -1
  81. package/models/components/nuveipseoptions.d.ts +2 -2
  82. package/models/components/transactioncapturecreate.d.ts +10 -0
  83. package/models/components/transactioncapturecreate.d.ts.map +1 -1
  84. package/models/components/transactioncapturecreate.js +3 -0
  85. package/models/components/transactioncapturecreate.js.map +1 -1
  86. package/models/operations/gettransactioncapture.d.ts +28 -0
  87. package/models/operations/gettransactioncapture.d.ts.map +1 -0
  88. package/models/operations/gettransactioncapture.js +57 -0
  89. package/models/operations/gettransactioncapture.js.map +1 -0
  90. package/models/operations/index.d.ts +2 -0
  91. package/models/operations/index.d.ts.map +1 -1
  92. package/models/operations/index.js +2 -0
  93. package/models/operations/index.js.map +1 -1
  94. package/models/operations/listtransactioncaptures.d.ts +23 -0
  95. package/models/operations/listtransactioncaptures.d.ts.map +1 -0
  96. package/models/operations/listtransactioncaptures.js +55 -0
  97. package/models/operations/listtransactioncaptures.js.map +1 -0
  98. package/package.json +1 -1
  99. package/sdk/captures.d.ts +19 -0
  100. package/sdk/captures.d.ts.map +1 -0
  101. package/sdk/captures.js +32 -0
  102. package/sdk/captures.js.map +1 -0
  103. package/sdk/transactions.d.ts +3 -0
  104. package/sdk/transactions.d.ts.map +1 -1
  105. package/sdk/transactions.js +4 -0
  106. package/sdk/transactions.js.map +1 -1
  107. package/src/funcs/auditLogsList.ts +2 -2
  108. package/src/funcs/buyersList.ts +2 -2
  109. package/src/funcs/giftCardsList.ts +2 -2
  110. package/src/funcs/merchantAccountsList.ts +2 -2
  111. package/src/funcs/paymentLinksList.ts +2 -2
  112. package/src/funcs/paymentMethodsList.ts +2 -2
  113. package/src/funcs/paymentServiceDefinitionsList.ts +2 -2
  114. package/src/funcs/paymentServicesList.ts +2 -2
  115. package/src/funcs/payoutsList.ts +2 -2
  116. package/src/funcs/reportExecutionsList.ts +2 -2
  117. package/src/funcs/reportsExecutionsList.ts +2 -2
  118. package/src/funcs/reportsList.ts +2 -2
  119. package/src/funcs/threeDsScenariosList.ts +2 -2
  120. package/src/funcs/transactionsCapturesGet.ts +255 -0
  121. package/src/funcs/transactionsCapturesList.ts +247 -0
  122. package/src/funcs/transactionsEventsList.ts +2 -2
  123. package/src/funcs/transactionsList.ts +2 -2
  124. package/src/lib/config.ts +3 -3
  125. package/src/lib/encodings.ts +1 -1
  126. package/src/lib/env.ts +7 -3
  127. package/src/lib/matchers.ts +1 -1
  128. package/src/lib/primitives.ts +16 -0
  129. package/src/models/components/capture.ts +142 -0
  130. package/src/models/components/capturecollection.ts +56 -0
  131. package/src/models/components/index.ts +2 -0
  132. package/src/models/components/nuveipseoptions.ts +2 -2
  133. package/src/models/components/transactioncapturecreate.ts +13 -0
  134. package/src/models/operations/gettransactioncapture.ts +58 -0
  135. package/src/models/operations/index.ts +2 -0
  136. package/src/models/operations/listtransactioncaptures.ts +51 -0
  137. package/src/sdk/captures.ts +51 -0
  138. package/src/sdk/transactions.ts +6 -0
  139. package/lib/dlv.d.ts +0 -14
  140. package/lib/dlv.d.ts.map +0 -1
  141. package/lib/dlv.js +0 -49
  142. package/lib/dlv.js.map +0 -1
  143. package/lib/is-plain-object.d.ts +0 -2
  144. package/lib/is-plain-object.d.ts.map +0 -1
  145. package/lib/is-plain-object.js +0 -41
  146. package/lib/is-plain-object.js.map +0 -1
  147. package/src/lib/dlv.ts +0 -53
  148. package/src/lib/is-plain-object.ts +0 -43
@@ -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
+ }
@@ -3,7 +3,6 @@
3
3
  */
4
4
 
5
5
  import { Gr4vyCore } from "../core.js";
6
- import { dlv } from "../lib/dlv.js";
7
6
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
8
7
  import { matchStatusCode } from "../lib/http.js";
9
8
  import * as M from "../lib/matchers.js";
@@ -303,7 +302,8 @@ async function $do(
303
302
  >;
304
303
  "~next"?: { cursor: string };
305
304
  } => {
306
- const nextCursor = dlv(responseData, "next_cursor");
305
+ const nextCursor =
306
+ (responseData as { next_cursor?: unknown | null }).next_cursor;
307
307
  if (typeof nextCursor !== "string") {
308
308
  return { next: () => null };
309
309
  }
@@ -3,7 +3,6 @@
3
3
  */
4
4
 
5
5
  import { Gr4vyCore } from "../core.js";
6
- import { dlv } from "../lib/dlv.js";
7
6
  import { encodeFormQuery, encodeSimple } from "../lib/encodings.js";
8
7
  import { matchStatusCode } from "../lib/http.js";
9
8
  import * as M from "../lib/matchers.js";
@@ -323,7 +322,8 @@ async function $do(
323
322
  >;
324
323
  "~next"?: { cursor: string };
325
324
  } => {
326
- const nextCursor = dlv(responseData, "next_cursor");
325
+ const nextCursor =
326
+ (responseData as { next_cursor?: unknown | null }).next_cursor;
327
327
  if (typeof nextCursor !== "string") {
328
328
  return { next: () => null };
329
329
  }
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",
81
- genVersion: "2.900.1",
82
- userAgent: "speakeasy-sdk/typescript 2.2.0 2.900.1 1.0.0 @gr4vy/sdk",
80
+ sdkVersion: "2.3.0",
81
+ genVersion: "2.903.2",
82
+ userAgent: "speakeasy-sdk/typescript 2.3.0 2.903.2 1.0.0 @gr4vy/sdk",
83
83
  } as const;
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  import { bytesToBase64 } from "./base64.js";
6
- import { isPlainObject } from "./is-plain-object.js";
6
+ import { isPlainObject } from "./primitives.js";
7
7
 
8
8
  export class EncodingError extends Error {
9
9
  constructor(message: string) {
package/src/lib/env.ts CHANGED
@@ -4,7 +4,6 @@
4
4
 
5
5
  import * as z from "zod/v3";
6
6
  import { SDKOptions } from "./config.js";
7
- import { dlv } from "./dlv.js";
8
7
 
9
8
  export interface Env {
10
9
  GR4VY_BEARER_AUTH?: string | undefined;
@@ -46,11 +45,16 @@ export function env(): Env {
46
45
  return envMemo;
47
46
  }
48
47
 
48
+ const globals = globalThis as {
49
+ Deno?: { env?: { toObject?: () => Record<string, string | undefined> } };
50
+ process?: { env?: Record<string, string | undefined> };
51
+ };
52
+
49
53
  let envObject: Record<string, unknown> = {};
50
54
  if (isDeno()) {
51
- envObject = (globalThis as any).Deno?.env?.toObject?.() ?? {};
55
+ envObject = globals.Deno?.env?.toObject?.() ?? {};
52
56
  } else {
53
- envObject = dlv(globalThis, "process.env") ?? {};
57
+ envObject = globals.process?.env ?? {};
54
58
  }
55
59
 
56
60
  envMemo = envSchema.parse(envObject);
@@ -6,7 +6,7 @@ import { ResponseValidationError } from "../models/errors/responsevalidationerro
6
6
  import { SDKError } from "../models/errors/sdkerror.js";
7
7
  import { ERR, OK, Result } from "../types/fp.js";
8
8
  import { matchResponse, matchStatusCode, StatusCodePredicate } from "./http.js";
9
- import { isPlainObject } from "./is-plain-object.js";
9
+ import { isPlainObject } from "./primitives.js";
10
10
 
11
11
  export type Encoding =
12
12
  | "jsonl"
@@ -148,3 +148,19 @@ export function allRequired<V extends Record<string, unknown>>(
148
148
 
149
149
  return v as ReturnType<typeof allRequired<V>>;
150
150
  }
151
+
152
+ export function isPlainObject(
153
+ value: unknown,
154
+ ): value is Record<string, unknown> {
155
+ if (value === null || typeof value !== "object") return false;
156
+ if (Object.prototype.toString.call(value) !== "[object Object]") return false;
157
+ const proto = Object.getPrototypeOf(value);
158
+ if (proto === null || proto === Object.prototype) return true;
159
+ // cross-realm plain objects (vm contexts, iframes) inherit from a
160
+ // different realm's Object.prototype, which itself has a null prototype
161
+ try {
162
+ return Object.getPrototypeOf(proto) === null;
163
+ } catch {
164
+ return false;
165
+ }
166
+ }
@@ -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
+ }
@@ -46,6 +46,8 @@ export * from "./buyercreate.js";
46
46
  export * from "./buyers.js";
47
47
  export * from "./buyerupdate.js";
48
48
  export * from "./cancelstatus.js";
49
+ export * from "./capture.js";
50
+ export * from "./capturecollection.js";
49
51
  export * from "./capturestatus.js";
50
52
  export * from "./cardpaymentmethodcreate.js";
51
53
  export * from "./cardscheme.js";
@@ -10,11 +10,11 @@ export type NuveiPSEOptions = {
10
10
  */
11
11
  userType?: string | null | undefined;
12
12
  /**
13
- * Customers document type
13
+ * Customer's document type
14
14
  */
15
15
  userFisNumber?: string | null | undefined;
16
16
  /**
17
- * Customers document number
17
+ * Customer's document number
18
18
  */
19
19
  fiscalNumber?: string | null | undefined;
20
20
  /**
@@ -31,6 +31,14 @@ export type TransactionCaptureCreate = {
31
31
  * An array of cart items that represents the line items of this capture.
32
32
  */
33
33
  cartItems?: Array<CartItem> | null | undefined;
34
+ /**
35
+ * Whether this is marked as the final capture for the associated transaction. Must be `true` or omitted when multi-capture is not enabled; a value of `false` is only valid when multi-capture is available on the connection.
36
+ */
37
+ final?: boolean | undefined;
38
+ /**
39
+ * An external identifier that can be used to match the capture against your own records.
40
+ */
41
+ externalIdentifier?: string | null | undefined;
34
42
  };
35
43
 
36
44
  /** @internal */
@@ -38,6 +46,8 @@ export type TransactionCaptureCreate$Outbound = {
38
46
  amount?: number | null | undefined;
39
47
  airline?: Airline$Outbound | null | undefined;
40
48
  cart_items?: Array<CartItem$Outbound> | null | undefined;
49
+ final: boolean;
50
+ external_identifier?: string | null | undefined;
41
51
  };
42
52
 
43
53
  /** @internal */
@@ -49,9 +59,12 @@ export const TransactionCaptureCreate$outboundSchema: z.ZodType<
49
59
  amount: z.nullable(z.number().int()).optional(),
50
60
  airline: z.nullable(Airline$outboundSchema).optional(),
51
61
  cartItems: z.nullable(z.array(CartItem$outboundSchema)).optional(),
62
+ final: z.boolean().default(true),
63
+ externalIdentifier: z.nullable(z.string()).optional(),
52
64
  }).transform((v) => {
53
65
  return remap$(v, {
54
66
  cartItems: "cart_items",
67
+ externalIdentifier: "external_identifier",
55
68
  });
56
69
  });
57
70
 
@@ -0,0 +1,58 @@
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
+
8
+ export type GetTransactionCaptureGlobals = {
9
+ merchantAccountId?: string | undefined;
10
+ };
11
+
12
+ export type GetTransactionCaptureRequest = {
13
+ /**
14
+ * The unique identifier of the transaction.
15
+ */
16
+ transactionId: string;
17
+ /**
18
+ * The unique identifier of the capture.
19
+ */
20
+ captureId: string;
21
+ /**
22
+ * The ID of the merchant account to use for this request.
23
+ */
24
+ merchantAccountId?: string | null | undefined;
25
+ };
26
+
27
+ /** @internal */
28
+ export type GetTransactionCaptureRequest$Outbound = {
29
+ transaction_id: string;
30
+ capture_id: string;
31
+ merchantAccountId?: string | null | undefined;
32
+ };
33
+
34
+ /** @internal */
35
+ export const GetTransactionCaptureRequest$outboundSchema: z.ZodType<
36
+ GetTransactionCaptureRequest$Outbound,
37
+ z.ZodTypeDef,
38
+ GetTransactionCaptureRequest
39
+ > = z.object({
40
+ transactionId: z.string(),
41
+ captureId: z.string(),
42
+ merchantAccountId: z.nullable(z.string()).optional(),
43
+ }).transform((v) => {
44
+ return remap$(v, {
45
+ transactionId: "transaction_id",
46
+ captureId: "capture_id",
47
+ });
48
+ });
49
+
50
+ export function getTransactionCaptureRequestToJSON(
51
+ getTransactionCaptureRequest: GetTransactionCaptureRequest,
52
+ ): string {
53
+ return JSON.stringify(
54
+ GetTransactionCaptureRequest$outboundSchema.parse(
55
+ getTransactionCaptureRequest,
56
+ ),
57
+ );
58
+ }