@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.
355 lines (338 loc) • 17.2 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _ApiClient = _interopRequireDefault(require("../ApiClient"));
var _Contact = _interopRequireDefault(require("../model/Contact"));
var _ContactsList = _interopRequireDefault(require("../model/ContactsList"));
var _EmailsPayload = _interopRequireDefault(require("../model/EmailsPayload"));
var _ListPayload = _interopRequireDefault(require("../model/ListPayload"));
var _ListUpdatePayload = _interopRequireDefault(require("../model/ListUpdatePayload"));
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.
*
*/
/**
* Lists service.
* @module api/ListsApi
* @version 4.0.26
*/
var ListsApi = exports["default"] = /*#__PURE__*/function () {
/**
* Constructs a new ListsApi.
* @alias module:api/ListsApi
* @class
* @param {module:ApiClient} [apiClient] Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
function ListsApi(apiClient) {
_classCallCheck(this, ListsApi);
this.apiClient = apiClient || _ApiClient["default"].instance;
}
/**
* Callback function to receive the result of the listsByListnameContactsGet operation.
* @callback module:api/ListsApi~listsByListnameContactsGetCallback
* @param {String} error Error message, if any.
* @param {Array.<module:model/Contact>} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Load Contacts in List
* Returns a list of contacts. Required Access Level: ViewContacts
* @param {String} listname Name of your list.
* @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/ListsApi~listsByListnameContactsGetCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link Array.<module:model/Contact>}
*/
return _createClass(ListsApi, [{
key: "listsByListnameContactsGet",
value: function listsByListnameContactsGet(listname, opts, callback) {
opts = opts || {};
var postBody = null;
// verify the required parameter 'listname' is set
if (listname === undefined || listname === null) {
throw new Error("Missing the required parameter 'listname' when calling listsByListnameContactsGet");
}
var pathParams = {
'listname': listname
};
var queryParams = {
'limit': opts['limit'],
'offset': opts['offset']
};
var headerParams = {};
var formParams = {};
var authNames = ['apikey'];
var contentTypes = [];
var accepts = ['application/json'];
var returnType = [_Contact["default"]];
return this.apiClient.callApi('/lists/{listname}/contacts', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback);
}
/**
* Callback function to receive the result of the listsByNameContactsPost operation.
* @callback module:api/ListsApi~listsByNameContactsPostCallback
* @param {String} error Error message, if any.
* @param {module:model/ContactsList} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Add Contacts to List
* Add existing Contacts to specified list. Required Access Level: ModifyContacts
* @param {String} name Name of your list.
* @param {module:model/EmailsPayload} emailsPayload Provide either rule or a list of emails, not both.
* @param {module:api/ListsApi~listsByNameContactsPostCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/ContactsList}
*/
}, {
key: "listsByNameContactsPost",
value: function listsByNameContactsPost(name, emailsPayload, callback) {
var postBody = emailsPayload;
// verify the required parameter 'name' is set
if (name === undefined || name === null) {
throw new Error("Missing the required parameter 'name' when calling listsByNameContactsPost");
}
// verify the required parameter 'emailsPayload' is set
if (emailsPayload === undefined || emailsPayload === null) {
throw new Error("Missing the required parameter 'emailsPayload' when calling listsByNameContactsPost");
}
var pathParams = {
'name': name
};
var queryParams = {};
var headerParams = {};
var formParams = {};
var authNames = ['apikey'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = _ContactsList["default"];
return this.apiClient.callApi('/lists/{name}/contacts', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback);
}
/**
* Callback function to receive the result of the listsByNameContactsRemovePost operation.
* @callback module:api/ListsApi~listsByNameContactsRemovePostCallback
* @param {String} error Error message, if any.
* @param data This operation does not return a value.
* @param {String} response The complete HTTP response.
*/
/**
* Remove Contacts from List
* Remove specified Contacts from your list. Required Access Level: ModifyContacts
* @param {String} name Name of your list.
* @param {module:model/EmailsPayload} emailsPayload Provide either rule or a list of emails, not both.
* @param {module:api/ListsApi~listsByNameContactsRemovePostCallback} callback The callback function, accepting three arguments: error, data, response
*/
}, {
key: "listsByNameContactsRemovePost",
value: function listsByNameContactsRemovePost(name, emailsPayload, callback) {
var postBody = emailsPayload;
// verify the required parameter 'name' is set
if (name === undefined || name === null) {
throw new Error("Missing the required parameter 'name' when calling listsByNameContactsRemovePost");
}
// verify the required parameter 'emailsPayload' is set
if (emailsPayload === undefined || emailsPayload === null) {
throw new Error("Missing the required parameter 'emailsPayload' when calling listsByNameContactsRemovePost");
}
var pathParams = {
'name': name
};
var queryParams = {};
var headerParams = {};
var formParams = {};
var authNames = ['apikey'];
var contentTypes = ['application/json'];
var accepts = [];
var returnType = null;
return this.apiClient.callApi('/lists/{name}/contacts/remove', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback);
}
/**
* Callback function to receive the result of the listsByNameDelete operation.
* @callback module:api/ListsApi~listsByNameDeleteCallback
* @param {String} error Error message, if any.
* @param data This operation does not return a value.
* @param {String} response The complete HTTP response.
*/
/**
* Delete List
* Deletes List and removes all the Contacts from it (does not delete Contacts). Required Access Level: ModifyContacts
* @param {String} name Name of your list.
* @param {module:api/ListsApi~listsByNameDeleteCallback} callback The callback function, accepting three arguments: error, data, response
*/
}, {
key: "listsByNameDelete",
value: function listsByNameDelete(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 listsByNameDelete");
}
var pathParams = {
'name': name
};
var queryParams = {};
var headerParams = {};
var formParams = {};
var authNames = ['apikey'];
var contentTypes = [];
var accepts = [];
var returnType = null;
return this.apiClient.callApi('/lists/{name}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback);
}
/**
* Callback function to receive the result of the listsByNameGet operation.
* @callback module:api/ListsApi~listsByNameGetCallback
* @param {String} error Error message, if any.
* @param {module:model/ContactsList} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Load List
* Returns detailed information about specified list. Required Access Level: ViewContacts
* @param {String} name Name of your list.
* @param {module:api/ListsApi~listsByNameGetCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/ContactsList}
*/
}, {
key: "listsByNameGet",
value: function listsByNameGet(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 listsByNameGet");
}
var pathParams = {
'name': name
};
var queryParams = {};
var headerParams = {};
var formParams = {};
var authNames = ['apikey'];
var contentTypes = [];
var accepts = ['application/json'];
var returnType = _ContactsList["default"];
return this.apiClient.callApi('/lists/{name}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback);
}
/**
* Callback function to receive the result of the listsByNamePut operation.
* @callback module:api/ListsApi~listsByNamePutCallback
* @param {String} error Error message, if any.
* @param {module:model/ContactsList} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Update List
* Update existing list. Required Access Level: ModifyContacts
* @param {String} name Name of your list.
* @param {module:model/ListUpdatePayload} listUpdatePayload
* @param {module:api/ListsApi~listsByNamePutCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/ContactsList}
*/
}, {
key: "listsByNamePut",
value: function listsByNamePut(name, listUpdatePayload, callback) {
var postBody = listUpdatePayload;
// verify the required parameter 'name' is set
if (name === undefined || name === null) {
throw new Error("Missing the required parameter 'name' when calling listsByNamePut");
}
// verify the required parameter 'listUpdatePayload' is set
if (listUpdatePayload === undefined || listUpdatePayload === null) {
throw new Error("Missing the required parameter 'listUpdatePayload' when calling listsByNamePut");
}
var pathParams = {
'name': name
};
var queryParams = {};
var headerParams = {};
var formParams = {};
var authNames = ['apikey'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = _ContactsList["default"];
return this.apiClient.callApi('/lists/{name}', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback);
}
/**
* Callback function to receive the result of the listsGet operation.
* @callback module:api/ListsApi~listsGetCallback
* @param {String} error Error message, if any.
* @param {Array.<module:model/ContactsList>} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Load Lists
* Returns all your existing lists. 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/ListsApi~listsGetCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link Array.<module:model/ContactsList>}
*/
}, {
key: "listsGet",
value: function listsGet(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 = [_ContactsList["default"]];
return this.apiClient.callApi('/lists', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback);
}
/**
* Callback function to receive the result of the listsPost operation.
* @callback module:api/ListsApi~listsPostCallback
* @param {String} error Error message, if any.
* @param {module:model/ContactsList} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Add List
* Add a new list. Required Access Level: ModifyContacts
* @param {module:model/ListPayload} listPayload
* @param {module:api/ListsApi~listsPostCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/ContactsList}
*/
}, {
key: "listsPost",
value: function listsPost(listPayload, callback) {
var postBody = listPayload;
// verify the required parameter 'listPayload' is set
if (listPayload === undefined || listPayload === null) {
throw new Error("Missing the required parameter 'listPayload' when calling listsPost");
}
var pathParams = {};
var queryParams = {};
var headerParams = {};
var formParams = {};
var authNames = ['apikey'];
var contentTypes = ['application/json'];
var accepts = ['application/json'];
var returnType = _ContactsList["default"];
return this.apiClient.callApi('/lists', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback);
}
}]);
}();