export type Address = {address1?: string | undefined, address2?: string | undefined, address3?: string | undefined, address4?: string | undefined, address5?: string | undefined, address6?: string | undefined, address7?: string | undefined, zip?: string | undefined, city?: string | undefined, country_code?: string | undefined}; export type GPSCoordinates = {gps_longitude: number, gps_latitude: number}; export type TimeInterval = {from: string, to: string}; export type OpeningDay = {day_id: string, time_intervals: Array}; export type Store = {store_id: string, store_code: string, name: string, store_address?: Address | undefined, contact_email?: string | undefined, manager_name?: string | undefined, phone_number?: string | undefined, partner_id: string, system_id: string, gps_coordinates?: GPSCoordinates | undefined, url_address?: string | undefined, opening?: Array | undefined, image_urls?: Array | undefined, visibility_for_customer?: (0 | 1) | undefined, short_description?: string | undefined, description?: string | undefined, registration_id?: string | undefined, last_change?: string | undefined, state?: (0 | 1 | 2) | undefined}; export type PropertyRecord = {property_record_id?: string | undefined, property_id: string, property_name?: string | undefined, property_value?: (string | number | number | boolean | Array | Record) | undefined, last_change?: string | undefined}; export type RewardProductRelationCondition = {related_to?: ('product' | 'product_group' | 'product_brand') | undefined, count?: number | undefined, min_price?: number | undefined, max_price?: number | undefined}; export type RewardProductRelationBonus = {related_to?: ('product' | 'product_group' | 'product_brand') | undefined, count?: number | undefined, min_price?: number | undefined, max_price?: number | undefined}; export type Tag = {tag_id?: string | undefined, name?: string | undefined, text_id?: string | undefined, state?: (0 | 1 | 2) | undefined, last_change?: string | undefined}; export type Reward = {reward_id?: string | undefined, code: string, name: string, note?: string | undefined, subtitle?: string | undefined, points_cost?: number | undefined, valid_time_from?: string | undefined, valid_time_to?: string | undefined, reward_group: 0 | 1 | 2 | 4, reward_type_id?: string | undefined, store_list: Array, additional_properties?: Array | undefined, priority?: (1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9) | undefined, image_urls?: Array | undefined, reward_external_url?: string | undefined, has_product_condition?: boolean | undefined, has_group_condition?: boolean | undefined, has_brand_condition?: boolean | undefined, has_product_bonus?: boolean | undefined, has_group_bonus?: boolean | undefined, has_brand_bonus?: boolean | undefined, reward_product_relation_conditions?: Array | undefined, reward_product_relation_bonuses?: Array | undefined, is_automated?: boolean | undefined, tags?: Array | undefined, last_change?: string | undefined, state?: (0 | 1 | 2) | undefined}; export type Voucher = {voucher_id?: string | undefined, customer_id: string, store_id?: string | undefined, code?: string | undefined, value?: number | undefined, applied_date?: string | undefined, valid_from?: string | undefined, valid_to?: string | undefined, reward_group?: string | undefined, note?: string | undefined, reward?: Reward | undefined, created_at?: string | undefined, last_change?: string | undefined, state?: (0 | 1 | 2) | undefined}; export type UpdateApiVouchersVoucherIdArgs = {'Accept-Language'?: string | undefined, voucher_id: string, body: {voucher: Voucher}}; export type UpdateApiVouchersVoucherIdOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update a voucher * * PUT /vouchers/{voucher_id} * * Also accepts auth: basicAuth */ export const updateApiVouchersVoucherId = async (args: UpdateApiVouchersVoucherIdArgs, options?: UpdateApiVouchersVoucherIdOptions) => { const {baseUrl = "https://sandbox.crmcarecloud.com/webservice/rest-api/enterprise-interface/v1.0", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args['Accept-Language'] != null) headers.set("Accept-Language", String(args['Accept-Language'])) if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/vouchers/${encodeURIComponent(String(args.voucher_id))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 undefined };