import type { AxiosRequestConfig } from 'axios' ; import type { HttpClient } from '../http' ; import type { CompletePasswordReset } from '../user' ; import type { LoginServiceProviderData } from './LoginServiceProviderData' ; import type { RegisteredServiceProvider } from './RegisteredServiceProvider' ; import type { NewServiceProvider } from './NewServiceProvider' ; import type { UpdateServiceProviderData } from './UpdateServiceProviderData' ; export class ServiceProviderAPI { constructor ( private readonly client ) { } public static readonly URL = { COMPLETE : 'complete' , LOGIN : 'login' , PASSWORD_RESET : 'password-reset' , PROVIDER : '/provider' , REGISTER : 'register' , } ; async deleteServiceProvider ( data ) { const config = { data , method : 'delete' , url : `${ ServiceProviderAPI . URL . PROVIDER }` , } ; await this . client . sendJSON ( config ) ; } async getServiceProvider ( ) { const config = { method : 'get' , url : `${ ServiceProviderAPI . URL . PROVIDER }` , } ; const response = await this . client . sendJSON < RegisteredServiceProvider > ( config ) ; return response . data ; } async postLoginServiceProvider ( data ) { const config = { data , method : 'post' , url : `${ ServiceProviderAPI . URL . PROVIDER }/${ ServiceProviderAPI . URL . LOGIN }` , } ; const response = await this . client . sendJSON < RegisteredServiceProvider > ( config ) ; return response . data ; } async postPasswordReset ( data ) { const config = { data , method : 'post' , url : `${ ServiceProviderAPI . URL . PROVIDER }/${ ServiceProviderAPI . URL . PASSWORD_RESET }` , } ; await this . client . sendJSON ( config ) ; } async postPasswordResetComplete ( data ) { const config = { data , method : 'post' , url : `${ ServiceProviderAPI . URL . PROVIDER }/${ ServiceProviderAPI . URL . PASSWORD_RESET }/${ ServiceProviderAPI . URL . COMPLETE }` , } ; await this . client . sendJSON ( config ) ; } async postRegisterServiceProvider ( data ) { const config = { data , method : 'post' , url : `${ ServiceProviderAPI . URL . PROVIDER }/${ ServiceProviderAPI . URL . REGISTER }` , } ; const response = await this . client . sendJSON < RegisteredServiceProvider > ( config ) ; return response . data ; } async putProvider ( data ) { const config = { data , method : 'put' , url : `${ ServiceProviderAPI . URL . PROVIDER }` , } ; await this . client . sendJSON ( config ) ; } }