@hyperone/client v0.0.5
@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/clientInstallation using npm
npm i @hyperone/clientUsage
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/credentialsnpm:
npm i @hyperone/credentialsThen 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.