# @proffix/restapi-angular-library

> Programmbibliothek für die einfache Verwendung der PROFFIX REST API in Angular Applikationen

Latest version **3.0.2** (published 2019-04-25) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @proffix/restapi-angular-library
pnpm add @proffix/restapi-angular-library
yarn add @proffix/restapi-angular-library
bun add @proffix/restapi-angular-library
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2019-04-25 |
| First published | 2017-11-14 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 892.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | PROFFIX Software AG |
| Maintainers | proffix |

## Links

- npm: https://www.npmjs.com/package/@proffix/restapi-angular-library
- Repository: https://github.com/PROFFIX-NET/restapi-angular-library
- Homepage: https://github.com/PROFFIX-NET/restapi-angular-library#readme
- Issues: https://github.com/PROFFIX-NET/restapi-angular-library/issues
- npm.io page: https://npm.io/package/@proffix/restapi-angular-library

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^1.9.0

## Recent versions

- 3.0.2 (latest) — 2019-04-25
- 2.0.22 (beta) — 2018-11-28
- 2.0.26 — 2019-04-08
- 2.0.25 — 2019-03-26
- 2.0.24 — 2019-03-26
- 2.0.23 — 2019-03-26
- 3.0.1 — 2019-03-26
- 3.0.0 — 2018-12-14
- 2.0.21 — 2018-11-22
- 2.0.20 — 2018-11-22
- 2.0.19 — 2018-11-06
- 2.0.18 — 2018-08-21
- 2.0.17 — 2018-08-21
- 2.0.16 — 2018-07-03
- 2.0.15 — 2018-07-03
- … 20 more at https://npm.io/package/@proffix/restapi-angular-library/versions

## README

PROFFIX REST API Library für Angular
====================================

Die PROFFIX REST API Library für [Angular](https://angular.io) ermöglicht die einfache Kommunikation mit der PROFFIX REST API in Angular-
Anwendungen. Die Library ist unabhängig von der grafischen Oberfläche und kann mit Ionic oder anderen Frameworks verwendet werden.


Erste Schritte
--------------

Ein lauffähiges Angular-Projekt muss vorhanden sein. Über die [Angular CLI](https://cli.angular.io) lässt sich das einfach erstellen.

### 1. Library im Projekt installieren
Die Library ist über npm verfügbar: `npm install @proffix/restapi-angular-library --save`

### 2. Konfiguration und Bootstrapping
Es muss eine von `Configuration` vererbte Klasse erstellt werden, in der die beiden abstrakten Methoden `requiredWebserviceVersion` und
`requiredLicencedModules` überschrieben werden müssen.

```ts
import { Injectable } from '@angular/core';
import { PxConfiguration, PxModule, PxVersion } from '@proffix/restapi-angular-library';

@Injectable()
export class AppConfiguration extends PxConfiguration {
  public get requiredWebserviceVersion(): PxVersion {
    return { Major: 2, Minor: 7, Patch: 1 };
  }
  public get requiredLicencedModules(): string[] {
    return [ "ZEI", "ADR" ];
  }
}
```

Die `AppConfiguration` muss *Injectable* sein, da sie dem dem Dependency Injector als `Configuration` für die Library mitgegeben werden muss.
Zusätzliche wird das `PxRestApiModule` geladen und über `PxRestApiModule.forRoot()` importiert.

```ts
// Root Module (src/app.module.ts)

import { PxRestApiModule, PxConfiguration } from '@proffix/restapi-angular-library';

// ...
imports: [ PxRestApiModule.forRoot() ],
providers: [
  AppConfiguration,
  { provide: PxConfiguration, useExisting: AppConfiguration }
],
// ...
```

### 3. Verbindungseinstellungen hinterlegen
Die Verbindungseinstellungen (Klasse `ConnectionSettings`) werden durch den `ConnectionSettingsService` im LocalStorage abgelegt.

```ts
// Angular Component

import { PxConnectionSettings, PxConnectionSettingsService } from '@proffix/restapi-angular-library';

// ...
constructor(private connectionSettingsService: PxConnectionSettingsService) {
  let connectionSettings: PxConnectionSettings =  {
    WebserviceUrl: "https://restapi.company.invalid",
    WebservicePasswortHash: "d3612ab62..."
  };
  connectionSettingsService.save(connectionSettings);
}
```
Hinweis: Der SHA256 kann über die statische Methode `Hash.sha256` erstellt werden, nachdem die Klasse `Hash` importiert wurde.

### 4. Login durchführen
Der Login kann durchgeführt werden, wenn gültige Verbindungseinstellungen hinterlegt wurden.

```ts
// Angular Component

import { PxLogin, PxLoginService, PxConfiguration } from '@proffix/restapi-angular-library';

// ...
constructor(private loginService: PxLoginService, private configuration: PxConfiguration) {
  let login: PxLogin =  {
    Benutzer: "pxuser",
    Passwort: "d3612ab62...",
    Datenbank: { Name: "PXDB" },
    Module: this.configuration.getRequiredLicencedModulesAsStringArray() // Die Module können aus der AppConfiguration gelesen werden
  };
  this.loginService.doLogin(login).subscribe( // nur zu Anschauungszwecken, nie HTTP-Requests in einem Konstruktor absetzen
      login => console.log("Login successful: " + login.Benutzer),
      error => console.log("Login failed")
    );
}
```

---
_Source: https://npm.io/package/@proffix/restapi-angular-library · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
