0.0.45-temp • Published 4 years ago

@revas/ts-api v0.0.45-temp

Weekly downloads
73
License
MIT
Repository
-
Last release
4 years ago

Revas Platform API Typescript Client

Installation

yarn add @revas/platform-api

Usage

import Revas from '@revas/platform-api'

// Simple client instance with token and organizationId configured
const revas = new Revas.Client({
  accessToken: 'JWT_TOKEN_FROM_AUTHENTICATION',
  organizationId: 'REVAS_ORGANIZATION_ID'
})

// Revas can be also configured with simple getter functions
const revas = new Revas.Client({
  accessToken: () => {
    return 'JWT_TOKEN_FROM_AUTHENTICATION'
  },
  organizationId: () => {
    return 'REVAS_ORGANIZATION_ID'
  }
})

const request = ...
const response = revas.Contact.GetContact(request)

// The options are overrideable for each request but won't change client config
const response = revas.Contact.GetContact(request, {
  organizationId: 'REVAS_ORGANIZATION_ID'
})

Public API

// The public calls require the client with the public key
const revas = new Revas.Client({
  publicKey: 'REVAS_PUBLIC_KEY'
})
revas.Content.GetPublicDirectory(request)
revas.Content.ListPublicContents(request)
revas.Content.GetPublicContent(request)

Error Management

try {
  const response = revas.Contact.GetContact(request, {
    organizationId: 'REVAS_ORGANIZATION_ID'
  })
} catch (e: RevasError) {
  // for everything more than 200
}

Change global options

const revas = new Revas.Client({
  accessToken: 'JWT_TOKEN_FROM_AUTHENTICATION',
  organizationId: 'REVAS_ORGANIZATION_ID'
})

revas.setGlobalOptions({
  organizationId: 'ANOTHER_REVAS_ORGANIZATION_ID'
})

Example in Revas app

// eg. with auth0 and organization store
const auth0Client = ...
const revasClient = new Revas.Client({
  accessToken: () => {
    return auth0Client.getTokenSilently()
  }
})
const organizationStore = new ...(revasClient, ...)
revasClient.setGlobalOptions({
  organizationId: () => {
    return organizationStore.getOrganization().id
  }
})
revasClient.setGlobalOptions({
  organizationId: organizationStore.getOrganization().id
})
0.0.45-temp

4 years ago

0.0.43-temp

4 years ago

0.0.44-temp

4 years ago

0.0.42-temp

4 years ago

0.0.40-temp

4 years ago

0.0.41-temp

4 years ago

0.0.38-temp

4 years ago

0.0.39-temp

4 years ago

0.0.37-temp

4 years ago

0.0.36-temp

4 years ago

0.0.35-temp

4 years ago

0.0.34-temp

5 years ago

0.0.32-temp

5 years ago

0.0.33-temp

5 years ago

0.0.31-temp

5 years ago

0.0.30-temp

5 years ago

0.0.26-temp

5 years ago

0.0.28-temp

5 years ago

0.0.29-temp

5 years ago

0.0.27-temp

5 years ago

0.0.25-temp

5 years ago

0.0.24-temp

5 years ago

0.0.22-temp

5 years ago

0.0.23-temp

5 years ago

0.0.21-temp

5 years ago

0.0.20-temp

5 years ago

0.0.19-temp

5 years ago

0.0.18-temp

5 years ago

0.0.16-temp

5 years ago

0.0.17-temp

5 years ago

0.0.14-temp

5 years ago

0.0.15-temp

5 years ago

0.0.13-temp

5 years ago

0.0.12-temp

5 years ago

0.0.11-temp

5 years ago

0.0.10-temp

5 years ago

0.0.9-temp

5 years ago

0.0.8-temp

5 years ago

0.0.7-temp

5 years ago

0.0.6-temp

5 years ago

0.0.5-temp

5 years ago

0.0.4-temp

5 years ago