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.

228 lines (217 loc) 11.3 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _ApiClient = _interopRequireDefault(require("../ApiClient")); var _Segment = _interopRequireDefault(require("../model/Segment")); var _SegmentPayload = _interopRequireDefault(require("../model/SegmentPayload")); 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. * */ /** * Segments service. * @module api/SegmentsApi * @version 4.0.26 */ var SegmentsApi = exports["default"] = /*#__PURE__*/function () { /** * Constructs a new SegmentsApi. * @alias module:api/SegmentsApi * @class * @param {module:ApiClient} [apiClient] Optional API client implementation to use, * default to {@link module:ApiClient#instance} if unspecified. */ function SegmentsApi(apiClient) { _classCallCheck(this, SegmentsApi); this.apiClient = apiClient || _ApiClient["default"].instance; } /** * Callback function to receive the result of the segmentsByNameDelete operation. * @callback module:api/SegmentsApi~segmentsByNameDeleteCallback * @param {String} error Error message, if any. * @param data This operation does not return a value. * @param {String} response The complete HTTP response. */ /** * Delete Segment * Delete an existing segment. Required Access Level: ModifyContacts * @param {String} name Name of your segment. * @param {module:api/SegmentsApi~segmentsByNameDeleteCallback} callback The callback function, accepting three arguments: error, data, response */ return _createClass(SegmentsApi, [{ key: "segmentsByNameDelete", value: function segmentsByNameDelete(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 segmentsByNameDelete"); } var pathParams = { 'name': name }; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = ['apikey']; var contentTypes = []; var accepts = []; var returnType = null; return this.apiClient.callApi('/segments/{name}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback); } /** * Callback function to receive the result of the segmentsByNameGet operation. * @callback module:api/SegmentsApi~segmentsByNameGetCallback * @param {String} error Error message, if any. * @param {module:model/Segment} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Load Segment * Returns details for the specified segment. Required Access Level: ViewContacts * @param {String} name Name of the segment you want to load. Will load all contacts if the 'All Contacts' name has been provided * @param {module:api/SegmentsApi~segmentsByNameGetCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/Segment} */ }, { key: "segmentsByNameGet", value: function segmentsByNameGet(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 segmentsByNameGet"); } var pathParams = { 'name': name }; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = ['apikey']; var contentTypes = []; var accepts = ['application/json']; var returnType = _Segment["default"]; return this.apiClient.callApi('/segments/{name}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback); } /** * Callback function to receive the result of the segmentsByNamePut operation. * @callback module:api/SegmentsApi~segmentsByNamePutCallback * @param {String} error Error message, if any. * @param {module:model/Segment} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Update Segment * Rename or change RULE for your segment. Required Access Level: ModifyContacts * @param {String} name Name of your segment. * @param {module:model/SegmentPayload} segmentPayload * @param {module:api/SegmentsApi~segmentsByNamePutCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/Segment} */ }, { key: "segmentsByNamePut", value: function segmentsByNamePut(name, segmentPayload, callback) { var postBody = segmentPayload; // verify the required parameter 'name' is set if (name === undefined || name === null) { throw new Error("Missing the required parameter 'name' when calling segmentsByNamePut"); } // verify the required parameter 'segmentPayload' is set if (segmentPayload === undefined || segmentPayload === null) { throw new Error("Missing the required parameter 'segmentPayload' when calling segmentsByNamePut"); } var pathParams = { 'name': name }; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = ['apikey']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = _Segment["default"]; return this.apiClient.callApi('/segments/{name}', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback); } /** * Callback function to receive the result of the segmentsGet operation. * @callback module:api/SegmentsApi~segmentsGetCallback * @param {String} error Error message, if any. * @param {Array.<module:model/Segment>} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Load Segments * Returns a list of all your available Segments. Required Access Level: ViewContacts * @param {Object} opts Optional parameters * @param {Number} [limit] Maximum number of returned items. * @param {Number} [offset] How many items should be returned ahead. * @param {module:api/SegmentsApi~segmentsGetCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link Array.<module:model/Segment>} */ }, { key: "segmentsGet", value: function segmentsGet(opts, callback) { opts = opts || {}; var postBody = null; var pathParams = {}; var queryParams = { 'limit': opts['limit'], 'offset': opts['offset'] }; var headerParams = {}; var formParams = {}; var authNames = ['apikey']; var contentTypes = []; var accepts = ['application/json']; var returnType = [_Segment["default"]]; return this.apiClient.callApi('/segments', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback); } /** * Callback function to receive the result of the segmentsPost operation. * @callback module:api/SegmentsApi~segmentsPostCallback * @param {String} error Error message, if any. * @param {module:model/Segment} data The data returned by the service call. * @param {String} response The complete HTTP response. */ /** * Add Segment * Add a new segment, based on specified RULE. Required Access Level: ModifyContacts * @param {module:model/SegmentPayload} segmentPayload * @param {module:api/SegmentsApi~segmentsPostCallback} callback The callback function, accepting three arguments: error, data, response * data is of type: {@link module:model/Segment} */ }, { key: "segmentsPost", value: function segmentsPost(segmentPayload, callback) { var postBody = segmentPayload; // verify the required parameter 'segmentPayload' is set if (segmentPayload === undefined || segmentPayload === null) { throw new Error("Missing the required parameter 'segmentPayload' when calling segmentsPost"); } var pathParams = {}; var queryParams = {}; var headerParams = {}; var formParams = {}; var authNames = ['apikey']; var contentTypes = ['application/json']; var accepts = ['application/json']; var returnType = _Segment["default"]; return this.apiClient.callApi('/segments', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback); } }]); }();