export type CreateApiApiV1UUpdateProfileArgs = {'Api-Key': string, 'Api-Secret': string, body: {accessToken: string, username: string, email?: string | undefined, avatar?: string | undefined, signature?: string | undefined, birthday?: string | undefined, address?: string | undefined, cmnd?: string | undefined}}; export type CreateApiApiV1UUpdateProfileOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Cập nhật hồ sơ cá nhân * * POST /api/v1/u/update-profile */ export const createApiApiV1UUpdateProfile = async (args: CreateApiApiV1UUpdateProfileArgs, options?: CreateApiApiV1UUpdateProfileOptions) => { const {baseUrl = "http://baovothuat.net", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/x-www-form-urlencoded") headers.set('accept', "application/x-www-form-urlencoded;charset=utf-8;") if (args['Api-Key'] != null) headers.set("Api-Key", String(args['Api-Key'])) if (args['Api-Secret'] != null) headers.set("Api-Secret", String(args['Api-Secret'])) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/u/update-profile${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: new URLSearchParams(Object.entries(args.body).flatMap(([key, value]) => (value == null ? [] : [[key, String(value)]])))}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };