import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { Observable } from 'rxjs' ; import { environment } from '../../../../environments/environment' ; import { Account } from '../../accounts/models/account' ; const baseUrl = environment . baseCustomerServiceUrl ; @ Injectable ( { providedIn : 'root' } ) export class AccountService { constructor ( private http ) { } fetchAllAccounts ( ) { let url = `${ baseUrl }/accounts` ; console . log ( "Fetch all accounts URL is " + url ) ; return this . http . get < Account [ ] > ( url ) ; } fetchById ( id ) { let url = `${ baseUrl }/accounts/${ id }` ; console . log ( "Fetch account URL is " + url ) ; return this . http . get < Account > ( url ) ; } createAccount ( account ) { let url = `${ baseUrl }/accounts` ; console . log ( "Create account URL is " + url ) ; return this . http . post < Account > ( url , account ) ; } updateAccount ( account ) { let url = `${ baseUrl }/accounts/${ account . id }` ; console . log ( "Update account URL is " + url ) ; return this . http . put < Account > ( url , account ) ; } }