UNPKG

tickethead-sdk

Version:

SDK for the Tickethead API

122 lines 5.12 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.NotificationService = void 0; const query_1 = require("../common/query"); /** * Service class for sending notifications. */ class NotificationService { constructor(client, tenantClient, version) { this.client = client; this.tenantClient = tenantClient; this.version = version; } /** * Sends a notification via the account service * @param data the content of the notification and its topic * @returns was the notification sent successfully */ sendNotification(data) { return __awaiter(this, void 0, void 0, function* () { const res = yield this.client.post(`account/${this.version}/notification/send`, data); return res.data.data; }); } /** * Sends a notification via the account service * @param id.id the id of the notification to be sent * @returns was the notification sent successfully */ sendExistingNotification(id) { return __awaiter(this, void 0, void 0, function* () { const res = yield this.client.post(`account/${this.version}/notification/${id.id}/send`, {}); return res.data.data; }); } /** * Sends a notification to all the users who are holding tickets for this event * @param data the content of the notification * @returns was the notification sent successfully */ sendNotificationForEvent(id, data) { return __awaiter(this, void 0, void 0, function* () { const res = yield this.tenantClient.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.id}/notification`, data); return res.data.data; }); } /** * Sends a notification to all the users who are holding tickets for this ticket config * @param data the content of the notification * @returns was the notification sent successfully */ sendNotificationForTicketConfig(id, data) { return __awaiter(this, void 0, void 0, function* () { const res = yield this.tenantClient.post(`event/${this.version}/organizer/${id.organizerId}/event/${id.eventId}/ticket_config/${id.ticketConfigId}/notification`, data); return res.data.data; }); } /** * Retrieves a list of notifications based on the provided query parameters. * @param query - The query parameters for filtering the notifications (optional). */ listNotifications() { return __awaiter(this, arguments, void 0, function* (query = {}) { const res = yield this.client.get(`account/${this.version}/notification?${(0, query_1.getStringifiedQuery)(query)}`); return res.data.data; }); } /** * Fetches a previously created notification * @param id.id the id of the notification to be fetched * @returns requested notification */ getNotification(id) { return __awaiter(this, void 0, void 0, function* () { const res = yield this.client.get(`account/${this.version}/notification/${id.id}`); return res.data.data; }); } /** * Creates a new notification. * @param data The notification data. */ createNotification(data) { return __awaiter(this, void 0, void 0, function* () { const res = yield this.client.post(`account/${this.version}/notification`, data); return res.data.data; }); } /** * Updates a notification with the specified ID. * * @param {IdParam} id - The ID of the notification to update. * @param {GeneralNotification} data - The updated notification data. */ updateNotification(id, data) { return __awaiter(this, void 0, void 0, function* () { const res = yield this.client.patch(`account/${this.version}/notification/${id.id}`, data); return res.data.data; }); } /** * Deletes a notification by its ID. * @param id - The ID of the notification to delete. */ deleteNotification(id) { return __awaiter(this, void 0, void 0, function* () { const res = yield this.client.delete(`account/${this.version}/notification/${id.id}`); return res.data.data; }); } } exports.NotificationService = NotificationService; //# sourceMappingURL=service.js.map