TelescopeClient simplifies the process of making requests to the Telescope API by abstracting the complexities of authentication and returning the API response in a simple and useful format.
npm install @kbabichau/telescope-integration-client
- Import the TelescopeClient class and the required interfaces:
import TelescopeClient, { TelescopeEnvironment } from '@kbabichau/telescope-integration-client';
- Instantiate TelescopeClient with the required arguments:
const options = {
environment: TelescopeEnvironment.Staging,
host: 'https://telescope-api.example.com',
clientId: 'client_id',
clientSecret: 'client_secret',
telescopeClientId: 'telescope_client_id'
};
const telescopeClient = new TelescopeClient(options);
- Make requests to the Telescope API using the available methods:
telescopeClient.getTelescopeConfig('/urn/some-config')
.then((data) => {
console.log(data);
})
.catch((error) => {
console.log(error);
});
- Enjoy the simplified process of making requests to the Telescope API in your JavaScript applications!
An enum representing the available Telescope environments.
An interface containing the options required to instantiate a new instance of TelescopeClient.
Properties:
-
environment
: A required field representing the Telescope environment the client should connect to. -
host
: A required field representing the url of the Telescope host. -
clientId
: A required field representing the client id for the OAuth2 authentication protocol. -
clientSecret
: A required field representing the client secret for the OAuth2 authentication protocol. -
telescopeClientId
: A required field representing the Telescope client id.
The class that simplifies the process of making requests to the Telescope API.
Methods:
-
getTelescopeConfig<T>(configUrn: string): Promise<T>
: A method that makes a GET request to retrieve a Telescope configuration object by the configUrn ID.
An error class that extends the Error class to allow for more granular error handling.
Properties:
-
status
: A required number property representing the HTTP status code of the error. -
message
: A required string property representing a description of the error.
This project is licensed under the MIT License.