@moovio/sdk 0.0.0-dev.17 → 0.0.0-dev.19
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.
- package/README.md +75 -60
- package/bin/mcp-server.js +1295 -966
- package/bin/mcp-server.js.map +25 -16
- package/funcs/cardsGetMetadata.d.ts +21 -0
- package/funcs/cardsGetMetadata.d.ts.map +1 -0
- package/funcs/cardsGetMetadata.js +126 -0
- package/funcs/cardsGetMetadata.js.map +1 -0
- package/hooks/access-token-hook.d.ts +25 -0
- package/hooks/access-token-hook.d.ts.map +1 -0
- package/hooks/access-token-hook.js +60 -0
- package/hooks/access-token-hook.js.map +1 -0
- package/hooks/registration.d.ts.map +1 -1
- package/hooks/registration.js +4 -0
- package/hooks/registration.js.map +1 -1
- package/jsr.json +1 -1
- package/lib/config.d.ts +7 -3
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js +3 -3
- package/lib/config.js.map +1 -1
- package/mcp-server/cli/start/command.d.ts.map +1 -1
- package/mcp-server/cli/start/command.js +8 -0
- package/mcp-server/cli/start/command.js.map +1 -1
- package/mcp-server/cli/start/impl.d.ts +1 -0
- package/mcp-server/cli/start/impl.d.ts.map +1 -1
- package/mcp-server/cli/start/impl.js +2 -0
- package/mcp-server/cli/start/impl.js.map +1 -1
- package/mcp-server/mcp-server.js +1 -1
- package/mcp-server/server.d.ts +1 -0
- package/mcp-server/server.d.ts.map +1 -1
- package/mcp-server/server.js +4 -1
- package/mcp-server/server.js.map +1 -1
- package/mcp-server/tools/cardsGetMetadata.d.ts +8 -0
- package/mcp-server/tools/cardsGetMetadata.d.ts.map +1 -0
- package/mcp-server/tools/cardsGetMetadata.js +67 -0
- package/mcp-server/tools/cardsGetMetadata.js.map +1 -0
- package/models/components/cardmetadata.d.ts +91 -0
- package/models/components/cardmetadata.d.ts.map +1 -0
- package/models/components/cardmetadata.js +85 -0
- package/models/components/cardmetadata.js.map +1 -0
- package/models/components/cardmetadatarequest.d.ts +30 -0
- package/models/components/cardmetadatarequest.d.ts.map +1 -0
- package/models/components/cardmetadatarequest.js +62 -0
- package/models/components/cardmetadatarequest.js.map +1 -0
- package/models/components/collectionpaymentmethodtype.d.ts +1 -0
- package/models/components/collectionpaymentmethodtype.d.ts.map +1 -1
- package/models/components/collectionpaymentmethodtype.js +1 -0
- package/models/components/collectionpaymentmethodtype.js.map +1 -1
- package/models/components/createreversal.d.ts +6 -0
- package/models/components/createreversal.d.ts.map +1 -1
- package/models/components/createreversal.js +3 -0
- package/models/components/createreversal.js.map +1 -1
- package/models/components/index.d.ts +4 -0
- package/models/components/index.d.ts.map +1 -1
- package/models/components/index.js +4 -0
- package/models/components/index.js.map +1 -1
- package/models/components/reversalamountdetails.d.ts +21 -0
- package/models/components/reversalamountdetails.d.ts.map +1 -0
- package/models/components/reversalamountdetails.js +60 -0
- package/models/components/reversalamountdetails.js.map +1 -0
- package/models/components/reversalamountdetailsvalidationerror.d.ts +17 -0
- package/models/components/reversalamountdetailsvalidationerror.d.ts.map +1 -0
- package/models/components/reversalamountdetailsvalidationerror.js +59 -0
- package/models/components/reversalamountdetailsvalidationerror.js.map +1 -0
- package/models/errors/cardmetadatarequesterror.d.ts +31 -0
- package/models/errors/cardmetadatarequesterror.d.ts.map +1 -0
- package/models/errors/cardmetadatarequesterror.js +85 -0
- package/models/errors/cardmetadatarequesterror.js.map +1 -0
- package/models/errors/index.d.ts +1 -0
- package/models/errors/index.d.ts.map +1 -1
- package/models/errors/index.js +1 -0
- package/models/errors/index.js.map +1 -1
- package/models/errors/reversalvalidationerror.d.ts +4 -0
- package/models/errors/reversalvalidationerror.d.ts.map +1 -1
- package/models/errors/reversalvalidationerror.js +6 -0
- package/models/errors/reversalvalidationerror.js.map +1 -1
- package/models/operations/getcardmetadata.d.ts +24 -0
- package/models/operations/getcardmetadata.d.ts.map +1 -0
- package/models/operations/getcardmetadata.js +72 -0
- package/models/operations/getcardmetadata.js.map +1 -0
- package/models/operations/index.d.ts +1 -0
- package/models/operations/index.d.ts.map +1 -1
- package/models/operations/index.js +1 -0
- package/models/operations/index.js.map +1 -1
- package/package.json +1 -1
- package/sdk/cards.d.ts +10 -0
- package/sdk/cards.d.ts.map +1 -1
- package/sdk/cards.js +12 -0
- package/sdk/cards.js.map +1 -1
- package/src/funcs/cardsGetMetadata.ts +184 -0
- package/src/hooks/access-token-hook.ts +73 -0
- package/src/hooks/registration.ts +5 -0
- package/src/lib/config.ts +8 -3
- package/src/mcp-server/cli/start/command.ts +9 -0
- package/src/mcp-server/cli/start/impl.ts +3 -0
- package/src/mcp-server/mcp-server.ts +1 -1
- package/src/mcp-server/server.ts +5 -1
- package/src/mcp-server/tools/cardsGetMetadata.ts +41 -0
- package/src/models/components/cardmetadata.ts +160 -0
- package/src/models/components/cardmetadatarequest.ts +72 -0
- package/src/models/components/collectionpaymentmethodtype.ts +1 -0
- package/src/models/components/createreversal.ts +13 -0
- package/src/models/components/index.ts +4 -0
- package/src/models/components/reversalamountdetails.ts +61 -0
- package/src/models/components/reversalamountdetailsvalidationerror.ts +55 -0
- package/src/models/errors/cardmetadatarequesterror.ts +80 -0
- package/src/models/errors/index.ts +1 -0
- package/src/models/errors/reversalvalidationerror.ts +12 -0
- package/src/models/operations/getcardmetadata.ts +67 -0
- package/src/models/operations/index.ts +1 -0
- package/src/sdk/cards.ts +21 -0
- package/test/tests/accessToken.test.ts +86 -0
|
@@ -7,12 +7,22 @@ import { safeParse } from "../../lib/schemas.js";
|
|
|
7
7
|
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
8
|
import * as types from "../../types/primitives.js";
|
|
9
9
|
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
import {
|
|
11
|
+
ReversalAmountDetails,
|
|
12
|
+
ReversalAmountDetails$inboundSchema,
|
|
13
|
+
ReversalAmountDetails$Outbound,
|
|
14
|
+
ReversalAmountDetails$outboundSchema,
|
|
15
|
+
} from "./reversalamountdetails.js";
|
|
10
16
|
|
|
11
17
|
export type CreateReversal = {
|
|
12
18
|
/**
|
|
13
19
|
* Amount to reverse in cents. Partial amounts will automatically trigger a refund instead of a cancellation.
|
|
14
20
|
*/
|
|
15
21
|
amount: number;
|
|
22
|
+
/**
|
|
23
|
+
* Breakdown of the reversed amount.
|
|
24
|
+
*/
|
|
25
|
+
amountDetails?: ReversalAmountDetails | undefined;
|
|
16
26
|
};
|
|
17
27
|
|
|
18
28
|
/** @internal */
|
|
@@ -22,10 +32,12 @@ export const CreateReversal$inboundSchema: z.ZodType<
|
|
|
22
32
|
unknown
|
|
23
33
|
> = z.object({
|
|
24
34
|
amount: types.number(),
|
|
35
|
+
amountDetails: types.optional(ReversalAmountDetails$inboundSchema),
|
|
25
36
|
});
|
|
26
37
|
/** @internal */
|
|
27
38
|
export type CreateReversal$Outbound = {
|
|
28
39
|
amount: number;
|
|
40
|
+
amountDetails?: ReversalAmountDetails$Outbound | undefined;
|
|
29
41
|
};
|
|
30
42
|
|
|
31
43
|
/** @internal */
|
|
@@ -35,6 +47,7 @@ export const CreateReversal$outboundSchema: z.ZodType<
|
|
|
35
47
|
CreateReversal
|
|
36
48
|
> = z.object({
|
|
37
49
|
amount: z.number().int(),
|
|
50
|
+
amountDetails: ReversalAmountDetails$outboundSchema.optional(),
|
|
38
51
|
});
|
|
39
52
|
|
|
40
53
|
export function createReversalToJSON(createReversal: CreateReversal): string {
|
|
@@ -110,6 +110,8 @@ export * from "./cardbrandfees.js";
|
|
|
110
110
|
export * from "./cardexpiration.js";
|
|
111
111
|
export * from "./cardexpirationerror.js";
|
|
112
112
|
export * from "./cardissuingnetwork.js";
|
|
113
|
+
export * from "./cardmetadata.js";
|
|
114
|
+
export * from "./cardmetadatarequest.js";
|
|
113
115
|
export * from "./cardpaymentdetails.js";
|
|
114
116
|
export * from "./cardpaymentdetailserror.js";
|
|
115
117
|
export * from "./cardpaymentpaymentmethod.js";
|
|
@@ -455,6 +457,8 @@ export * from "./resolutionlinkrecipient.js";
|
|
|
455
457
|
export * from "./resolutionlinkstatus.js";
|
|
456
458
|
export * from "./returnpolicytype.js";
|
|
457
459
|
export * from "./reversal.js";
|
|
460
|
+
export * from "./reversalamountdetails.js";
|
|
461
|
+
export * from "./reversalamountdetailsvalidationerror.js";
|
|
458
462
|
export * from "./reversedwithcancellation.js";
|
|
459
463
|
export * from "./reversedwithrefund.js";
|
|
460
464
|
export * from "./revoketokenrequest.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 { safeParse } from "../../lib/schemas.js";
|
|
7
|
+
import { Result as SafeParseResult } from "../../types/fp.js";
|
|
8
|
+
import * as types from "../../types/primitives.js";
|
|
9
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
import {
|
|
11
|
+
AmountDecimal,
|
|
12
|
+
AmountDecimal$inboundSchema,
|
|
13
|
+
AmountDecimal$Outbound,
|
|
14
|
+
AmountDecimal$outboundSchema,
|
|
15
|
+
} from "./amountdecimal.js";
|
|
16
|
+
|
|
17
|
+
export type ReversalAmountDetails = {
|
|
18
|
+
/**
|
|
19
|
+
* The amount of surcharge to refund. Should be proportionate to the surcharge on the original transfer. This does not reply if the reversal resulted in a cancellation instead of a refund
|
|
20
|
+
*/
|
|
21
|
+
surcharge?: AmountDecimal | undefined;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/** @internal */
|
|
25
|
+
export const ReversalAmountDetails$inboundSchema: z.ZodType<
|
|
26
|
+
ReversalAmountDetails,
|
|
27
|
+
z.ZodTypeDef,
|
|
28
|
+
unknown
|
|
29
|
+
> = z.object({
|
|
30
|
+
surcharge: types.optional(AmountDecimal$inboundSchema),
|
|
31
|
+
});
|
|
32
|
+
/** @internal */
|
|
33
|
+
export type ReversalAmountDetails$Outbound = {
|
|
34
|
+
surcharge?: AmountDecimal$Outbound | undefined;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** @internal */
|
|
38
|
+
export const ReversalAmountDetails$outboundSchema: z.ZodType<
|
|
39
|
+
ReversalAmountDetails$Outbound,
|
|
40
|
+
z.ZodTypeDef,
|
|
41
|
+
ReversalAmountDetails
|
|
42
|
+
> = z.object({
|
|
43
|
+
surcharge: AmountDecimal$outboundSchema.optional(),
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
export function reversalAmountDetailsToJSON(
|
|
47
|
+
reversalAmountDetails: ReversalAmountDetails,
|
|
48
|
+
): string {
|
|
49
|
+
return JSON.stringify(
|
|
50
|
+
ReversalAmountDetails$outboundSchema.parse(reversalAmountDetails),
|
|
51
|
+
);
|
|
52
|
+
}
|
|
53
|
+
export function reversalAmountDetailsFromJSON(
|
|
54
|
+
jsonString: string,
|
|
55
|
+
): SafeParseResult<ReversalAmountDetails, SDKValidationError> {
|
|
56
|
+
return safeParse(
|
|
57
|
+
jsonString,
|
|
58
|
+
(x) => ReversalAmountDetails$inboundSchema.parse(JSON.parse(x)),
|
|
59
|
+
`Failed to parse 'ReversalAmountDetails' from JSON`,
|
|
60
|
+
);
|
|
61
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
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 * as types from "../../types/primitives.js";
|
|
9
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
10
|
+
|
|
11
|
+
export type ReversalAmountDetailsValidationError = {
|
|
12
|
+
surcharge?: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
/** @internal */
|
|
16
|
+
export const ReversalAmountDetailsValidationError$inboundSchema: z.ZodType<
|
|
17
|
+
ReversalAmountDetailsValidationError,
|
|
18
|
+
z.ZodTypeDef,
|
|
19
|
+
unknown
|
|
20
|
+
> = z.object({
|
|
21
|
+
surcharge: types.optional(types.string()),
|
|
22
|
+
});
|
|
23
|
+
/** @internal */
|
|
24
|
+
export type ReversalAmountDetailsValidationError$Outbound = {
|
|
25
|
+
surcharge?: string | undefined;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/** @internal */
|
|
29
|
+
export const ReversalAmountDetailsValidationError$outboundSchema: z.ZodType<
|
|
30
|
+
ReversalAmountDetailsValidationError$Outbound,
|
|
31
|
+
z.ZodTypeDef,
|
|
32
|
+
ReversalAmountDetailsValidationError
|
|
33
|
+
> = z.object({
|
|
34
|
+
surcharge: z.string().optional(),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export function reversalAmountDetailsValidationErrorToJSON(
|
|
38
|
+
reversalAmountDetailsValidationError: ReversalAmountDetailsValidationError,
|
|
39
|
+
): string {
|
|
40
|
+
return JSON.stringify(
|
|
41
|
+
ReversalAmountDetailsValidationError$outboundSchema.parse(
|
|
42
|
+
reversalAmountDetailsValidationError,
|
|
43
|
+
),
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
export function reversalAmountDetailsValidationErrorFromJSON(
|
|
47
|
+
jsonString: string,
|
|
48
|
+
): SafeParseResult<ReversalAmountDetailsValidationError, SDKValidationError> {
|
|
49
|
+
return safeParse(
|
|
50
|
+
jsonString,
|
|
51
|
+
(x) =>
|
|
52
|
+
ReversalAmountDetailsValidationError$inboundSchema.parse(JSON.parse(x)),
|
|
53
|
+
`Failed to parse 'ReversalAmountDetailsValidationError' from JSON`,
|
|
54
|
+
);
|
|
55
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
import * as z from "zod/v3";
|
|
6
|
+
import * as types from "../../types/primitives.js";
|
|
7
|
+
import * as components from "../components/index.js";
|
|
8
|
+
import { MoovError } from "./mooverror.js";
|
|
9
|
+
|
|
10
|
+
export type CardMetadataRequestErrorData = {
|
|
11
|
+
error?: string | undefined;
|
|
12
|
+
e2ee?: components.End2EndEncryptionError | undefined;
|
|
13
|
+
cardNumber?: string | undefined;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export class CardMetadataRequestError extends MoovError {
|
|
17
|
+
error?: string | undefined;
|
|
18
|
+
e2ee?: components.End2EndEncryptionError | undefined;
|
|
19
|
+
cardNumber?: string | undefined;
|
|
20
|
+
|
|
21
|
+
/** The original data that was passed to this error instance. */
|
|
22
|
+
data$: CardMetadataRequestErrorData;
|
|
23
|
+
|
|
24
|
+
constructor(
|
|
25
|
+
err: CardMetadataRequestErrorData,
|
|
26
|
+
httpMeta: { response: Response; request: Request; body: string },
|
|
27
|
+
) {
|
|
28
|
+
const message = "message" in err && typeof err.message === "string"
|
|
29
|
+
? err.message
|
|
30
|
+
: `API error occurred: ${JSON.stringify(err)}`;
|
|
31
|
+
super(message, httpMeta);
|
|
32
|
+
this.data$ = err;
|
|
33
|
+
if (err.error != null) this.error = err.error;
|
|
34
|
+
if (err.e2ee != null) this.e2ee = err.e2ee;
|
|
35
|
+
if (err.cardNumber != null) this.cardNumber = err.cardNumber;
|
|
36
|
+
|
|
37
|
+
this.name = "CardMetadataRequestError";
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** @internal */
|
|
42
|
+
export const CardMetadataRequestError$inboundSchema: z.ZodType<
|
|
43
|
+
CardMetadataRequestError,
|
|
44
|
+
z.ZodTypeDef,
|
|
45
|
+
unknown
|
|
46
|
+
> = z.object({
|
|
47
|
+
error: types.optional(types.string()),
|
|
48
|
+
e2ee: types.optional(components.End2EndEncryptionError$inboundSchema),
|
|
49
|
+
cardNumber: types.optional(types.string()),
|
|
50
|
+
request$: z.instanceof(Request),
|
|
51
|
+
response$: z.instanceof(Response),
|
|
52
|
+
body$: z.string(),
|
|
53
|
+
})
|
|
54
|
+
.transform((v) => {
|
|
55
|
+
return new CardMetadataRequestError(v, {
|
|
56
|
+
request: v.request$,
|
|
57
|
+
response: v.response$,
|
|
58
|
+
body: v.body$,
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
/** @internal */
|
|
63
|
+
export type CardMetadataRequestError$Outbound = {
|
|
64
|
+
error?: string | undefined;
|
|
65
|
+
e2ee?: components.End2EndEncryptionError$Outbound | undefined;
|
|
66
|
+
cardNumber?: string | undefined;
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/** @internal */
|
|
70
|
+
export const CardMetadataRequestError$outboundSchema: z.ZodType<
|
|
71
|
+
CardMetadataRequestError$Outbound,
|
|
72
|
+
z.ZodTypeDef,
|
|
73
|
+
CardMetadataRequestError
|
|
74
|
+
> = z.instanceof(CardMetadataRequestError)
|
|
75
|
+
.transform(v => v.data$)
|
|
76
|
+
.pipe(z.object({
|
|
77
|
+
error: z.string().optional(),
|
|
78
|
+
e2ee: components.End2EndEncryptionError$outboundSchema.optional(),
|
|
79
|
+
cardNumber: z.string().optional(),
|
|
80
|
+
}));
|
|
@@ -10,6 +10,7 @@ export * from "./authtokenrequesterror.js";
|
|
|
10
10
|
export * from "./bankaccountvalidationerror.js";
|
|
11
11
|
export * from "./brandvalidationerror.js";
|
|
12
12
|
export * from "./cardacquiringrefund.js";
|
|
13
|
+
export * from "./cardmetadatarequesterror.js";
|
|
13
14
|
export * from "./connectaccountrequestvalidationerror.js";
|
|
14
15
|
export * from "./createaccounterror.js";
|
|
15
16
|
export * from "./createinvoiceerror.js";
|
|
@@ -4,14 +4,17 @@
|
|
|
4
4
|
|
|
5
5
|
import * as z from "zod/v3";
|
|
6
6
|
import * as types from "../../types/primitives.js";
|
|
7
|
+
import * as components from "../components/index.js";
|
|
7
8
|
import { MoovError } from "./mooverror.js";
|
|
8
9
|
|
|
9
10
|
export type ReversalValidationErrorData = {
|
|
10
11
|
amount?: string | undefined;
|
|
12
|
+
amountDetails?: components.ReversalAmountDetailsValidationError | undefined;
|
|
11
13
|
};
|
|
12
14
|
|
|
13
15
|
export class ReversalValidationError extends MoovError {
|
|
14
16
|
amount?: string | undefined;
|
|
17
|
+
amountDetails?: components.ReversalAmountDetailsValidationError | undefined;
|
|
15
18
|
|
|
16
19
|
/** The original data that was passed to this error instance. */
|
|
17
20
|
data$: ReversalValidationErrorData;
|
|
@@ -26,6 +29,7 @@ export class ReversalValidationError extends MoovError {
|
|
|
26
29
|
super(message, httpMeta);
|
|
27
30
|
this.data$ = err;
|
|
28
31
|
if (err.amount != null) this.amount = err.amount;
|
|
32
|
+
if (err.amountDetails != null) this.amountDetails = err.amountDetails;
|
|
29
33
|
|
|
30
34
|
this.name = "ReversalValidationError";
|
|
31
35
|
}
|
|
@@ -38,6 +42,9 @@ export const ReversalValidationError$inboundSchema: z.ZodType<
|
|
|
38
42
|
unknown
|
|
39
43
|
> = z.object({
|
|
40
44
|
amount: types.optional(types.string()),
|
|
45
|
+
amountDetails: types.optional(
|
|
46
|
+
components.ReversalAmountDetailsValidationError$inboundSchema,
|
|
47
|
+
),
|
|
41
48
|
request$: z.instanceof(Request),
|
|
42
49
|
response$: z.instanceof(Response),
|
|
43
50
|
body$: z.string(),
|
|
@@ -53,6 +60,9 @@ export const ReversalValidationError$inboundSchema: z.ZodType<
|
|
|
53
60
|
/** @internal */
|
|
54
61
|
export type ReversalValidationError$Outbound = {
|
|
55
62
|
amount?: string | undefined;
|
|
63
|
+
amountDetails?:
|
|
64
|
+
| components.ReversalAmountDetailsValidationError$Outbound
|
|
65
|
+
| undefined;
|
|
56
66
|
};
|
|
57
67
|
|
|
58
68
|
/** @internal */
|
|
@@ -64,4 +74,6 @@ export const ReversalValidationError$outboundSchema: z.ZodType<
|
|
|
64
74
|
.transform(v => v.data$)
|
|
65
75
|
.pipe(z.object({
|
|
66
76
|
amount: z.string().optional(),
|
|
77
|
+
amountDetails: components
|
|
78
|
+
.ReversalAmountDetailsValidationError$outboundSchema.optional(),
|
|
67
79
|
}));
|
|
@@ -0,0 +1,67 @@
|
|
|
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 * as components from "../components/index.js";
|
|
10
|
+
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
|
|
11
|
+
|
|
12
|
+
export type GetCardMetadataResponse = {
|
|
13
|
+
headers: { [k: string]: Array<string> };
|
|
14
|
+
result: components.CardMetadata;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** @internal */
|
|
18
|
+
export const GetCardMetadataResponse$inboundSchema: z.ZodType<
|
|
19
|
+
GetCardMetadataResponse,
|
|
20
|
+
z.ZodTypeDef,
|
|
21
|
+
unknown
|
|
22
|
+
> = z.object({
|
|
23
|
+
Headers: z.record(z.array(z.string())).default({}),
|
|
24
|
+
Result: components.CardMetadata$inboundSchema,
|
|
25
|
+
}).transform((v) => {
|
|
26
|
+
return remap$(v, {
|
|
27
|
+
"Headers": "headers",
|
|
28
|
+
"Result": "result",
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
/** @internal */
|
|
32
|
+
export type GetCardMetadataResponse$Outbound = {
|
|
33
|
+
Headers: { [k: string]: Array<string> };
|
|
34
|
+
Result: components.CardMetadata$Outbound;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/** @internal */
|
|
38
|
+
export const GetCardMetadataResponse$outboundSchema: z.ZodType<
|
|
39
|
+
GetCardMetadataResponse$Outbound,
|
|
40
|
+
z.ZodTypeDef,
|
|
41
|
+
GetCardMetadataResponse
|
|
42
|
+
> = z.object({
|
|
43
|
+
headers: z.record(z.array(z.string())),
|
|
44
|
+
result: components.CardMetadata$outboundSchema,
|
|
45
|
+
}).transform((v) => {
|
|
46
|
+
return remap$(v, {
|
|
47
|
+
headers: "Headers",
|
|
48
|
+
result: "Result",
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
export function getCardMetadataResponseToJSON(
|
|
53
|
+
getCardMetadataResponse: GetCardMetadataResponse,
|
|
54
|
+
): string {
|
|
55
|
+
return JSON.stringify(
|
|
56
|
+
GetCardMetadataResponse$outboundSchema.parse(getCardMetadataResponse),
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
export function getCardMetadataResponseFromJSON(
|
|
60
|
+
jsonString: string,
|
|
61
|
+
): SafeParseResult<GetCardMetadataResponse, SDKValidationError> {
|
|
62
|
+
return safeParse(
|
|
63
|
+
jsonString,
|
|
64
|
+
(x) => GetCardMetadataResponse$inboundSchema.parse(JSON.parse(x)),
|
|
65
|
+
`Failed to parse 'GetCardMetadataResponse' from JSON`,
|
|
66
|
+
);
|
|
67
|
+
}
|
|
@@ -60,6 +60,7 @@ export * from "./getbrand.js";
|
|
|
60
60
|
export * from "./getcancellation.js";
|
|
61
61
|
export * from "./getcapability.js";
|
|
62
62
|
export * from "./getcard.js";
|
|
63
|
+
export * from "./getcardmetadata.js";
|
|
63
64
|
export * from "./getdispute.js";
|
|
64
65
|
export * from "./getdisputeevidence.js";
|
|
65
66
|
export * from "./getdisputeevidencedata.js";
|
package/src/sdk/cards.ts
CHANGED
|
@@ -4,10 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
import { cardsDisable } from "../funcs/cardsDisable.js";
|
|
6
6
|
import { cardsGet } from "../funcs/cardsGet.js";
|
|
7
|
+
import { cardsGetMetadata } from "../funcs/cardsGetMetadata.js";
|
|
7
8
|
import { cardsLink } from "../funcs/cardsLink.js";
|
|
8
9
|
import { cardsList } from "../funcs/cardsList.js";
|
|
9
10
|
import { cardsUpdate } from "../funcs/cardsUpdate.js";
|
|
10
11
|
import { ClientSDK, RequestOptions } from "../lib/sdks.js";
|
|
12
|
+
import * as components from "../models/components/index.js";
|
|
11
13
|
import * as operations from "../models/operations/index.js";
|
|
12
14
|
import { unwrapAsync } from "../types/fp.js";
|
|
13
15
|
|
|
@@ -123,4 +125,23 @@ export class Cards extends ClientSDK {
|
|
|
123
125
|
options,
|
|
124
126
|
));
|
|
125
127
|
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Look up metadata for a card without linking it to a Moov account.
|
|
131
|
+
*
|
|
132
|
+
* Only use this endpoint if you have provided Moov with a copy of your PCI attestation of compliance.
|
|
133
|
+
*
|
|
134
|
+
* To access this endpoint using an [access token](https://docs.moov.io/api/authentication/access-tokens/)
|
|
135
|
+
* you'll need to specify the `/card-metadata.read` scope.
|
|
136
|
+
*/
|
|
137
|
+
async getMetadata(
|
|
138
|
+
request: components.CardMetadataRequest,
|
|
139
|
+
options?: RequestOptions,
|
|
140
|
+
): Promise<operations.GetCardMetadataResponse> {
|
|
141
|
+
return unwrapAsync(cardsGetMetadata(
|
|
142
|
+
this,
|
|
143
|
+
request,
|
|
144
|
+
options,
|
|
145
|
+
));
|
|
146
|
+
}
|
|
126
147
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { describe, expect, test } from "bun:test";
|
|
2
|
+
import { HTTPClient, Moov } from "@moovio/sdk";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Builds a Moov SDK instance whose HTTPClient captures every outgoing
|
|
6
|
+
* Request without hitting the network. The captured Request can then be
|
|
7
|
+
* inspected for headers, URL, etc.
|
|
8
|
+
*/
|
|
9
|
+
function captureRequests(opts: ConstructorParameters<typeof Moov>[0]) {
|
|
10
|
+
const requests: Request[] = [];
|
|
11
|
+
const httpClient = new HTTPClient({
|
|
12
|
+
fetcher: async (input, init) => {
|
|
13
|
+
const req = input instanceof Request ? input : new Request(input, init);
|
|
14
|
+
requests.push(req.clone());
|
|
15
|
+
return new Response(null, { status: 200 });
|
|
16
|
+
},
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const moov = new Moov({ ...opts, httpClient });
|
|
20
|
+
return { moov, requests };
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
describe("accessToken option", () => {
|
|
24
|
+
test("sets Authorization: Bearer header on outgoing requests", async () => {
|
|
25
|
+
const { moov, requests } = captureRequests({
|
|
26
|
+
accessToken: "test-access-token-123",
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
await moov.ping.ping();
|
|
30
|
+
|
|
31
|
+
expect(requests.length).toBe(1);
|
|
32
|
+
expect(requests[0].headers.get("Authorization")).toBe(
|
|
33
|
+
"Bearer test-access-token-123",
|
|
34
|
+
);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
test("applies bearer auth on every request, not just the first", async () => {
|
|
38
|
+
const { moov, requests } = captureRequests({
|
|
39
|
+
accessToken: "another-token",
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
await moov.ping.ping();
|
|
43
|
+
await moov.ping.ping();
|
|
44
|
+
await moov.ping.ping();
|
|
45
|
+
|
|
46
|
+
expect(requests.length).toBe(3);
|
|
47
|
+
for (const req of requests) {
|
|
48
|
+
expect(req.headers.get("Authorization")).toBe("Bearer another-token");
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
test("HTTP Basic auth still works when accessToken is not set", async () => {
|
|
53
|
+
const { moov, requests } = captureRequests({
|
|
54
|
+
security: { username: "my-public-key", password: "my-secret-key" },
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
await moov.ping.ping();
|
|
58
|
+
|
|
59
|
+
expect(requests.length).toBe(1);
|
|
60
|
+
const auth = requests[0].headers.get("Authorization");
|
|
61
|
+
expect(auth).toMatch(/^Basic /);
|
|
62
|
+
|
|
63
|
+
// Decode the base64 portion and confirm the credentials round-trip.
|
|
64
|
+
const encoded = auth!.slice("Basic ".length);
|
|
65
|
+
const decoded = Buffer.from(encoded, "base64").toString("utf8");
|
|
66
|
+
expect(decoded).toBe("my-public-key:my-secret-key");
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
test("no Authorization header is sent when neither auth mode is configured", async () => {
|
|
70
|
+
const { moov, requests } = captureRequests({});
|
|
71
|
+
|
|
72
|
+
await moov.ping.ping();
|
|
73
|
+
|
|
74
|
+
expect(requests.length).toBe(1);
|
|
75
|
+
expect(requests[0].headers.get("Authorization")).toBeNull();
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
test("throws at construction when both accessToken and Basic creds are set", () => {
|
|
79
|
+
expect(() =>
|
|
80
|
+
new Moov({
|
|
81
|
+
accessToken: "some-token",
|
|
82
|
+
security: { username: "u", password: "p" },
|
|
83
|
+
})
|
|
84
|
+
).toThrow(/cannot both be set/i);
|
|
85
|
+
});
|
|
86
|
+
});
|