UNPKG

mailinator-client

Version:
32 lines (31 loc) 1.34 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.GetInboxMessageAttachmentRequest = void 0; const MailinatorHttpClient_1 = require("../MailinatorHttpClient"); const Constants_1 = require("../Constants"); const _resolveTemplateUrl = (domain, inbox, messageId, attachmentId) => { return `https://api.mailinator.com/v2/domains/${domain}/inboxes/${inbox}/messages/${messageId}/attachments/${attachmentId}`; }; class GetInboxMessageAttachmentRequest { constructor(domain, inbox, messageId, attachmentId) { this.domain = domain; this.inbox = inbox; this.messageId = messageId; this.attachmentId = attachmentId; } execute(apiToken) { const _headers = { [Constants_1.AUTHORIZATION]: apiToken }; return MailinatorHttpClient_1.default.get(_resolveTemplateUrl(this.domain, this.inbox, this.messageId, this.attachmentId), _headers) .then((res) => { // workaround to keep the API consistent return Promise.resolve({ statusCode: res.message.statusCode || 200, result: res.message, headers: res.message.headers }); }); } } exports.GetInboxMessageAttachmentRequest = GetInboxMessageAttachmentRequest;