@funxtion/ng-funxtion-api-client
v1.5.3
Published
This is an Angular library for communication with the [Funxtion API v2](https://developers.funxtion.com/docs/2.0/introduction).
Keywords
Readme
Funxtion API Client for Angular
This is an Angular library for communication with the Funxtion API v2.
Installation
npm i @funxtion/ng-funxtion-api-clientDependencies
OAuth 2
Manfred Steyer's Angular OAuth 2
npm i angular-oauth2-oidcThis service can be accessed through FunxtionApiClientService.oauth.
JSON API
npm i angular2-jsonapiThis service can be accessed through FunxtionApiClientService.datastore.
Refreshing of tokens happens automatically in the OauthService for logged in users. This service also passes the tokens to the DatastoreService.
Environment
Implement the EnvironmentVariables interface on your environment file. Do this for both your local and production environment files.
Usage
AppModule
import { NgModule } from '@angular/core';
import { FunxtionApiClientModule, FunxtionApiClientService } from '@funxtion/ng-funxtion-api-client';
@NgModule({
imports: [FunxtionApiClientModule],
providers: [FunxtionApiClientService]
})
export class AppModule {}AppComponent
import { FunxtionApiClientService } from '@funxtion/ng-funxtion-api-client';
import { environment } from '../environments/environment';
export class AppComponent {
constructor(private funxtion: FunxtionApiClientService) {
this.funxtion.setup(environment).then(() => {
// optionally listen for API errors
this.funxtion.datastore.error$.subscribe((error) => {
// handle the error(s)
});
// other logic for the app
});
}
}Services
In addition to the third party services mentioned in the dependencies section, the library contains the following custom services:
UserService
Use this service for managing user actions.
Properties
- data (User model)
- password (can be used for form model binding, gets erased after login and register)
Methods
- login
- logout
- register
- getUser
ClientService
Use this service for managing client actions.
Properties
- data (Client model)
Methods
- getClient
