@aurigma/axios-backoffice-api-client 2.54.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,9 @@
1
+ # LICENSING TERMS
2
+
3
+ The axios-backoffice-api-client library is a part of Aurigma's Customer's Canvas software. It is covered by the same terms as Customer's Canvas:
4
+
5
+ [https://customerscanvas.com/docs/cc/licensing.htm](https://customerscanvas.com/docs/cc/licensing.htm)
6
+
7
+ It means that if you already have a valid Customer's Canvas license or in a process of its evaluation, feel free to use the axios-backoffice-api-client.
8
+
9
+ You can not use any part of this library separately.
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # Aurigma Customer's Canvas SDK - BackOffice API Client
2
+
3
+ This module is an Axios 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).
4
+
5
+ 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/).
6
+
7
+ ## Pre-requisites
8
+
9
+ To be able to use this package, you need to meet the following requirements:
10
+
11
+ - You must have an account at Customer's Canvas.
12
+ - You need to use it in Javascript\Typescript applications.
13
+
14
+ For other platforms, see the [Backend services](https://customerscanvas.com/dev/getting-started/about-backend-services.html) article in Customer's Canvas documentation.
15
+
16
+ ## Usage
17
+
18
+ Install it as a regular npm package:
19
+
20
+ ```
21
+ npm install @aurigma/axios-backoffice-api-client
22
+ ```
23
+
24
+ ### NodeJs
25
+
26
+ 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.
27
+
28
+ ```js
29
+ const backoffice = require("@aurigma/axios-backoffice-api-client");
30
+ const axios = require("axios").default;
31
+
32
+ // You need to create external app in BackOffice with required scopes to receive clientId\clientSecret
33
+ // https://customerscanvas.com/dev/getting-started/about-backend-services.html#authorization
34
+ const clientId = "";
35
+ const clientSecret = "";
36
+ const apiUrl = "https://api.customerscanvashub.com/";
37
+
38
+ const getToken = async (clientId, clientSecret) => {
39
+ const requestConfig = {
40
+ method: "post",
41
+ url: apiUrl + "connect/token",
42
+ headers: {
43
+ "Content-Type": "application/x-www-form-urlencoded",
44
+ },
45
+ data: new URLSearchParams({
46
+ client_id: clientId,
47
+ client_secret: clientSecret,
48
+ grant_type: "client_credentials",
49
+ }),
50
+ };
51
+
52
+ const response = await axios(requestConfig);
53
+ return response.data["access_token"];
54
+ };
55
+
56
+ const token = await getToken(clientId, clientSecret);
57
+ ```
58
+
59
+ And then you can call ApiClients methods with this token:
60
+
61
+ ```js
62
+ const config = new backoffice.ApiClientConfiguration();
63
+ config.apiUrl = apiUrl;
64
+ config.setAuthorizationToken(token);
65
+
66
+ const buildInfoClient = new backoffice.BuildInfoApiClient(config);
67
+ const buildInfo = await buildInfoClient.getInfo();
68
+ ```
69
+
70
+ ### Frontend
71
+
72
+ You should retrieve access token from your backend, how it's explained above.
73
+
74
+ ```ts
75
+ import {
76
+ ApiClientConfiguration,
77
+ BuildInfoApiClient,
78
+ } from "@aurigma/axios-backoffice-api-client";
79
+
80
+ // A token should be received from your backend
81
+ const token = "";
82
+ // In general you can use "https://api.customerscanvashub.com" as a base api url.
83
+ // But this url may be different for on-premises version of Customer's Canvas
84
+ const baseApiUrl = "https://api.customerscanvashub.com";
85
+
86
+ const config = new ApiClientConfiguration();
87
+ config.apiUrl = baseApiUrl;
88
+ config.setAuthorizationToken(token);
89
+
90
+ const buildInfoClient = new BuildInfoApiClient(config);
91
+ buildInfoClient.getInfo().then((data) => console.log(data));
92
+ ```
93
+
94
+ 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).
95
+
96
+ > NOTE: The class name for each client is formed as <i>ClientName</i>ApiClient, e.g. `BuildInfo` -> `BuildInfoApiClient`, etc.