@enfonica/messaging
Version:
Enfonica Messaging SDK for Node.js
278 lines (277 loc) • 13.7 kB
TypeScript
/// <reference types="node" />
import * as gax from 'google-gax';
import { Callback, Descriptors, PaginationCallback } from 'google-gax';
import { Transform } from 'stream';
import * as protos from '../../protos/protos';
/**
* Manages Messages.
* Messages can be SMS, whatsapp messages, etc.
* @class
* @memberof v1
*/
export declare class MessagesClient {
private _terminated;
private _opts;
private _gaxModule;
private _gaxGrpc;
private _protos;
private _defaults;
auth: any;
descriptors: Descriptors;
innerApiCalls: {
[name: string]: Function;
};
pathTemplates: {
[name: string]: gax.PathTemplate;
};
messagesStub?: Promise<{
[name: string]: Function;
}>;
/**
* Construct an instance of MessagesClient.
*
* @param {object} [options] - The configuration object. See the subsequent
* parameters for more details.
* @param {object} [options.credentials] - Credentials object.
* @param {string} [options.credentials.client_email]
* @param {string} [options.credentials.private_key]
* @param {string} [options.email] - Account email address. Required when
* using a .pem or .p12 keyFilename.
* @param {string} [options.keyFilename] - Full path to the a .json, .pem, or
* .p12 key downloaded from the Google Developers Console. If you provide
* a path to a JSON file, the projectId option below is not necessary.
* NOTE: .pem and .p12 require you to specify options.email as well.
* @param {number} [options.port] - The port on which to connect to
* the remote host.
* @param {string} [options.projectId] - The project ID from the Google
* Developer's Console, e.g. 'grape-spaceship-123'. We will also check
* the environment variable GCLOUD_PROJECT for your project ID. If your
* app is running in an environment which supports
* {@link https://developers.google.com/identity/protocols/application-default-credentials Application Default Credentials},
* your project ID will be detected automatically.
* @param {string} [options.apiEndpoint] - The domain name of the
* API remote host.
*/
constructor(opts?: any);
/**
* Initialize the client.
* Performs asynchronous operations (such as authentication) and prepares the client.
* This function will be called automatically when any class method is called for the
* first time, but if you need to initialize it before calling an actual method,
* feel free to call initialize() directly.
*
* You can await on this method if you want to make sure the client is initialized.
*
* @returns {Promise} A promise that resolves to an authenticated service stub.
*/
initialize(): Promise<{
[name: string]: Function;
}>;
/**
* The DNS address for this API service.
*/
static get servicePath(): string;
/**
* The DNS address for this API service - same as servicePath(),
* exists for compatibility reasons.
*/
static get apiEndpoint(): string;
/**
* The port for this API service.
*/
static get port(): number;
/**
* The scopes needed to make gRPC calls for every method defined
* in this service.
*/
static get scopes(): string[];
getProjectId(): Promise<string>;
getProjectId(callback: Callback<string, undefined, undefined>): void;
createMessage(request: protos.enfonica.messaging.v1.ICreateMessageRequest, options?: gax.CallOptions): Promise<[protos.enfonica.messaging.v1.IMessage, protos.enfonica.messaging.v1.ICreateMessageRequest | undefined, {} | undefined]>;
createMessage(request: protos.enfonica.messaging.v1.ICreateMessageRequest, options: gax.CallOptions, callback: Callback<protos.enfonica.messaging.v1.IMessage, protos.enfonica.messaging.v1.ICreateMessageRequest | null | undefined, {} | null | undefined>): void;
createMessage(request: protos.enfonica.messaging.v1.ICreateMessageRequest, callback: Callback<protos.enfonica.messaging.v1.IMessage, protos.enfonica.messaging.v1.ICreateMessageRequest | null | undefined, {} | null | undefined>): void;
getMessage(request: protos.enfonica.messaging.v1.IGetMessageRequest, options?: gax.CallOptions): Promise<[protos.enfonica.messaging.v1.IMessage, protos.enfonica.messaging.v1.IGetMessageRequest | undefined, {} | undefined]>;
getMessage(request: protos.enfonica.messaging.v1.IGetMessageRequest, options: gax.CallOptions, callback: Callback<protos.enfonica.messaging.v1.IMessage, protos.enfonica.messaging.v1.IGetMessageRequest | null | undefined, {} | null | undefined>): void;
getMessage(request: protos.enfonica.messaging.v1.IGetMessageRequest, callback: Callback<protos.enfonica.messaging.v1.IMessage, protos.enfonica.messaging.v1.IGetMessageRequest | null | undefined, {} | null | undefined>): void;
listMessages(request: protos.enfonica.messaging.v1.IListMessagesRequest, options?: gax.CallOptions): Promise<[protos.enfonica.messaging.v1.IMessage[], protos.enfonica.messaging.v1.IListMessagesRequest | null, protos.enfonica.messaging.v1.IListMessagesResponse]>;
listMessages(request: protos.enfonica.messaging.v1.IListMessagesRequest, options: gax.CallOptions, callback: PaginationCallback<protos.enfonica.messaging.v1.IListMessagesRequest, protos.enfonica.messaging.v1.IListMessagesResponse | null | undefined, protos.enfonica.messaging.v1.IMessage>): void;
listMessages(request: protos.enfonica.messaging.v1.IListMessagesRequest, callback: PaginationCallback<protos.enfonica.messaging.v1.IListMessagesRequest, protos.enfonica.messaging.v1.IListMessagesResponse | null | undefined, protos.enfonica.messaging.v1.IMessage>): void;
/**
* Equivalent to {@link listMessages}, but returns a NodeJS Stream object.
*
* This fetches the paged responses for {@link listMessages} continuously
* and invokes the callback registered for 'data' event for each element in the
* responses.
*
* The returned object has 'end' method when no more elements are required.
*
* autoPaginate option will be ignored.
*
* @see {@link https://nodejs.org/api/stream.html}
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* The resource name of the parent of which to list messages.
* Must be of the form `projects/*`.
* @param {number} request.pageSize
* The maximum number of Messages to return in the response.
* Default value is 10 and maximum value is 100.
* @param {string} request.pageToken
* A pagination token returned from a previous call to `ListMessages`
* that indicates where this listing should continue from.
* @param {google.protobuf.Timestamp} request.startTime
* The timestamp (inclusive) from which to retrieve messages. The
* create_time of the Message is used.
*
* This field is deprecated. Use `filter` instead. If a value is specified for
* both `start_time` and `filter`, the call will fail.
*
* (-- api-linter: core::0132::request-unknown-fields=disabled
* aip.dev/not-precedent: List has additional fields in this package. --)
* (-- deprecated --)
* @param {google.protobuf.Timestamp} request.endTime
* The timestamp (exclusive) until which to retrieve messages. The
* create_time of the Message is used.
*
* This field is deprecated. Use `filter` instead. If a value is specified for
* both `end_time` and `filter`, the call will fail.
*
* (-- api-linter: core::0132::request-unknown-fields=disabled
* aip.dev/not-precedent: List has additional fields in this package. --)
* (-- deprecated --)
* @param {string} request.filter
* Filter string to specify which results should be returned.
*
* The following fields can be filtered:
* - `createTime`
* - `to`
* - `from`
* - `status`
* - `direction`
* - `encoding`
*
* For example:
* createTime >= '2021-01-01T06:00:00.0Z' AND createTime < '2021-02-01' AND
* status = DELIVERED OR status = UNDELIVERED AND to = '+61*' OR from = '+61*'
*
* Note that OR has higher precendence than AND.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Stream}
* An object stream which emits an object representing [Message]{@link enfonica.messaging.v1.Message} on 'data' event.
*/
listMessagesStream(request?: protos.enfonica.messaging.v1.IListMessagesRequest, options?: gax.CallOptions): Transform;
/**
* Equivalent to {@link listMessages}, but returns an iterable object.
*
* for-await-of syntax is used with the iterable to recursively get response element on-demand.
*
* @param {Object} request
* The request object that will be sent.
* @param {string} request.parent
* The resource name of the parent of which to list messages.
* Must be of the form `projects/*`.
* @param {number} request.pageSize
* The maximum number of Messages to return in the response.
* Default value is 10 and maximum value is 100.
* @param {string} request.pageToken
* A pagination token returned from a previous call to `ListMessages`
* that indicates where this listing should continue from.
* @param {google.protobuf.Timestamp} request.startTime
* The timestamp (inclusive) from which to retrieve messages. The
* create_time of the Message is used.
*
* This field is deprecated. Use `filter` instead. If a value is specified for
* both `start_time` and `filter`, the call will fail.
*
* (-- api-linter: core::0132::request-unknown-fields=disabled
* aip.dev/not-precedent: List has additional fields in this package. --)
* (-- deprecated --)
* @param {google.protobuf.Timestamp} request.endTime
* The timestamp (exclusive) until which to retrieve messages. The
* create_time of the Message is used.
*
* This field is deprecated. Use `filter` instead. If a value is specified for
* both `end_time` and `filter`, the call will fail.
*
* (-- api-linter: core::0132::request-unknown-fields=disabled
* aip.dev/not-precedent: List has additional fields in this package. --)
* (-- deprecated --)
* @param {string} request.filter
* Filter string to specify which results should be returned.
*
* The following fields can be filtered:
* - `createTime`
* - `to`
* - `from`
* - `status`
* - `direction`
* - `encoding`
*
* For example:
* createTime >= '2021-01-01T06:00:00.0Z' AND createTime < '2021-02-01' AND
* status = DELIVERED OR status = UNDELIVERED AND to = '+61*' OR from = '+61*'
*
* Note that OR has higher precendence than AND.
* @param {object} [options]
* Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details.
* @returns {Object}
* An iterable Object that conforms to @link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols.
*/
listMessagesAsync(request?: protos.enfonica.messaging.v1.IListMessagesRequest, options?: gax.CallOptions): AsyncIterable<protos.enfonica.messaging.v1.IMessage>;
/**
* Return a fully-qualified message resource name string.
*
* @param {string} project
* @param {string} message
* @returns {string} Resource name string.
*/
messagePath(project: string, message: string): string;
/**
* Parse the project from Message resource.
*
* @param {string} messageName
* A fully-qualified path representing Message resource.
* @returns {string} A string representing the project.
*/
matchProjectFromMessageName(messageName: string): string | number;
/**
* Parse the message from Message resource.
*
* @param {string} messageName
* A fully-qualified path representing Message resource.
* @returns {string} A string representing the message.
*/
matchMessageFromMessageName(messageName: string): string | number;
/**
* Return a fully-qualified unsubscriber resource name string.
*
* @param {string} project
* @param {string} unsubscriber
* @returns {string} Resource name string.
*/
unsubscriberPath(project: string, unsubscriber: string): string;
/**
* Parse the project from Unsubscriber resource.
*
* @param {string} unsubscriberName
* A fully-qualified path representing Unsubscriber resource.
* @returns {string} A string representing the project.
*/
matchProjectFromUnsubscriberName(unsubscriberName: string): string | number;
/**
* Parse the unsubscriber from Unsubscriber resource.
*
* @param {string} unsubscriberName
* A fully-qualified path representing Unsubscriber resource.
* @returns {string} A string representing the unsubscriber.
*/
matchUnsubscriberFromUnsubscriberName(unsubscriberName: string): string | number;
/**
* Terminate the GRPC channel and close the client.
*
* The client will no longer be usable and all future behavior is undefined.
*/
close(): Promise<void>;
}