import { Service } from '../service'; import { AppwriteException, Client } from '../client'; import type { Models } from '../models'; import type { UploadProgress, Payload } from '../client'; import { Query } from '../query'; export class Messaging extends Service { constructor(client: Client) { super(client); } /** * Create a subscriber. * * * @param {string} topicId * @param {string} subscriberId * @param {string} targetId * @throws {AppwriteException} * @returns {Promise} */ async createSubscriber(topicId: string, subscriberId: string, targetId: string): Promise { if (typeof topicId === 'undefined') { throw new AppwriteException('Missing required parameter: "topicId"'); } if (typeof subscriberId === 'undefined') { throw new AppwriteException('Missing required parameter: "subscriberId"'); } if (typeof targetId === 'undefined') { throw new AppwriteException('Missing required parameter: "targetId"'); } const apiPath = '/messaging/topics/{topicId}/subscribers'.replace('{topicId}', topicId); const payload: Payload = {}; if (typeof subscriberId !== 'undefined') { payload['subscriberId'] = subscriberId; } if (typeof targetId !== 'undefined') { payload['targetId'] = targetId; } const uri = new URL(this.client.config.endpoint + apiPath); return await this.client.call('post', uri, { 'content-type': 'application/json', }, payload); } /** * Delete a subscriber. * * * @param {string} topicId * @param {string} subscriberId * @throws {AppwriteException} * @returns {Promise} */ async deleteSubscriber(topicId: string, subscriberId: string): Promise<{}> { if (typeof topicId === 'undefined') { throw new AppwriteException('Missing required parameter: "topicId"'); } if (typeof subscriberId === 'undefined') { throw new AppwriteException('Missing required parameter: "subscriberId"'); } const apiPath = '/messaging/topics/{topicId}/subscribers/{subscriberId}'.replace('{topicId}', topicId).replace('{subscriberId}', subscriberId); const payload: Payload = {}; const uri = new URL(this.client.config.endpoint + apiPath); return await this.client.call('delete', uri, { 'content-type': 'application/json', }, payload); } };