30 lines
954 B
TypeScript
30 lines
954 B
TypeScript
import { GetPlacesResponse } from '~/business-logic/core/places/get-places/data/response-object/protocols';
|
|
import IGetPlacesPort from '~/business-logic/core/places/get-places/port';
|
|
import { HTTPPovider } from '~/driven/boundaries/http-boundary/httpBoundary';
|
|
import { HttpOptionsType } from '~/driven/boundaries/http-boundary/protocols';
|
|
import { apiUrls } from '~/driven/utils/configs/appConfig';
|
|
import { getPlacesAdapterReturnType } from './protocols';
|
|
|
|
const getPlacesAdapter = (): IGetPlacesPort & getPlacesAdapterReturnType => {
|
|
// url of api
|
|
const url = apiUrls.core.getPlaces;
|
|
// make the options of request
|
|
const options: HttpOptionsType = {
|
|
url,
|
|
method: 'GET',
|
|
};
|
|
// make the httpHandler
|
|
const httpProvider = new HTTPPovider();
|
|
|
|
const httpHandler = async () =>
|
|
httpProvider.request<GetPlacesResponse>(options);
|
|
|
|
// return the method
|
|
return {
|
|
httpHandler,
|
|
url,
|
|
};
|
|
};
|
|
|
|
export default getPlacesAdapter;
|