mailinator-client
Version:
Mailinator REST API client for JavaScript applications.
62 lines (61 loc) • 2.25 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.GetInboxRequest = void 0;
const MailinatorRestClient_1 = require("../MailinatorRestClient");
const Constants_1 = require("../Constants");
const _resolveTemplateUrl = (domain, inbox) => {
if (inbox === undefined) {
inbox = '';
}
return `https://api.mailinator.com/v2/domains/${domain}/inboxes/${inbox}`;
};
class GetInboxRequest {
constructor(domain, inbox, skip, limit, sort, decodeSubject, cursor, full, del, wait) {
this.domain = domain;
this.inbox = inbox;
this.skip = skip;
this.limit = limit;
this.sort = sort;
this.decodeSubject = decodeSubject;
this.cursor = cursor;
this.full = full;
this.del = del;
this.wait = wait;
}
execute(apiToken) {
const _options = {
queryParameters: {
params: {}
},
additionalHeaders: {
[Constants_1.AUTHORIZATION]: apiToken
}
};
if (this.skip !== undefined) {
_options.queryParameters.params['skip'] = this.skip;
}
if (this.limit !== undefined) {
_options.queryParameters.params['limit'] = this.limit;
}
if (this.sort !== undefined) {
_options.queryParameters.params['sort'] = this.sort;
}
if (this.decodeSubject !== undefined) {
_options.queryParameters.params['decode_subject'] = this.decodeSubject.toString();
}
if (this.cursor !== undefined) {
_options.queryParameters.params['cursor'] = this.cursor;
}
if (this.full !== undefined) {
_options.queryParameters.params['full'] = this.full.toString();
}
if (this.del !== undefined) {
_options.queryParameters.params['delete'] = this.del;
}
if (this.wait !== undefined) {
_options.queryParameters.params['wait'] = this.wait;
}
return MailinatorRestClient_1.default.get(_resolveTemplateUrl(this.domain, this.inbox), _options);
}
}
exports.GetInboxRequest = GetInboxRequest;