/** * State object * @typedef {Object} PrimeroHttpState * @property data - The response body (as JSON) * @property response - The HTTP response from the Primero server (excluding the body). Responses will be returned in JSON format * @property references - An array of all previous data objects used in the Job * @private */ /** * Options object * @typedef {Object} RequestOptions * @property {object} query - An object of query parameters to be encoded into the URL * @property {object} headers - An object of all request headers * @property {string} [parseAs='json'] - The response format to parse (e.g., 'json', 'text', or 'stream') */ /** * Make a GET request to any Primero endpoint. * @public * @function * @example GET all cases * http.get('/cases'); * @param {string} path - Path to the resource. * @param {RequestOptions} [options = {}] - An object containing query params and headers for the request * @state {PrimeroHttpState} * @returns {Operation} */ export function get(path: string, options?: RequestOptions): Operation; /** * Make a POST request to any Primero endpoint. * @public * @example POST a case to Primero * http.post('cases',{ * age: 16, * sex: "female", * name: "Edwine Edgemont", * }); * @function * @param {string} path - Path to the resource. * @param {object} data - the body data in JSON format. * @param {RequestOptions} [options={}] - An object containing query params and headers for the request * @state {PrimeroHttpState} * @returns {Operation} */ export function post(path: string, data: object, options?: RequestOptions): Operation; /** * Make a PATCH request to Primero * @public * @example Update a single case resource * http.patch('cases/344f3c08-affc-4d8a-b4d3-925b9f4d2867', { * age: 17, * sex: "female", * name: "Edwine Edgemont", * }); * @function * @param {string} path - Path to the resource. * @param {object} data - the body data in JSON format. * @param {RequestOptions} [options={}] - An object containing query params and headers for the request * @state {PrimeroHttpState} * @returns {Operation} */ export function patch(path: string, data: object, options?: RequestOptions): Operation; /** * State object */ export type PrimeroHttpState = { /** * - The response body (as JSON) */ data: any; /** * - The HTTP response from the Primero server (excluding the body). Responses will be returned in JSON format */ response: any; /** * - An array of all previous data objects used in the Job */ references: any; }; /** * Options object */ export type RequestOptions = { /** * - An object of query parameters to be encoded into the URL */ query: object; /** * - An object of all request headers */ headers: object; /** * - The response format to parse (e.g., 'json', 'text', or 'stream') */ parseAs?: string; };