@docusign/iam-sdk
Version:
Developer-friendly & type-safe Typescript SDK specifically catered to leverage *@docusign/iam-sdk* API.
140 lines (126 loc) • 3.37 kB
text/typescript
/*
* Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
*/
import * as z from "zod/v3";
import { remap as remap$ } from "../../lib/primitives.js";
import { safeParse } from "../../lib/schemas.js";
import { Result as SafeParseResult } from "../../types/fp.js";
import * as types from "../../types/primitives.js";
import { SDKValidationError } from "../errors/sdkvalidationerror.js";
export type UserInfoLink = {
rel: string;
href: string;
};
export type Organization = {
organizationId: string;
links: Array<UserInfoLink>;
};
export type Account = {
accountId: string;
isDefault: boolean;
accountName: string;
baseUri: string;
organization?: Organization | undefined;
};
export type UserInfo = {
sub: string;
name: string;
givenName: string;
familyName: string;
created: string;
email: string;
accounts: Array<Account>;
};
/** @internal */
export const UserInfoLink$inboundSchema: z.ZodType<
UserInfoLink,
z.ZodTypeDef,
unknown
> = z.object({
rel: types.string(),
href: types.string(),
});
export function userInfoLinkFromJSON(
jsonString: string,
): SafeParseResult<UserInfoLink, SDKValidationError> {
return safeParse(
jsonString,
(x) => UserInfoLink$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'UserInfoLink' from JSON`,
);
}
/** @internal */
export const Organization$inboundSchema: z.ZodType<
Organization,
z.ZodTypeDef,
unknown
> = z.object({
organization_id: types.string(),
links: z.array(z.lazy(() => UserInfoLink$inboundSchema)),
}).transform((v) => {
return remap$(v, {
"organization_id": "organizationId",
});
});
export function organizationFromJSON(
jsonString: string,
): SafeParseResult<Organization, SDKValidationError> {
return safeParse(
jsonString,
(x) => Organization$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Organization' from JSON`,
);
}
/** @internal */
export const Account$inboundSchema: z.ZodType<Account, z.ZodTypeDef, unknown> =
z.object({
account_id: types.string(),
is_default: types.boolean(),
account_name: types.string(),
base_uri: types.string(),
organization: types.optional(z.lazy(() => Organization$inboundSchema)),
}).transform((v) => {
return remap$(v, {
"account_id": "accountId",
"is_default": "isDefault",
"account_name": "accountName",
"base_uri": "baseUri",
});
});
export function accountFromJSON(
jsonString: string,
): SafeParseResult<Account, SDKValidationError> {
return safeParse(
jsonString,
(x) => Account$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'Account' from JSON`,
);
}
/** @internal */
export const UserInfo$inboundSchema: z.ZodType<
UserInfo,
z.ZodTypeDef,
unknown
> = z.object({
sub: types.string(),
name: types.string(),
given_name: types.string(),
family_name: types.string(),
created: types.string(),
email: types.string(),
accounts: z.array(z.lazy(() => Account$inboundSchema)),
}).transform((v) => {
return remap$(v, {
"given_name": "givenName",
"family_name": "familyName",
});
});
export function userInfoFromJSON(
jsonString: string,
): SafeParseResult<UserInfo, SDKValidationError> {
return safeParse(
jsonString,
(x) => UserInfo$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'UserInfo' from JSON`,
);
}