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.
346 lines (310 loc) • 12.2 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 ErrorResponse from '../model/ErrorResponse';
import Job from '../model/Job';
import JobCreateRequest from '../model/JobCreateRequest';
import JobCreateResponse from '../model/JobCreateResponse';
import ProcessedJob from '../model/ProcessedJob';
/**
* Jobs service.
* @module api/JobsApi
* @version 1.0.0
*/
export default class JobsApi {
/**
* 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.
*/
constructor(apiClient) {
this.apiClient = apiClient || ApiClient.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}
*/
jobAsyncPost(body, callback) {
let 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");
}
let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['key'];
let contentTypes = ['application/json'];
let accepts = ['application/json', 'application/octet-stream'];
let returnType = Job;
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>}
*/
jobGet(callback) {
let postBody = null;
let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['key'];
let contentTypes = [];
let accepts = ['application/json', 'application/octet-stream'];
let returnType = [Job];
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}
*/
jobIdDelete(id, callback) {
let 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");
}
let pathParams = {
'id': id
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['key'];
let contentTypes = [];
let accepts = ['application/json', 'application/octet-stream'];
let returnType = Job;
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}
*/
jobIdGet(id, callback) {
let 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");
}
let pathParams = {
'id': id
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['key'];
let contentTypes = [];
let accepts = ['application/json', 'application/octet-stream'];
let returnType = Job;
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}
*/
jobIdPut(id, body, callback) {
let 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");
}
let pathParams = {
'id': id
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['key'];
let contentTypes = ['application/json'];
let accepts = ['application/json', 'application/octet-stream'];
let returnType = Job;
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}
*/
jobPost(body, callback) {
let 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");
}
let pathParams = {
};
let queryParams = {
};
let headerParams = {
};
let formParams = {
};
let authNames = ['key'];
let contentTypes = ['application/json'];
let accepts = ['application/json', 'application/octet-stream'];
let returnType = JobCreateResponse;
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}
*/
jobSyncPost(body, opts, callback) {
opts = opts || {};
let 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");
}
let pathParams = {
};
let queryParams = {
};
let headerParams = {
'X-Response-Type': opts['xResponseType'],
'X-Proxy-Region': opts['xProxyRegion']
};
let formParams = {
};
let authNames = ['key'];
let contentTypes = ['application/json'];
let accepts = ['application/json', 'application/octet-stream'];
let returnType = ProcessedJob;
return this.apiClient.callApi(
'/job/sync', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, null, callback
);
}
}