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.
300 lines (285 loc) • 13.9 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports["default"] = void 0;
var _ApiClient = _interopRequireDefault(require("../ApiClient"));
var _ErrorResponse = _interopRequireDefault(require("../model/ErrorResponse"));
var _Job = _interopRequireDefault(require("../model/Job"));
var _JobCreateRequest = _interopRequireDefault(require("../model/JobCreateRequest"));
var _JobCreateResponse = _interopRequireDefault(require("../model/JobCreateResponse"));
var _ProcessedJob = _interopRequireDefault(require("../model/ProcessedJob"));
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); } /**
* 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.
*
*/
/**
* Jobs service.
* @module api/JobsApi
* @version 1.0.0
*/
var JobsApi = exports["default"] = /*#__PURE__*/function () {
/**
* Constructs a new JobsApi.
* @alias module:api/JobsApi
* @class
* @param {module:ApiClient} [apiClient] Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
function JobsApi(apiClient) {
_classCallCheck(this, JobsApi);
this.apiClient = apiClient || _ApiClient["default"].instance;
}
/**
* Callback function to receive the result of the jobAsyncPost operation.
* @callback module:api/JobsApi~jobAsyncPostCallback
* @param {String} error Error message, if any.
* @param {module:model/Job} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Receives a job and process it asyncrhonously
* Receives a Job in body and process it asynchronusly and returns job details as job_id which can be used to retrieve data related to that job
* @param {module:model/JobCreateRequest} body
* @param {module:api/JobsApi~jobAsyncPostCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/Job}
*/
return _createClass(JobsApi, [{
key: "jobAsyncPost",
value: function jobAsyncPost(body, callback) {
var postBody = body;
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling jobAsyncPost");
}
var pathParams = {};
var queryParams = {};
var headerParams = {};
var formParams = {};
var authNames = ['key'];
var contentTypes = ['application/json'];
var accepts = ['application/json', 'application/octet-stream'];
var returnType = _Job["default"];
return this.apiClient.callApi('/job/async', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback);
}
/**
* Callback function to receive the result of the jobGet operation.
* @callback module:api/JobsApi~jobGetCallback
* @param {String} error Error message, if any.
* @param {Array.<module:model/Job>} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Get jobs
* Get existing jobs owned by authenticated user account
* @param {module:api/JobsApi~jobGetCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link Array.<module:model/Job>}
*/
}, {
key: "jobGet",
value: function jobGet(callback) {
var postBody = null;
var pathParams = {};
var queryParams = {};
var headerParams = {};
var formParams = {};
var authNames = ['key'];
var contentTypes = [];
var accepts = ['application/json', 'application/octet-stream'];
var returnType = [_Job["default"]];
return this.apiClient.callApi('/job', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback);
}
/**
* Callback function to receive the result of the jobIdDelete operation.
* @callback module:api/JobsApi~jobIdDeleteCallback
* @param {String} error Error message, if any.
* @param {module:model/Job} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Delete existing job
* Delete existing job owned by authenticated user account
* @param {String} id objectid for existing job to delete it
* @param {module:api/JobsApi~jobIdDeleteCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/Job}
*/
}, {
key: "jobIdDelete",
value: function jobIdDelete(id, callback) {
var postBody = null;
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling jobIdDelete");
}
var pathParams = {
'id': id
};
var queryParams = {};
var headerParams = {};
var formParams = {};
var authNames = ['key'];
var contentTypes = [];
var accepts = ['application/json', 'application/octet-stream'];
var returnType = _Job["default"];
return this.apiClient.callApi('/job/{id}', 'DELETE', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback);
}
/**
* Callback function to receive the result of the jobIdGet operation.
* @callback module:api/JobsApi~jobIdGetCallback
* @param {String} error Error message, if any.
* @param {module:model/Job} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Retrieve specific job status
* Retrieve specific job status
* @param {String} id
* @param {module:api/JobsApi~jobIdGetCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/Job}
*/
}, {
key: "jobIdGet",
value: function jobIdGet(id, callback) {
var postBody = null;
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling jobIdGet");
}
var pathParams = {
'id': id
};
var queryParams = {};
var headerParams = {};
var formParams = {};
var authNames = ['key'];
var contentTypes = [];
var accepts = ['application/json', 'application/octet-stream'];
var returnType = _Job["default"];
return this.apiClient.callApi('/job/{id}', 'GET', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback);
}
/**
* Callback function to receive the result of the jobIdPut operation.
* @callback module:api/JobsApi~jobIdPutCallback
* @param {String} error Error message, if any.
* @param {module:model/Job} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Update existing job
* Update existing job owned by authenticated user account
* @param {String} id
* @param {module:model/JobCreateRequest} body
* @param {module:api/JobsApi~jobIdPutCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/Job}
*/
}, {
key: "jobIdPut",
value: function jobIdPut(id, body, callback) {
var postBody = body;
// verify the required parameter 'id' is set
if (id === undefined || id === null) {
throw new Error("Missing the required parameter 'id' when calling jobIdPut");
}
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling jobIdPut");
}
var pathParams = {
'id': id
};
var queryParams = {};
var headerParams = {};
var formParams = {};
var authNames = ['key'];
var contentTypes = ['application/json'];
var accepts = ['application/json', 'application/octet-stream'];
var returnType = _Job["default"];
return this.apiClient.callApi('/job/{id}', 'PUT', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback);
}
/**
* Callback function to receive the result of the jobPost operation.
* @callback module:api/JobsApi~jobPostCallback
* @param {String} error Error message, if any.
* @param {module:model/JobCreateResponse} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Create new job
* Creates new job owned authenticated user account
* @param {module:model/JobCreateRequest} body
* @param {module:api/JobsApi~jobPostCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/JobCreateResponse}
*/
}, {
key: "jobPost",
value: function jobPost(body, callback) {
var postBody = body;
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling jobPost");
}
var pathParams = {};
var queryParams = {};
var headerParams = {};
var formParams = {};
var authNames = ['key'];
var contentTypes = ['application/json'];
var accepts = ['application/json', 'application/octet-stream'];
var returnType = _JobCreateResponse["default"];
return this.apiClient.callApi('/job', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback);
}
/**
* Callback function to receive the result of the jobSyncPost operation.
* @callback module:api/JobsApi~jobSyncPostCallback
* @param {String} error Error message, if any.
* @param {module:model/ProcessedJob} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Receives a job and process it syncrhonously
* Receives a Job in body and process it synchronusly and returns the data object
* @param {module:model/JobCreateRequest} body
* @param {Object} opts Optional parameters
* @param {module:model/String} [xResponseType] Specify the desired response type you want to get. If you want to use json-parsed option, include 'data_to_scrape' object in your request body. The default value for this header is 'raw-html'
* @param {module:model/String} [xProxyRegion] Specify the proxy region for the scraped website request. The default value is 'mx'
* @param {module:api/JobsApi~jobSyncPostCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/ProcessedJob}
*/
}, {
key: "jobSyncPost",
value: function jobSyncPost(body, opts, callback) {
opts = opts || {};
var postBody = body;
// verify the required parameter 'body' is set
if (body === undefined || body === null) {
throw new Error("Missing the required parameter 'body' when calling jobSyncPost");
}
var pathParams = {};
var queryParams = {};
var headerParams = {
'X-Response-Type': opts['xResponseType'],
'X-Proxy-Region': opts['xProxyRegion']
};
var formParams = {};
var authNames = ['key'];
var contentTypes = ['application/json'];
var accepts = ['application/json', 'application/octet-stream'];
var returnType = _ProcessedJob["default"];
return this.apiClient.callApi('/job/sync', 'POST', pathParams, queryParams, headerParams, formParams, postBody, authNames, contentTypes, accepts, returnType, null, callback);
}
}]);
}();