UNPKG

@elasticemail/elasticemail-client

Version:

Official ElasticEmail SDK. This API is based on the REST API architecture, allowing the user to easily manage their data with this resource-based approach.

247 lines (236 loc) 13.8 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _ApiClient = _interopRequireDefault(require("../ApiClient")); var _EmailData = _interopRequireDefault(require("../model/EmailData")); var _EmailJobStatus = _interopRequireDefault(require("../model/EmailJobStatus")); var _EmailMessageData = _interopRequireDefault(require("../model/EmailMessageData")); var _EmailSend = _interopRequireDefault(require("../model/EmailSend")); var _EmailTransactionalMessageData = _interopRequireDefault(require("../model/EmailTransactionalMessageData")); var _MergeEmailPayload = _interopRequireDefault(require("../model/MergeEmailPayload")); function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; } function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } } function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; } function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; } function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /** * Elastic Email REST API * This API is based on the REST API architecture, allowing the user to easily manage their data with this resource-based approach. Every API call is established on which specific request type (GET, POST, PUT, DELETE) will be used. The API has a limit of 20 concurrent connections and a hard timeout of 600 seconds per request. To start using this API, you will need your Access Token (available <a target=\"_blank\" href=\"https://app.elasticemail.com/marketing/settings/new/manage-api\">here</a>). Remember to keep it safe. Required access levels are listed in the given request’s description. Downloadable library clients can be found in our Github repository <a target=\"_blank\" href=\"https://github.com/ElasticEmail?tab=repositories&q=%22rest+api%22+in%3Areadme\">here</a> * * The version of the OpenAPI document: 4.0.0 * Contact: support@elasticemail.com * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. * */ /** * Emails service. * @module api/EmailsApi * @version 4.0.26 */ var EmailsApi = exports["default"] = /*#__PURE__*/function () { /** * Constructs a new EmailsApi. * @alias module:api/EmailsApi * @class * @param {module:ApiClient} [apiClient] Optional API client implementation to use, * default to {@link module:ApiClient#instance} if unspecified. */ function EmailsApi(apiClient) { _classCallCheck(this, EmailsApi); this.apiClient = apiClient || _ApiClient["default"].instance; } /** * Callback function to receive the result of the emailsByMsgidViewGet operation. * @callback module:api/EmailsApi~emailsByMsgidViewGetCallback * @param {String} error Error message, if any. * @param {module:model/EmailData} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * View Email * Returns email details for viewing or rendering. Required Access Level: None * @param {String} msgid Message identifier * @param {module:api/EmailsApi~emailsByMsgidViewGetCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/EmailData} */ return _createClass(EmailsApi, [{ key: "emailsByMsgidViewGet", value: function emailsByMsgidViewGet(msgid, callback) { var postBody = null; // verify the required parameter 'msgid' is set if (msgid === undefined || msgid === null) { throw new Error("Missing the required parameter 'msgid' when calling emailsByMsgidViewGet"); } var pathParams = { 'msgid': msgid }; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = ['apikey']; var contentTypes = []; var accepts = ['application/json']; var returnType = _EmailData["default"]; return this.apiClient.callApi('/emails/{msgid}/view', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback); } /** * Callback function to receive the result of the emailsByTransactionidStatusGet operation. * @callback module:api/EmailsApi~emailsByTransactionidStatusGetCallback * @param {String} error Error message, if any. * @param {module:model/EmailJobStatus} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Get Status * Get status details of an email transaction. Required Access Level: ViewReports * @param {String} transactionid Transaction identifier * @param {Object} opts Optional parameters * @param {Boolean} [showFailed = false)] Include Bounced email addresses. * @param {Boolean} [showSent = false)] Include Sent email addresses. * @param {Boolean} [showDelivered = false)] Include all delivered email addresses. * @param {Boolean} [showPending = false)] Include Ready to send email addresses. * @param {Boolean} [showOpened = false)] Include Opened email addresses. * @param {Boolean} [showClicked = false)] Include Clicked email addresses. * @param {Boolean} [showAbuse = false)] Include Reported as abuse email addresses. * @param {Boolean} [showUnsubscribed = false)] Include Unsubscribed email addresses. * @param {Boolean} [showErrors = false)] Include error messages for bounced emails. * @param {Boolean} [showMessageIDs = false)] Include all MessageIDs for this transaction * @param {module:api/EmailsApi~emailsByTransactionidStatusGetCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/EmailJobStatus} */ }, { key: "emailsByTransactionidStatusGet", value: function emailsByTransactionidStatusGet(transactionid, opts, callback) { opts = opts || {}; var postBody = null; // verify the required parameter 'transactionid' is set if (transactionid === undefined || transactionid === null) { throw new Error("Missing the required parameter 'transactionid' when calling emailsByTransactionidStatusGet"); } var pathParams = { 'transactionid': transactionid }; var queryParams = { 'showFailed': opts['showFailed'], 'showSent': opts['showSent'], 'showDelivered': opts['showDelivered'], 'showPending': opts['showPending'], 'showOpened': opts['showOpened'], 'showClicked': opts['showClicked'], 'showAbuse': opts['showAbuse'], 'showUnsubscribed': opts['showUnsubscribed'], 'showErrors': opts['showErrors'], 'showMessageIDs': opts['showMessageIDs'] }; var headerParams = {}; var formParams = {}; var authNames = ['apikey']; var contentTypes = []; var accepts = ['application/json']; var returnType = _EmailJobStatus["default"]; return this.apiClient.callApi('/emails/{transactionid}/status', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback); } /** * Callback function to receive the result of the emailsMergefilePost operation. * @callback module:api/EmailsApi~emailsMergefilePostCallback * @param {String} error Error message, if any. * @param {module:model/EmailSend} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Send Bulk Emails CSV * Send to a list of contacts submitted in a CSV data file. The first column in the CSV must be the email address and the CSV must contain a header row. Additional fields can be included with a named header row and can be merged with the template using {merge} tags in the content. Example CSV: email, firstname, lastname test1@gmail.com, michael, smith test2@gmail.com, janet, smith Merge file must not be empty. Required Access Level: SendHttp * @param {module:model/MergeEmailPayload} mergeEmailPayload Email data * @param {module:api/EmailsApi~emailsMergefilePostCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/EmailSend} */ }, { key: "emailsMergefilePost", value: function emailsMergefilePost(mergeEmailPayload, callback) { var postBody = mergeEmailPayload; // verify the required parameter 'mergeEmailPayload' is set if (mergeEmailPayload === undefined || mergeEmailPayload === null) { throw new Error("Missing the required parameter 'mergeEmailPayload' when calling emailsMergefilePost"); } var pathParams = {}; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = ['apikey']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = _EmailSend["default"]; return this.apiClient.callApi('/emails/mergefile', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback); } /** * Callback function to receive the result of the emailsPost operation. * @callback module:api/EmailsApi~emailsPostCallback * @param {String} error Error message, if any. * @param {module:model/EmailSend} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Send Bulk Emails * Send bulk merge email. Required Access Level: SendHttp * @param {module:model/EmailMessageData} emailMessageData Email data * @param {module:api/EmailsApi~emailsPostCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/EmailSend} */ }, { key: "emailsPost", value: function emailsPost(emailMessageData, callback) { var postBody = emailMessageData; // verify the required parameter 'emailMessageData' is set if (emailMessageData === undefined || emailMessageData === null) { throw new Error("Missing the required parameter 'emailMessageData' when calling emailsPost"); } var pathParams = {}; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = ['apikey']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = _EmailSend["default"]; return this.apiClient.callApi('/emails', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback); } /** * Callback function to receive the result of the emailsTransactionalPost operation. * @callback module:api/EmailsApi~emailsTransactionalPostCallback * @param {String} error Error message, if any. * @param {module:model/EmailSend} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Send Transactional Email * Send transactional emails (recipients will be known to each other). Required Access Level: SendHttp * @param {module:model/EmailTransactionalMessageData} emailTransactionalMessageData Email data * @param {module:api/EmailsApi~emailsTransactionalPostCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/EmailSend} */ }, { key: "emailsTransactionalPost", value: function emailsTransactionalPost(emailTransactionalMessageData, callback) { var postBody = emailTransactionalMessageData; // verify the required parameter 'emailTransactionalMessageData' is set if (emailTransactionalMessageData === undefined || emailTransactionalMessageData === null) { throw new Error("Missing the required parameter 'emailTransactionalMessageData' when calling emailsTransactionalPost"); } var pathParams = {}; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = ['apikey']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = _EmailSend["default"]; return this.apiClient.callApi('/emails/transactional', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback); } }]); }();