import { Injectable , Inject , Optional } from '@angular/core' ; import { Http , Response } from '@angular/http' ; import { SDKModels } from './SDKModels' ; import { BaseLoopBackApi } from '../core/base.service' ; import { LoopBackConfig } from '../../lb.config' ; import { LoopBackAuth } from '../core/auth.service' ; import { LoopBackFilter , SDKToken , AccessToken } from '../../models/BaseModels' ; import { JSONSearchParams } from '../core/search.params' ; import { ErrorHandler } from '../core/error.service' ; import { Subject } from 'rxjs/Subject' ; import { Observable } from 'rxjs/Rx' ; import { User } from '../../models/User' ; /**
 * Api services for the `User` model.
 */ @ Injectable ( ) export class UserApi extends BaseLoopBackApi { constructor ( @ Inject ( Http ) protected http , @ Inject ( SDKModels ) protected models , @ Inject ( LoopBackAuth ) protected auth , @ Inject ( JSONSearchParams ) protected searchParams , @ Optional ( ) @ Inject ( ErrorHandler ) protected errorHandler ) { super ( http , models , auth , searchParams , errorHandler ) ; } param { any } id param { any } fk returns { object } public findByIdAccessTokens ( id , fk ) { let _method = "GET" ; let _url = LoopBackConfig . getPath ( ) + "/" + LoopBackConfig . getApiVersion ( ) + "/Users/:id/accessTokens/:fk" ; let _routeParams = { id : id , fk : fk } ; let _postBody = { } ; let _urlParams = { } ; let result = this . request ( _method , _url , _routeParams , _urlParams , _postBody ) ; return result ; } param { any } id param { any } fk returns { object } public destroyByIdAccessTokens ( id , fk ) { let _method = "DELETE" ; let _url = LoopBackConfig . getPath ( ) + "/" + LoopBackConfig . getApiVersion ( ) + "/Users/:id/accessTokens/:fk" ; let _routeParams = { id : id , fk : fk } ; let _postBody = { } ; let _urlParams = { } ; let result = this . request ( _method , _url , _routeParams , _urlParams , _postBody ) ; return result ; } param { any } id param { any } fk param { object } data returns { object } public updateByIdAccessTokens ( id , fk , data = { } ) { let _method = "PUT" ; let _url = LoopBackConfig . getPath ( ) + "/" + LoopBackConfig . getApiVersion ( ) + "/Users/:id/accessTokens/:fk" ; let _routeParams = { id : id , fk : fk } ; let _postBody = { data : data } ; let _urlParams = { } ; let result = this . request ( _method , _url , _routeParams , _urlParams , _postBody ) ; return result ; } param { any } id param { object } filter returns { object [ ] } public getAccessTokens ( id , filter = { } ) { let _method = "GET" ; let _url = LoopBackConfig . getPath ( ) + "/" + LoopBackConfig . getApiVersion ( ) + "/Users/:id/accessTokens" ; let _routeParams = { id : id } ; let _postBody = { } ; let _urlParams = { } ; if ( filter ) _urlParams . filter = filter ; let result = this . request ( _method , _url , _routeParams , _urlParams , _postBody ) ; return result ; } param { any } id param { object } data returns { object } public createAccessTokens ( id , data = { } ) { let _method = "POST" ; let _url = LoopBackConfig . getPath ( ) + "/" + LoopBackConfig . getApiVersion ( ) + "/Users/:id/accessTokens" ; let _routeParams = { id : id } ; let _postBody = { data : data } ; let _urlParams = { } ; let result = this . request ( _method , _url , _routeParams , _urlParams , _postBody ) ; return result ; } param { any } id returns { object } public deleteAccessTokens ( id ) { let _method = "DELETE" ; let _url = LoopBackConfig . getPath ( ) + "/" + LoopBackConfig . getApiVersion ( ) + "/Users/:id/accessTokens" ; let _routeParams = { id : id } ; let _postBody = { } ; let _urlParams = { } ; let result = this . request ( _method , _url , _routeParams , _urlParams , _postBody ) ; return result ; } param { any } id param { object } where returns { object } public countAccessTokens ( id , where = { } ) { let _method = "GET" ; let _url = LoopBackConfig . getPath ( ) + "/" + LoopBackConfig . getApiVersion ( ) + "/Users/:id/accessTokens/count" ; let _routeParams = { id : id } ; let _postBody = { } ; let _urlParams = { } ; if ( where ) _urlParams . where = where ; let result = this . request ( _method , _url , _routeParams , _urlParams , _postBody ) ; return result ; } param { object } data returns { object } public patchOrCreate ( data = { } ) { let _method = "PATCH" ; let _url = LoopBackConfig . getPath ( ) + "/" + LoopBackConfig . getApiVersion ( ) + "/Users" ; let _routeParams = { } ; let _postBody = { data : data } ; let _urlParams = { } ; let result = this . request ( _method , _url , _routeParams , _urlParams , _postBody ) ; return result ; } param { any } id param { object } data returns { object } public patchAttributes ( id , data = { } ) { let _method = "PATCH" ; let _url = LoopBackConfig . getPath ( ) + "/" + LoopBackConfig . getApiVersion ( ) + "/Users/:id" ; let _routeParams = { id : id } ; let _postBody = { data : data } ; let _urlParams = { } ; let result = this . request ( _method , _url , _routeParams , _urlParams , _postBody ) ; return result ; } param { string } include param { object } data returns { object } public login ( credentials , include = 'user' , rememberMe = true ) { let _method = "POST" ; let _url = LoopBackConfig . getPath ( ) + "/" + LoopBackConfig . getApiVersion ( ) + "/Users/login" ; let _routeParams = { } ; let _postBody = { credentials : credentials } ; let _urlParams = { } ; if ( include ) _urlParams . include = include ; let result = this . request ( _method , _url , _routeParams , _urlParams , _postBody ) . map ( ( response ) => { response . ttl = parseInt ( response . ttl ) ; response . rememberMe = rememberMe ; this . auth . setToken ( response ) ; return response ; } ) ; return result ; } param { object } data returns { object } public logout ( ) { let _method = "POST" ; let _url = LoopBackConfig . getPath ( ) + "/" + LoopBackConfig . getApiVersion ( ) + "/Users/logout" ; let _routeParams = { } ; let _postBody = { } ; let _urlParams = { } ; _urlParams . access_token = this . auth . getAccessTokenId ( ) ; this . auth . clear ( ) ; let result = this . request ( _method , _url , _routeParams , _urlParams , _postBody ) ; return result ; } param { string } uid param { string } token param { string } redirect returns { object } public confirm ( uid , token , redirect = { } ) { let _method = "GET" ; let _url = LoopBackConfig . getPath ( ) + "/" + LoopBackConfig . getApiVersion ( ) + "/Users/confirm" ; let _routeParams = { } ; let _postBody = { } ; let _urlParams = { } ; if ( uid ) _urlParams . uid = uid ; if ( token ) _urlParams . token = token ; if ( redirect ) _urlParams . redirect = redirect ; let result = this . request ( _method , _url , _routeParams , _urlParams , _postBody ) ; return result ; } param { object } data returns { object } public resetPassword ( options ) { let _method = "POST" ; let _url = LoopBackConfig . getPath ( ) + "/" + LoopBackConfig . getApiVersion ( ) + "/Users/reset" ; let _routeParams = { } ; let _postBody = { options : options } ; let _urlParams = { } ; let result = this . request ( _method , _url , _routeParams , _urlParams , _postBody ) ; return result ; } param { object } data returns { object } public changePassword ( oldPassword , newPassword ) { let _method = "POST" ; let _url = LoopBackConfig . getPath ( ) + "/" + LoopBackConfig . getApiVersion ( ) + "/Users/change-password" ; let _routeParams = { } ; let _postBody = { } ; let _urlParams = { } ; if ( oldPassword ) _urlParams . oldPassword = oldPassword ; if ( newPassword ) _urlParams . newPassword = newPassword ; let result = this . request ( _method , _url , _routeParams , _urlParams , _postBody ) ; return result ; } param { any } id param { object } data returns { object [ ] } public createManyAccessTokens ( id , data = [ ] ) { let _method = "POST" ; let _url = LoopBackConfig . getPath ( ) + "/" + LoopBackConfig . getApiVersion ( ) + "/Users/:id/accessTokens" ; let _routeParams = { id : id } ; let _postBody = { data : data } ; let _urlParams = { } ; let result = this . request ( _method , _url , _routeParams , _urlParams , _postBody ) ; return result ; } ngdoc name methodOf description returns public getCurrent ( ) { let _method = "GET" ; let _url = LoopBackConfig . getPath ( ) + "/" + LoopBackConfig . getApiVersion ( ) + "/Users" + "/:id" ; let id = this . auth . getCurrentUserId ( ) ; if ( id == null ) id = '__anonymous__' ; let _routeParams = { id : id } ; let _urlParams = { } ; let _postBody = { } ; return this . request ( _method , _url , _routeParams , _urlParams , _postBody ) ; } /**
     * Get data of the currently logged user that was returned by the last
     * call to  sdk . User or
     *  sdk . User . Return null when there
     * is no user logged in or the data of the current user were not fetched
     * yet.
     *
     *  returns public getCachedCurrent ( ) { return this . auth . getCurrentUserData ( ) ; } /**
     * Get data of the currently logged access tokern that was returned by the last
     * call to  sdk . User returns public getCurrentToken ( ) { return this . auth . getToken ( ) ; } name returns { boolean } public isAuthenticated ( ) { return ! ( this . getCurrentId ( ) === '' || this . getCurrentId ( ) == null || this . getCurrentId ( ) == 'null' ) ; } name returns public getCurrentId ( ) { return this . auth . getCurrentUserId ( ) ; } /**
     * The name of the model represented by this $resource,
     * i.e. `User`.
     */ public getModelName ( ) { return "User" ; } }