diff --git a/src/base/client.ts b/src/base/client.ts index 98e2b33..562c5f3 100644 --- a/src/base/client.ts +++ b/src/base/client.ts @@ -26,11 +26,12 @@ config(); * * @class ClientConfig */ -export class ClientConfig { +export class ClientConfig { public baseUri?: string; public cacheManager?: ICacheManager; public headers?: BasicHeaders; - public parameters?: CommonParameters; + // Params defaults to CommonParameters + public parameters?: Params; public retrySettings?: OperationOptions; public fetchOptions?: RequestInit; } diff --git a/src/base/staticClient.ts b/src/base/staticClient.ts index df4194e..90da65f 100644 --- a/src/base/staticClient.ts +++ b/src/base/staticClient.ts @@ -34,6 +34,7 @@ export type SdkFetchOptions = { rawResponse?: boolean; retrySettings?: OperationOptions; fetchOptions?: RequestInit; + disableTransformBody?: boolean; body?: unknown; }; @@ -175,7 +176,7 @@ export const transformRequestBody = ( * @returns Either the Response object or the DTO inside it wrapped in a promise, * depending upon options.rawResponse */ -async function runFetch( +export async function runFetch( method: "delete" | "get" | "patch" | "post" | "put", options: SdkFetchOptions ): Promise { @@ -218,7 +219,9 @@ async function runFetch( }; if (typeof options.body !== "undefined") { - fetchOptions.body = transformRequestBody(options.body, fetchOptions); + fetchOptions.body = options.disableTransformBody + ? (options.body as BodyInit) + : transformRequestBody(options.body, fetchOptions); } logFetch(resource, fetchOptions); diff --git a/src/index.ts b/src/index.ts index c01fc20..6717902 100644 --- a/src/index.ts +++ b/src/index.ts @@ -12,7 +12,14 @@ export { ResponseError, } from "./base/client"; -import { _get, _delete, _patch, _post, _put } from "./base/staticClient"; +import { + _get, + _delete, + _patch, + _post, + _put, + runFetch, +} from "./base/staticClient"; export { getObjectFromResponse, @@ -26,6 +33,7 @@ export const StaticClient = { patch: _patch, post: _post, put: _put, + runFetch, }; export { IAuthToken, ShopperToken, stripBearer } from "./base/authHelper";