UNPKG

@lableb/javascript-sdk

Version:

Lableb cloud search client for javascript

48 lines (33 loc) 1.35 kB
import { LablebHttpClient } from "../../http-client"; import { SearchByIdRequestParams } from "../../request/search-by-id/search-by-id.request.type"; import { camelCaseToSnackCaseObject, } from "../../utils"; import { LablebAPIResponseWrapper, LablebSDKContext } from "../lableb-client/lableb-client.type"; import { SearchByIdResponse } from "./search-by-id.type"; /** * call the api(including creating the request and intercept the response) * then inject the feedback data in */ export async function lablebClientSearchById( this: LablebSDKContext, searchOptions: SearchByIdRequestParams ): Promise<LablebAPIResponseWrapper<SearchByIdResponse>> { return await lablebClientNativeSearchById.bind(this)(searchOptions); } /** * use request builder to form the search request * call any interceptor before doing the request * call the api */ async function lablebClientNativeSearchById( this: LablebSDKContext, searchOptions: SearchByIdRequestParams ): Promise<LablebAPIResponseWrapper<SearchByIdResponse>> { const { url, headers, method, params } = await this.requestBuilder.searchById(searchOptions); const interceptedRequestParams = ({ method, url, headers, params: camelCaseToSnackCaseObject(params), }); return await LablebHttpClient(interceptedRequestParams); }