UNPKG

scraper-api-datachaser

Version:

The scraping SaaS platform provides a RESTful API for developers to perform web scraping tasks. Users can submit scraping tasks, monitor task status, retrieve scraped data, and manage their account through the API.

276 lines (263 loc) 11.7 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports["default"] = void 0; var _ApiClient = _interopRequireDefault(require("../ApiClient")); var _Actions = _interopRequireDefault(require("./Actions")); var _DataToScrape = _interopRequireDefault(require("./DataToScrape")); var _Frecuency = _interopRequireDefault(require("./Frecuency")); 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 _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; } function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } } function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; } 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); } /** * Scraper API * The scraping SaaS platform provides a RESTful API for developers to perform web scraping tasks. Users can submit scraping tasks, monitor task status, retrieve scraped data, and manage their account through the API. * * The version of the OpenAPI document: 1.0.0 * * * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). * https://openapi-generator.tech * Do not edit the class manually. * */ /** * The Job model module. * @module model/Job * @version 1.0.0 */ var Job = /*#__PURE__*/function () { /** * Constructs a new <code>Job</code>. * @alias module:model/Job * @param id {String} * @param website {String} * @param frecuency {module:model/Frecuency} */ function Job(id, website, frecuency) { _classCallCheck(this, Job); Job.initialize(this, id, website, frecuency); } /** * Initializes the fields of this object. * This method is used by the constructors of any subclasses, in order to implement multiple inheritance (mix-ins). * Only for internal use. */ return _createClass(Job, null, [{ key: "initialize", value: function initialize(obj, id, website, frecuency) { obj['id'] = id; obj['website'] = website; obj['frecuency'] = frecuency; } /** * Constructs a <code>Job</code> from a plain JavaScript object, optionally creating a new instance. * Copies all relevant properties from <code>data</code> to <code>obj</code> if supplied or a new instance if not. * @param {Object} data The plain JavaScript object bearing properties of interest. * @param {module:model/Job} obj Optional instance to populate. * @return {module:model/Job} The populated <code>Job</code> instance. */ }, { key: "constructFromObject", value: function constructFromObject(data, obj) { if (data) { obj = obj || new Job(); if (data.hasOwnProperty('id')) { obj['id'] = _ApiClient["default"].convertToType(data['id'], 'String'); } if (data.hasOwnProperty('website')) { obj['website'] = _ApiClient["default"].convertToType(data['website'], 'String'); } if (data.hasOwnProperty('actions')) { obj['actions'] = _ApiClient["default"].convertToType(data['actions'], [_Actions["default"]]); } if (data.hasOwnProperty('data_to_scrape')) { obj['data_to_scrape'] = _ApiClient["default"].convertToType(data['data_to_scrape'], [_DataToScrape["default"]]); } if (data.hasOwnProperty('frecuency')) { obj['frecuency'] = _Frecuency["default"].constructFromObject(data['frecuency']); } if (data.hasOwnProperty('status')) { obj['status'] = _ApiClient["default"].convertToType(data['status'], 'String'); } if (data.hasOwnProperty('created_at')) { obj['created_at'] = _ApiClient["default"].convertToType(data['created_at'], 'String'); } if (data.hasOwnProperty('updated_at')) { obj['updated_at'] = _ApiClient["default"].convertToType(data['updated_at'], 'String'); } } return obj; } /** * Validates the JSON data with respect to <code>Job</code>. * @param {Object} data The plain JavaScript object bearing properties of interest. * @return {boolean} to indicate whether the JSON data is valid with respect to <code>Job</code>. */ }, { key: "validateJSON", value: function validateJSON(data) { // check to make sure all required properties are present in the JSON string var _iterator = _createForOfIteratorHelper(Job.RequiredProperties), _step; try { for (_iterator.s(); !(_step = _iterator.n()).done;) { var property = _step.value; if (!data.hasOwnProperty(property)) { throw new Error("The required field `" + property + "` is not found in the JSON data: " + JSON.stringify(data)); } } // ensure the json data is a string } catch (err) { _iterator.e(err); } finally { _iterator.f(); } if (data['id'] && !(typeof data['id'] === 'string' || data['id'] instanceof String)) { throw new Error("Expected the field `id` to be a primitive type in the JSON string but got " + data['id']); } // ensure the json data is a string if (data['website'] && !(typeof data['website'] === 'string' || data['website'] instanceof String)) { throw new Error("Expected the field `website` to be a primitive type in the JSON string but got " + data['website']); } if (data['actions']) { // data not null // ensure the json data is an array if (!Array.isArray(data['actions'])) { throw new Error("Expected the field `actions` to be an array in the JSON data but got " + data['actions']); } // validate the optional field `actions` (array) var _iterator2 = _createForOfIteratorHelper(data['actions']), _step2; try { for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) { var item = _step2.value; _Actions["default"].validateJSON(item); } } catch (err) { _iterator2.e(err); } finally { _iterator2.f(); } ; } if (data['data_to_scrape']) { // data not null // ensure the json data is an array if (!Array.isArray(data['data_to_scrape'])) { throw new Error("Expected the field `data_to_scrape` to be an array in the JSON data but got " + data['data_to_scrape']); } // validate the optional field `data_to_scrape` (array) var _iterator3 = _createForOfIteratorHelper(data['data_to_scrape']), _step3; try { for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) { var _item = _step3.value; _DataToScrape["default"].validateJSON(_item); } } catch (err) { _iterator3.e(err); } finally { _iterator3.f(); } ; } // validate the optional field `frecuency` if (data['frecuency']) { // data not null _Frecuency["default"].validateJSON(data['frecuency']); } // ensure the json data is a string if (data['status'] && !(typeof data['status'] === 'string' || data['status'] instanceof String)) { throw new Error("Expected the field `status` to be a primitive type in the JSON string but got " + data['status']); } // ensure the json data is a string if (data['created_at'] && !(typeof data['created_at'] === 'string' || data['created_at'] instanceof String)) { throw new Error("Expected the field `created_at` to be a primitive type in the JSON string but got " + data['created_at']); } // ensure the json data is a string if (data['updated_at'] && !(typeof data['updated_at'] === 'string' || data['updated_at'] instanceof String)) { throw new Error("Expected the field `updated_at` to be a primitive type in the JSON string but got " + data['updated_at']); } return true; } }]); }(); Job.RequiredProperties = ["id", "website", "frecuency"]; /** * @member {String} id */ Job.prototype['id'] = undefined; /** * @member {String} website */ Job.prototype['website'] = undefined; /** * @member {Array.<module:model/Actions>} actions */ Job.prototype['actions'] = undefined; /** * @member {Array.<module:model/DataToScrape>} data_to_scrape */ Job.prototype['data_to_scrape'] = undefined; /** * @member {module:model/Frecuency} frecuency */ Job.prototype['frecuency'] = undefined; /** * @member {module:model/Job.StatusEnum} status */ Job.prototype['status'] = undefined; /** * @member {String} created_at */ Job.prototype['created_at'] = undefined; /** * @member {String} updated_at */ Job.prototype['updated_at'] = undefined; /** * Allowed values for the <code>status</code> property. * @enum {String} * @readonly */ Job['StatusEnum'] = { /** * value: "Pending" * @const */ "Pending": "Pending", /** * value: "In Progress" * @const */ "In Progress": "In Progress", /** * value: "Paused" * @const */ "Paused": "Paused", /** * value: "Completed" * @const */ "Completed": "Completed", /** * value: "Failed" * @const */ "Failed": "Failed", /** * value: "Cancelled" * @const */ "Cancelled": "Cancelled" }; var _default = exports["default"] = Job;