UNPKG

node-appwrite

Version:

Appwrite is an open-source self-hosted backend server that abstract and simplify complex and repetitive development tasks behind a very simple REST API

690 lines (679 loc) 23.7 kB
import { Client } from '../client.mjs'; import { Models } from '../models.mjs'; import { SmtpEncryption } from '../enums/smtp-encryption.mjs'; import '../query.mjs'; declare class Messaging { client: Client; constructor(client: Client); /** * List messages * * Get a list of all messages from the current Appwrite project. * * @param {string[]} queries * @param {string} search * @throws {AppwriteException} * @returns {Promise<Models.MessageList>} */ listMessages(queries?: string[], search?: string): Promise<Models.MessageList>; /** * Create email * * Create a new email message. * * @param {string} messageId * @param {string} subject * @param {string} content * @param {string[]} topics * @param {string[]} users * @param {string[]} targets * @param {string[]} cc * @param {string[]} bcc * @param {string[]} attachments * @param {boolean} draft * @param {boolean} html * @param {string} scheduledAt * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ createEmail(messageId: string, subject: string, content: string, topics?: string[], users?: string[], targets?: string[], cc?: string[], bcc?: string[], attachments?: string[], draft?: boolean, html?: boolean, scheduledAt?: string): Promise<Models.Message>; /** * Update email * * Update an email message by its unique ID. * * @param {string} messageId * @param {string[]} topics * @param {string[]} users * @param {string[]} targets * @param {string} subject * @param {string} content * @param {boolean} draft * @param {boolean} html * @param {string[]} cc * @param {string[]} bcc * @param {string} scheduledAt * @param {string[]} attachments * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updateEmail(messageId: string, topics?: string[], users?: string[], targets?: string[], subject?: string, content?: string, draft?: boolean, html?: boolean, cc?: string[], bcc?: string[], scheduledAt?: string, attachments?: string[]): Promise<Models.Message>; /** * Create push notification * * Create a new push notification. * * @param {string} messageId * @param {string} title * @param {string} body * @param {string[]} topics * @param {string[]} users * @param {string[]} targets * @param {object} data * @param {string} action * @param {string} image * @param {string} icon * @param {string} sound * @param {string} color * @param {string} tag * @param {string} badge * @param {boolean} draft * @param {string} scheduledAt * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ createPush(messageId: string, title: string, body: string, topics?: string[], users?: string[], targets?: string[], data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: string, draft?: boolean, scheduledAt?: string): Promise<Models.Message>; /** * Update push notification * * Update a push notification by its unique ID. * * @param {string} messageId * @param {string[]} topics * @param {string[]} users * @param {string[]} targets * @param {string} title * @param {string} body * @param {object} data * @param {string} action * @param {string} image * @param {string} icon * @param {string} sound * @param {string} color * @param {string} tag * @param {number} badge * @param {boolean} draft * @param {string} scheduledAt * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updatePush(messageId: string, topics?: string[], users?: string[], targets?: string[], title?: string, body?: string, data?: object, action?: string, image?: string, icon?: string, sound?: string, color?: string, tag?: string, badge?: number, draft?: boolean, scheduledAt?: string): Promise<Models.Message>; /** * Create SMS * * Create a new SMS message. * * @param {string} messageId * @param {string} content * @param {string[]} topics * @param {string[]} users * @param {string[]} targets * @param {boolean} draft * @param {string} scheduledAt * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ createSms(messageId: string, content: string, topics?: string[], users?: string[], targets?: string[], draft?: boolean, scheduledAt?: string): Promise<Models.Message>; /** * Update SMS * * Update an email message by its unique ID. * * @param {string} messageId * @param {string[]} topics * @param {string[]} users * @param {string[]} targets * @param {string} content * @param {boolean} draft * @param {string} scheduledAt * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ updateSms(messageId: string, topics?: string[], users?: string[], targets?: string[], content?: string, draft?: boolean, scheduledAt?: string): Promise<Models.Message>; /** * Get message * * Get a message by its unique ID. * * @param {string} messageId * @throws {AppwriteException} * @returns {Promise<Models.Message>} */ getMessage(messageId: string): Promise<Models.Message>; /** * Delete message * * Delete a message. If the message is not a draft or scheduled, but has been sent, this will not recall the message. * * @param {string} messageId * @throws {AppwriteException} * @returns {Promise<{}>} */ delete(messageId: string): Promise<{}>; /** * List message logs * * Get the message activity logs listed by its unique ID. * * @param {string} messageId * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise<Models.LogList>} */ listMessageLogs(messageId: string, queries?: string[]): Promise<Models.LogList>; /** * List message targets * * Get a list of the targets associated with a message. * * @param {string} messageId * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise<Models.TargetList>} */ listTargets(messageId: string, queries?: string[]): Promise<Models.TargetList>; /** * List providers * * Get a list of all providers from the current Appwrite project. * * @param {string[]} queries * @param {string} search * @throws {AppwriteException} * @returns {Promise<Models.ProviderList>} */ listProviders(queries?: string[], search?: string): Promise<Models.ProviderList>; /** * Create APNS provider * * Create a new Apple Push Notification service provider. * * @param {string} providerId * @param {string} name * @param {string} authKey * @param {string} authKeyId * @param {string} teamId * @param {string} bundleId * @param {boolean} sandbox * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createApnsProvider(providerId: string, name: string, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean, enabled?: boolean): Promise<Models.Provider>; /** * Update APNS provider * * Update a Apple Push Notification service provider by its unique ID. * * @param {string} providerId * @param {string} name * @param {boolean} enabled * @param {string} authKey * @param {string} authKeyId * @param {string} teamId * @param {string} bundleId * @param {boolean} sandbox * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateApnsProvider(providerId: string, name?: string, enabled?: boolean, authKey?: string, authKeyId?: string, teamId?: string, bundleId?: string, sandbox?: boolean): Promise<Models.Provider>; /** * Create FCM provider * * Create a new Firebase Cloud Messaging provider. * * @param {string} providerId * @param {string} name * @param {object} serviceAccountJSON * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createFcmProvider(providerId: string, name: string, serviceAccountJSON?: object, enabled?: boolean): Promise<Models.Provider>; /** * Update FCM provider * * Update a Firebase Cloud Messaging provider by its unique ID. * * @param {string} providerId * @param {string} name * @param {boolean} enabled * @param {object} serviceAccountJSON * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateFcmProvider(providerId: string, name?: string, enabled?: boolean, serviceAccountJSON?: object): Promise<Models.Provider>; /** * Create Mailgun provider * * Create a new Mailgun provider. * * @param {string} providerId * @param {string} name * @param {string} apiKey * @param {string} domain * @param {boolean} isEuRegion * @param {string} fromName * @param {string} fromEmail * @param {string} replyToName * @param {string} replyToEmail * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createMailgunProvider(providerId: string, name: string, apiKey?: string, domain?: string, isEuRegion?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; /** * Update Mailgun provider * * Update a Mailgun provider by its unique ID. * * @param {string} providerId * @param {string} name * @param {string} apiKey * @param {string} domain * @param {boolean} isEuRegion * @param {boolean} enabled * @param {string} fromName * @param {string} fromEmail * @param {string} replyToName * @param {string} replyToEmail * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateMailgunProvider(providerId: string, name?: string, apiKey?: string, domain?: string, isEuRegion?: boolean, enabled?: boolean, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise<Models.Provider>; /** * Create Msg91 provider * * Create a new MSG91 provider. * * @param {string} providerId * @param {string} name * @param {string} templateId * @param {string} senderId * @param {string} authKey * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createMsg91Provider(providerId: string, name: string, templateId?: string, senderId?: string, authKey?: string, enabled?: boolean): Promise<Models.Provider>; /** * Update Msg91 provider * * Update a MSG91 provider by its unique ID. * * @param {string} providerId * @param {string} name * @param {boolean} enabled * @param {string} templateId * @param {string} senderId * @param {string} authKey * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateMsg91Provider(providerId: string, name?: string, enabled?: boolean, templateId?: string, senderId?: string, authKey?: string): Promise<Models.Provider>; /** * Create Sendgrid provider * * Create a new Sendgrid provider. * * @param {string} providerId * @param {string} name * @param {string} apiKey * @param {string} fromName * @param {string} fromEmail * @param {string} replyToName * @param {string} replyToEmail * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createSendgridProvider(providerId: string, name: string, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; /** * Update Sendgrid provider * * Update a Sendgrid provider by its unique ID. * * @param {string} providerId * @param {string} name * @param {boolean} enabled * @param {string} apiKey * @param {string} fromName * @param {string} fromEmail * @param {string} replyToName * @param {string} replyToEmail * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateSendgridProvider(providerId: string, name?: string, enabled?: boolean, apiKey?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string): Promise<Models.Provider>; /** * Create SMTP provider * * Create a new SMTP provider. * * @param {string} providerId * @param {string} name * @param {string} host * @param {number} port * @param {string} username * @param {string} password * @param {SmtpEncryption} encryption * @param {boolean} autoTLS * @param {string} mailer * @param {string} fromName * @param {string} fromEmail * @param {string} replyToName * @param {string} replyToEmail * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createSmtpProvider(providerId: string, name: string, host: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; /** * Update SMTP provider * * Update a SMTP provider by its unique ID. * * @param {string} providerId * @param {string} name * @param {string} host * @param {number} port * @param {string} username * @param {string} password * @param {SmtpEncryption} encryption * @param {boolean} autoTLS * @param {string} mailer * @param {string} fromName * @param {string} fromEmail * @param {string} replyToName * @param {string} replyToEmail * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateSmtpProvider(providerId: string, name?: string, host?: string, port?: number, username?: string, password?: string, encryption?: SmtpEncryption, autoTLS?: boolean, mailer?: string, fromName?: string, fromEmail?: string, replyToName?: string, replyToEmail?: string, enabled?: boolean): Promise<Models.Provider>; /** * Create Telesign provider * * Create a new Telesign provider. * * @param {string} providerId * @param {string} name * @param {string} from * @param {string} customerId * @param {string} apiKey * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createTelesignProvider(providerId: string, name: string, from?: string, customerId?: string, apiKey?: string, enabled?: boolean): Promise<Models.Provider>; /** * Update Telesign provider * * Update a Telesign provider by its unique ID. * * @param {string} providerId * @param {string} name * @param {boolean} enabled * @param {string} customerId * @param {string} apiKey * @param {string} from * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateTelesignProvider(providerId: string, name?: string, enabled?: boolean, customerId?: string, apiKey?: string, from?: string): Promise<Models.Provider>; /** * Create Textmagic provider * * Create a new Textmagic provider. * * @param {string} providerId * @param {string} name * @param {string} from * @param {string} username * @param {string} apiKey * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createTextmagicProvider(providerId: string, name: string, from?: string, username?: string, apiKey?: string, enabled?: boolean): Promise<Models.Provider>; /** * Update Textmagic provider * * Update a Textmagic provider by its unique ID. * * @param {string} providerId * @param {string} name * @param {boolean} enabled * @param {string} username * @param {string} apiKey * @param {string} from * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateTextmagicProvider(providerId: string, name?: string, enabled?: boolean, username?: string, apiKey?: string, from?: string): Promise<Models.Provider>; /** * Create Twilio provider * * Create a new Twilio provider. * * @param {string} providerId * @param {string} name * @param {string} from * @param {string} accountSid * @param {string} authToken * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createTwilioProvider(providerId: string, name: string, from?: string, accountSid?: string, authToken?: string, enabled?: boolean): Promise<Models.Provider>; /** * Update Twilio provider * * Update a Twilio provider by its unique ID. * * @param {string} providerId * @param {string} name * @param {boolean} enabled * @param {string} accountSid * @param {string} authToken * @param {string} from * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateTwilioProvider(providerId: string, name?: string, enabled?: boolean, accountSid?: string, authToken?: string, from?: string): Promise<Models.Provider>; /** * Create Vonage provider * * Create a new Vonage provider. * * @param {string} providerId * @param {string} name * @param {string} from * @param {string} apiKey * @param {string} apiSecret * @param {boolean} enabled * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ createVonageProvider(providerId: string, name: string, from?: string, apiKey?: string, apiSecret?: string, enabled?: boolean): Promise<Models.Provider>; /** * Update Vonage provider * * Update a Vonage provider by its unique ID. * * @param {string} providerId * @param {string} name * @param {boolean} enabled * @param {string} apiKey * @param {string} apiSecret * @param {string} from * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ updateVonageProvider(providerId: string, name?: string, enabled?: boolean, apiKey?: string, apiSecret?: string, from?: string): Promise<Models.Provider>; /** * Get provider * * Get a provider by its unique ID. * * @param {string} providerId * @throws {AppwriteException} * @returns {Promise<Models.Provider>} */ getProvider(providerId: string): Promise<Models.Provider>; /** * Delete provider * * Delete a provider by its unique ID. * * @param {string} providerId * @throws {AppwriteException} * @returns {Promise<{}>} */ deleteProvider(providerId: string): Promise<{}>; /** * List provider logs * * Get the provider activity logs listed by its unique ID. * * @param {string} providerId * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise<Models.LogList>} */ listProviderLogs(providerId: string, queries?: string[]): Promise<Models.LogList>; /** * List subscriber logs * * Get the subscriber activity logs listed by its unique ID. * * @param {string} subscriberId * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise<Models.LogList>} */ listSubscriberLogs(subscriberId: string, queries?: string[]): Promise<Models.LogList>; /** * List topics * * Get a list of all topics from the current Appwrite project. * * @param {string[]} queries * @param {string} search * @throws {AppwriteException} * @returns {Promise<Models.TopicList>} */ listTopics(queries?: string[], search?: string): Promise<Models.TopicList>; /** * Create topic * * Create a new topic. * * @param {string} topicId * @param {string} name * @param {string[]} subscribe * @throws {AppwriteException} * @returns {Promise<Models.Topic>} */ createTopic(topicId: string, name: string, subscribe?: string[]): Promise<Models.Topic>; /** * Get topic * * Get a topic by its unique ID. * * @param {string} topicId * @throws {AppwriteException} * @returns {Promise<Models.Topic>} */ getTopic(topicId: string): Promise<Models.Topic>; /** * Update topic * * Update a topic by its unique ID. * * @param {string} topicId * @param {string} name * @param {string[]} subscribe * @throws {AppwriteException} * @returns {Promise<Models.Topic>} */ updateTopic(topicId: string, name?: string, subscribe?: string[]): Promise<Models.Topic>; /** * Delete topic * * Delete a topic by its unique ID. * * @param {string} topicId * @throws {AppwriteException} * @returns {Promise<{}>} */ deleteTopic(topicId: string): Promise<{}>; /** * List topic logs * * Get the topic activity logs listed by its unique ID. * * @param {string} topicId * @param {string[]} queries * @throws {AppwriteException} * @returns {Promise<Models.LogList>} */ listTopicLogs(topicId: string, queries?: string[]): Promise<Models.LogList>; /** * List subscribers * * Get a list of all subscribers from the current Appwrite project. * * @param {string} topicId * @param {string[]} queries * @param {string} search * @throws {AppwriteException} * @returns {Promise<Models.SubscriberList>} */ listSubscribers(topicId: string, queries?: string[], search?: string): Promise<Models.SubscriberList>; /** * Create subscriber * * Create a new subscriber. * * @param {string} topicId * @param {string} subscriberId * @param {string} targetId * @throws {AppwriteException} * @returns {Promise<Models.Subscriber>} */ createSubscriber(topicId: string, subscriberId: string, targetId: string): Promise<Models.Subscriber>; /** * Get subscriber * * Get a subscriber by its unique ID. * * @param {string} topicId * @param {string} subscriberId * @throws {AppwriteException} * @returns {Promise<Models.Subscriber>} */ getSubscriber(topicId: string, subscriberId: string): Promise<Models.Subscriber>; /** * Delete subscriber * * Delete a subscriber by its unique ID. * * @param {string} topicId * @param {string} subscriberId * @throws {AppwriteException} * @returns {Promise<{}>} */ deleteSubscriber(topicId: string, subscriberId: string): Promise<{}>; } export { Messaging };