export type GetApiTombaV1PhoneValidatorArgs = {phone: string, country_code?: string | undefined}; export type GetApiTombaV1PhoneValidatorOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Validate a phone number and get carrier information. * * GET /tomba/v1/phone-validator */ export const getApiTombaV1PhoneValidator = async (args: GetApiTombaV1PhoneValidatorArgs, options?: GetApiTombaV1PhoneValidatorOptions) => { const {baseUrl = "https://api.orthogonal.com/mpp", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.phone != null) query.append("phone", String(args.phone)) if (args.country_code != null) query.append("country_code", String(args.country_code)) const url = `${baseUrl.replace(/\/+$/, '')}/tomba/v1/phone-validator${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 };