@hyperone/client
TypeScript icon, indicating that this package has built-in type declarations

0.0.5 • Public • Published

@hyperone/client

@hyperone/client is an automatically generated library used to interact with HyperOne API.

Installation

You are able to get this library using npm, or yarn.

Installation using yarn

yarn add @hyperone/client

Installation using npm

npm i @hyperone/client

Usage

The recommended way to use this package is to use it along with @hyperone/credentials library. To to that install @hyperone/credentials using your package manager:

yarn:

yarn add @hyperone/credentials

npm:

npm i @hyperone/credentials

Then import use it as a token provider in your code:

import { getPassportCredentialsHelper } from "@hyperone/credentials";
import { Credentials } from "@hyperone/client";

const helper = getPassportCredentialsHelper();
const config = new Configuration({
  accessToken: () => helper.getToken("https://api.hyperone.com/v2"), // token audience
});

You can acquire more knoweledge about @hyperone/credentials library on its GitHub page.

Configuration object allows you to use choosen API client.

Example:

import { getPassportCredentialsHelper } from "@hyperone/credentials";
import { Configuration, IamProjectApi } from "@hyperone/client";

const helper = getPassportCredentialsHelper();
const config = new Configuration({
  accessToken: () => helper.getToken("https://api.hyperone.com/v2"), // token audience
});

const getProjects = async () => {
  const projectApiClient = new IamProjectApi(config);
  const response = await projectApiClient.iamProjectList();
  console.log(response);
};

getProjects();

"Prefer" header

Some operations on API may be time-consuming. In this case server may return HTTP Status 202 with x-event-id header containing request ID, and handle the operation asynchronously. If you want to avoid this behavior, you can send prefer header RFC7240 with your request, which will cause returning the operation result as response to this request.

To use this header from sdk simply add baseOptions object to your configuration:

const config = new Configuration({
  accessToken: () => helper.getToken("https://api.hyperone.com/v2"),
  baseOptions: {
    headers: {
      Prefer: `respond-async,wait=${60 * 60 * 24}`,
    },
  },
});

You can get more information about prefer usage in HyperOne API in its documentation.

Documentation

For full documentation of this library check docs directory.

Package Sidebar

Install

npm i @hyperone/client

Weekly Downloads

21

Version

0.0.5

License

Unlicense

Unpacked Size

13 MB

Total Files

377

Last publish

Collaborators

  • frederico.silva
  • adobrawy