export type SubShippingAddressChangeRequest = {firstName?: string | undefined, lastName?: string | undefined, companyName?: string | undefined, line1?: string | undefined, line2?: string | undefined, line3?: string | undefined, city?: string | undefined, countrySubdivision?: string | undefined, postalCode?: string | undefined, country?: string | undefined, phoneNumber?: string | undefined, countyName?: string | undefined, emailAddress?: string | undefined}; export type CreateApiV1SubscriptionsSubIdShipToAddressArgs = {subId: string, token: string, body: SubShippingAddressChangeRequest}; export type CreateApiV1SubscriptionsSubIdShipToAddressOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Modify Subscription Shipping Address * * POST /v1/subscriptions/{subId}/ship-to-address */ export const createApiV1SubscriptionsSubIdShipToAddress = async (args: CreateApiV1SubscriptionsSubIdShipToAddressArgs, options?: CreateApiV1SubscriptionsSubIdShipToAddressOptions) => { const {baseUrl = "https://api.digitalriver.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.token != null) headers.set("token", String(args.token)) const url = `${baseUrl.replace(/\/+$/, '')}/v1/subscriptions/${encodeURIComponent(String(args.subId))}/ship-to-address${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 undefined };