import {z} from 'zod' export type LatLongCustomerServiceRecordX = {id?: string | undefined, firstName?: string | undefined, middleInitial?: string | undefined, lastName?: string | undefined, businessName?: string | undefined, streetNumber?: string | undefined, streetNumberSuffix?: string | undefined, preDirectional?: ('' | 'N' | 'NE' | 'E' | 'SE' | 'S' | 'SW' | 'W' | 'NW') | undefined, streetName?: string | undefined, streetSuffix?: string | undefined, postDirectional?: ('' | 'N' | 'NE' | 'E' | 'SE' | 'S' | 'SW' | 'W' | 'NW') | undefined, city?: string | undefined, state?: string | undefined, country?: string | undefined, postalCode?: string | undefined, secondaryLocationDescription?: ('' | 'APARTMENT' | 'BUILDING' | 'BASEMENT' | 'DEPARTMENT' | 'FLOOR' | 'FRONT' | 'HANGER' | 'KEY' | 'LOBBY' | 'LOT' | 'LOWER' | 'OFFICE' | 'PENTHOUSE' | 'PIER' | 'REAR' | 'ROOM' | 'SIDE' | 'SLIP' | 'SPACE' | 'SUITE' | 'STOP' | 'TRAILER' | 'UNIT' | 'UPPER') | undefined, unit?: string | undefined, customerType?: ('BUSINESS' | 'RESIDENTIAL') | undefined, firstNameSecondary?: string | undefined, blockCustomerName?: boolean | undefined, customerName?: string | undefined, latitude?: number | undefined, longitude?: number | undefined}; export type AddressX = {id?: string | undefined, firstName?: string | undefined, middleInitial?: string | undefined, lastName?: string | undefined, businessName?: string | undefined, streetNumber?: string | undefined, streetNumberSuffix?: string | undefined, preDirectional?: ('' | 'N' | 'NE' | 'E' | 'SE' | 'S' | 'SW' | 'W' | 'NW') | undefined, streetName?: string | undefined, streetSuffix?: string | undefined, postDirectional?: ('' | 'N' | 'NE' | 'E' | 'SE' | 'S' | 'SW' | 'W' | 'NW') | undefined, city?: string | undefined, state?: string | undefined, country?: string | undefined, postalCode?: string | undefined, secondaryLocationDescription?: ('' | 'APARTMENT' | 'BUILDING' | 'BASEMENT' | 'DEPARTMENT' | 'FLOOR' | 'FRONT' | 'HANGER' | 'KEY' | 'LOBBY' | 'LOT' | 'LOWER' | 'OFFICE' | 'PENTHOUSE' | 'PIER' | 'REAR' | 'ROOM' | 'SIDE' | 'SLIP' | 'SPACE' | 'SUITE' | 'STOP' | 'TRAILER' | 'UNIT' | 'UPPER') | undefined, unit?: string | undefined}; export type DirectoryListingX = {listed?: boolean | undefined, type?: ('ERROR' | 'LIST_PUBLISH' | 'LIST_NOT_PUBLISH' | 'NOT_LIST_NOT_PUBLISH' | 'PORTED' | 'COMPLEX') | undefined, address?: AddressX | undefined}; export type E911AddressX = {id?: string | undefined, firstName?: string | undefined, middleInitial?: string | undefined, lastName?: string | undefined, businessName?: string | undefined, streetNumber?: string | undefined, streetNumberSuffix?: string | undefined, preDirectional?: ('' | 'N' | 'NE' | 'E' | 'SE' | 'S' | 'SW' | 'W' | 'NW') | undefined, streetName?: string | undefined, streetSuffix?: string | undefined, postDirectional?: ('' | 'N' | 'NE' | 'E' | 'SE' | 'S' | 'SW' | 'W' | 'NW') | undefined, city?: string | undefined, state?: string | undefined, country?: string | undefined, postalCode?: string | undefined, secondaryLocationDescription?: ('' | 'APARTMENT' | 'BUILDING' | 'BASEMENT' | 'DEPARTMENT' | 'FLOOR' | 'FRONT' | 'HANGER' | 'KEY' | 'LOBBY' | 'LOT' | 'LOWER' | 'OFFICE' | 'PENTHOUSE' | 'PIER' | 'REAR' | 'ROOM' | 'SIDE' | 'SLIP' | 'SPACE' | 'SUITE' | 'STOP' | 'TRAILER' | 'UNIT' | 'UPPER') | undefined, unit?: string | undefined, customerType?: ('BUSINESS' | 'RESIDENTIAL') | undefined, latitude?: string | undefined, longitude?: string | undefined, language?: string | undefined}; export type TelephoneNumberAccountBareX = {phoneNumber?: string | undefined, referenceType?: ('SIP_TRUNK' | 'END_USER' | 'IVR' | 'LINE_APPEARANCE' | 'LINE_HUNTGROUP' | 'TELEPHONE' | 'VFAX' | 'BUSINESS_LINE' | 'BUSINESS_LINE_HUNT_GROUP' | 'CALL_GROUP' | 'CALL_QUEUE' | 'AUTO_ATTENDANT' | 'SPECIALTY_LINE' | 'CONTACT_CENTER') | undefined, referenceId?: string | undefined, functionType?: ('ELS' | 'TollFree' | 'TemporaryNumber' | 'SPTN') | undefined, canAcceptSMS?: boolean | undefined, operationalStatus?: ('ACTIVE' | 'STAGED') | undefined, portId?: string | undefined, servicePackageType?: ('Usage' | 'PrimaryLocalFlatRate' | 'PrimaryLocalAndDomesticLDFlatRate' | 'SecondaryLocalFlatRate' | 'SecondaryLocalAndDomesticLDFlatRate') | undefined, tollFree?: boolean | undefined, id?: string | undefined, tags?: Array | undefined}; export type FileDataBase64X = {contentType?: string | undefined, name?: string | undefined, contentBase64?: string | undefined}; export type SmsActionX = 'CHANGE_CAMPAIGN' | 'DISABLE' | 'ENABLE' | 'PORT_COMPLETED'; export type SmsSettingsX = {smsLoaDocumentVersionId?: string | undefined, updatedAt?: string | undefined, campaignId?: string | undefined, smsLoa?: FileDataBase64X | undefined, enableSMS?: boolean | undefined, createdAt?: string | undefined, authorizingPerson?: string | undefined, smsAction?: SmsActionX | undefined, smsCarrierId?: string | undefined, campaignName?: string | undefined, remoteCampaignId?: string | undefined}; export type DynamicTelephoneNumberActivationX = {partitionId?: string | undefined, accountId?: string | undefined, carrierId?: string | undefined, orderId?: string | undefined, tnQuantity?: number | undefined, deviceId?: string | undefined, userId?: string | undefined, customerServiceRecord?: LatLongCustomerServiceRecordX | undefined, directoryListing?: DirectoryListingX | undefined, e911Address?: E911AddressX | undefined, tnSettings?: TelephoneNumberAccountBareX | undefined, ringType?: ('StandardRing' | 'Ring1' | 'Ring2' | 'Ring3' | 'Ring4' | 'Ring5' | 'Ring6' | 'Ring7') | undefined, archived?: boolean | undefined, alianzaOrderId?: string | undefined, smsSettings?: SmsSettingsX | undefined, id?: string | undefined}; export type CreateApiV2PartitionPartitionIdAccountAccountIdDynamicInventoryOrdersArgs = {accountId: string, partitionId: string, body: DynamicTelephoneNumberActivationX}; export type CreateApiV2PartitionPartitionIdAccountAccountIdDynamicInventoryOrdersOptions = {baseUrl?: string | undefined, XAuthToken?: string | undefined, fetch?: typeof fetch | undefined}; export const latLongCustomerServiceRecordX = z.object({id: z.string().optional(), firstName: z.string().min(3).max(256).optional(), middleInitial: z.string().min(3).max(256).optional(), lastName: z.string().min(3).max(256).optional(), businessName: z.string().min(3).max(256).optional(), streetNumber: z.string().min(3).max(256).optional(), streetNumberSuffix: z.string().min(3).max(256).optional(), preDirectional: z.enum(["", "N", "NE", "E", "SE", "S", "SW", "W", "NW"]).optional(), streetName: z.string().min(3).max(256).optional(), streetSuffix: z.string().min(3).max(256).optional(), postDirectional: z.enum(["", "N", "NE", "E", "SE", "S", "SW", "W", "NW"]).optional(), city: z.string().min(3).max(256).optional(), state: z.string().min(3).max(256).optional(), country: z.string().min(3).max(256).optional(), postalCode: z.string().min(3).max(256).optional(), secondaryLocationDescription: z.enum(["", "APARTMENT", "BUILDING", "BASEMENT", "DEPARTMENT", "FLOOR", "FRONT", "HANGER", "KEY", "LOBBY", "LOT", "LOWER", "OFFICE", "PENTHOUSE", "PIER", "REAR", "ROOM", "SIDE", "SLIP", "SPACE", "SUITE", "STOP", "TRAILER", "UNIT", "UPPER"]).optional(), unit: z.string().max(10).optional(), customerType: z.enum(["BUSINESS", "RESIDENTIAL"]).optional(), firstNameSecondary: z.string().min(3).max(256).optional(), blockCustomerName: z.boolean().optional(), customerName: z.string().min(3).max(256).optional(), latitude: z.number().optional(), longitude: z.number().optional()}); export const addressX = z.object({id: z.string().optional(), firstName: z.string().min(1).max(256).optional(), middleInitial: z.string().max(256).optional(), lastName: z.string().max(256).optional(), businessName: z.string().max(256).optional(), streetNumber: z.string().optional(), streetNumberSuffix: z.string().optional(), preDirectional: z.enum(["", "N", "NE", "E", "SE", "S", "SW", "W", "NW"]).optional(), streetName: z.string().max(256).optional(), streetSuffix: z.string().optional(), postDirectional: z.enum(["", "N", "NE", "E", "SE", "S", "SW", "W", "NW"]).optional(), city: z.string().max(256).optional(), state: z.string().optional(), country: z.string().optional(), postalCode: z.string().optional(), secondaryLocationDescription: z.enum(["", "APARTMENT", "BUILDING", "BASEMENT", "DEPARTMENT", "FLOOR", "FRONT", "HANGER", "KEY", "LOBBY", "LOT", "LOWER", "OFFICE", "PENTHOUSE", "PIER", "REAR", "ROOM", "SIDE", "SLIP", "SPACE", "SUITE", "STOP", "TRAILER", "UNIT", "UPPER"]).optional(), unit: z.string().max(10).optional()}); export const directoryListingX = z.object({listed: z.boolean().optional(), type: z.enum(["ERROR", "LIST_PUBLISH", "LIST_NOT_PUBLISH", "NOT_LIST_NOT_PUBLISH", "PORTED", "COMPLEX"]).optional(), address: addressX.optional()}); export const e911AddressX = z.object({id: z.string().optional(), firstName: z.string().optional(), middleInitial: z.string().optional(), lastName: z.string().optional(), businessName: z.string().optional(), streetNumber: z.string().optional(), streetNumberSuffix: z.string().optional(), preDirectional: z.enum(["", "N", "NE", "E", "SE", "S", "SW", "W", "NW"]).optional(), streetName: z.string().optional(), streetSuffix: z.string().optional(), postDirectional: z.enum(["", "N", "NE", "E", "SE", "S", "SW", "W", "NW"]).optional(), city: z.string().optional(), state: z.string().optional(), country: z.string().optional(), postalCode: z.string().optional(), secondaryLocationDescription: z.enum(["", "APARTMENT", "BUILDING", "BASEMENT", "DEPARTMENT", "FLOOR", "FRONT", "HANGER", "KEY", "LOBBY", "LOT", "LOWER", "OFFICE", "PENTHOUSE", "PIER", "REAR", "ROOM", "SIDE", "SLIP", "SPACE", "SUITE", "STOP", "TRAILER", "UNIT", "UPPER"]).optional(), unit: z.string().optional(), customerType: z.enum(["BUSINESS", "RESIDENTIAL"]).optional(), latitude: z.string().optional(), longitude: z.string().optional(), language: z.string().optional()}); export const dynamicInventoryOrderTelephoneNumberX = z.object({tn: z.string().optional(), id: z.string().optional()}); export const dynamicInventoryX = z.object({carrierId: z.string().optional(), orderId: z.string().optional(), tns: z.array(dynamicInventoryOrderTelephoneNumberX).optional(), id: z.string().optional()}); export const fileDataBase64X = z.object({contentType: z.string().optional(), name: z.string().optional(), contentBase64: z.string().optional()}); export const smsActionX = z.enum(["CHANGE_CAMPAIGN", "DISABLE", "ENABLE", "PORT_COMPLETED"]); export const smsSettingsX = z.object({smsLoaDocumentVersionId: z.string().optional(), updatedAt: z.string().optional(), campaignId: z.string().optional(), smsLoa: fileDataBase64X.optional(), enableSMS: z.boolean().optional(), createdAt: z.string().optional(), authorizingPerson: z.string().optional(), smsAction: smsActionX.optional(), smsCarrierId: z.string().optional(), campaignName: z.string().optional(), remoteCampaignId: z.string().optional()}); export const dynamicInventoryOrderX = z.object({partitionId: z.string().optional(), accountId: z.string().optional(), customerServiceRecord: latLongCustomerServiceRecordX.optional(), directoryListing: directoryListingX.optional(), e911Address: e911AddressX.optional(), inventory: z.array(dynamicInventoryX).optional(), deviceId: z.string().optional(), referenceId: z.string().optional(), referenceType: z.string().optional(), smsSettings: smsSettingsX.optional(), userId: z.string().optional(), id: z.string().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Creates Dynamic inventory orders, those orders eventually will activate telephone numbers received on a request * * POST /v2/partition/{partitionId}/account/{accountId}/dynamic-inventory/orders */ export const createApiV2PartitionPartitionIdAccountAccountIdDynamicInventoryOrders = async (args: CreateApiV2PartitionPartitionIdAccountAccountIdDynamicInventoryOrdersArgs, options?: CreateApiV2PartitionPartitionIdAccountAccountIdDynamicInventoryOrdersOptions) => { 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', "application/json") if (XAuthToken !== undefined) headers.set("X-AUTH-TOKEN", XAuthToken) const url = `${baseUrl.replace(/\/+$/, '')}/v2/partition/${encodeURIComponent(String(args.partitionId))}/account/${encodeURIComponent(String(args.accountId))}/dynamic-inventory/orders${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 validateResponse(dynamicInventoryOrderX, await res.json()) };