TODO: publish
npm i emo-platform-api-sdk
Set ACCESS_TOKEN environment variable.
You can get your access token at the dashboard
import type { AxiosError } from 'axios'
import { EmoApiClient } from 'emo-platform-api-sdk'
const apiClient = new EmoApiClient({
  accessToken: 'YOUR ACCESS TOKEN',
  refreshToken: 'YOUR REFRESH TOKEN',
})
// Get my account information
apiClient.getMe()
  .then(response => {
    console.log(response)
  })
  .catch((error: AxiosError) => {
    console.error(`Status code: ${error?.response?.status}`)
    console.error(error?.response?.data)
    console.log(error)
  })
// Get my rooms
apiClient.getRooms()
  .then(response => {
    console.log(response)
  })
  .catch((error: AxiosError) => {
    console.error(`Status code: ${error?.response?.status}`)
    console.error(error?.response?.data)
  })
// response example
{
  listing: { offset: 0, limit: 50, total: 1 },
  rooms: [
    {
      uuid: 'bcbcbcbc-1234-5678-abcd-aaaaaaaaaaaa',
      name: 'My first room',
      roomType: 'normal',
      roomMembers: [Array]
    }
  ]
}
// Post a message
// You can obtain uuids of rooms from `getRooms` API.
const roomUuid = 'bcbcbcbc-1234-5678-abcd-aaaaaaaaaaaa'
apiClient
  .postTextMessage(roomUuid, {
    text: 'Hello, BOCCO!',
  })
  .then(response => {
    console.log(response)
  })
  .catch((error: AxiosError) => {
    console.error(`Status code: ${error?.response?.status}`)
    console.error(error?.response?.data)
  })Then you will see the response of GET /v1/me
Please see further documentation at docs/index.html
- Node.js 16+ required.
yarn install
yarn build
Output will be placed under /dist.
yarn build:watch
yarn doc
Documentation will be placed under docs/.
To call SDK functions, modifying dev.ts would be easy.
yarn dev:watch
Whenever you save dev.ts, it's recompiled and run.