export type LcrCarrierSetEntry = {workload?: number | undefined, lcr_route_sid: string, voip_carrier_sid: string, priority: number}; export type LcrRouteAndCarrierEntries = {lcr_sid: string, regex: string, priority: number, description?: string | undefined, lcr_carrier_set_entries?: Array | undefined}; export type LcrRoutes = Array; export type CreateApiLcrsLcrSidRoutesArgs = {body: LcrRoutes}; export type CreateApiLcrsLcrSidRoutesOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create least cost routing routes and carrier set entries * * POST /Lcrs/{LcrSid}/Routes */ export const createApiLcrsLcrSidRoutes = async (args: CreateApiLcrsLcrSidRoutesArgs, options?: CreateApiLcrsLcrSidRoutesOptions) => { const {baseUrl = "https://api.jambonz.cloud/v1", fetch: fetchFn = fetch, bearerAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/Lcrs/${encodeURIComponent(String(args.LcrSid))}/Routes${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 undefined };