UNPKG

instagram-private-api

Version:

Instagram private API wrapper for full access to instagram

53 lines 1.68 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const entity_1 = require("../core/entity"); class DirectThreadEntity extends entity_1.Entity { constructor() { super(...arguments); this.threadId = null; this.userIds = null; } async broadcastText(text) { return await this.broadcast({ item: 'text', form: { text, }, }); } async broadcastPhoto(options) { const { upload_id } = await this.client.upload.photo({ uploadId: options.uploadId, file: options.file, }); return await this.broadcast({ item: 'configure_photo', form: { allow_full_aspect_ratio: options.allowFullAspectRatio || true, upload_id, }, }); } async broadcast(options) { if (this.threadId === null && this.userIds === null) { throw new Error('DirectThread: No recipients set'); } const baseParams = { item: options.item, form: options.form, }; let params; if (this.threadId) { params = Object.assign(baseParams, { threadIds: this.threadId }); } else { params = Object.assign(baseParams, { userIds: this.userIds }); } const response = await this.client.directThread.broadcast(params); this.threadId = response.payload.thread_id; this.userIds = null; return response.payload; } } exports.DirectThreadEntity = DirectThreadEntity; //# sourceMappingURL=direct-thread.entity.js.map