import { ProviderService as ProviderServiceAbstraction } from "../abstractions/provider.service" ; import { StateService } from "../abstractions/state.service" ; import { ProviderData } from "../models/data/providerData" ; import { Provider } from "../models/domain/provider" ; export class ProviderService implements ProviderServiceAbstraction { constructor ( private stateService ) { } async get ( id ) { const providers = await this . stateService . getProviders ( ) ; if ( providers == null || ! providers . hasOwnProperty ( id ) ) { return null ; } return new Provider ( providers [ id ] ) ; } async getAll ( ) { const providers = await this . stateService . getProviders ( ) ; const response = [ ] ; for ( const id in providers ) { if ( providers . hasOwnProperty ( id ) ) { response . push ( new Provider ( providers [ id ] ) ) ; } } return response ; } async save ( providers ) { await this . stateService . setProviders ( providers ) ; } }