2.55.1 • Published 8 days ago

@aurigma/axios-asset-storage-api-client v2.55.1

Weekly downloads
-
License
SEE LICENSE IN Li...
Repository
-
Last release
8 days ago

Aurigma Customer's Canvas SDK - Asset Storage API Client

This module is an Axios API client for Asset Storage API service which is a part of Customer's Canvas 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.

The API client is automatically generated with NSwag tool. 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.

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 Javascript\Typescript applications.

For other platforms, see the Backend services article in Customer's Canvas documentation.

Usage

Install it as a regular npm package:

npm install @aurigma/axios-asset-storage-api-client

NodeJs

Receive an access token through your backend as explained in the documentation and deliver it to your app.

const assetStorageApiClient = require("@aurigma/axios-asset-storage-api-client").AssetStorageApiClient;
const axios = require("axios").default;

// You need to create external app in BackOffice with required scopes to receive clientId\clientSecret
// https://customerscanvas.com/dev/getting-started/about-backend-services.html#authorization
const clientId = "";
const clientSecret = "";
const apiUrl = "https://api.customerscanvashub.com/";

const getToken = async (clientId, clientSecret) => {
  const requestConfig = {
    method: "post",
    url: apiUrl + "connect/token",
    headers: {
      "Content-Type": "application/x-www-form-urlencoded",
    },
    data: new URLSearchParams({
      client_id: clientId,
      client_secret: clientSecret,
      grant_type: "client_credentials",
    }),
  };

  const response = await axios(requestConfig);
  return response.data["access_token"];
};

const token = await getToken(clientId, clientSecret);

And then you can call ApiClients methods with this token:

const config = new assetStorageApiClient.ApiClientConfiguration();
config.apiUrl = apiUrl;
config.setAuthorizationToken(token);

const buildInfoClient = new assetStorageApiClient.BuildInfoApiClient(config);
const buildInfo = await buildInfoClient.getInfo();

const designsClient = new assetStorageApiClient.DesignsApiClient(config);
const designs = await designsClient.getAll();

console.log(token);
console.log(buildInfo);
console.log(designs);

Frontend

You should retrieve access token from your backend, how it's explained above.

import { AssetStorageApiClient } from "@aurigma/axios-asset-storage-api-client";

// get token on backend by clientId\clientSecret. Never use clientId\clientSecret on frontend!
// https://customerscanvas.com/dev/getting-started/about-backend-services.html#authorization
const token = "";

const config = new AssetStorageApiClient.ApiClientConfiguration();
config.apiUrl = "";
config.setAuthorizationToken(token);

const buildInfoClient = new AssetStorageApiClient.BuildInfoApiClient(config)
buildInfoClient.getInfo().then(data => console.log(data));

const designsClient = new AssetStorageApiClient.DesignsApiClient(config);
designsClient.getAll(undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, undefined, 1)
             .then(data => console.log(data));

To find out what other clients are available in this module, refer Asset Storage API Reference.

NOTE: The class name for each client is formed as ClientNameApiClient, e.g. BuildInfo -> BuildInfoApiClient, etc.

2.55.1

8 days ago

2.54.1

1 month ago

2.53.1

2 months ago

2.53.2

2 months ago

2.52.1

2 months ago

2.51.1

3 months ago

2.50.1

3 months ago

2.46.1

6 months ago

2.48.1

5 months ago

2.42.1

9 months ago

2.44.1

7 months ago

2.43.1

8 months ago

2.41.1

11 months ago

2.39.5

1 year ago

2.39.1

1 year ago

2.38.1

1 year ago

2.38.3

1 year ago

2.37.1

1 year ago

2.36.2

1 year ago

2.34.1

1 year ago

2.35.2

1 year ago

2.31.6

1 year ago

2.31.1

1 year ago

2.30.1

2 years ago

2.33.1

1 year ago

2.32.2

1 year ago

2.28.1

2 years ago

2.29.1

2 years ago

2.22.1

2 years ago

2.23.1

2 years ago

2.26.1

2 years ago

2.21.1

2 years ago

2.20.1

2 years ago

2.18.1

2 years ago

2.19.1

2 years ago

2.17.1

2 years ago

2.16.1

2 years ago