/* * 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 { CustomMappings, CustomMappings$inboundSchema, CustomMappings$Outbound, CustomMappings$outboundSchema, } from "./custommappings.js"; export type EcommerceStore = { /** * A unique identifier for an object. */ id: string; /** * The store's name */ name?: string | null | undefined; /** * The store's website URL */ storeUrl?: string | null | undefined; /** * The store's admin login URL */ adminUrl?: string | null | undefined; /** * When custom mappings are configured on the resource, the result is included here. */ customMappings?: CustomMappings | null | undefined; /** * The date and time when the object was created. */ createdAt?: Date | null | undefined; /** * The date and time when the object was last updated. */ updatedAt?: Date | null | undefined; }; /** @internal */ export const EcommerceStore$inboundSchema: z.ZodType< EcommerceStore, z.ZodTypeDef, unknown > = z.object({ id: z.string(), name: z.nullable(z.string()).optional(), store_url: z.nullable(z.string()).optional(), admin_url: z.nullable(z.string()).optional(), custom_mappings: z.nullable(CustomMappings$inboundSchema).optional(), created_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), updated_at: z.nullable( z.string().datetime({ offset: true }).transform(v => new Date(v)), ).optional(), }).transform((v) => { return remap$(v, { "store_url": "storeUrl", "admin_url": "adminUrl", "custom_mappings": "customMappings", "created_at": "createdAt", "updated_at": "updatedAt", }); }); /** @internal */ export type EcommerceStore$Outbound = { id: string; name?: string | null | undefined; store_url?: string | null | undefined; admin_url?: string | null | undefined; custom_mappings?: CustomMappings$Outbound | null | undefined; created_at?: string | null | undefined; updated_at?: string | null | undefined; }; /** @internal */ export const EcommerceStore$outboundSchema: z.ZodType< EcommerceStore$Outbound, z.ZodTypeDef, EcommerceStore > = z.object({ id: z.string(), name: z.nullable(z.string()).optional(), storeUrl: z.nullable(z.string()).optional(), adminUrl: z.nullable(z.string()).optional(), customMappings: z.nullable(CustomMappings$outboundSchema).optional(), createdAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), updatedAt: z.nullable(z.date().transform(v => v.toISOString())).optional(), }).transform((v) => { return remap$(v, { storeUrl: "store_url", adminUrl: "admin_url", customMappings: "custom_mappings", createdAt: "created_at", updatedAt: "updated_at", }); }); /** * @internal * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. */ export namespace EcommerceStore$ { /** @deprecated use `EcommerceStore$inboundSchema` instead. */ export const inboundSchema = EcommerceStore$inboundSchema; /** @deprecated use `EcommerceStore$outboundSchema` instead. */ export const outboundSchema = EcommerceStore$outboundSchema; /** @deprecated use `EcommerceStore$Outbound` instead. */ export type Outbound = EcommerceStore$Outbound; } export function ecommerceStoreToJSON(ecommerceStore: EcommerceStore): string { return JSON.stringify(EcommerceStore$outboundSchema.parse(ecommerceStore)); } export function ecommerceStoreFromJSON( jsonString: string, ): SafeParseResult { return safeParse( jsonString, (x) => EcommerceStore$inboundSchema.parse(JSON.parse(x)), `Failed to parse 'EcommerceStore' from JSON`, ); }