npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@aurigma/axios-storefront-products-api-client

v2.50.1

Published

Axios API Client for Storefront API service of Customer's Canvas web-to-print system.

Downloads

2,491

Readme

Aurigma Customer's Canvas SDK - Storefront API Client

This module is an Axios API client for Storefront 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-storefront-products-api-client

NodeJs

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

const storefront = require("@aurigma/axios-storefront-products-api-client");
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 storefront.ApiClientConfiguration();
config.apiUrl = apiUrl;
config.setAuthorizationToken(token);

const productsApiClient =
  new storefront.ProductsApiClient(config);
const products = await productsApiClient.getAllProducts();

Frontend

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

import {
  ApiClientConfiguration,
  ProductsApiClient,
} from "@aurigma/axios-storefront-products-api-client";

// A token should be received from your backend
const token = "";
// 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";

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

const productsClient = new ProductsApiClient(config);
productsClient.getAllProducts().then((data) => console.log(data));

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

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