import { HttpClient , HttpRequest , HttpResponse } from '@/data/protocols/http' ; import { GetStorage } from '@/data/protocols/cache' ; export class AuthorizeHttpClientDecorator implements HttpClient { constructor ( private readonly getStorage , private readonly httpClient ) { } async request ( data ) { const account = this . getStorage . get ( 'account' ) ; if ( account ?. accessToken ) { Object . assign ( data , { headers : Object . assign ( data . headers || { } , { 'x-access-token' : account . accessToken } ) } ) ; } const httpResponse = await this . httpClient . request ( data ) ; return httpResponse ; } }