@docusign/iam-sdk
Version:
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@docusign/iam-sdk* API.
97 lines (88 loc) • 2.66 kB
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
export type JWTGrantResponse = {
/**
* The value of the access token. This value will be added to the Authorization header of all Docusign API calls.
*/
accessToken: string;
/**
* The type of token. For access tokens, the value of this will be Bearer.
*/
tokenType: string;
/**
* The number of seconds until the access token expires.
*/
expiresIn: number;
};
/** @internal */
export const JWTGrantResponse$inboundSchema: z.ZodType<
JWTGrantResponse,
z.ZodTypeDef,
unknown
> = z.object({
access_token: z.string(),
token_type: z.string(),
expires_in: z.number().int(),
}).transform((v) => {
return remap$(v, {
"access_token": "accessToken",
"token_type": "tokenType",
"expires_in": "expiresIn",
});
});
/** @internal */
export type JWTGrantResponse$Outbound = {
access_token: string;
token_type: string;
expires_in: number;
};
/** @internal */
export const JWTGrantResponse$outboundSchema: z.ZodType<
JWTGrantResponse$Outbound,
z.ZodTypeDef,
JWTGrantResponse
> = z.object({
accessToken: z.string(),
tokenType: z.string(),
expiresIn: z.number().int(),
}).transform((v) => {
return remap$(v, {
accessToken: "access_token",
tokenType: "token_type",
expiresIn: "expires_in",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace JWTGrantResponse$ {
/** @deprecated use `JWTGrantResponse$inboundSchema` instead. */
export const inboundSchema = JWTGrantResponse$inboundSchema;
/** @deprecated use `JWTGrantResponse$outboundSchema` instead. */
export const outboundSchema = JWTGrantResponse$outboundSchema;
/** @deprecated use `JWTGrantResponse$Outbound` instead. */
export type Outbound = JWTGrantResponse$Outbound;
}
export function jwtGrantResponseToJSON(
jwtGrantResponse: JWTGrantResponse,
): string {
return JSON.stringify(
JWTGrantResponse$outboundSchema.parse(jwtGrantResponse),
);
}
export function jwtGrantResponseFromJSON(
jsonString: string,
): SafeParseResult<JWTGrantResponse, SDKValidationError> {
return safeParse(
jsonString,
(x) => JWTGrantResponse$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'JWTGrantResponse' from JSON`,
);
}