import { makeRequest } from './make-request'; import { HttpRequest } from '../types/request'; import { HttpResponse } from '../types/response'; /** * A function that makes a HTTP request with the POST method * @param url URL for the request * @param key secret key for the request * @param body raw body for the request * @param additionalHeaders any headers that are additional to contentType and x-api-key * @param targetApiSystemCode the BizOps system code to which the request is being made * @param expectEmptyResponse indicates that the expected Response will have empty body * @returns it returns an HTTP promise response */ export async function post({ url, key, body, additionalHeaders = {}, targetApiSystemCode = '', expectEmptyResponse = false }: HttpRequest, fetch: Function): Promise { const options = { method: 'POST', headers: { 'Content-Type': 'application/json', 'X-api-key': key, ...additionalHeaders }, body: JSON.stringify(body) }; return makeRequest(url, options, fetch, targetApiSystemCode, expectEmptyResponse); }