import {z} from 'zod' export type PinterestLibIntegerFormatType = string; export type Country = 'AD' | 'AE' | 'AF' | 'AG' | 'AI' | 'AL' | 'AM' | 'AO' | 'AQ' | 'AR' | 'AS' | 'AT' | 'AU' | 'AW' | 'AX' | 'AZ' | 'BA' | 'BB' | 'BD' | 'BE' | 'BF' | 'BG' | 'BH' | 'BI' | 'BJ' | 'BL' | 'BM' | 'BN' | 'BO' | 'BQ' | 'BR' | 'BS' | 'BT' | 'BV' | 'BW' | 'BY' | 'BZ' | 'CA' | 'CC' | 'CD' | 'CF' | 'CG' | 'CH' | 'CI' | 'CK' | 'CL' | 'CM' | 'CN' | 'CO' | 'CR' | 'CU' | 'CV' | 'CW' | 'CX' | 'CY' | 'CZ' | 'DE' | 'DJ' | 'DK' | 'DM' | 'DO' | 'DZ' | 'EC' | 'EE' | 'EG' | 'EH' | 'ER' | 'ES' | 'ET' | 'FI' | 'FJ' | 'FK' | 'FM' | 'FO' | 'FR' | 'GA' | 'GB' | 'GD' | 'GE' | 'GF' | 'GG' | 'GH' | 'GI' | 'GL' | 'GM' | 'GN' | 'GP' | 'GQ' | 'GR' | 'GS' | 'GT' | 'GU' | 'GW' | 'GY' | 'HK' | 'HM' | 'HN' | 'HR' | 'HT' | 'HU' | 'ID' | 'IE' | 'IL' | 'IM' | 'IN' | 'IO' | 'IQ' | 'IR' | 'IS' | 'IT' | 'JE' | 'JM' | 'JO' | 'JP' | 'KE' | 'KG' | 'KH' | 'KI' | 'KM' | 'KN' | 'KR' | 'KW' | 'KY' | 'KZ' | 'LA' | 'LB' | 'LC' | 'LI' | 'LK' | 'LR' | 'LS' | 'LT' | 'LU' | 'LV' | 'LY' | 'MA' | 'MC' | 'MD' | 'ME' | 'MF' | 'MG' | 'MH' | 'MK' | 'ML' | 'MM' | 'MN' | 'MO' | 'MP' | 'MQ' | 'MR' | 'MS' | 'MT' | 'MU' | 'MV' | 'MW' | 'MX' | 'MY' | 'MZ' | 'NA' | 'NC' | 'NE' | 'NF' | 'NG' | 'NI' | 'NL' | 'NO' | 'NP' | 'NR' | 'NU' | 'NZ' | 'OM' | 'PA' | 'PE' | 'PF' | 'PG' | 'PH' | 'PK' | 'PL' | 'PM' | 'PN' | 'PR' | 'PS' | 'PT' | 'PW' | 'PY' | 'QA' | 'RE' | 'RO' | 'RS' | 'RU' | 'RW' | 'SA' | 'SB' | 'SC' | 'SD' | 'SE' | 'SG' | 'SH' | 'SI' | 'SJ' | 'SK' | 'SL' | 'SM' | 'SN' | 'SO' | 'SR' | 'SS' | 'ST' | 'SV' | 'SX' | 'SY' | 'SZ' | 'TC' | 'TD' | 'TF' | 'TG' | 'TH' | 'TJ' | 'TK' | 'TL' | 'TM' | 'TN' | 'TO' | 'TR' | 'TT' | 'TV' | 'TW' | 'TZ' | 'UA' | 'UG' | 'UM' | 'US' | 'UY' | 'UZ' | 'VA' | 'VC' | 'VE' | 'VG' | 'VI' | 'VN' | 'VU' | 'WF' | 'WS' | 'YE' | 'YT' | 'ZA' | 'ZM' | 'ZW'; export type CatalogsAiContentDisclosureLabel = 'ai_modified' | 'synthetic_performer'; export type CatalogsAiContentDisclosure = {disclosure: Array, url: string}; export type UpdatableItemAttributesGtinString = string | null; export type UpdatableItemAttributesGtinInteger = number | null; export type UpdatableItemAttributesGtin = UpdatableItemAttributesGtinString | UpdatableItemAttributesGtinInteger | null; export type ItemAttributesRequestImageLinkList = Array; export type ItemAttributesRequestImageLink = string | ItemAttributesRequestImageLinkList; export type ItemAttributesRequest = {ad_image_0_link?: (string | null) | undefined, ad_image_0_tag?: (string | null) | undefined, ad_image_10_link?: (string | null) | undefined, ad_image_10_tag?: (string | null) | undefined, ad_image_11_link?: (string | null) | undefined, ad_image_11_tag?: (string | null) | undefined, ad_image_12_link?: (string | null) | undefined, ad_image_12_tag?: (string | null) | undefined, ad_image_13_link?: (string | null) | undefined, ad_image_13_tag?: (string | null) | undefined, ad_image_14_link?: (string | null) | undefined, ad_image_14_tag?: (string | null) | undefined, ad_image_15_link?: (string | null) | undefined, ad_image_15_tag?: (string | null) | undefined, ad_image_16_link?: (string | null) | undefined, ad_image_16_tag?: (string | null) | undefined, ad_image_17_link?: (string | null) | undefined, ad_image_17_tag?: (string | null) | undefined, ad_image_18_link?: (string | null) | undefined, ad_image_18_tag?: (string | null) | undefined, ad_image_19_link?: (string | null) | undefined, ad_image_19_tag?: (string | null) | undefined, ad_image_1_link?: (string | null) | undefined, ad_image_1_tag?: (string | null) | undefined, ad_image_2_link?: (string | null) | undefined, ad_image_2_tag?: (string | null) | undefined, ad_image_3_link?: (string | null) | undefined, ad_image_3_tag?: (string | null) | undefined, ad_image_4_link?: (string | null) | undefined, ad_image_4_tag?: (string | null) | undefined, ad_image_5_link?: (string | null) | undefined, ad_image_5_tag?: (string | null) | undefined, ad_image_6_link?: (string | null) | undefined, ad_image_6_tag?: (string | null) | undefined, ad_image_7_link?: (string | null) | undefined, ad_image_7_tag?: (string | null) | undefined, ad_image_8_link?: (string | null) | undefined, ad_image_8_tag?: (string | null) | undefined, ad_image_9_link?: (string | null) | undefined, ad_image_9_tag?: (string | null) | undefined, ad_link?: (string | null) | undefined, ad_video_0_link?: (string | null) | undefined, ad_video_0_tag?: (string | null) | undefined, ad_video_1_link?: (string | null) | undefined, ad_video_1_tag?: (string | null) | undefined, ad_video_2_link?: (string | null) | undefined, ad_video_2_tag?: (string | null) | undefined, additional_image_link?: (Array | null) | undefined, adult?: (boolean | null) | undefined, age_group?: (string | null) | undefined, ai_disclosures?: Array | undefined, android_deep_link?: string | undefined, availability?: string | undefined, average_review_rating?: (number | null) | undefined, brand?: (string | null) | undefined, checkout_enabled?: (boolean | null) | undefined, color?: (string | null) | undefined, condition?: (string | null) | undefined, custom_label_0?: (string | null) | undefined, custom_label_1?: (string | null) | undefined, custom_label_2?: (string | null) | undefined, custom_label_3?: (string | null) | undefined, custom_label_4?: (string | null) | undefined, custom_number_0?: (number | null) | undefined, custom_number_1?: (number | null) | undefined, custom_number_2?: (number | null) | undefined, custom_number_3?: (number | null) | undefined, custom_number_4?: (number | null) | undefined, description?: string | undefined, free_shipping_label?: (boolean | null) | undefined, free_shipping_limit?: (string | null) | undefined, gender?: (string | null) | undefined, google_product_category?: (string | null) | undefined, gtin?: UpdatableItemAttributesGtin | undefined, id?: string | undefined, image_link?: ItemAttributesRequestImageLink | undefined, installment_price?: (string | null) | undefined, ios_deep_link?: string | undefined, item_group_id?: (string | null) | undefined, last_updated_time?: (number | null) | undefined, link?: string | undefined, material?: (string | null) | undefined, min_ad_price?: (string | null) | undefined, mobile_link?: (string | null) | undefined, mpn?: (string | null) | undefined, number_of_ratings?: (number | null) | undefined, number_of_reviews?: (number | null) | undefined, pattern?: (string | null) | undefined, price?: string | undefined, product_type?: (string | null) | undefined, promotion_id?: (string | null) | undefined, sale_price?: (string | null) | undefined, sale_price_effective_date?: (string | null) | undefined, save_pin_disabled?: boolean | undefined, shipping?: (string | null) | undefined, shipping_height?: (string | null) | undefined, shipping_weight?: (string | null) | undefined, shipping_width?: (string | null) | undefined, size?: (string | null) | undefined, size_system?: (string | null) | undefined, size_type?: (string | null) | undefined, tax?: (string | null) | undefined, title?: string | undefined, unit_pricing_base_measure?: (string | null) | undefined, unit_pricing_measure?: (string | null) | undefined, variant_names?: (Array | null) | undefined, variant_values?: (Array | null) | undefined, video_link?: (string | null) | undefined}; export type UpdatableItemAttributes = {ad_image_0_link?: (string | null) | undefined, ad_image_0_tag?: (string | null) | undefined, ad_image_10_link?: (string | null) | undefined, ad_image_10_tag?: (string | null) | undefined, ad_image_11_link?: (string | null) | undefined, ad_image_11_tag?: (string | null) | undefined, ad_image_12_link?: (string | null) | undefined, ad_image_12_tag?: (string | null) | undefined, ad_image_13_link?: (string | null) | undefined, ad_image_13_tag?: (string | null) | undefined, ad_image_14_link?: (string | null) | undefined, ad_image_14_tag?: (string | null) | undefined, ad_image_15_link?: (string | null) | undefined, ad_image_15_tag?: (string | null) | undefined, ad_image_16_link?: (string | null) | undefined, ad_image_16_tag?: (string | null) | undefined, ad_image_17_link?: (string | null) | undefined, ad_image_17_tag?: (string | null) | undefined, ad_image_18_link?: (string | null) | undefined, ad_image_18_tag?: (string | null) | undefined, ad_image_19_link?: (string | null) | undefined, ad_image_19_tag?: (string | null) | undefined, ad_image_1_link?: (string | null) | undefined, ad_image_1_tag?: (string | null) | undefined, ad_image_2_link?: (string | null) | undefined, ad_image_2_tag?: (string | null) | undefined, ad_image_3_link?: (string | null) | undefined, ad_image_3_tag?: (string | null) | undefined, ad_image_4_link?: (string | null) | undefined, ad_image_4_tag?: (string | null) | undefined, ad_image_5_link?: (string | null) | undefined, ad_image_5_tag?: (string | null) | undefined, ad_image_6_link?: (string | null) | undefined, ad_image_6_tag?: (string | null) | undefined, ad_image_7_link?: (string | null) | undefined, ad_image_7_tag?: (string | null) | undefined, ad_image_8_link?: (string | null) | undefined, ad_image_8_tag?: (string | null) | undefined, ad_image_9_link?: (string | null) | undefined, ad_image_9_tag?: (string | null) | undefined, ad_link?: (string | null) | undefined, ad_video_0_link?: (string | null) | undefined, ad_video_0_tag?: (string | null) | undefined, ad_video_1_link?: (string | null) | undefined, ad_video_1_tag?: (string | null) | undefined, ad_video_2_link?: (string | null) | undefined, ad_video_2_tag?: (string | null) | undefined, adult?: (boolean | null) | undefined, age_group?: (string | null) | undefined, android_deep_link?: string | undefined, availability?: string | undefined, average_review_rating?: (number | null) | undefined, brand?: (string | null) | undefined, checkout_enabled?: (boolean | null) | undefined, color?: (string | null) | undefined, condition?: (string | null) | undefined, custom_label_0?: (string | null) | undefined, custom_label_1?: (string | null) | undefined, custom_label_2?: (string | null) | undefined, custom_label_3?: (string | null) | undefined, custom_label_4?: (string | null) | undefined, custom_number_0?: (number | null) | undefined, custom_number_1?: (number | null) | undefined, custom_number_2?: (number | null) | undefined, custom_number_3?: (number | null) | undefined, custom_number_4?: (number | null) | undefined, description?: string | undefined, free_shipping_label?: (boolean | null) | undefined, free_shipping_limit?: (string | null) | undefined, gender?: (string | null) | undefined, google_product_category?: (string | null) | undefined, gtin?: UpdatableItemAttributesGtin | undefined, id?: string | undefined, installment_price?: (string | null) | undefined, ios_deep_link?: string | undefined, item_group_id?: (string | null) | undefined, last_updated_time?: (number | null) | undefined, link?: string | undefined, material?: (string | null) | undefined, min_ad_price?: (string | null) | undefined, mobile_link?: (string | null) | undefined, mpn?: (string | null) | undefined, number_of_ratings?: (number | null) | undefined, number_of_reviews?: (number | null) | undefined, pattern?: (string | null) | undefined, price?: string | undefined, product_type?: (string | null) | undefined, promotion_id?: (string | null) | undefined, sale_price?: (string | null) | undefined, sale_price_effective_date?: (string | null) | undefined, shipping?: (string | null) | undefined, shipping_height?: (string | null) | undefined, shipping_weight?: (string | null) | undefined, shipping_width?: (string | null) | undefined, size?: (string | null) | undefined, size_system?: (string | null) | undefined, size_type?: (string | null) | undefined, tax?: (string | null) | undefined, title?: string | undefined, unit_pricing_base_measure?: (string | null) | undefined, unit_pricing_measure?: (string | null) | undefined, variant_names?: (Array | null) | undefined, variant_values?: (Array | null) | undefined}; export type UpdateMaskFieldType = 'ad_link' | 'adult' | 'age_group' | 'availability' | 'average_review_rating' | 'brand' | 'checkout_enabled' | 'color' | 'condition' | 'custom_label_0' | 'custom_label_1' | 'custom_label_2' | 'custom_label_3' | 'custom_label_4' | 'custom_number_0' | 'custom_number_1' | 'custom_number_2' | 'custom_number_3' | 'custom_number_4' | 'description' | 'free_shipping_label' | 'free_shipping_limit' | 'gender' | 'google_product_category' | 'gtin' | 'item_group_id' | 'last_updated_time' | 'link' | 'material' | 'min_ad_price' | 'mpn' | 'number_of_ratings' | 'number_of_reviews' | 'pattern' | 'price' | 'product_type' | 'sale_price' | 'shipping' | 'shipping_height' | 'shipping_weight' | 'shipping_width' | 'size' | 'size_system' | 'size_type' | 'tax' | 'title' | 'variant_names' | 'variant_values' | 'promotion_id'; export type CatalogsRetailBatchRequestItemsItems = {attributes: ItemAttributesRequest, item_id: string, operation: 'CREATE'} | {attributes: UpdatableItemAttributes, item_id: string, operation: 'UPDATE', update_mask?: (Array | null) | undefined} | {attributes: ItemAttributesRequest, item_id: string, operation: 'UPSERT'} | {item_id: string, last_updated_time?: number | undefined, operation: 'DELETE'}; export type CatalogsLocale = 'af-ZA' | 'ar-SA' | 'bg-BG' | 'bn-IN' | 'cs-CZ' | 'da-DK' | 'de' | 'el-GR' | 'en-AU' | 'en-CA' | 'en-GB' | 'en-IN' | 'en-US' | 'es-419' | 'es-AR' | 'es-ES' | 'es-MX' | 'fi-FI' | 'fr' | 'fr-CA' | 'he-IL' | 'hi-IN' | 'hr-HR' | 'hu-HU' | 'id-ID' | 'it' | 'ja' | 'ko-KR' | 'ms-MY' | 'nb-NO' | 'nl' | 'pl-PL' | 'pt-BR' | 'pt-PT' | 'ro-RO' | 'ru-RU' | 'sk-SK' | 'sv-SE' | 'te-IN' | 'th-TH' | 'tl-PH' | 'tr' | 'uk-UA' | 'vi-VN' | 'zh-CN' | 'zh-TW'; export type Language = 'AM' | 'AR' | 'AZ' | 'BG' | 'BN' | 'BS' | 'CA' | 'CS' | 'DA' | 'DV' | 'DZ' | 'DE' | 'EL' | 'EN' | 'ES' | 'ET' | 'FA' | 'FI' | 'FR' | 'HE' | 'HI' | 'HR' | 'HU' | 'HY' | 'ID' | 'IN' | 'IS' | 'IT' | 'IW' | 'JA' | 'KA' | 'KM' | 'KO' | 'LO' | 'LT' | 'LV' | 'MK' | 'MN' | 'MS' | 'MY' | 'NB' | 'NE' | 'NL' | 'NO' | 'PL' | 'PT' | 'RO' | 'RU' | 'SK' | 'SL' | 'SQ' | 'SR' | 'SV' | 'TL' | 'UK' | 'VI' | 'TE' | 'TH' | 'TR' | 'XX' | 'ZH'; export type CatalogsHotelAddress = {addr1?: string | undefined, city?: string | undefined, country?: string | undefined, postal_code?: string | undefined, region?: string | undefined}; export type CatalogsHotelGuestRatings = {max_score?: (number | null) | undefined, number_of_reviewers?: (number | null) | undefined, rating_system?: (string | null) | undefined, score?: (number | null) | undefined}; export type CatalogsHotelAttributes = {address?: CatalogsHotelAddress | undefined, base_price?: (string | null) | undefined, brand?: (string | null) | undefined, category?: (string | null) | undefined, custom_label_0?: (string | null) | undefined, custom_label_1?: (string | null) | undefined, custom_label_2?: (string | null) | undefined, custom_label_3?: (string | null) | undefined, custom_label_4?: (string | null) | undefined, description?: (string | null) | undefined, guest_ratings?: CatalogsHotelGuestRatings | undefined, latitude?: number | undefined, link?: (string | null) | undefined, longitude?: (number | null) | undefined, name?: (string | null) | undefined, neighborhood?: (Array | null) | undefined, sale_price?: (string | null) | undefined}; export type CatalogsUpdatableHotelAttributes = {address?: CatalogsHotelAddress | undefined, base_price?: (string | null) | undefined, brand?: (string | null) | undefined, category?: (string | null) | undefined, custom_label_0?: (string | null) | undefined, custom_label_1?: (string | null) | undefined, custom_label_2?: (string | null) | undefined, custom_label_3?: (string | null) | undefined, custom_label_4?: (string | null) | undefined, description?: (string | null) | undefined, guest_ratings?: CatalogsHotelGuestRatings | undefined, latitude?: number | undefined, link?: (string | null) | undefined, longitude?: (number | null) | undefined, name?: (string | null) | undefined, neighborhood?: (Array | null) | undefined, sale_price?: (string | null) | undefined}; export type CatalogsHotelBatchItem = {attributes: CatalogsHotelAttributes, hotel_id: string, operation: 'CREATE'} | {attributes: CatalogsHotelAttributes, hotel_id: string, operation: 'UPSERT'} | {attributes: CatalogsUpdatableHotelAttributes, hotel_id: string, operation: 'UPDATE'} | {hotel_id: string, operation: 'DELETE'}; export type CatalogsCreativeAssetsAttributes = {android_deep_link?: (string | null) | undefined, custom_label_0?: (string | null) | undefined, custom_label_1?: (string | null) | undefined, custom_label_2?: (string | null) | undefined, custom_label_3?: (string | null) | undefined, custom_label_4?: (string | null) | undefined, description?: string | undefined, google_product_category?: (string | null) | undefined, ios_deep_link?: (string | null) | undefined, link?: string | undefined, title?: string | undefined, visibility?: (string | null) | undefined}; export type CatalogsUpdatableCreativeAssetsAttributes = {android_deep_link?: (string | null) | undefined, custom_label_0?: (string | null) | undefined, custom_label_1?: (string | null) | undefined, custom_label_2?: (string | null) | undefined, custom_label_3?: (string | null) | undefined, custom_label_4?: (string | null) | undefined, description?: string | undefined, google_product_category?: (string | null) | undefined, ios_deep_link?: (string | null) | undefined, link?: string | undefined, title?: string | undefined, visibility?: (string | null) | undefined}; export type CatalogsCreativeAssetsBatchItem = {attributes: CatalogsCreativeAssetsAttributes, creative_assets_id: string, operation: 'CREATE'} | {attributes: CatalogsCreativeAssetsAttributes, creative_assets_id: string, operation: 'UPSERT'} | {attributes: CatalogsUpdatableCreativeAssetsAttributes, creative_assets_id: string, operation: 'UPDATE'} | {creative_assets_id: string, operation: 'DELETE'}; export type CatalogsVerticalBatchRequest = {catalog_id?: PinterestLibIntegerFormatType | undefined, catalog_type: 'RETAIL', country: Country, items: Array, language: CatalogsLocale | Language} | {catalog_id?: PinterestLibIntegerFormatType | undefined, catalog_type: 'HOTEL', country: Country, items: Array, language: CatalogsLocale | Language} | {catalog_id?: PinterestLibIntegerFormatType | undefined, catalog_type: 'CREATIVE_ASSETS', country: Country, items: Array, language: CatalogsLocale | Language}; export type ItemUpdateBatchRecord = {attributes?: UpdatableItemAttributes | undefined, item_id?: string | undefined, update_mask?: (Array | null) | undefined}; export type ItemUpsertBatchRecord = {attributes?: ItemAttributesRequest | undefined, item_id?: string | undefined}; export type ItemCreateBatchRecord = {attributes?: ItemAttributesRequest | undefined, item_id?: string | undefined}; export type ItemDeleteDiscontinuedBatchRecord = {item_id?: string | undefined}; export type ItemDeleteBatchRecord = {item_id?: string | undefined}; export type CatalogsItemsBatchRequest = {country: Country, items: Array, language: CatalogsLocale | Language, operation: 'UPDATE'} | {country: Country, items: Array, language: CatalogsLocale | Language, operation: 'UPSERT'} | {country: Country, items: Array, language: CatalogsLocale | Language, operation: 'CREATE'} | {country: Country, items: Array, language: CatalogsLocale | Language, operation: 'DELETE_DISCONTINUED'} | {country: Country, items: Array, language: CatalogsLocale | Language, operation: 'DELETE'}; export type CatalogsItemsBatchPostRequest = CatalogsVerticalBatchRequest | CatalogsItemsBatchRequest; export type CreateApiCatalogsItemsBatchArgs = {ad_account_id?: string | undefined, body: CatalogsItemsBatchPostRequest}; export type CreateApiCatalogsItemsBatchOptions = {baseUrl?: string | undefined, pinterestOauth2?: string | undefined, fetch?: typeof fetch | undefined}; export const pinterestLibIntegerFormatType = z.string(); export const itemValidationEvent = z.object({attribute: z.string().optional(), code: z.number().int().optional(), message: z.string().optional()}); export const itemProcessingStatus = z.enum(["SUCCESS", "FAILURE", "PROCESSING"]); export const itemProcessingRecord = z.object({errors: z.array(itemValidationEvent).optional(), item_id: z.string().optional(), status: itemProcessingStatus.optional(), warnings: z.array(itemValidationEvent).optional()}); export const batchOperationStatus = z.enum(["PROCESSING", "COMPLETED", "FAILED"]); export const hotelProcessingRecord = z.object({errors: z.array(itemValidationEvent).optional(), hotel_id: z.string().optional(), status: itemProcessingStatus.optional(), warnings: z.array(itemValidationEvent).optional()}); export const creativeAssetsProcessingRecord = z.object({creative_assets_id: z.string().optional(), errors: z.array(itemValidationEvent).optional(), status: itemProcessingStatus.optional(), warnings: z.array(itemValidationEvent).optional()}); export const catalogsItemsBatch = z.discriminatedUnion("catalog_type", [z.object({batch_id: pinterestLibIntegerFormatType.optional(), catalog_type: z.literal("RETAIL"), completed_time: z.string().nullable().optional(), created_time: z.string().nullable(), items: z.array(itemProcessingRecord).optional(), status: batchOperationStatus.optional()}), z.object({batch_id: pinterestLibIntegerFormatType.optional(), catalog_type: z.literal("HOTEL"), completed_time: z.string().nullable().optional(), created_time: z.string().optional(), items: z.array(hotelProcessingRecord).optional(), status: batchOperationStatus.optional()}), z.object({batch_id: pinterestLibIntegerFormatType.optional(), catalog_type: z.literal("CREATIVE_ASSETS"), completed_time: z.string().nullable().optional(), created_time: z.string().optional(), items: z.array(creativeAssetsProcessingRecord).optional(), status: batchOperationStatus.optional()})]); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Operate on item batch * * POST /catalogs/items/batch * * Also accepts auth: client_credentials */ export const createApiCatalogsItemsBatch = async (args: CreateApiCatalogsItemsBatchArgs, options?: CreateApiCatalogsItemsBatchOptions) => { const {baseUrl = "https://api.pinterest.com/v5", fetch: fetchFn = fetch, pinterestOauth2} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args.ad_account_id != null) query.append("ad_account_id", String(args.ad_account_id)) if (pinterestOauth2 !== undefined) headers.set('authorization', `Bearer ${pinterestOauth2}`) const url = `${baseUrl.replace(/\/+$/, '')}/catalogs/items/batch${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(catalogsItemsBatch, await res.json()) };