UNPKG

@aurigma/ng-backoffice-api-client

Version:

Angular API Client for BackOffice API service of Customer's Canvas web-to-print system.

80 lines (56 loc) 3.18 kB
Aurigma Customer's Canvas SDK - BackOffice API Client ====================================================== This module is an Angular API client for BackOffice API service which is a part of [**Customer's Canvas**](https://customerscanvas.com) web-to-print system. It is supposed that you are familiar with its services and understand how to use its APIs. To learn more about Customer's Canvas and its services, refer the [Getting Started section of its documentation](https://customerscanvas.com/dev/getting-started/intro.html). The API client is automatically generated with [NSwag tool](https://github.com/RicoSuter/NSwag). If for any reasons this API client does not work well for you, feel free to generate it yourself using Swagger document published at [Customer's Canvas API Gateway](https://api.customerscanvashub.com/). ## Pre-requisites To be able to use this package, you need to meet the following requirements: * You must have an account at Customer's Canvas. * You need to use it in Angular applications **only**. For other platforms, see the [Backend services](https://customerscanvas.com/dev/getting-started/about-backend-services.html) article in Customer's Canvas documentation. ## Usage Install it as a regular npm package: ``` npm install @aurigma/ng-backoffice-api-client ``` Receive an access token through your backend as explained in the [documentation](https://customerscanvas.com/dev/getting-started/about-backend-services.html#authorization) and deliver it to your app. Setup module parameters in the **app.module.ts**: ``` ts import {BackOfficeApiModule} from '@aurigma/ng-backoffice-api-client'; // ... // In general you can use "https://api.customerscanvashub.com" as a base api url. // But this url may be different for on-premises version of Customer's Canvas const baseApiUrl = "https://api.customerscanvashub.com"; // A token should be received from your backend const accessToken = "..."; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, HttpClientModule, BackOfficeApiModule.forRoot(accessToken, baseApiUrl, null) ], providers: [], bootstrap: [AppComponent] }) export class AppModule { } ``` Now you can inject this module in your services. For example, imagine that you want to use it in a **app.component.ts**. For simplicity, we will just request a service version information. However, you can use other clients in a similar manner. It may look as follows: ``` ts import { Component } from '@angular/core'; import { BuildInfoApiClient } from '@aurigma/ng-backoffice-api-client'; @Component({ selector: 'app-root', templateUrl: './app.component.html', styleUrls: ['./app.component.scss'] }) export class AppComponent { constructor(private buildInfo: BuildInfoApiClient) { this.buildInfo.getInfo().subscribe(info => console.log(info)); } } ``` To find out what other clients are available in this module, refer [BackOffice API Reference](https://customerscanvas.com/dev/backend/backend/api/BackOfficeApi.OpenApi2.html). > NOTE: The class name for each client is formed as <i>ClientName</i>ApiClient, e.g. `BuildInfo` -> `BuildInfoApiClient`, etc.