import { Inject , Injectable } from '@angular/core' ; import 'rxjs/add/operator/toPromise' ; import { Http , Headers , Response , RequestOptions } from '@angular/http' ; import { UtilsService } from "./utils.service" ; import { environment } from "../../environments/environment" ; import { ContextService } from "./context.service" ; import { Router } from "@angular/router" ; @ Injectable ( ) export class AccountService { constructor ( private context , private router , private http , private utils ) { } login ( username , password ) { let body = { "id" : username , "password" : password } ; const headers = new Headers ( { 'content-type' : 'application/json' } ) ; const options = new RequestOptions ( { headers : headers } ) ; return this . http . post ( '' , body ) . toPromise ( ) . then ( ( response ) => { return response . json ( ) ; } ) . catch ( this . utils . catchError ) ; } resetPassword ( email ) { return this . utils . setTimeoutPromise ( 1000 ) . then ( ( ) => { let response = { success : false } ; return response . success ; } ) ; } createAccount ( email , password ) { return this . utils . setTimeoutPromise ( 1000 ) . then ( ( ) => { let response = { success : false } ; return response . success ; } ) ; } getNotifications ( ) { return this . utils . setTimeoutPromise ( 0 ) . then ( ( ) => { return { requests : 3 } ; } ) ; } }