@moovio/sdk 0.6.1 → 0.6.2

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 (95) hide show
  1. package/README.md +19 -0
  2. package/bin/mcp-server.js +769 -272
  3. package/bin/mcp-server.js.map +20 -9
  4. package/docs/sdks/receipts/README.md +189 -0
  5. package/funcs/receiptsCreate.d.ts +18 -0
  6. package/funcs/receiptsCreate.d.ts.map +1 -0
  7. package/funcs/receiptsCreate.js +133 -0
  8. package/funcs/receiptsCreate.js.map +1 -0
  9. package/funcs/receiptsList.d.ts +16 -0
  10. package/funcs/receiptsList.d.ts.map +1 -0
  11. package/funcs/receiptsList.js +121 -0
  12. package/funcs/receiptsList.js.map +1 -0
  13. package/jsr.json +1 -1
  14. package/lib/config.d.ts +3 -3
  15. package/lib/config.js +3 -3
  16. package/mcp-server/mcp-server.js +1 -1
  17. package/mcp-server/server.d.ts.map +1 -1
  18. package/mcp-server/server.js +5 -1
  19. package/mcp-server/server.js.map +1 -1
  20. package/mcp-server/tools/receiptsCreate.d.ts +9 -0
  21. package/mcp-server/tools/receiptsCreate.d.ts.map +1 -0
  22. package/mcp-server/tools/receiptsCreate.js +66 -0
  23. package/mcp-server/tools/receiptsCreate.js.map +1 -0
  24. package/mcp-server/tools/receiptsList.d.ts +8 -0
  25. package/mcp-server/tools/receiptsList.d.ts.map +1 -0
  26. package/mcp-server/tools/receiptsList.js +65 -0
  27. package/mcp-server/tools/receiptsList.js.map +1 -0
  28. package/models/components/index.d.ts +4 -0
  29. package/models/components/index.d.ts.map +1 -1
  30. package/models/components/index.js +4 -0
  31. package/models/components/index.js.map +1 -1
  32. package/models/components/receiptkind.d.ts +31 -0
  33. package/models/components/receiptkind.d.ts.map +1 -0
  34. package/models/components/receiptkind.js +63 -0
  35. package/models/components/receiptkind.js.map +1 -0
  36. package/models/components/receiptrequest.d.ts +76 -0
  37. package/models/components/receiptrequest.d.ts.map +1 -0
  38. package/models/components/receiptrequest.js +80 -0
  39. package/models/components/receiptrequest.js.map +1 -0
  40. package/models/components/receiptresponse.d.ts +94 -0
  41. package/models/components/receiptresponse.d.ts.map +1 -0
  42. package/models/components/receiptresponse.js +90 -0
  43. package/models/components/receiptresponse.js.map +1 -0
  44. package/models/components/sentreceipt.d.ts +42 -0
  45. package/models/components/sentreceipt.d.ts.map +1 -0
  46. package/models/components/sentreceipt.js +73 -0
  47. package/models/components/sentreceipt.js.map +1 -0
  48. package/models/errors/index.d.ts +1 -0
  49. package/models/errors/index.d.ts.map +1 -1
  50. package/models/errors/index.js +1 -0
  51. package/models/errors/index.js.map +1 -1
  52. package/models/errors/receiptvalidationerror.d.ts +46 -0
  53. package/models/errors/receiptvalidationerror.d.ts.map +1 -0
  54. package/models/errors/receiptvalidationerror.js +98 -0
  55. package/models/errors/receiptvalidationerror.js.map +1 -0
  56. package/models/operations/createreceipts.d.ts +74 -0
  57. package/models/operations/createreceipts.d.ts.map +1 -0
  58. package/models/operations/createreceipts.js +118 -0
  59. package/models/operations/createreceipts.js.map +1 -0
  60. package/models/operations/index.d.ts +2 -0
  61. package/models/operations/index.d.ts.map +1 -1
  62. package/models/operations/index.js +2 -0
  63. package/models/operations/index.js.map +1 -1
  64. package/models/operations/listreceipts.d.ts +102 -0
  65. package/models/operations/listreceipts.d.ts.map +1 -0
  66. package/models/operations/listreceipts.js +145 -0
  67. package/models/operations/listreceipts.js.map +1 -0
  68. package/package.json +1 -1
  69. package/sdk/receipts.d.ts +20 -0
  70. package/sdk/receipts.d.ts.map +1 -0
  71. package/sdk/receipts.js +32 -0
  72. package/sdk/receipts.js.map +1 -0
  73. package/sdk/sdk.d.ts +3 -0
  74. package/sdk/sdk.d.ts.map +1 -1
  75. package/sdk/sdk.js +4 -0
  76. package/sdk/sdk.js.map +1 -1
  77. package/src/funcs/receiptsCreate.ts +190 -0
  78. package/src/funcs/receiptsList.ts +171 -0
  79. package/src/lib/config.ts +3 -3
  80. package/src/mcp-server/mcp-server.ts +1 -1
  81. package/src/mcp-server/server.ts +5 -1
  82. package/src/mcp-server/tools/receiptsCreate.ts +39 -0
  83. package/src/mcp-server/tools/receiptsList.ts +38 -0
  84. package/src/models/components/index.ts +4 -0
  85. package/src/models/components/receiptkind.ts +36 -0
  86. package/src/models/components/receiptrequest.ts +123 -0
  87. package/src/models/components/receiptresponse.ts +157 -0
  88. package/src/models/components/sentreceipt.ts +79 -0
  89. package/src/models/errors/index.ts +1 -0
  90. package/src/models/errors/receiptvalidationerror.ts +99 -0
  91. package/src/models/operations/createreceipts.ts +161 -0
  92. package/src/models/operations/index.ts +2 -0
  93. package/src/models/operations/listreceipts.ts +222 -0
  94. package/src/sdk/receipts.ts +46 -0
  95. package/src/sdk/sdk.ts +6 -0
@@ -0,0 +1,171 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { MoovCore } from "../core.js";
6
+ import { encodeFormQuery, 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 { APIError } from "../models/errors/apierror.js";
14
+ import {
15
+ ConnectionError,
16
+ InvalidRequestError,
17
+ RequestAbortedError,
18
+ RequestTimeoutError,
19
+ UnexpectedClientError,
20
+ } from "../models/errors/httpclienterrors.js";
21
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
22
+ import * as operations from "../models/operations/index.js";
23
+ import { APICall, APIPromise } from "../types/async.js";
24
+ import { Result } from "../types/fp.js";
25
+
26
+ /**
27
+ * List receipts by trasnferID, scheduleID, or occurrenceID.
28
+ *
29
+ * To access this endpoint using an [access token](https://docs.moov.io/api/authentication/access-tokens/)
30
+ * you'll need to specify the `/accounts/{accountID}/transfers.read` scope.
31
+ */
32
+ export function receiptsList(
33
+ client: MoovCore,
34
+ request: operations.ListReceiptsRequest,
35
+ options?: RequestOptions,
36
+ ): APIPromise<
37
+ Result<
38
+ operations.ListReceiptsResponse,
39
+ | APIError
40
+ | SDKValidationError
41
+ | UnexpectedClientError
42
+ | InvalidRequestError
43
+ | RequestAbortedError
44
+ | RequestTimeoutError
45
+ | ConnectionError
46
+ >
47
+ > {
48
+ return new APIPromise($do(
49
+ client,
50
+ request,
51
+ options,
52
+ ));
53
+ }
54
+
55
+ async function $do(
56
+ client: MoovCore,
57
+ request: operations.ListReceiptsRequest,
58
+ options?: RequestOptions,
59
+ ): Promise<
60
+ [
61
+ Result<
62
+ operations.ListReceiptsResponse,
63
+ | APIError
64
+ | SDKValidationError
65
+ | UnexpectedClientError
66
+ | InvalidRequestError
67
+ | RequestAbortedError
68
+ | RequestTimeoutError
69
+ | ConnectionError
70
+ >,
71
+ APICall,
72
+ ]
73
+ > {
74
+ const parsed = safeParse(
75
+ request,
76
+ (value) => operations.ListReceiptsRequest$outboundSchema.parse(value),
77
+ "Input validation failed",
78
+ );
79
+ if (!parsed.ok) {
80
+ return [parsed, { status: "invalid" }];
81
+ }
82
+ const payload = parsed.value;
83
+ const body = null;
84
+
85
+ const path = pathToFunc("/receipts")();
86
+
87
+ const query = encodeFormQuery({
88
+ "id": payload.id,
89
+ }, { explode: false });
90
+
91
+ const headers = new Headers(compactMap({
92
+ Accept: "application/json",
93
+ "x-moov-version": encodeSimple(
94
+ "x-moov-version",
95
+ client._options.xMoovVersion,
96
+ { explode: false, charEncoding: "none" },
97
+ ),
98
+ }));
99
+
100
+ const securityInput = await extractSecurity(client._options.security);
101
+ const requestSecurity = resolveGlobalSecurity(securityInput);
102
+
103
+ const context = {
104
+ baseURL: options?.serverURL ?? client._baseURL ?? "",
105
+ operationID: "listReceipts",
106
+ oAuth2Scopes: [],
107
+
108
+ resolvedSecurity: requestSecurity,
109
+
110
+ securitySource: client._options.security,
111
+ retryConfig: options?.retries
112
+ || client._options.retryConfig
113
+ || { strategy: "none" },
114
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
115
+ };
116
+
117
+ const requestRes = client._createRequest(context, {
118
+ security: requestSecurity,
119
+ method: "GET",
120
+ baseURL: options?.serverURL,
121
+ path: path,
122
+ headers: headers,
123
+ query: query,
124
+ body: body,
125
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
126
+ }, options);
127
+ if (!requestRes.ok) {
128
+ return [requestRes, { status: "invalid" }];
129
+ }
130
+ const req = requestRes.value;
131
+
132
+ const doResult = await client._do(req, {
133
+ context,
134
+ errorCodes: ["401", "403", "429", "4XX", "500", "504", "5XX"],
135
+ retryConfig: context.retryConfig,
136
+ retryCodes: context.retryCodes,
137
+ });
138
+ if (!doResult.ok) {
139
+ return [doResult, { status: "request-error", request: req }];
140
+ }
141
+ const response = doResult.value;
142
+
143
+ const responseFields = {
144
+ HttpMeta: { Response: response, Request: req },
145
+ };
146
+
147
+ const [result] = await M.match<
148
+ operations.ListReceiptsResponse,
149
+ | APIError
150
+ | SDKValidationError
151
+ | UnexpectedClientError
152
+ | InvalidRequestError
153
+ | RequestAbortedError
154
+ | RequestTimeoutError
155
+ | ConnectionError
156
+ >(
157
+ M.json(200, operations.ListReceiptsResponse$inboundSchema, {
158
+ hdrs: true,
159
+ key: "Result",
160
+ }),
161
+ M.fail([401, 403, 429]),
162
+ M.fail([500, 504]),
163
+ M.fail("4XX"),
164
+ M.fail("5XX"),
165
+ )(response, { extraFields: responseFields });
166
+ if (!result.ok) {
167
+ return [result, { status: "complete", request: req, response }];
168
+ }
169
+
170
+ return [result, { status: "complete", request: req, response }];
171
+ }
package/src/lib/config.ts CHANGED
@@ -69,7 +69,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
69
69
  export const SDK_METADATA = {
70
70
  language: "typescript",
71
71
  openapiDocVersion: "latest",
72
- sdkVersion: "0.6.1",
73
- genVersion: "2.539.1",
74
- userAgent: "speakeasy-sdk/typescript 0.6.1 2.539.1 latest @moovio/sdk",
72
+ sdkVersion: "0.6.2",
73
+ genVersion: "2.541.0",
74
+ userAgent: "speakeasy-sdk/typescript 0.6.2 2.541.0 latest @moovio/sdk",
75
75
  } as const;
@@ -19,7 +19,7 @@ const routes = buildRouteMap({
19
19
  export const app = buildApplication(routes, {
20
20
  name: "mcp",
21
21
  versionInfo: {
22
- currentVersion: "0.6.1",
22
+ currentVersion: "0.6.2",
23
23
  },
24
24
  });
25
25
 
@@ -99,6 +99,8 @@ import { tool$paymentLinksUpdate } from "./tools/paymentLinksUpdate.js";
99
99
  import { tool$paymentMethodsGet } from "./tools/paymentMethodsGet.js";
100
100
  import { tool$paymentMethodsList } from "./tools/paymentMethodsList.js";
101
101
  import { tool$pingPing } from "./tools/pingPing.js";
102
+ import { tool$receiptsCreate } from "./tools/receiptsCreate.js";
103
+ import { tool$receiptsList } from "./tools/receiptsList.js";
102
104
  import { tool$representativesCreate } from "./tools/representativesCreate.js";
103
105
  import { tool$representativesDelete } from "./tools/representativesDelete.js";
104
106
  import { tool$representativesGet } from "./tools/representativesGet.js";
@@ -149,7 +151,7 @@ export function createMCPServer(deps: {
149
151
  }) {
150
152
  const server = new McpServer({
151
153
  name: "Moov",
152
- version: "0.6.1",
154
+ version: "0.6.2",
153
155
  });
154
156
 
155
157
  const client = new MoovCore({
@@ -293,6 +295,8 @@ export function createMCPServer(deps: {
293
295
  tool(tool$onboardingGetInvite);
294
296
  tool(tool$onboardingRevokeInvite);
295
297
  tool(tool$pingPing);
298
+ tool(tool$receiptsCreate);
299
+ tool(tool$receiptsList);
296
300
  tool(tool$terminalApplicationsCreate);
297
301
  tool(tool$terminalApplicationsList);
298
302
  tool(tool$terminalApplicationsGet);
@@ -0,0 +1,39 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
6
+ import { receiptsCreate } from "../../funcs/receiptsCreate.js";
7
+ import * as components from "../../models/components/index.js";
8
+ import { formatResult, ToolDefinition } from "../tools.js";
9
+
10
+ const args = {
11
+ request: z.array(components.ReceiptRequest$inboundSchema),
12
+ };
13
+
14
+ export const tool$receiptsCreate: ToolDefinition<typeof args> = {
15
+ name: "receipts_create",
16
+ description: ` Create receipts for transfers and scheduled transfers.
17
+
18
+ To access this endpoint using an [access token](https://docs.moov.io/api/authentication/access-tokens/)
19
+ you'll need to specify the \`/accounts/{accountID}/transfers.write\` scope.`,
20
+ args,
21
+ tool: async (client, args, ctx) => {
22
+ const [result, apiCall] = await receiptsCreate(
23
+ client,
24
+ args.request,
25
+ { fetchOptions: { signal: ctx.signal } },
26
+ ).$inspect();
27
+
28
+ if (!result.ok) {
29
+ return {
30
+ content: [{ type: "text", text: result.error.message }],
31
+ isError: true,
32
+ };
33
+ }
34
+
35
+ const value = result.value.result;
36
+
37
+ return formatResult(value, apiCall);
38
+ },
39
+ };
@@ -0,0 +1,38 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { receiptsList } from "../../funcs/receiptsList.js";
6
+ import * as operations from "../../models/operations/index.js";
7
+ import { formatResult, ToolDefinition } from "../tools.js";
8
+
9
+ const args = {
10
+ request: operations.ListReceiptsRequest$inboundSchema,
11
+ };
12
+
13
+ export const tool$receiptsList: ToolDefinition<typeof args> = {
14
+ name: "receipts_list",
15
+ description: `List receipts by trasnferID, scheduleID, or occurrenceID.
16
+
17
+ To access this endpoint using an [access token](https://docs.moov.io/api/authentication/access-tokens/)
18
+ you'll need to specify the \`/accounts/{accountID}/transfers.read\` scope.`,
19
+ args,
20
+ tool: async (client, args, ctx) => {
21
+ const [result, apiCall] = await receiptsList(
22
+ client,
23
+ args.request,
24
+ { fetchOptions: { signal: ctx.signal } },
25
+ ).$inspect();
26
+
27
+ if (!result.ok) {
28
+ return {
29
+ content: [{ type: "text", text: result.error.message }],
30
+ isError: true,
31
+ };
32
+ }
33
+
34
+ const value = result.value.result;
35
+
36
+ return formatResult(value, apiCall);
37
+ },
38
+ };
@@ -269,6 +269,9 @@ export * from "./profile.js";
269
269
  export * from "./pullfromcardpaymentmethod.js";
270
270
  export * from "./pushtocardpaymentmethod.js";
271
271
  export * from "./qrcode.js";
272
+ export * from "./receiptkind.js";
273
+ export * from "./receiptrequest.js";
274
+ export * from "./receiptresponse.js";
272
275
  export * from "./recur.js";
273
276
  export * from "./refundcarddetails.js";
274
277
  export * from "./refundcardstatus.js";
@@ -296,6 +299,7 @@ export * from "./schedulepaymentmethod.js";
296
299
  export * from "./scheduleresponse.js";
297
300
  export * from "./seccode.js";
298
301
  export * from "./security.js";
302
+ export * from "./sentreceipt.js";
299
303
  export * from "./settings.js";
300
304
  export * from "./sourcedestinationoptions.js";
301
305
  export * from "./sweep.js";
@@ -0,0 +1,36 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
6
+ import { ClosedEnum } from "../../types/enums.js";
7
+
8
+ /**
9
+ * The type of receipt being requested.
10
+ */
11
+ export const ReceiptKind = {
12
+ SaleCustomerV1: "sale.customer.v1",
13
+ } as const;
14
+ /**
15
+ * The type of receipt being requested.
16
+ */
17
+ export type ReceiptKind = ClosedEnum<typeof ReceiptKind>;
18
+
19
+ /** @internal */
20
+ export const ReceiptKind$inboundSchema: z.ZodNativeEnum<typeof ReceiptKind> = z
21
+ .nativeEnum(ReceiptKind);
22
+
23
+ /** @internal */
24
+ export const ReceiptKind$outboundSchema: z.ZodNativeEnum<typeof ReceiptKind> =
25
+ ReceiptKind$inboundSchema;
26
+
27
+ /**
28
+ * @internal
29
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
30
+ */
31
+ export namespace ReceiptKind$ {
32
+ /** @deprecated use `ReceiptKind$inboundSchema` instead. */
33
+ export const inboundSchema = ReceiptKind$inboundSchema;
34
+ /** @deprecated use `ReceiptKind$outboundSchema` instead. */
35
+ export const outboundSchema = ReceiptKind$outboundSchema;
36
+ }
@@ -0,0 +1,123 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
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
+ ReceiptKind,
11
+ ReceiptKind$inboundSchema,
12
+ ReceiptKind$outboundSchema,
13
+ } from "./receiptkind.js";
14
+
15
+ /**
16
+ * A receipt request for a specific transfer, schedule, or schedule occurrence.
17
+ */
18
+ export type ReceiptRequest = {
19
+ /**
20
+ * The type of receipt being requested.
21
+ */
22
+ kind: ReceiptKind;
23
+ /**
24
+ * The email address to send the receipt to.
25
+ *
26
+ * @remarks
27
+ * Either email or emailAccountID must be provided, but not both.
28
+ */
29
+ email?: string | undefined;
30
+ /**
31
+ * The accountID to send the receipt to.
32
+ *
33
+ * @remarks
34
+ * Either email or emailAccountID must be provided, but not both.
35
+ */
36
+ emailAccountID?: string | undefined;
37
+ /**
38
+ * The ID of the transfer associated with this receipt.
39
+ *
40
+ * @remarks
41
+ * Exactly one of forTransferID, forScheduleID, or forOccurrenceID must be provided.
42
+ */
43
+ forTransferID?: string | undefined;
44
+ /**
45
+ * The ID of the schedule associated with this receipt.
46
+ *
47
+ * @remarks
48
+ * Exactly one of forTransferID, forScheduleID, or forOccurrenceID must be provided.
49
+ */
50
+ forScheduleID?: string | undefined;
51
+ /**
52
+ * The ID of the schedule occurrence associated with this receipt.
53
+ *
54
+ * @remarks
55
+ * Exactly one of forTransferID, forScheduleID, or forOccurrenceID must be provided.
56
+ */
57
+ forOccurrenceID?: string | undefined;
58
+ };
59
+
60
+ /** @internal */
61
+ export const ReceiptRequest$inboundSchema: z.ZodType<
62
+ ReceiptRequest,
63
+ z.ZodTypeDef,
64
+ unknown
65
+ > = z.object({
66
+ kind: ReceiptKind$inboundSchema,
67
+ email: z.string().optional(),
68
+ emailAccountID: z.string().optional(),
69
+ forTransferID: z.string().optional(),
70
+ forScheduleID: z.string().optional(),
71
+ forOccurrenceID: z.string().optional(),
72
+ });
73
+
74
+ /** @internal */
75
+ export type ReceiptRequest$Outbound = {
76
+ kind: string;
77
+ email?: string | undefined;
78
+ emailAccountID?: string | undefined;
79
+ forTransferID?: string | undefined;
80
+ forScheduleID?: string | undefined;
81
+ forOccurrenceID?: string | undefined;
82
+ };
83
+
84
+ /** @internal */
85
+ export const ReceiptRequest$outboundSchema: z.ZodType<
86
+ ReceiptRequest$Outbound,
87
+ z.ZodTypeDef,
88
+ ReceiptRequest
89
+ > = z.object({
90
+ kind: ReceiptKind$outboundSchema,
91
+ email: z.string().optional(),
92
+ emailAccountID: z.string().optional(),
93
+ forTransferID: z.string().optional(),
94
+ forScheduleID: z.string().optional(),
95
+ forOccurrenceID: z.string().optional(),
96
+ });
97
+
98
+ /**
99
+ * @internal
100
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
101
+ */
102
+ export namespace ReceiptRequest$ {
103
+ /** @deprecated use `ReceiptRequest$inboundSchema` instead. */
104
+ export const inboundSchema = ReceiptRequest$inboundSchema;
105
+ /** @deprecated use `ReceiptRequest$outboundSchema` instead. */
106
+ export const outboundSchema = ReceiptRequest$outboundSchema;
107
+ /** @deprecated use `ReceiptRequest$Outbound` instead. */
108
+ export type Outbound = ReceiptRequest$Outbound;
109
+ }
110
+
111
+ export function receiptRequestToJSON(receiptRequest: ReceiptRequest): string {
112
+ return JSON.stringify(ReceiptRequest$outboundSchema.parse(receiptRequest));
113
+ }
114
+
115
+ export function receiptRequestFromJSON(
116
+ jsonString: string,
117
+ ): SafeParseResult<ReceiptRequest, SDKValidationError> {
118
+ return safeParse(
119
+ jsonString,
120
+ (x) => ReceiptRequest$inboundSchema.parse(JSON.parse(x)),
121
+ `Failed to parse 'ReceiptRequest' from JSON`,
122
+ );
123
+ }
@@ -0,0 +1,157 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
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
+ ReceiptKind,
11
+ ReceiptKind$inboundSchema,
12
+ ReceiptKind$outboundSchema,
13
+ } from "./receiptkind.js";
14
+ import {
15
+ SentReceipt,
16
+ SentReceipt$inboundSchema,
17
+ SentReceipt$Outbound,
18
+ SentReceipt$outboundSchema,
19
+ } from "./sentreceipt.js";
20
+
21
+ export type ReceiptResponse = {
22
+ /**
23
+ * Unique identifier for the receipt request.
24
+ */
25
+ receiptID: string;
26
+ /**
27
+ * AccountID for which the receipt request was created.
28
+ */
29
+ createdBy: string;
30
+ /**
31
+ * The date and time the receipt was disabled.
32
+ */
33
+ disabledOn?: Date | undefined;
34
+ /**
35
+ * The type of receipt.
36
+ */
37
+ kind: ReceiptKind;
38
+ /**
39
+ * The email address the receipt is sent to.
40
+ *
41
+ * @remarks
42
+ * Either email or emailAccountID will be in the response, but not both.
43
+ */
44
+ email?: string | undefined;
45
+ /**
46
+ * The accountID the receipt is sent to.
47
+ *
48
+ * @remarks
49
+ * Either email or emailAccountID will be in the response, but not both.
50
+ */
51
+ emailAccountID?: string | undefined;
52
+ /**
53
+ * The ID of the transfer associated with this receipt.
54
+ *
55
+ * @remarks
56
+ * Exactly one of forTransferID, forScheduleID, or forOccurrenceID must be provided.
57
+ */
58
+ forTransferID?: string | undefined;
59
+ /**
60
+ * The ID of the schedule associated with this receipt.
61
+ *
62
+ * @remarks
63
+ * Exactly one of forTransferID, forScheduleID, or forOccurrenceID must be provided.
64
+ */
65
+ forScheduleID?: string | undefined;
66
+ /**
67
+ * The ID of the schedule occurrence associated with this receipt.
68
+ *
69
+ * @remarks
70
+ * Exactly one of forTransferID, forScheduleID, or forOccurrenceID must be provided.
71
+ */
72
+ forOccurrenceID?: string | undefined;
73
+ /**
74
+ * The list of receipts that have been sent.
75
+ */
76
+ sentFor: Array<SentReceipt>;
77
+ };
78
+
79
+ /** @internal */
80
+ export const ReceiptResponse$inboundSchema: z.ZodType<
81
+ ReceiptResponse,
82
+ z.ZodTypeDef,
83
+ unknown
84
+ > = z.object({
85
+ receiptID: z.string(),
86
+ createdBy: z.string(),
87
+ disabledOn: z.string().datetime({ offset: true }).transform(v => new Date(v))
88
+ .optional(),
89
+ kind: ReceiptKind$inboundSchema,
90
+ email: z.string().optional(),
91
+ emailAccountID: z.string().optional(),
92
+ forTransferID: z.string().optional(),
93
+ forScheduleID: z.string().optional(),
94
+ forOccurrenceID: z.string().optional(),
95
+ sentFor: z.array(SentReceipt$inboundSchema),
96
+ });
97
+
98
+ /** @internal */
99
+ export type ReceiptResponse$Outbound = {
100
+ receiptID: string;
101
+ createdBy: string;
102
+ disabledOn?: string | undefined;
103
+ kind: string;
104
+ email?: string | undefined;
105
+ emailAccountID?: string | undefined;
106
+ forTransferID?: string | undefined;
107
+ forScheduleID?: string | undefined;
108
+ forOccurrenceID?: string | undefined;
109
+ sentFor: Array<SentReceipt$Outbound>;
110
+ };
111
+
112
+ /** @internal */
113
+ export const ReceiptResponse$outboundSchema: z.ZodType<
114
+ ReceiptResponse$Outbound,
115
+ z.ZodTypeDef,
116
+ ReceiptResponse
117
+ > = z.object({
118
+ receiptID: z.string(),
119
+ createdBy: z.string(),
120
+ disabledOn: z.date().transform(v => v.toISOString()).optional(),
121
+ kind: ReceiptKind$outboundSchema,
122
+ email: z.string().optional(),
123
+ emailAccountID: z.string().optional(),
124
+ forTransferID: z.string().optional(),
125
+ forScheduleID: z.string().optional(),
126
+ forOccurrenceID: z.string().optional(),
127
+ sentFor: z.array(SentReceipt$outboundSchema),
128
+ });
129
+
130
+ /**
131
+ * @internal
132
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
133
+ */
134
+ export namespace ReceiptResponse$ {
135
+ /** @deprecated use `ReceiptResponse$inboundSchema` instead. */
136
+ export const inboundSchema = ReceiptResponse$inboundSchema;
137
+ /** @deprecated use `ReceiptResponse$outboundSchema` instead. */
138
+ export const outboundSchema = ReceiptResponse$outboundSchema;
139
+ /** @deprecated use `ReceiptResponse$Outbound` instead. */
140
+ export type Outbound = ReceiptResponse$Outbound;
141
+ }
142
+
143
+ export function receiptResponseToJSON(
144
+ receiptResponse: ReceiptResponse,
145
+ ): string {
146
+ return JSON.stringify(ReceiptResponse$outboundSchema.parse(receiptResponse));
147
+ }
148
+
149
+ export function receiptResponseFromJSON(
150
+ jsonString: string,
151
+ ): SafeParseResult<ReceiptResponse, SDKValidationError> {
152
+ return safeParse(
153
+ jsonString,
154
+ (x) => ReceiptResponse$inboundSchema.parse(JSON.parse(x)),
155
+ `Failed to parse 'ReceiptResponse' from JSON`,
156
+ );
157
+ }