/** * State object * @typedef {Object} HttpState * @property data - the parsed response body * @property response - the response from the HTTP server, including headers, statusCode, body, etc * @property references - an array of all previous data objects used in the Job **/ /** * Options provided to the HTTP request * @typedef {Object} RequestOptions * @public * @property {object|string} body - body data to append to the request. JSON will be converted to a string (but a content-type header will not be attached to the request). * @property {object} errors - Map of errorCodes -> error messages, ie, `{ 404: 'Resource not found;' }`. Pass `false` to suppress errors for this code. * @property {object} form - Pass a JSON object to be serialised into a multipart HTML form (as FormData) in the body. * @property {object} query - An object of query parameters to be encoded into the URL. * @property {object} headers - An object of headers to append to the request. * @property {string} parseAs - Parse the response body as json, text or stream. By default will use the response headers. * @property {number} timeout - Request timeout in ms. Default: 300 seconds. * @property {object} tls - TLS/SSL authentication options. See https://nodejs.org/api/tls.html#tlscreatesecurecontextoptions */ /** * Make a GET request to Stripe * @example Get all invoices * http.get('/invoices') * @function * @public * @param {string} path - Path to resource * @param {RequestOptions} options - Optional request options * @returns {Operation} * @state {HttpState} */ export function get(path: string, options: RequestOptions): Operation; /** * Make a POST request to Stripe * @example Post a new payment intent * http.post( * '/payment_intents', * {}, * { * query: { * amount: 10000, * currency: 'usd', * }, * } * ); * @function * @public * @param {string} path - Path to resource * @param {object} body - Object which will be attached to the POST body * @param {RequestOptions} options - Optional request options * @returns {Operation} * @state {HttpState} */ export function post(path: string, body: object, options: RequestOptions): Operation; /** * Make a general HTTP request to Stripe * @example Get all customers * http.request('GET', 'customers'); * @function * @public * @param {string} method - HTTP method to use * @param {string} path - Path to resource * @param {object} body - Object which will be attached to the POST body * @param {RequestOptions} options - Optional request options * @returns {Operation} * @state {HttpState} */ export function request(method: string, path: string, body: object, options?: RequestOptions): Operation; /** * State object */ export type HttpState = { /** * - the parsed response body */ data: any; /** * - the response from the HTTP server, including headers, statusCode, body, etc */ response: any; /** * - an array of all previous data objects used in the Job */ references: any; }; /** * Options provided to the HTTP request */ export type RequestOptions = any;