export type StatusRequest = {status_id: number}; export type CreateApiBranchesBranchIdVisibilityStatusArgs = {Authorization: string, 'User-Agent': string, 'Brand-Id': string, branch_id: string, body: StatusRequest}; export type CreateApiBranchesBranchIdVisibilityStatusOptions = {baseUrl?: string | undefined, CareemIDPClientCredentials?: string | undefined, fetch?: typeof fetch | undefined}; /** * Update branch status on SuperApp * * POST /branches/{branch_id}/visibility/status */ export const createApiBranchesBranchIdVisibilityStatus = async (args: CreateApiBranchesBranchIdVisibilityStatusArgs, options?: CreateApiBranchesBranchIdVisibilityStatusOptions) => { const {baseUrl = "https://apigateway.careemdash.com/pos/api/v1", fetch: fetchFn = fetch, CareemIDPClientCredentials} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (args.Authorization != null) headers.set("Authorization", String(args.Authorization)) if (args['User-Agent'] != null) headers.set("User-Agent", String(args['User-Agent'])) if (args['Brand-Id'] != null) headers.set("Brand-Id", String(args['Brand-Id'])) if (CareemIDPClientCredentials !== undefined) headers.set('authorization', `Bearer ${CareemIDPClientCredentials}`) const url = `${baseUrl.replace(/\/+$/, '')}/branches/${encodeURIComponent(String(args.branch_id))}/visibility/status${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 };