import {z} from 'zod' export type UpdateSubscriptionRequest = {plan_id: string, item_price_id: string}; export type UpdateApiSubscriptionsSubscriptionIdUpdateArgs = {subscription_id: string, 'X-Profile-Id': string, body: UpdateSubscriptionRequest}; export type UpdateApiSubscriptionsSubscriptionIdUpdateOptions = {baseUrl: string, apiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const subscriptionId = z.string(); export const subscriptionStatus = z.enum(["active", "created", "in_active", "pending", "trial", "paused", "unpaid", "onetime", "cancelled", "failed"]); export const profileId = z.string(); export const merchantId = z.string(); export const customerId = z.string(); export const paymentId = z.string(); export const intentStatus = z.enum(["succeeded", "failed", "cancelled", "cancelled_post_capture", "processing", "requires_customer_action", "requires_merchant_action", "requires_payment_method", "requires_confirmation", "requires_capture", "partially_captured", "partially_captured_and_capturable", "partially_authorized_and_requires_capture", "partially_captured_and_processing", "conflicted", "expired", "review"]); export const minorUnit = z.number().int(); export const currency = z.enum(["AED", "AFN", "ALL", "AMD", "ANG", "AOA", "ARS", "AUD", "AWG", "AZN", "BAM", "BBD", "BDT", "BGN", "BHD", "BIF", "BMD", "BND", "BOB", "BRL", "BSD", "BTN", "BWP", "BYN", "BZD", "CAD", "CDF", "CHF", "CLF", "CLP", "CNY", "COP", "CRC", "CUC", "CUP", "CVE", "CZK", "DJF", "DKK", "DOP", "DZD", "EGP", "ERN", "ETB", "EUR", "FJD", "FKP", "GBP", "GEL", "GHS", "GIP", "GMD", "GNF", "GTQ", "GYD", "HKD", "HNL", "HRK", "HTG", "HUF", "IDR", "ILS", "INR", "IQD", "IRR", "ISK", "JMD", "JOD", "JPY", "KES", "KGS", "KHR", "KMF", "KPW", "KRW", "KWD", "KYD", "KZT", "LAK", "LBP", "LKR", "LRD", "LSL", "LYD", "MAD", "MDL", "MGA", "MKD", "MMK", "MNT", "MOP", "MRU", "MUR", "MVR", "MWK", "MXN", "MYR", "MZN", "NAD", "NGN", "NIO", "NOK", "NPR", "NZD", "OMR", "PAB", "PEN", "PGK", "PHP", "PKR", "PLN", "PYG", "QAR", "RON", "RSD", "RUB", "RWF", "SAR", "SBD", "SCR", "SDG", "SEK", "SGD", "SHP", "SLE", "SLL", "SOS", "SRD", "SSP", "STD", "STN", "SVC", "SYP", "SZL", "THB", "TJS", "TMT", "TND", "TOP", "TRY", "TTD", "TWD", "TZS", "UAH", "UGX", "USD", "UYU", "UZS", "VES", "VND", "VUV", "WST", "XAF", "XCD", "XOF", "XPF", "YER", "ZAR", "ZMW", "ZWL"]); export const dokuBankTransferInstructions = z.object({expires_at: z.string(), reference: z.string(), instructions_url: z.string()}); export const receiverDetails = z.object({amount_received: z.number().int(), amount_charged: z.number().int().nullable().optional(), amount_remaining: z.number().int().nullable().optional()}); export const achTransfer = z.object({account_number: z.string(), bank_name: z.string(), routing_number: z.string(), swift_code: z.string()}); export const sepaBankTransferInstructions = z.object({account_holder_name: z.string(), bic: z.string(), country: z.string(), iban: z.string(), reference: z.string()}); export const bacsBankTransferInstructions = z.object({account_holder_name: z.string(), account_number: z.string(), sort_code: z.string()}); export const multibancoTransferInstructions = z.object({reference: z.string(), entity: z.string()}); export const bankTransferNextStepsData = z.union([z.object({doku_bank_transfer_instructions: dokuBankTransferInstructions, receiver: receiverDetails.nullable().optional()}), z.object({ach_credit_transfer: achTransfer, receiver: receiverDetails.nullable().optional()}), z.object({sepa_bank_instructions: sepaBankTransferInstructions, receiver: receiverDetails.nullable().optional()}), z.object({bacs_bank_instructions: bacsBankTransferInstructions, receiver: receiverDetails.nullable().optional()}), z.object({multibanco: multibancoTransferInstructions, receiver: receiverDetails.nullable().optional()})]); export const nextActionCall = z.union([z.literal("post_session_tokens"), z.literal("confirm"), z.literal("sync"), z.literal("complete_authorize"), z.literal("await_merchant_callback"), z.object({deny: z.object({message: z.string()})}), z.literal("eligibility_check")]); export const sdkNextAction = z.object({next_action: nextActionCall, should_block_confirm: z.boolean().nullable().optional()}); export const gpayMerchantInfo = z.object({merchant_id: z.string().nullable().optional(), merchant_name: z.string()}); export const gpayShippingAddressParameters = z.object({phone_number_required: z.boolean()}); export const gpayBillingAddressFormat = z.enum(["FULL", "MIN"]); export const gpayBillingAddressParameters = z.object({phone_number_required: z.boolean(), format: gpayBillingAddressFormat}); export const gpayAllowedMethodsParameters = z.object({allowed_auth_methods: z.array(z.string()), allowed_card_networks: z.array(z.string()), billing_address_required: z.boolean().nullable().optional(), billing_address_parameters: gpayBillingAddressParameters.nullable().optional(), assurance_details_required: z.boolean().nullable().optional(), allow_credit_cards: z.boolean().nullable().optional()}); export const gpayTokenParameters = z.object({gateway: z.string().nullable().optional(), gateway_merchant_id: z.string().nullable().optional(), "stripe:version": z.string().nullable().optional(), "stripe:publishableKey": z.string().nullable().optional(), protocol_version: z.string().nullable().optional(), public_key: z.string().nullable().optional()}); export const gpayTokenizationSpecification = z.object({type: z.string(), parameters: gpayTokenParameters}); export const gpayAllowedPaymentMethods = z.object({type: z.string(), parameters: gpayAllowedMethodsParameters, tokenization_specification: gpayTokenizationSpecification}); export const countryAlpha2 = z.enum(["AF", "AX", "AL", "DZ", "AS", "AD", "AO", "AI", "AQ", "AG", "AR", "AM", "AW", "AU", "AT", "AZ", "BS", "BH", "BD", "BB", "BY", "BE", "BZ", "BJ", "BM", "BT", "BO", "BQ", "BA", "BW", "BV", "BR", "IO", "BN", "BG", "BF", "BI", "KH", "CM", "CA", "CV", "KY", "CF", "TD", "CL", "CN", "CX", "CC", "CO", "KM", "CG", "CD", "CK", "CR", "CI", "HR", "CU", "CW", "CY", "CZ", "DK", "DJ", "DM", "DO", "EC", "EG", "SV", "GQ", "ER", "EE", "ET", "FK", "FO", "FJ", "FI", "FR", "GF", "PF", "TF", "GA", "GM", "GE", "DE", "GH", "GI", "GR", "GL", "GD", "GP", "GU", "GT", "GG", "GN", "GW", "GY", "HT", "HM", "VA", "HN", "HK", "HU", "IS", "IN", "ID", "IR", "IQ", "IE", "IM", "IL", "IT", "JM", "JP", "JE", "JO", "KZ", "KE", "KI", "KP", "KR", "KW", "KG", "LA", "LV", "LB", "LS", "LR", "LY", "LI", "LT", "LU", "MO", "MK", "MG", "MW", "MY", "MV", "ML", "MT", "MH", "MQ", "MR", "MU", "YT", "MX", "FM", "MD", "MC", "MN", "ME", "MS", "MA", "MZ", "MM", "NA", "NR", "NP", "NL", "NC", "NZ", "NI", "NE", "NG", "NU", "NF", "MP", "NO", "OM", "PK", "PW", "PS", "PA", "PG", "PY", "PE", "PH", "PN", "PL", "PT", "PR", "QA", "RE", "RO", "RU", "RW", "BL", "SH", "KN", "LC", "MF", "PM", "VC", "WS", "SM", "ST", "SA", "SN", "RS", "SC", "SL", "SG", "SX", "SK", "SI", "SB", "SO", "ZA", "GS", "SS", "ES", "LK", "SD", "SR", "SJ", "SZ", "SE", "CH", "SY", "TW", "TJ", "TZ", "TH", "TL", "TG", "TK", "TO", "TT", "TN", "TR", "TM", "TC", "TV", "UG", "UA", "AE", "GB", "UM", "UY", "UZ", "VU", "VE", "VN", "VG", "VI", "WF", "EH", "YE", "ZM", "ZW", "US"]); export const gpayTransactionInfo = z.object({country_code: countryAlpha2, currency_code: currency, total_price_status: z.string(), total_price: z.string()}); export const secretInfoToInitiateSdk = z.object({display: z.string(), payment: z.string()}); export const samsungPayMerchantPaymentInformation = z.object({name: z.string(), url: z.string().nullable().optional(), country_code: countryAlpha2}); export const samsungPayAmountFormat = z.enum(["FORMAT_TOTAL_PRICE_ONLY", "FORMAT_TOTAL_ESTIMATED_AMOUNT"]); export const samsungPayAmountDetails = z.object({option: samsungPayAmountFormat, currency_code: currency, total: z.string()}); export const samsungPayProtocolType = z.literal("PROTOCOL3DS"); export const paypalFlow = z.literal("checkout"); export const paypalTransactionInfo = z.object({flow: paypalFlow, currency_code: currency, total_price: z.string()}); export const paypalCaptureMethod = z.enum(["capture", "authorize"]); export const thirdPartySdkSessionResponse = z.object({secrets: secretInfoToInitiateSdk}); export const nullObject = z.unknown(); export const applePaySessionResponse = z.union([thirdPartySdkSessionResponse, z.unknown(), nullObject]); export const amountInfo = z.object({label: z.string(), type: z.string().nullable().optional(), amount: z.string()}); export const applePayAddressParameters = z.enum(["postalAddress", "phone", "email"]); export const applePayBillingContactFields = z.array(applePayAddressParameters); export const applePayShippingContactFields = z.array(applePayAddressParameters); export const applePayPaymentTiming = z.enum(["immediate", "recurring"]); export const recurringPaymentIntervalUnit = z.enum(["year", "month", "day", "hour", "minute"]); export const applePayRegularBillingRequest = z.object({amount: z.string(), label: z.string(), payment_timing: applePayPaymentTiming, recurring_payment_start_date: z.string().nullable().optional(), recurring_payment_end_date: z.string().nullable().optional(), recurring_payment_interval_unit: recurringPaymentIntervalUnit.nullable().optional(), recurring_payment_interval_count: z.number().int().nullable().optional()}); export const applePayRecurringPaymentRequest = z.object({payment_description: z.string(), regular_billing: applePayRegularBillingRequest, billing_agreement: z.string().nullable().optional(), management_u_r_l: z.string()}); export const applePayPaymentRequest = z.object({country_code: countryAlpha2, currency_code: currency, total: amountInfo, merchant_capabilities: z.array(z.string()).nullable().optional(), supported_networks: z.array(z.string()).nullable().optional(), merchant_identifier: z.string().nullable().optional(), required_billing_contact_fields: applePayBillingContactFields.nullable().optional(), required_shipping_contact_fields: applePayShippingContactFields.nullable().optional(), recurring_payment_request: applePayRecurringPaymentRequest.nullable().optional()}); export const cardNetwork = z.enum(["Visa", "Mastercard", "AmericanExpress", "JCB", "DinersClub", "Discover", "CartesBancaires", "UnionPay", "Interac", "RuPay", "Maestro", "Star", "Pulse", "Accel", "Nyce", "Prop", "PrivateLabel", "Dinacard"]); export const ctpServiceProvider = z.enum(["visa", "mastercard"]); export const amazonPayPaymentIntent = z.enum(["Confirm", "Authorize", "AuthorizeWithCapture"]); export const amazonPayDeliveryPrice = z.object({amount: minorUnit, currency_code: currency}); export const amazonPayShippingMethod = z.object({shipping_method_name: z.string(), shipping_method_code: z.string()}); export const amazonPayDeliveryOptions = z.object({id: z.string(), price: amazonPayDeliveryPrice, shipping_method: amazonPayShippingMethod, is_default: z.boolean()}); export const sessionToken = z.discriminatedUnion("wallet_name", [z.object({delayed_session_token: z.boolean(), connector: z.string(), sdk_next_action: sdkNextAction, wallet_name: z.literal("google_pay")}), z.object({merchant_info: gpayMerchantInfo, shipping_address_required: z.boolean(), email_required: z.boolean(), shipping_address_parameters: gpayShippingAddressParameters, allowed_payment_methods: z.array(gpayAllowedPaymentMethods), transaction_info: gpayTransactionInfo, delayed_session_token: z.boolean(), connector: z.string(), sdk_next_action: sdkNextAction, secrets: secretInfoToInitiateSdk.nullable().optional(), wallet_name: z.literal("google_pay")}), z.object({version: z.string(), service_id: z.string(), order_number: z.string(), merchant: samsungPayMerchantPaymentInformation, amount: samsungPayAmountDetails, protocol: samsungPayProtocolType, allowed_brands: z.array(z.string()), billing_address_required: z.boolean(), shipping_address_required: z.boolean(), wallet_name: z.literal("samsung_pay")}), z.object({session_token: z.string(), session_id: z.string(), wallet_name: z.literal("klarna")}), z.object({connector: z.string(), session_token: z.string(), sdk_next_action: sdkNextAction, client_token: z.string().nullable().optional(), transaction_info: paypalTransactionInfo.nullable().optional(), data_user_id_token: z.string().nullable().optional(), currency: currency.nullable().optional(), intent: paypalCaptureMethod.nullable().optional(), wallet_name: z.literal("paypal")}), z.object({session_token_data: applePaySessionResponse.nullable().optional(), payment_request_data: applePayPaymentRequest.nullable().optional(), connector: z.string(), delayed_session_token: z.boolean(), sdk_next_action: sdkNextAction, connector_reference_id: z.string().nullable().optional(), connector_sdk_public_key: z.string().nullable().optional(), connector_merchant_id: z.string().nullable().optional(), wallet_name: z.literal("apple_pay")}), z.object({open_banking_session_token: z.string(), wallet_name: z.literal("open_banking")}), z.object({client_id: z.string(), client_name: z.string(), client_profile_id: z.string(), transaction_currency_code: currency, transaction_amount: z.string(), email_address: z.string().max(255).nullable().optional(), wallet_name: z.literal("paze")}), z.object({dpa_id: z.string(), dpa_name: z.string(), locale: z.string(), card_brands: z.array(cardNetwork), acquirer_bin: z.string(), acquirer_merchant_id: z.string(), merchant_category_code: z.string().nullable().optional(), merchant_country_code: z.string(), transaction_amount: z.string(), transaction_currency_code: currency, phone_number: z.string().max(255).nullable().optional(), email: z.string().max(255).nullable().optional(), phone_country_code: z.string().nullable().optional(), provider: ctpServiceProvider.nullable().optional(), dpa_client_id: z.string().nullable().optional(), wallet_name: z.literal("click_to_pay")}), z.object({merchant_id: z.string(), ledger_currency: currency, store_id: z.string(), payment_intent: amazonPayPaymentIntent, total_shipping_amount: z.string(), total_tax_amount: z.string(), total_base_amount: z.string(), delivery_options: z.array(amazonPayDeliveryOptions), wallet_name: z.literal("amazon_pay")}), z.object({wallet_name: z.literal("no_session_token_received")})]); export const pollConfig = z.object({delay_in_secs: z.number().int().gte(0), frequency: z.number().int().gte(0)}); export const threeDsMethodKey = z.enum(["threeDSMethodData", "JWT"]); export const threeDsMethodData = z.object({three_ds_method_data_submission: z.boolean(), three_ds_method_data: z.string().nullable().optional(), three_ds_method_url: z.string().nullable().optional(), three_ds_method_key: threeDsMethodKey.nullable().optional(), consume_post_message_for_three_ds_method_completion: z.boolean()}); export const pollConfigResponse = z.object({poll_id: z.string(), delay_in_secs: z.number().int(), frequency: z.number().int()}); export const threeDsData = z.object({three_ds_authentication_url: z.string(), three_ds_authorize_url: z.string(), three_ds_method_details: threeDsMethodData, poll_config: pollConfigResponse, message_version: z.string().nullable().optional(), directory_server_id: z.string().nullable().optional(), card_network: cardNetwork.nullable().optional(), three_ds_connector: z.string().nullable().optional()}); export const sdkNextActionData = z.object({next_action: nextActionCall, order_id: z.string().nullable().optional()}); export const mobilePaymentConsent = z.enum(["consent_required", "consent_not_required", "consent_optional"]); export const iframeData = z.object({three_ds_method_url: z.string(), three_ds_method_data_submission: z.boolean(), three_ds_method_data: z.string().nullable().optional(), directory_server_id: z.string(), message_version: z.string().nullable().optional(), method_key: z.literal("threeDSMethodData")}); export const dDCData = z.object({iframe_url: z.string(), timeout_ms: z.number().int().nullable().optional()}); export const nextActionData = z.discriminatedUnion("type", [z.object({redirect_to_url: z.string(), type: z.literal("redirect_to_url")}), z.object({bank_transfer_steps_and_charges_details: bankTransferNextStepsData, type: z.literal("display_bank_transfer_information")}), z.object({session_token: sessionToken.nullable().optional(), type: z.literal("third_party_sdk_session_token")}), z.object({image_data_url: z.string(), display_to_timestamp: z.number().int().nullable().optional(), qr_code_url: z.string(), display_text: z.string().nullable().optional(), border_color: z.string().nullable().optional(), raw_qr_data: z.string().nullable().optional(), type: z.literal("qr_code_information")}), z.object({qr_code_fetch_url: z.string(), type: z.literal("fetch_qr_code_information")}), z.object({sdk_uri: z.string(), display_from_timestamp: z.number().int(), display_to_timestamp: z.number().int().nullable().optional(), poll_config: pollConfig.nullable().optional(), type: z.literal("invoke_upi_intent_sdk")}), z.object({qr_code_url: z.string(), display_from_timestamp: z.number().int(), display_to_timestamp: z.number().int().nullable().optional(), poll_config: pollConfig.nullable().optional(), type: z.literal("invoke_upi_qr_flow")}), z.object({voucher_details: z.string(), type: z.literal("display_voucher_information")}), z.object({display_from_timestamp: z.number().int(), display_to_timestamp: z.number().int().nullable().optional(), poll_config: pollConfig.nullable().optional(), type: z.literal("wait_screen_information")}), z.object({three_ds_data: threeDsData, type: z.literal("three_ds_invoke")}), z.object({next_action_data: sdkNextActionData, type: z.literal("invoke_sdk_client")}), z.object({consent_data_required: mobilePaymentConsent, type: z.literal("collect_otp")}), z.object({iframe_data: iframeData, type: z.literal("invoke_hidden_iframe")}), z.object({ddc_data: dDCData, type: z.literal("invoke_ddc")})]); export const paymentExperience = z.enum(["redirect_to_url", "invoke_sdk_client", "display_qr_code", "one_click", "link_wallet", "invoke_payment_app", "display_wait_screen", "collect_otp"]); export const paymentMethodType = z.enum(["ach", "affirm", "afterpay_clearpay", "alfamart", "ali_pay", "ali_pay_hk", "alma", "amazon_pay", "paysera", "apple_pay", "atome", "bacs", "bancontact_card", "becs", "benefit", "bizum", "blik", "bluecode", "boleto", "bca_bank_transfer", "bni_va", "breadpay", "bri_va", "bhn_card_network", "card_redirect", "cimb_va", "classic", "credit", "crypto_currency", "cashapp", "dana", "danamon_va", "debit", "duit_now", "efecty", "eft", "eft_debit_order", "eps", "flexiti", "fps", "evoucher", "giropay", "givex", "google_pay", "go_pay", "gcash", "ideal", "interac", "indomaret", "klarna", "kakao_pay", "local_bank_redirect", "mandiri_va", "knet", "mb_way", "mobile_pay", "momo", "momo_atm", "multibanco", "online_banking_thailand", "online_banking_czech_republic", "online_banking_finland", "online_banking_fpx", "online_banking_poland", "online_banking_slovakia", "oxxo", "pago_efectivo", "permata_bank_transfer", "open_banking_uk", "pay_bright", "payjustnow", "paypal", "paze", "pix", "pix_key", "pix_emv", "pix_qr", "pix_automatico_qr", "pix_automatico_push", "pay_safe_card", "przelewy24", "prompt_pay", "pse", "qris", "red_compra", "red_pagos", "samsung_pay", "sepa", "sepa_bank_transfer", "sepa_guarenteed_debit", "skrill", "sofort", "swish", "touch_n_go", "trustly", "twint", "upi_collect", "upi_intent", "upi_qr", "vipps", "viet_qr", "venmo", "walley", "we_chat_pay", "seven_eleven", "lawson", "mini_stop", "family_mart", "seicomart", "pay_easy", "local_bank_transfer", "mifinity", "open_banking_pis", "direct_carrier_billing", "instant_bank_transfer", "instant_bank_transfer_finland", "instant_bank_transfer_poland", "revolut_pay", "indonesian_bank_transfer", "open_banking", "network_token"]); export const addressDetails = z.object({city: z.string().max(50).nullable().optional(), country: countryAlpha2.nullable().optional(), line1: z.string().max(200).nullable().optional(), line2: z.string().max(50).nullable().optional(), line3: z.string().max(50).nullable().optional(), zip: z.string().max(50).nullable().optional(), state: z.string().nullable().optional(), first_name: z.string().max(255).nullable().optional(), last_name: z.string().max(255).nullable().optional(), origin_zip: z.string().max(50).nullable().optional()}); export const phoneDetails = z.object({number: z.string().nullable().optional(), country_code: z.string().nullable().optional()}); export const address = z.object({address: addressDetails.nullable().optional(), phone: phoneDetails.nullable().optional(), email: z.string().nullable().optional()}); export const paymentType = z.enum(["normal", "new_mandate", "setup_mandate", "recurring_mandate", "installment"]); export const paymentResponseData = z.object({payment_id: paymentId, status: intentStatus, amount: minorUnit, currency: currency, profile_id: profileId.nullable().optional(), connector: z.string().nullable().optional(), payment_method_id: z.string().nullable().optional(), return_url: z.string().nullable().optional(), next_action: nextActionData.nullable().optional(), payment_experience: paymentExperience.nullable().optional(), error_code: z.string().nullable().optional(), error_message: z.string().nullable().optional(), payment_method_type: paymentMethodType.nullable().optional(), client_secret: z.string().nullable().optional(), billing: address.nullable().optional(), shipping: address.nullable().optional(), payment_type: paymentType.nullable().optional(), payment_token: z.string().nullable().optional()}); export const invoiceId = z.string(); export const merchantConnectorAccountId = z.string(); export const invoiceStatus = z.enum(["invoice_created", "payment_pending", "payment_pending_timeout", "payment_succeeded", "payment_failed", "payment_canceled", "invoice_paid", "manual_review", "voided"]); export const invoice = z.object({id: invoiceId, subscription_id: subscriptionId, merchant_id: merchantId, profile_id: profileId, merchant_connector_id: merchantConnectorAccountId, payment_intent_id: paymentId.nullable().optional(), payment_method_id: z.string().nullable().optional(), customer_id: customerId, amount: minorUnit, currency: currency, status: invoiceStatus, billing_processor_invoice_id: z.string().nullable().optional()}); export const subscriptionResponse = z.object({id: subscriptionId, merchant_reference_id: z.string().nullable().optional(), status: subscriptionStatus, plan_id: z.string().nullable().optional(), item_price_id: z.string().nullable().optional(), profile_id: profileId, client_secret: z.string().nullable().optional(), merchant_id: merchantId, coupon_code: z.string().nullable().optional(), customer_id: customerId, payment: paymentResponseData.nullable().optional(), invoice: invoice.nullable().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 }; /** * Subscription - Update * * PUT /subscriptions/{subscription_id}/update */ export const updateApiSubscriptionsSubscriptionIdUpdate = async (args: UpdateApiSubscriptionsSubscriptionIdUpdateArgs, options: UpdateApiSubscriptionsSubscriptionIdUpdateOptions) => { const {baseUrl, fetch: fetchFn = fetch, apiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (args['X-Profile-Id'] != null) headers.set("X-Profile-Id", String(args['X-Profile-Id'])) if (apiKey !== undefined) headers.set("Authorization", apiKey) const url = `${baseUrl.replace(/\/+$/, '')}/subscriptions/${encodeURIComponent(String(args.subscription_id))}/update${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 validateResponse(subscriptionResponse, await res.json()) };