/*
* 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";
import {
Address,
Address$inboundSchema,
Address$Outbound,
Address$outboundSchema,
} from "./address.js";
import {
CustomMappings,
CustomMappings$inboundSchema,
CustomMappings$Outbound,
CustomMappings$outboundSchema,
} from "./custommappings.js";
import {
Email,
Email$inboundSchema,
Email$Outbound,
Email$outboundSchema,
} from "./email.js";
import {
PassThroughBody,
PassThroughBody$inboundSchema,
PassThroughBody$Outbound,
PassThroughBody$outboundSchema,
} from "./passthroughbody.js";
import {
PhoneNumber,
PhoneNumber$inboundSchema,
PhoneNumber$Outbound,
PhoneNumber$outboundSchema,
} from "./phonenumber.js";
export type User = {
/**
* The unique identifier for the user
*/
id?: string | undefined;
/**
* The parent user id
*/
parentId?: string | null | undefined;
/**
* The username of the user
*/
username?: string | null | undefined;
/**
* The first name of the person.
*/
firstName?: string | null | undefined;
/**
* The last name of the person.
*/
lastName?: string | null | undefined;
/**
* The job title of the person.
*/
title?: string | null | undefined;
/**
* The division the person is currently in. Usually a collection of departments or teams or regions.
*/
division?: string | null | undefined;
/**
* The department the person is currently in. [Deprecated](https://developers.apideck.com/changelog) in favor of the dedicated department_id and department_name field.
*
* @deprecated field: This will be removed in a future release, please migrate away from it as soon as possible.
*/
department?: string | null | undefined;
/**
* The name of the company.
*/
companyName?: string | null | undefined;
/**
* An Employee Number, Employee ID or Employee Code, is a unique number that has been assigned to each individual staff member within a company.
*/
employeeNumber?: string | null | undefined;
/**
* A description of the object.
*/
description?: string | null | undefined;
/**
* The URL of the user's avatar
*/
image?: string | null | undefined;
/**
* language code according to ISO 639-1. For the United States - EN
*/
language?: string | null | undefined;
/**
* The status of the user
*/
status?: string | null | undefined;
addresses?: Array
| undefined;
phoneNumbers?: Array | undefined;
emails: Array;
/**
* When custom mappings are configured on the resource, the result is included here.
*/
customMappings?: CustomMappings | null | undefined;
/**
* The date and time when the user was last updated.
*/
updatedAt?: string | null | undefined;
/**
* The date and time when the user was created.
*/
createdAt?: string | null | undefined;
/**
* The pass_through property allows passing service-specific, custom data or structured modifications in request body when creating or updating resources.
*/
passThrough?: Array | undefined;
};
/** @internal */
export const User$inboundSchema: z.ZodType = z
.object({
id: z.string().optional(),
parent_id: z.nullable(z.string()).optional(),
username: z.nullable(z.string()).optional(),
first_name: z.nullable(z.string()).optional(),
last_name: z.nullable(z.string()).optional(),
title: z.nullable(z.string()).optional(),
division: z.nullable(z.string()).optional(),
department: z.nullable(z.string()).optional(),
company_name: z.nullable(z.string()).optional(),
employee_number: z.nullable(z.string()).optional(),
description: z.nullable(z.string()).optional(),
image: z.nullable(z.string()).optional(),
language: z.nullable(z.string()).optional(),
status: z.nullable(z.string()).optional(),
addresses: z.array(Address$inboundSchema).optional(),
phone_numbers: z.array(PhoneNumber$inboundSchema).optional(),
emails: z.array(Email$inboundSchema),
custom_mappings: z.nullable(CustomMappings$inboundSchema).optional(),
updated_at: z.nullable(z.string()).optional(),
created_at: z.nullable(z.string()).optional(),
pass_through: z.array(PassThroughBody$inboundSchema).optional(),
}).transform((v) => {
return remap$(v, {
"parent_id": "parentId",
"first_name": "firstName",
"last_name": "lastName",
"company_name": "companyName",
"employee_number": "employeeNumber",
"phone_numbers": "phoneNumbers",
"custom_mappings": "customMappings",
"updated_at": "updatedAt",
"created_at": "createdAt",
"pass_through": "passThrough",
});
});
/** @internal */
export type User$Outbound = {
id?: string | undefined;
parent_id?: string | null | undefined;
username?: string | null | undefined;
first_name?: string | null | undefined;
last_name?: string | null | undefined;
title?: string | null | undefined;
division?: string | null | undefined;
department?: string | null | undefined;
company_name?: string | null | undefined;
employee_number?: string | null | undefined;
description?: string | null | undefined;
image?: string | null | undefined;
language?: string | null | undefined;
status?: string | null | undefined;
addresses?: Array | undefined;
phone_numbers?: Array | undefined;
emails: Array;
custom_mappings?: CustomMappings$Outbound | null | undefined;
updated_at?: string | null | undefined;
created_at?: string | null | undefined;
pass_through?: Array | undefined;
};
/** @internal */
export const User$outboundSchema: z.ZodType =
z.object({
id: z.string().optional(),
parentId: z.nullable(z.string()).optional(),
username: z.nullable(z.string()).optional(),
firstName: z.nullable(z.string()).optional(),
lastName: z.nullable(z.string()).optional(),
title: z.nullable(z.string()).optional(),
division: z.nullable(z.string()).optional(),
department: z.nullable(z.string()).optional(),
companyName: z.nullable(z.string()).optional(),
employeeNumber: z.nullable(z.string()).optional(),
description: z.nullable(z.string()).optional(),
image: z.nullable(z.string()).optional(),
language: z.nullable(z.string()).optional(),
status: z.nullable(z.string()).optional(),
addresses: z.array(Address$outboundSchema).optional(),
phoneNumbers: z.array(PhoneNumber$outboundSchema).optional(),
emails: z.array(Email$outboundSchema),
customMappings: z.nullable(CustomMappings$outboundSchema).optional(),
updatedAt: z.nullable(z.string()).optional(),
createdAt: z.nullable(z.string()).optional(),
passThrough: z.array(PassThroughBody$outboundSchema).optional(),
}).transform((v) => {
return remap$(v, {
parentId: "parent_id",
firstName: "first_name",
lastName: "last_name",
companyName: "company_name",
employeeNumber: "employee_number",
phoneNumbers: "phone_numbers",
customMappings: "custom_mappings",
updatedAt: "updated_at",
createdAt: "created_at",
passThrough: "pass_through",
});
});
/**
* @internal
* @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
*/
export namespace User$ {
/** @deprecated use `User$inboundSchema` instead. */
export const inboundSchema = User$inboundSchema;
/** @deprecated use `User$outboundSchema` instead. */
export const outboundSchema = User$outboundSchema;
/** @deprecated use `User$Outbound` instead. */
export type Outbound = User$Outbound;
}
export function userToJSON(user: User): string {
return JSON.stringify(User$outboundSchema.parse(user));
}
export function userFromJSON(
jsonString: string,
): SafeParseResult {
return safeParse(
jsonString,
(x) => User$inboundSchema.parse(JSON.parse(x)),
`Failed to parse 'User' from JSON`,
);
}