export type OcapiV1LoyaltyMembersFriendsMemberFriendSubscriptionSharingUpdate = {friendCanUseMemberSubscription: boolean}; export type UpdateApiOcapiV1MembersCurrentFriendsIdSubscriptionSharingArgs = {id: string, loyaltySessionToken?: string | undefined, 'Connect-Region-Code'?: string | undefined, body: OcapiV1LoyaltyMembersFriendsMemberFriendSubscriptionSharingUpdate}; export type UpdateApiOcapiV1MembersCurrentFriendsIdSubscriptionSharingOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Sets the subscription sharing details of a member friend * * PUT /ocapi/v1/members/current/friends/{id}/subscription-sharing */ export const updateApiOcapiV1MembersCurrentFriendsIdSubscriptionSharing = async (args: UpdateApiOcapiV1MembersCurrentFriendsIdSubscriptionSharingArgs, options: UpdateApiOcapiV1MembersCurrentFriendsIdSubscriptionSharingOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.loyaltySessionToken != null) headers.set("loyaltySessionToken", String(args.loyaltySessionToken)) if (args['Connect-Region-Code'] != null) headers.set("Connect-Region-Code", String(args['Connect-Region-Code'])) const url = `${baseUrl.replace(/\/+$/, '')}/ocapi/v1/members/current/friends/${encodeURIComponent(String(args.id))}/subscription-sharing${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 };