mailinator-client
Version:
Mailinator REST API client for JavaScript applications.
31 lines (30 loc) • 1.25 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetMessageAttachmentRequest = void 0;
const MailinatorHttpClient_1 = require("../MailinatorHttpClient");
const Constants_1 = require("../Constants");
const _resolveTemplateUrl = (domain, messageId, attachmentId) => {
return `https://api.mailinator.com/v2/domains/${domain}/messages/${messageId}/attachments/${attachmentId}`;
};
class GetMessageAttachmentRequest {
constructor(domain, messageId, attachmentId) {
this.domain = domain;
this.messageId = messageId;
this.attachmentId = attachmentId;
}
execute(apiToken) {
const _headers = {
[Constants_1.AUTHORIZATION]: apiToken
};
return MailinatorHttpClient_1.default.get(_resolveTemplateUrl(this.domain, 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.GetMessageAttachmentRequest = GetMessageAttachmentRequest;
;