channelape-sdk
Version:
A client for interacting with ChannelApe's API
106 lines (83 loc) • 3.13 kB
Markdown
TypeScript and JavaScript SDK for the [ChannelApe REST API](https://docs.channelape.io/)
[](https://travis-ci.org/ChannelApe/channelape-typescript-sdk) [](https://sonarcloud.io/dashboard?id=channelape-typescript-sdk) [](https://sonarcloud.io/dashboard?id=channelape-typescript-sdk)
- [Getting Started](
- [Sessions](
- [Actions](
- [Channels](
- [Orders](
The ChannelApe SDK is asynchronous and all functions return promises.
Create a new instance of the ChannelApeClient with your sessionId.
```typescript
const channelApeClient = new ChannelApeClient({
sessionId: '4674b668-c4d2-4270-bf9b-ebaab78c378d'
});
```
* timeout - Number of milliseconds to wait for the API to send response headers. Defaults to 180000 (3 minutes). Cannot be set lower than 2000 (2 seconds).
* endpoint - Envrionment endpoint you would like to hit. Defaults to https://api.channelape.com
* logLevel - Level of logs you wish to see from the SDK. Defaults to OFF.
* maximumRequestRetryTimeout - Number of milliseconds to keep retrying a request for when an undesired response status code is received. Defaults to 180000 (3 minutes). Cannot be set lower than 2000 (2 seconds).
Retrieve session using sessionId passed into ChannelApeClient.
```typescript
channelapeClient.sessions().get()
.then((session: Session) => {
// do what you need to do with session data here
});
```
```typescript
channelapeClient.actions().get(actionId)
.then((action: Action) => {
// do what you need to do with action data here
});
```
```typescript
channelapeClient.actions().complete(actionId)
.then((action: Action) => {
// do what you need to do with action data here
});
```
```typescript
channelapeClient.actions().error(actionId)
.then((action: Action) => {
// do what you need to do with action data here
});
```
```typescript
channelapeClient.actions().updateHealthCheck(actionId)
.then((action: Action) => {
// do what you need to do with action data here
});
```
```typescript
channelapeClient.channels().get(channelId)
.then((channel: Channel) => {
// do what you need to do with channel data here
});
```
```typescript
channelapeClient.orders().get(orderId)
.then((order: Order) => {
// do what you need to do with order data here
});
```
```typescript
channelapeClient.orders().update(order)
.then((updatedOrder: Order) => {
// do what you need to do with updatedOrder data here
});
```