@gr4vy/sdk 1.9.5 → 1.9.7

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 (59) hide show
  1. package/README.md +5 -0
  2. package/_speakeasy/.github/action-inputs-config.json +53 -0
  3. package/_speakeasy/.github/action-security-config.json +88 -0
  4. package/examples/package-lock.json +1 -1
  5. package/funcs/transactionsActionsList.d.ts +18 -0
  6. package/funcs/transactionsActionsList.d.ts.map +1 -0
  7. package/funcs/transactionsActionsList.js +154 -0
  8. package/funcs/transactionsActionsList.js.map +1 -0
  9. package/jsr.json +1 -1
  10. package/lib/config.d.ts +3 -3
  11. package/lib/config.js +3 -3
  12. package/models/components/flow.d.ts +12 -0
  13. package/models/components/flow.d.ts.map +1 -0
  14. package/models/components/flow.js +49 -0
  15. package/models/components/flow.js.map +1 -0
  16. package/models/components/flowaction.d.ts +12 -0
  17. package/models/components/flowaction.d.ts.map +1 -0
  18. package/models/components/flowaction.js +49 -0
  19. package/models/components/flowaction.js.map +1 -0
  20. package/models/components/index.d.ts +4 -0
  21. package/models/components/index.d.ts.map +1 -1
  22. package/models/components/index.js +4 -0
  23. package/models/components/index.js.map +1 -1
  24. package/models/components/transactionaction.d.ts +31 -0
  25. package/models/components/transactionaction.d.ts.map +1 -0
  26. package/models/components/transactionaction.js +63 -0
  27. package/models/components/transactionaction.js.map +1 -0
  28. package/models/components/transactionactions.d.ts +14 -0
  29. package/models/components/transactionactions.d.ts.map +1 -0
  30. package/models/components/transactionactions.js +51 -0
  31. package/models/components/transactionactions.js.map +1 -0
  32. package/models/operations/index.d.ts +1 -0
  33. package/models/operations/index.d.ts.map +1 -1
  34. package/models/operations/index.js +1 -0
  35. package/models/operations/index.js.map +1 -1
  36. package/models/operations/listtransactionactions.d.ts +23 -0
  37. package/models/operations/listtransactionactions.d.ts.map +1 -0
  38. package/models/operations/listtransactionactions.js +55 -0
  39. package/models/operations/listtransactionactions.js.map +1 -0
  40. package/package.json +1 -1
  41. package/sdk/actions.d.ts +12 -0
  42. package/sdk/actions.d.ts.map +1 -0
  43. package/sdk/actions.js +22 -0
  44. package/sdk/actions.js.map +1 -0
  45. package/sdk/transactions.d.ts +3 -0
  46. package/sdk/transactions.d.ts.map +1 -1
  47. package/sdk/transactions.js +4 -0
  48. package/sdk/transactions.js.map +1 -1
  49. package/src/funcs/transactionsActionsList.ts +259 -0
  50. package/src/lib/config.ts +3 -3
  51. package/src/models/components/flow.ts +19 -0
  52. package/src/models/components/flowaction.ts +22 -0
  53. package/src/models/components/index.ts +4 -0
  54. package/src/models/components/transactionaction.ts +61 -0
  55. package/src/models/components/transactionactions.ts +38 -0
  56. package/src/models/operations/index.ts +1 -0
  57. package/src/models/operations/listtransactionactions.ts +51 -0
  58. package/src/sdk/actions.ts +29 -0
  59. package/src/sdk/transactions.ts +6 -0
@@ -0,0 +1,259 @@
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 * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { safeParse } from "../lib/schemas.js";
10
+ import { RequestOptions } from "../lib/sdks.js";
11
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import * as components from "../models/components/index.js";
14
+ import { Gr4vyError } from "../models/errors/gr4vyerror.js";
15
+ import {
16
+ ConnectionError,
17
+ InvalidRequestError,
18
+ RequestAbortedError,
19
+ RequestTimeoutError,
20
+ UnexpectedClientError,
21
+ } from "../models/errors/httpclienterrors.js";
22
+ import * as errors from "../models/errors/index.js";
23
+ import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
24
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
25
+ import * as operations from "../models/operations/index.js";
26
+ import { APICall, APIPromise } from "../types/async.js";
27
+ import { Result } from "../types/fp.js";
28
+
29
+ /**
30
+ * Get Flow actions for transaction
31
+ *
32
+ * @remarks
33
+ * Retrieve the list of Flow actions that have been triggered for a transaction.
34
+ */
35
+ export function transactionsActionsList(
36
+ client: Gr4vyCore,
37
+ transactionId: string,
38
+ merchantAccountId?: string | null | undefined,
39
+ options?: RequestOptions,
40
+ ): APIPromise<
41
+ Result<
42
+ components.TransactionActions,
43
+ | errors.Error400
44
+ | errors.Error401
45
+ | errors.Error403
46
+ | errors.Error404
47
+ | errors.Error405
48
+ | errors.Error409
49
+ | errors.HTTPValidationError
50
+ | errors.Error425
51
+ | errors.Error429
52
+ | errors.Error500
53
+ | errors.Error502
54
+ | errors.Error504
55
+ | Gr4vyError
56
+ | ResponseValidationError
57
+ | ConnectionError
58
+ | RequestAbortedError
59
+ | RequestTimeoutError
60
+ | InvalidRequestError
61
+ | UnexpectedClientError
62
+ | SDKValidationError
63
+ >
64
+ > {
65
+ return new APIPromise($do(
66
+ client,
67
+ transactionId,
68
+ merchantAccountId,
69
+ options,
70
+ ));
71
+ }
72
+
73
+ async function $do(
74
+ client: Gr4vyCore,
75
+ transactionId: string,
76
+ merchantAccountId?: string | null | undefined,
77
+ options?: RequestOptions,
78
+ ): Promise<
79
+ [
80
+ Result<
81
+ components.TransactionActions,
82
+ | errors.Error400
83
+ | errors.Error401
84
+ | errors.Error403
85
+ | errors.Error404
86
+ | errors.Error405
87
+ | errors.Error409
88
+ | errors.HTTPValidationError
89
+ | errors.Error425
90
+ | errors.Error429
91
+ | errors.Error500
92
+ | errors.Error502
93
+ | errors.Error504
94
+ | Gr4vyError
95
+ | ResponseValidationError
96
+ | ConnectionError
97
+ | RequestAbortedError
98
+ | RequestTimeoutError
99
+ | InvalidRequestError
100
+ | UnexpectedClientError
101
+ | SDKValidationError
102
+ >,
103
+ APICall,
104
+ ]
105
+ > {
106
+ const input: operations.ListTransactionActionsRequest = {
107
+ transactionId: transactionId,
108
+ merchantAccountId: merchantAccountId,
109
+ };
110
+
111
+ const parsed = safeParse(
112
+ input,
113
+ (value) =>
114
+ operations.ListTransactionActionsRequest$outboundSchema.parse(value),
115
+ "Input validation failed",
116
+ );
117
+ if (!parsed.ok) {
118
+ return [parsed, { status: "invalid" }];
119
+ }
120
+ const payload = parsed.value;
121
+ const body = null;
122
+
123
+ const pathParams = {
124
+ transaction_id: encodeSimple("transaction_id", payload.transaction_id, {
125
+ explode: false,
126
+ charEncoding: "percent",
127
+ }),
128
+ };
129
+
130
+ const path = pathToFunc("/transactions/{transaction_id}/actions")(pathParams);
131
+
132
+ const headers = new Headers(compactMap({
133
+ Accept: "application/json",
134
+ "x-gr4vy-merchant-account-id": encodeSimple(
135
+ "x-gr4vy-merchant-account-id",
136
+ payload.merchantAccountId ?? client._options.merchantAccountId,
137
+ { explode: false, charEncoding: "none" },
138
+ ),
139
+ }));
140
+
141
+ const secConfig = await extractSecurity(client._options.bearerAuth);
142
+ const securityInput = secConfig == null ? {} : { bearerAuth: secConfig };
143
+ const requestSecurity = resolveGlobalSecurity(securityInput);
144
+
145
+ const context = {
146
+ options: client._options,
147
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
148
+ operationID: "list_transaction_actions",
149
+ oAuth2Scopes: null,
150
+
151
+ resolvedSecurity: requestSecurity,
152
+
153
+ securitySource: client._options.bearerAuth,
154
+ retryConfig: options?.retries
155
+ || client._options.retryConfig
156
+ || {
157
+ strategy: "backoff",
158
+ backoff: {
159
+ initialInterval: 200,
160
+ maxInterval: 200,
161
+ exponent: 1,
162
+ maxElapsedTime: 1000,
163
+ },
164
+ retryConnectionErrors: true,
165
+ }
166
+ || { strategy: "none" },
167
+ retryCodes: options?.retryCodes || ["5XX"],
168
+ };
169
+
170
+ const requestRes = client._createRequest(context, {
171
+ security: requestSecurity,
172
+ method: "GET",
173
+ baseURL: options?.serverURL,
174
+ path: path,
175
+ headers: headers,
176
+ body: body,
177
+ userAgent: client._options.userAgent,
178
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
179
+ }, options);
180
+ if (!requestRes.ok) {
181
+ return [requestRes, { status: "invalid" }];
182
+ }
183
+ const req = requestRes.value;
184
+
185
+ const doResult = await client._do(req, {
186
+ context,
187
+ errorCodes: [
188
+ "400",
189
+ "401",
190
+ "403",
191
+ "404",
192
+ "405",
193
+ "409",
194
+ "422",
195
+ "425",
196
+ "429",
197
+ "4XX",
198
+ "500",
199
+ "502",
200
+ "504",
201
+ "5XX",
202
+ ],
203
+ retryConfig: context.retryConfig,
204
+ retryCodes: context.retryCodes,
205
+ });
206
+ if (!doResult.ok) {
207
+ return [doResult, { status: "request-error", request: req }];
208
+ }
209
+ const response = doResult.value;
210
+
211
+ const responseFields = {
212
+ HttpMeta: { Response: response, Request: req },
213
+ };
214
+
215
+ const [result] = await M.match<
216
+ components.TransactionActions,
217
+ | errors.Error400
218
+ | errors.Error401
219
+ | errors.Error403
220
+ | errors.Error404
221
+ | errors.Error405
222
+ | errors.Error409
223
+ | errors.HTTPValidationError
224
+ | errors.Error425
225
+ | errors.Error429
226
+ | errors.Error500
227
+ | errors.Error502
228
+ | errors.Error504
229
+ | Gr4vyError
230
+ | ResponseValidationError
231
+ | ConnectionError
232
+ | RequestAbortedError
233
+ | RequestTimeoutError
234
+ | InvalidRequestError
235
+ | UnexpectedClientError
236
+ | SDKValidationError
237
+ >(
238
+ M.json(200, components.TransactionActions$inboundSchema),
239
+ M.jsonErr(400, errors.Error400$inboundSchema),
240
+ M.jsonErr(401, errors.Error401$inboundSchema),
241
+ M.jsonErr(403, errors.Error403$inboundSchema),
242
+ M.jsonErr(404, errors.Error404$inboundSchema),
243
+ M.jsonErr(405, errors.Error405$inboundSchema),
244
+ M.jsonErr(409, errors.Error409$inboundSchema),
245
+ M.jsonErr(422, errors.HTTPValidationError$inboundSchema),
246
+ M.jsonErr(425, errors.Error425$inboundSchema),
247
+ M.jsonErr(429, errors.Error429$inboundSchema),
248
+ M.jsonErr(500, errors.Error500$inboundSchema),
249
+ M.jsonErr(502, errors.Error502$inboundSchema),
250
+ M.jsonErr(504, errors.Error504$inboundSchema),
251
+ M.fail("4XX"),
252
+ M.fail("5XX"),
253
+ )(response, req, { extraFields: responseFields });
254
+ if (!result.ok) {
255
+ return [result, { status: "complete", request: req, response }];
256
+ }
257
+
258
+ return [result, { status: "complete", request: req, response }];
259
+ }
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: "1.9.5",
81
- genVersion: "2.788.4",
82
- userAgent: "speakeasy-sdk/typescript 1.9.5 2.788.4 1.0.0 @gr4vy/sdk",
80
+ sdkVersion: "1.9.7",
81
+ genVersion: "2.791.1",
82
+ userAgent: "speakeasy-sdk/typescript 1.9.7 2.791.1 1.0.0 @gr4vy/sdk",
83
83
  } as const;
@@ -0,0 +1,19 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import * as openEnums from "../../types/enums.js";
7
+ import { OpenEnum } from "../../types/enums.js";
8
+
9
+ export const Flow = {
10
+ Checkout: "checkout",
11
+ CardTransaction: "card-transaction",
12
+ NonCardTransaction: "non-card-transaction",
13
+ RedirectTransaction: "redirect-transaction",
14
+ } as const;
15
+ export type Flow = OpenEnum<typeof Flow>;
16
+
17
+ /** @internal */
18
+ export const Flow$inboundSchema: z.ZodType<Flow, z.ZodTypeDef, unknown> =
19
+ openEnums.inboundSchema(Flow);
@@ -0,0 +1,22 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import * as openEnums from "../../types/enums.js";
7
+ import { OpenEnum } from "../../types/enums.js";
8
+
9
+ export const FlowAction = {
10
+ SelectPaymentOptions: "select-payment-options",
11
+ RouteTransaction: "route-transaction",
12
+ DeclineEarly: "decline-early",
13
+ Skip3ds: "skip-3ds",
14
+ } as const;
15
+ export type FlowAction = OpenEnum<typeof FlowAction>;
16
+
17
+ /** @internal */
18
+ export const FlowAction$inboundSchema: z.ZodType<
19
+ FlowAction,
20
+ z.ZodTypeDef,
21
+ unknown
22
+ > = openEnums.inboundSchema(FlowAction);
@@ -85,6 +85,8 @@ export * from "./errorlocation.js";
85
85
  export * from "./field.js";
86
86
  export * from "./fiservinstallmentoptions.js";
87
87
  export * from "./fiservoptions.js";
88
+ export * from "./flow.js";
89
+ export * from "./flowaction.js";
88
90
  export * from "./forterantifraudoptions.js";
89
91
  export * from "./forterantifraudoptionscartitem.js";
90
92
  export * from "./forterantifraudoptionscartitembasicitemdata.js";
@@ -231,6 +233,8 @@ export * from "./threedsecurestatus.js";
231
233
  export * from "./threedsecurev2.js";
232
234
  export * from "./tokenpaymentmethodcreate.js";
233
235
  export * from "./transaction.js";
236
+ export * from "./transactionaction.js";
237
+ export * from "./transactionactions.js";
234
238
  export * from "./transactionbuyer.js";
235
239
  export * from "./transactioncancel.js";
236
240
  export * from "./transactioncapture.js";
@@ -0,0 +1,61 @@
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 { Flow, Flow$inboundSchema } from "./flow.js";
11
+ import { FlowAction, FlowAction$inboundSchema } from "./flowaction.js";
12
+
13
+ export type TransactionAction = {
14
+ /**
15
+ * Always `action`.
16
+ */
17
+ type: "action";
18
+ id: FlowAction;
19
+ flow: Flow;
20
+ /**
21
+ * The ID of the rule that triggered this action.
22
+ */
23
+ ruleId: string;
24
+ /**
25
+ * The date this action was created at.
26
+ */
27
+ createdAt: Date;
28
+ /**
29
+ * The outcome of the action.
30
+ */
31
+ outcome: { [k: string]: any };
32
+ };
33
+
34
+ /** @internal */
35
+ export const TransactionAction$inboundSchema: z.ZodType<
36
+ TransactionAction,
37
+ z.ZodTypeDef,
38
+ unknown
39
+ > = z.object({
40
+ type: z.literal("action").default("action"),
41
+ id: FlowAction$inboundSchema,
42
+ flow: Flow$inboundSchema,
43
+ rule_id: z.string(),
44
+ created_at: z.string().datetime({ offset: true }).transform(v => new Date(v)),
45
+ outcome: z.record(z.any()),
46
+ }).transform((v) => {
47
+ return remap$(v, {
48
+ "rule_id": "ruleId",
49
+ "created_at": "createdAt",
50
+ });
51
+ });
52
+
53
+ export function transactionActionFromJSON(
54
+ jsonString: string,
55
+ ): SafeParseResult<TransactionAction, SDKValidationError> {
56
+ return safeParse(
57
+ jsonString,
58
+ (x) => TransactionAction$inboundSchema.parse(JSON.parse(x)),
59
+ `Failed to parse 'TransactionAction' from JSON`,
60
+ );
61
+ }
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod/v3";
6
+ import { safeParse } from "../../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../../types/fp.js";
8
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
9
+ import {
10
+ TransactionAction,
11
+ TransactionAction$inboundSchema,
12
+ } from "./transactionaction.js";
13
+
14
+ export type TransactionActions = {
15
+ /**
16
+ * The list of actions triggered for a transaction.
17
+ */
18
+ items: Array<TransactionAction>;
19
+ };
20
+
21
+ /** @internal */
22
+ export const TransactionActions$inboundSchema: z.ZodType<
23
+ TransactionActions,
24
+ z.ZodTypeDef,
25
+ unknown
26
+ > = z.object({
27
+ items: z.array(TransactionAction$inboundSchema),
28
+ });
29
+
30
+ export function transactionActionsFromJSON(
31
+ jsonString: string,
32
+ ): SafeParseResult<TransactionActions, SDKValidationError> {
33
+ return safeParse(
34
+ jsonString,
35
+ (x) => TransactionActions$inboundSchema.parse(JSON.parse(x)),
36
+ `Failed to parse 'TransactionActions' from JSON`,
37
+ );
38
+ }
@@ -74,6 +74,7 @@ export * from "./listpaymentservices.js";
74
74
  export * from "./listpayouts.js";
75
75
  export * from "./listreportexecutions.js";
76
76
  export * from "./listreports.js";
77
+ export * from "./listtransactionactions.js";
77
78
  export * from "./listtransactionevents.js";
78
79
  export * from "./listtransactionrefunds.js";
79
80
  export * from "./listtransactions.js";
@@ -0,0 +1,51 @@
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 ListTransactionActionsGlobals = {
9
+ merchantAccountId?: string | undefined;
10
+ };
11
+
12
+ export type ListTransactionActionsRequest = {
13
+ /**
14
+ * The ID of the transaction
15
+ */
16
+ transactionId: string;
17
+ /**
18
+ * The ID of the merchant account to use for this request.
19
+ */
20
+ merchantAccountId?: string | null | undefined;
21
+ };
22
+
23
+ /** @internal */
24
+ export type ListTransactionActionsRequest$Outbound = {
25
+ transaction_id: string;
26
+ merchantAccountId?: string | null | undefined;
27
+ };
28
+
29
+ /** @internal */
30
+ export const ListTransactionActionsRequest$outboundSchema: z.ZodType<
31
+ ListTransactionActionsRequest$Outbound,
32
+ z.ZodTypeDef,
33
+ ListTransactionActionsRequest
34
+ > = z.object({
35
+ transactionId: z.string(),
36
+ merchantAccountId: z.nullable(z.string()).optional(),
37
+ }).transform((v) => {
38
+ return remap$(v, {
39
+ transactionId: "transaction_id",
40
+ });
41
+ });
42
+
43
+ export function listTransactionActionsRequestToJSON(
44
+ listTransactionActionsRequest: ListTransactionActionsRequest,
45
+ ): string {
46
+ return JSON.stringify(
47
+ ListTransactionActionsRequest$outboundSchema.parse(
48
+ listTransactionActionsRequest,
49
+ ),
50
+ );
51
+ }
@@ -0,0 +1,29 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { transactionsActionsList } from "../funcs/transactionsActionsList.js";
6
+ import { ClientSDK, RequestOptions } from "../lib/sdks.js";
7
+ import * as components from "../models/components/index.js";
8
+ import { unwrapAsync } from "../types/fp.js";
9
+
10
+ export class Actions extends ClientSDK {
11
+ /**
12
+ * Get Flow actions for transaction
13
+ *
14
+ * @remarks
15
+ * Retrieve the list of Flow actions that have been triggered for a transaction.
16
+ */
17
+ async list(
18
+ transactionId: string,
19
+ merchantAccountId?: string | null | undefined,
20
+ options?: RequestOptions,
21
+ ): Promise<components.TransactionActions> {
22
+ return unwrapAsync(transactionsActionsList(
23
+ this,
24
+ transactionId,
25
+ merchantAccountId,
26
+ options,
27
+ ));
28
+ }
29
+ }
@@ -15,6 +15,7 @@ import * as components from "../models/components/index.js";
15
15
  import * as operations from "../models/operations/index.js";
16
16
  import { unwrapAsync } from "../types/fp.js";
17
17
  import { PageIterator, unwrapResultIterator } from "../types/operations.js";
18
+ import { Actions } from "./actions.js";
18
19
  import { Events } from "./events.js";
19
20
  import { Gr4vyRefunds } from "./gr4vyrefunds.js";
20
21
  import { Settlements } from "./settlements.js";
@@ -25,6 +26,11 @@ export class Transactions extends ClientSDK {
25
26
  return (this._refunds ??= new Gr4vyRefunds(this._options));
26
27
  }
27
28
 
29
+ private _actions?: Actions;
30
+ get actions(): Actions {
31
+ return (this._actions ??= new Actions(this._options));
32
+ }
33
+
28
34
  private _events?: Events;
29
35
  get events(): Events {
30
36
  return (this._events ??= new Events(this._options));