export type ValidateSipUsernameDto = {username: string}; export type CreateApiV2RpcSpecialtyLineValidateSipUsernameArgs = {body: ValidateSipUsernameDto}; export type CreateApiV2RpcSpecialtyLineValidateSipUsernameOptions = {baseUrl?: string | undefined, XAuthToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Validate a SIP username * * POST /v2/rpc/specialty-line/validate-sip-username */ export const createApiV2RpcSpecialtyLineValidateSipUsername = async (args: CreateApiV2RpcSpecialtyLineValidateSipUsernameArgs, options?: CreateApiV2RpcSpecialtyLineValidateSipUsernameOptions) => { const {baseUrl = "https://api.alianza.com", fetch: fetchFn = fetch, XAuthToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "text/plain") if (XAuthToken !== undefined) headers.set("X-AUTH-TOKEN", XAuthToken) const url = `${baseUrl.replace(/\/+$/, '')}/v2/rpc/specialty-line/validate-sip-username${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 res.text() };