export type WordTypes = 'PROPER_NOUN' | 'LOCATION_NAME' | 'ORGANIZATION_NAME' | 'PERSON_NAME' | 'PERSON_FAMILY_NAME' | 'PERSON_GIVEN_NAME' | 'COMMON_NOUN' | 'VERB' | 'ADJECTIVE' | 'SUFFIX'; export type UpdateApiUserDictWordWordUuidArgs = {word_uuid: string, surface: Array, pronunciation: Array, accent_type: Array, word_type?: WordTypes | undefined, priority?: number | undefined}; export type UpdateApiUserDictWordWordUuidOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * ユーザー辞書に登録されている単語を更新する * * PUT /user_dict_word/{word_uuid} */ export const updateApiUserDictWordWordUuid = async (args: UpdateApiUserDictWordWordUuidArgs, options: UpdateApiUserDictWordWordUuidOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() for (const item of args.surface ?? []) query.append("surface", String(item)) for (const item of args.pronunciation ?? []) query.append("pronunciation", String(item)) for (const item of args.accent_type ?? []) query.append("accent_type", String(item)) if (args.word_type != null) query.append("word_type", String(args.word_type)) if (args.priority != null) query.append("priority", String(args.priority)) const url = `${baseUrl.replace(/\/+$/, '')}/user_dict_word/${encodeURIComponent(String(args.word_uuid))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };