open-index/open-npm huggingface dataset:
npm package: @funxtion/ng-funxtion-api-client
Description: This is an Angular library for communication with the [Funxtion API v2](https://developers.funxtion.com/docs/2.0/introduction).
Latest version: 1.5.3

# Funxtion API Client for Angular

This is an Angular library for communication with the [Funxtion API v2](https://developers.funxtion.com/docs/2.0/introduction).

## Installation

```
npm i @funxtion/ng-funxtion-api-client
```

### Dependencies <a id="dependencies"></id>

#### OAuth 2

[Manfred Steyer's Angular OAuth 2](https://manfredsteyer.github.io/angular-oauth2-oidc/docs/)

```
npm i angular-oauth2-oidc
```

This service can be accessed through `FunxtionApiClientService.oauth`.

#### JSON API

[Ghidoz' Angular 2 JSON API](https://github.com/ghidoz/angular2-jsonapi)

```
npm i angular2-jsonapi
```

This 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

```typescript
import { NgModule } from '@angular/core';
import { FunxtionApiClientModule, FunxtionApiClientService } from '@funxtion/ng-funxtion-api-client';

@NgModule({
    imports: [FunxtionApiClientModule],
    providers: [FunxtionApiClientService]
})
export class AppModule {}
```

### AppComponent

```typescript
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](#dependencies), 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