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.

264 lines (251 loc) 13 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _ApiClient = _interopRequireDefault(require("../ApiClient")); var _Campaign = _interopRequireDefault(require("../model/Campaign")); 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. * */ /** * Campaigns service. * @module api/CampaignsApi * @version 4.0.26 */ var CampaignsApi = exports["default"] = /*#__PURE__*/function () { /** * Constructs a new CampaignsApi. * @alias module:api/CampaignsApi * @class * @param {module:ApiClient} [apiClient] Optional API client implementation to use, * default to {@link module:ApiClient#instance} if unspecified. */ function CampaignsApi(apiClient) { _classCallCheck(this, CampaignsApi); this.apiClient = apiClient || _ApiClient["default"].instance; } /** * Callback function to receive the result of the campaignsByNameDelete operation. * @callback module:api/CampaignsApi~campaignsByNameDeleteCallback * @param {String} error Error message, if any. * @param data This operation does not return a value. * @param {String} response The complete HTTP response. */ /** * Delete Campaign * Delete the specific campaign. This does not cancel in progress email, see Cancel In Progress. Required Access Level: ModifyCampaigns * @param {String} name Name of Campaign to delete * @param {module:api/CampaignsApi~campaignsByNameDeleteCallback} callback The callback function, accepting three arguments: error, data, response */ return _createClass(CampaignsApi, [{ key: "campaignsByNameDelete", value: function campaignsByNameDelete(name, callback) { var postBody = null; // verify the required parameter 'name' is set if (name === undefined || name === null) { throw new Error("Missing the required parameter 'name' when calling campaignsByNameDelete"); } var pathParams = { 'name': name }; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = ['apikey']; var contentTypes = []; var accepts = []; var returnType = null; return this.apiClient.callApi('/campaigns/{name}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback); } /** * Callback function to receive the result of the campaignsByNameGet operation. * @callback module:api/CampaignsApi~campaignsByNameGetCallback * @param {String} error Error message, if any. * @param {module:model/Campaign} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Load Campaign * Returns the specified campaign details. Required Access Level: ViewCampaigns * @param {String} name Name of Campaign to get * @param {module:api/CampaignsApi~campaignsByNameGetCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/Campaign} */ }, { key: "campaignsByNameGet", value: function campaignsByNameGet(name, callback) { var postBody = null; // verify the required parameter 'name' is set if (name === undefined || name === null) { throw new Error("Missing the required parameter 'name' when calling campaignsByNameGet"); } var pathParams = { 'name': name }; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = ['apikey']; var contentTypes = []; var accepts = ['application/json']; var returnType = _Campaign["default"]; return this.apiClient.callApi('/campaigns/{name}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback); } /** * Callback function to receive the result of the campaignsByNamePausePut operation. * @callback module:api/CampaignsApi~campaignsByNamePausePutCallback * @param {String} error Error message, if any. * @param data This operation does not return a value. * @param {String} response The complete HTTP response. */ /** * Pause Campaign * Pauses the specific campaign, cancelling emails that are waiting to be sent. Required Access Level: ModifyCampaigns * @param {String} name Name of Campaign to pause * @param {module:api/CampaignsApi~campaignsByNamePausePutCallback} callback The callback function, accepting three arguments: error, data, response */ }, { key: "campaignsByNamePausePut", value: function campaignsByNamePausePut(name, callback) { var postBody = null; // verify the required parameter 'name' is set if (name === undefined || name === null) { throw new Error("Missing the required parameter 'name' when calling campaignsByNamePausePut"); } var pathParams = { 'name': name }; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = ['apikey']; var contentTypes = []; var accepts = []; var returnType = null; return this.apiClient.callApi('/campaigns/{name}/pause', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback); } /** * Callback function to receive the result of the campaignsByNamePut operation. * @callback module:api/CampaignsApi~campaignsByNamePutCallback * @param {String} error Error message, if any. * @param {module:model/Campaign} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Update Campaign * Updates a previously added campaign. Only Active and Paused campaigns can be updated. Required Access Level: ModifyCampaigns * @param {String} name Name of Campaign to update * @param {module:model/Campaign} campaign JSON representation of a campaign * @param {module:api/CampaignsApi~campaignsByNamePutCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/Campaign} */ }, { key: "campaignsByNamePut", value: function campaignsByNamePut(name, campaign, callback) { var postBody = campaign; // verify the required parameter 'name' is set if (name === undefined || name === null) { throw new Error("Missing the required parameter 'name' when calling campaignsByNamePut"); } // verify the required parameter 'campaign' is set if (campaign === undefined || campaign === null) { throw new Error("Missing the required parameter 'campaign' when calling campaignsByNamePut"); } var pathParams = { 'name': name }; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = ['apikey']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = _Campaign["default"]; return this.apiClient.callApi('/campaigns/{name}', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback); } /** * Callback function to receive the result of the campaignsGet operation. * @callback module:api/CampaignsApi~campaignsGetCallback * @param {String} error Error message, if any. * @param {Array.<module:model/Campaign>} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Load Campaigns * Returns a list all of your campaigns. Limited to 1000 results. Required Access Level: ViewCampaigns * @param {Object} opts Optional parameters * @param {String} [search] Text fragment used for searching in Campaign name (using the 'contains' rule) * @param {Number} [offset] How many items should be returned ahead. * @param {Number} [limit] Maximum number of returned items. * @param {module:api/CampaignsApi~campaignsGetCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link Array.<module:model/Campaign>} */ }, { key: "campaignsGet", value: function campaignsGet(opts, callback) { opts = opts || {}; var postBody = null; var pathParams = {}; var queryParams = { 'search': opts['search'], 'offset': opts['offset'], 'limit': opts['limit'] }; var headerParams = {}; var formParams = {}; var authNames = ['apikey']; var contentTypes = []; var accepts = ['application/json']; var returnType = [_Campaign["default"]]; return this.apiClient.callApi('/campaigns', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback); } /** * Callback function to receive the result of the campaignsPost operation. * @callback module:api/CampaignsApi~campaignsPostCallback * @param {String} error Error message, if any. * @param {module:model/Campaign} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Add Campaign * Add a campaign for processing. Required Access Level: ModifyCampaigns * @param {module:model/Campaign} campaign JSON representation of a campaign * @param {module:api/CampaignsApi~campaignsPostCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/Campaign} */ }, { key: "campaignsPost", value: function campaignsPost(campaign, callback) { var postBody = campaign; // verify the required parameter 'campaign' is set if (campaign === undefined || campaign === null) { throw new Error("Missing the required parameter 'campaign' when calling campaignsPost"); } var pathParams = {}; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = ['apikey']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = _Campaign["default"]; return this.apiClient.callApi('/campaigns', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback); } }]); }();