UNPKG

@zenvia/sdk

Version:

This SDK for [Node.js](https://nodejs.org/) was created based on the [Zenvia](https://www.zenvia.com/) [API](https://zenvia.github.io/zenvia-openapi-spec/).

120 lines (119 loc) 4.28 kB
/// <reference types="node" /> import { Channel, IChannel, IMessageBatch, ILoggerInstance, ISubscription, IPartialSubscription, IPartialTemplate, IClientOptions } from '../types'; import { Logger } from '../utils/logger'; import { ITemplate, MessageBatch } from '../types/zenvia'; import { ReportFlow } from './reports/report-flow'; import { ReportMessages } from './reports/report-messages'; import { Readable } from 'stream'; /** * Client class with the features. */ export declare class Client { private options?; private token; protected logger: Logger; /** * Returns a new `Client` that can be used to execute some functionality. * * @param token Zenvia platform token. * @param loggerInstance If you want, you can pass your log instance. */ constructor(token: string, loggerInstance?: ILoggerInstance, options?: IClientOptions); /** * This method returns a channel type object. * * @param channel [[Channel]] of the instance that you want to create. * @returns [[Channel]] type instance. */ getChannel(channel: Channel): IChannel; /** * This method creates a message batch. * * @param contacts A [[Readable]] object. * @param batch Either an [[ISmsMessageBatch]] object or a [[IWhatsAppMessageBatch]] object. * @returns A promise that resolves an [[IMessageBatch]] object */ sendMessageBatch(contacts: Readable | string, batch: MessageBatch): Promise<IMessageBatch>; /** * This method returns a list of flow reports. * * @returns [[ReportFlow]] type instance. */ getFlowReportClient(): ReportFlow; /** * This method returns a list of message reports. * * @returns [[ReportMessages]] type instance. */ getMessagesReportClient(): ReportMessages; /** * This method returns a list of subscriptions. * * @returns A promise that resolves to an array of [[ISubscription]] objects. */ listSubscriptions(): Promise<ISubscription[]>; /** * This method creates a subscription. * * @param subscription An [[ISubscription]] object. * @returns A promise that resolves to an [[ISubscription]] object. */ createSubscription(subscription: ISubscription): Promise<ISubscription>; /** * This method returns a subscription. * * @param id Subscription identifier. * @returns A promise that resolves to an [[ISubscription]] object. */ getSubscription(id: string): Promise<ISubscription>; /** * This method updates a subscription. * * @param id Subscription identifier. * @param subscription An [[IPartialSubscription]] object. * @returns A promise that resolves to an [[ISubscription]] object. */ updateSubscription(id: string, subscription: IPartialSubscription): Promise<ISubscription>; /** * This method deletes a subscription. * * @param id Subscription identifier. * @returns A promise that resolves to an [[ISubscription]] object. */ deleteSubscription(id: string): Promise<void>; /** * This method returns a list of templates. * * @returns A promise that resolves to an array of [[ITemplate]] objects. */ listTemplates(): Promise<ITemplate[]>; /** * This method returns a template. * * @param id Template identifier. * @returns A promise that resolves to an [[ITemplate]] object. */ getTemplate(id: string): Promise<ITemplate>; /** * This method creates a template. * * @param template An [[ITemplate]] object. * @returns A promise that resolves to an [[ITemplate]] object. */ createTemplate(template: ITemplate): Promise<ITemplate>; /** * This method updates a template. * * @param id Template identifier. * @param template An [[IPartialTemplate]] object. * @returns A promise that resolves to an [[ITemplate]] object. */ updateTemplate(id: string, template: IPartialTemplate): Promise<ITemplate>; /** * This method deletes a template. * * @param id Template identifier. * @returns A promise that resolves to an [[ITemplate]] object. */ deleteTemplate(id: string): Promise<void>; }