import { CreateProfileDtoReturnType } from '~/business-logic/core/users/create-user/create-profile/data/dto/protocols'; import createUserPort from '~/business-logic/core/users/create-user/ports'; import AdminUserModel from '~/business-logic/generic/admin-user/common/data/model/adminUserModel'; import { HTTPPovider } from '~/driven/boundaries/http-boundary/httpBoundary'; import { HttpOptionsType } from '~/driven/boundaries/http-boundary/protocols'; import { apiUrls } from '~/driven/utils/configs/appConfig'; const createProfileAdapter = ( userAdmin: AdminUserModel, updateAccessToken: (newAccessToken: string) => void, navigateToAuth: () => void, ): createUserPort['httpProfileHandler'] => { // make url const url = apiUrls.core.createUserProfile; // call http provider const httpProvider = new HTTPPovider( { accessToken: userAdmin.adminUserData.accessToken, refreshToken: userAdmin.adminUserData.refreshToken, }, updateAccessToken, navigateToAuth, ); const httpHandler = (newAccountData: CreateProfileDtoReturnType) => { // api options const httpOptions: HttpOptionsType = { url, method: 'POST', headers: { 'Content-Type': 'application/json', }, data: newAccountData, }; return httpProvider.request(httpOptions); }; return httpHandler; }; export default createProfileAdapter;