import { type AxiosInstance } from "axios"; export interface GrizzlyPartnerOptions { /** Partner protocol key from the personal account. */ key: string; baseUrl?: string; timeoutMs?: number; /** * HTTP proxy URL. Ignored when `axios` is set. * Example: `http://127.0.0.1:8080`. */ proxy?: string; axios?: AxiosInstance; } export interface PushRetryOptions { /** Extra attempts after the first request. Default `0`. */ retries?: number; /** Delay between attempts. The protocol asks for 10 seconds. */ retryDelayMs?: number; } export interface PushSmsParams extends PushRetryOptions { smsId: number; phone: number; phoneFrom: string; text: string; } export interface PushCallParams extends PushRetryOptions { callId: number; phone: number; phoneFrom: string; } export interface PushCallRecordParams extends PushRetryOptions { callId: number; phone: number; phoneFrom: string; /** Required when `file` is omitted. */ text?: string; /** wav, amr, mp3, or ogg. Required when `text` is omitted. */ file?: Blob; filename?: string; } export interface PartnerStatus { status: string; error?: string; } /** Inbound `GET_SERVICES` body sent by Grizzly to the partner server. */ export interface PartnerGetServicesRequest { action: "GET_SERVICES"; key: string; } export interface PartnerCountryStock { country: number; operatorMap: Record>; } export interface PartnerGetServicesResponse { status: "SUCCESS" | "ERROR"; countryList?: PartnerCountryStock[]; error?: string; } /** Inbound `GET_NUMBER` body sent by Grizzly to the partner server. */ export interface PartnerGetNumberRequest { action: "GET_NUMBER"; key: string; country: number; operator: string; service: string; sum: number; exceptionPhoneSet?: string[]; canGetAnotherSms?: boolean | number | string; } export interface PartnerGetNumberResponse { status: "SUCCESS" | "NO_NUMBERS" | "ERROR"; number?: number; activationId?: number; flashcall?: boolean; voice?: boolean; canGetAnotherSms?: boolean | number | string; error?: string; } /** * Inbound `FINISH_ACTIVATION` body. * `1` forbidden, `3` sold, `4` cancelled, `5` returned to the customer. */ export interface PartnerFinishActivationRequest { action: "FINISH_ACTIVATION"; key: string; activationId: number; status: 1 | 3 | 4 | 5; } export interface PartnerFinishActivationResponse { status: "SUCCESS" | "ERROR"; error?: string; } /** * Client for the calls a partner sends to Grizzly: SMS, flash-call, and * call-record delivery. `GET_SERVICES`, `GET_NUMBER`, and `FINISH_ACTIVATION` * are incoming requests — the types above describe those payloads. * * PUSH_CALL and PUSH_CALL_RECORD are posted to `/agent/api/sms`, the address * written in the protocol articles. The `action` field selects the method. * * @example * ```ts * const partner = new GrizzlyPartner({ key: process.env.GRIZZLY_PARTNER_KEY! }); * await partner.pushSms({ * smsId: 1, * phone: 447472190082, * phoneFrom: "Microsoft", * text: "code 5015", * }); * ``` */ export declare class GrizzlyPartner { private readonly key; private readonly http; /** * @param options Partner key from the personal account. * * @example * ```ts * const partner = new GrizzlyPartner({ key: process.env.GRIZZLY_PARTNER_KEY! }); * ``` */ constructor(options: GrizzlyPartnerOptions); /** * Deliver an inbound SMS (`PUSH_SMS`). * * @example * ```ts * await partner.pushSms({ * smsId: 1, * phone: 447472190082, * phoneFrom: "Microsoft", * text: "code 5015", * }); * ``` */ pushSms(params: PushSmsParams): Promise; /** * Deliver a flash-call (`PUSH_CALL`). * * @example * ```ts * await partner.pushCall({ * callId: 10, * phone: 447472190082, * phoneFrom: "100", * }); * ``` */ pushCall(params: PushCallParams): Promise; /** * Deliver a call recording (`PUSH_CALL_RECORD`). Pass `text`, `file`, or both. * * @example * ```ts * await partner.pushCallRecord({ * callId: 10, * phone: 447472190082, * phoneFrom: "100", * text: "your code is 5015", * }); * ``` */ pushCallRecord(params: PushCallRecordParams): Promise; private postJson; private send; } export type PartnerInboundRequest = PartnerGetServicesRequest | PartnerGetNumberRequest | PartnerFinishActivationRequest; /** * Classify a body Grizzly posted to the partner server. * * @example * ```ts * const inbound = parsePartnerRequest(JSON.parse(rawBody)); * if (inbound.action === "GET_NUMBER") { * inbound.service; * } * ``` */ export declare function parsePartnerRequest(data: unknown): PartnerInboundRequest; /** Reply to inbound `GET_SERVICES`. */ export declare function partnerServicesResponse(countryList: PartnerCountryStock[]): PartnerGetServicesResponse; /** Reply to inbound `GET_NUMBER`. */ export declare function partnerNumberResponse(response: Omit & { status?: PartnerGetNumberResponse["status"]; }): PartnerGetNumberResponse; /** Reply to inbound `FINISH_ACTIVATION`. */ export declare function partnerFinishResponse(error?: string): PartnerFinishActivationResponse; //# sourceMappingURL=partner.d.ts.map