export type GetApiV1ValidationsPhoneNumbersArgs = {phoneNumber: string, country?: string | undefined}; export type GetApiV1ValidationsPhoneNumbersOptions = {baseUrl: string, APITOKEN?: string | undefined, fetch?: typeof fetch | undefined}; /** * Validate phone number * * GET /v1/validations/phone-numbers */ export const getApiV1ValidationsPhoneNumbers = async (args: GetApiV1ValidationsPhoneNumbersArgs, options: GetApiV1ValidationsPhoneNumbersOptions) => { const {baseUrl, fetch: fetchFn = fetch, APITOKEN} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.phoneNumber != null) query.append("phoneNumber", String(args.phoneNumber)) if (args.country != null) query.append("country", String(args.country)) if (APITOKEN !== undefined) headers.set("X-Quandoo-AuthToken", APITOKEN) const url = `${baseUrl.replace(/\/+$/, '')}/v1/validations/phone-numbers${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };