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.
147 lines (124 loc) • 5.25 kB
JavaScript
/**
* 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.
*
*/
import ApiClient from '../ApiClient';
import Actions from './Actions';
import DataToScrape from './DataToScrape';
import Frecuency from './Frecuency';
/**
* The JobCreateRequest model module.
* @module model/JobCreateRequest
* @version 1.0.0
*/
class JobCreateRequest {
/**
* Constructs a new <code>JobCreateRequest</code>.
* @alias module:model/JobCreateRequest
* @param website {String}
*/
constructor(website) {
JobCreateRequest.initialize(this, website);
}
/**
* 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.
*/
static initialize(obj, website) {
obj['website'] = website;
}
/**
* Constructs a <code>JobCreateRequest</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/JobCreateRequest} obj Optional instance to populate.
* @return {module:model/JobCreateRequest} The populated <code>JobCreateRequest</code> instance.
*/
static constructFromObject(data, obj) {
if (data) {
obj = obj || new JobCreateRequest();
if (data.hasOwnProperty('website')) {
obj['website'] = ApiClient.convertToType(data['website'], 'String');
}
if (data.hasOwnProperty('actions')) {
obj['actions'] = ApiClient.convertToType(data['actions'], [Actions]);
}
if (data.hasOwnProperty('data_to_scrape')) {
obj['data_to_scrape'] = ApiClient.convertToType(data['data_to_scrape'], [DataToScrape]);
}
if (data.hasOwnProperty('frecuency')) {
obj['frecuency'] = Frecuency.constructFromObject(data['frecuency']);
}
}
return obj;
}
/**
* Validates the JSON data with respect to <code>JobCreateRequest</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>JobCreateRequest</code>.
*/
static validateJSON(data) {
// check to make sure all required properties are present in the JSON string
for (const property of JobCreateRequest.RequiredProperties) {
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
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)
for (const item of data['actions']) {
Actions.validateJSON(item);
};
}
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)
for (const item of data['data_to_scrape']) {
DataToScrape.validateJSON(item);
};
}
// validate the optional field `frecuency`
if (data['frecuency']) { // data not null
Frecuency.validateJSON(data['frecuency']);
}
return true;
}
}
JobCreateRequest.RequiredProperties = ["website"];
/**
* @member {String} website
*/
JobCreateRequest.prototype['website'] = undefined;
/**
* @member {Array.<module:model/Actions>} actions
*/
JobCreateRequest.prototype['actions'] = undefined;
/**
* @member {Array.<module:model/DataToScrape>} data_to_scrape
*/
JobCreateRequest.prototype['data_to_scrape'] = undefined;
/**
* @member {module:model/Frecuency} frecuency
*/
JobCreateRequest.prototype['frecuency'] = undefined;
export default JobCreateRequest;