/** * State object * @typedef {Object} HTTPState * @property data - the parsed response body * @property response - the response from the SurveyCTO server, including headers, statusCode, body, etc * @property references - an array of all previous data objects used in the Job **/ /** * Options provided to request() * @typedef {Object} RequestOptions * @public * @property {object} [headers] - An object of headers parameters. * @property {object} [body] - Body data to append to the request. * @property {object} [query] - An object of query parameters to be encoded into the URL. * @property {object} [contentType] - Set the content-type header to the appropriate format. Supported values: `json` and `form` * @property {string} [method = GET] - The HTTP method to use. */ /** * Make a HTTP request to SurveyCTO * @public * @example Post JSON data to SurveyCTO * http.request("/anEndpoint", { * method: "POST", * contentType: "json", * body: $.data, * }); * @example Upload a CSV blob to a dataset * http.request('datasets/library/records/upload', { * method: 'POST', * contentType: 'form', * body: { * file: { * blob: $.data, * type: 'text/csv', * filename: 'library.csv' * } * }, * }); * @function * @param {string} path - Path to resource * @param {RequestOptions} params - Query, body, headers and method parameters * @returns {Operation} * @state {HTTPState} */ export function request(path: string, params: RequestOptions): Operation; /** * Get resources from SurveyCTO * @public * @example Get a record with id * http.get('/datasets/enumerators_dataset/record', { * query: { * recordId: '4', * }, * }); * @example Get a dataset with id * http.get('/datasets/enumerators_dataset') * @example Get a dataset in csv format * http.get('/datasets/data/csv/enumerators_dataset', { * query: { * asAttachment: true, * }, * }); * @function * @param {string} path - Path to resource * @param {RequestOptions} params - Query and headers parameters * @returns {Operation} * @state {HTTPState} */ export function get(path: string, params?: RequestOptions): Operation; /** * Send a HTTP POST request to SurveyCTO * @public * @example Purge a dataset * http.post('/datasets/enumeratorse_dataset/purge'); * @function * @param {string} path - Path to resource * @param {RequestOptions} params - Query, body, and headers parameters * @returns {Operation} * @state {HTTPState} */ export function post(path: string, params?: RequestOptions): Operation; /** * Delete resources from SurveyCTO * @public * @alias delete * @example Delete a dataset * http.delete('/datasets/enumerators_dataset'); * @example Delete a dataset record * http.delete('/datasets/enumerators_dataset/record', { * query: { * recordId: 2, * }, * }); * @function * @param {string} path - Path to resource * @param {RequestOptions} params - Query and headers parameters * @returns {Operation} * @state {HTTPState} * */ export function _delete(path: string, params?: RequestOptions): Operation; /** * State object */ export type HTTPState = { /** * - the parsed response body */ data: any; /** * - the response from the SurveyCTO server, including headers, statusCode, body, etc */ response: any; /** * - an array of all previous data objects used in the Job */ references: any; }; /** * Options provided to request() */ export type RequestOptions = any;