0.0.24 • Published 10 months ago

@cloudterms/js v0.0.24

Weekly downloads
-
License
-
Repository
-
Last release
10 months ago

@cloudterms/js

JS Quickstart

The @cloudterms/js package provides a type-safe SDK for interacting with the CloudTerms API.

Docs | Example

Setup

Install @cloudterms/js

npm install @cloudterms/js

Set your environment variables

# Your application ID
CLOUDTERMS_APP_ID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
# Your application secret
CLOUDTERMS_APP_SECRET="sk_live.xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Usage

import { CloudTerms } from '@cloudterms/js'

// Initialize the SDK
const cloudterms = CloudTerms()
// You can also pass in your application ID and secret, this will override the environment variables
const cloudterms2 = CloudTerms({ appId: 'my-app-id', secret: 'my-app-secret' })

// Get all your applications terms
const terms = await cloudterms.terms.get()

// Check if a user has agreed to the latest terms
const hasAgreed = await cloudterms.user.hasAgreed('some-unique-user-id')

// Set that a user has agreed to the latest terms
const setAgreed = await cloudterms.user.setAgreed('some-unique-user-id')

Methods

CloudTerms().terms.get()

Get all your applications terms

Response:

{
  terms: [
    {
      id: number
      applicationId: string // Your application ID
      name: string // Name of the term
      userId: string // Unique user ID provided by your application
      orgId: string | null // Your organization ID in CloudTerms, if applicable
      termId: string
      content: string // HTML content of the term
      createdAt: Date
      updatedAt: Date
    }
  ]
}

CloudTerms().user.hasAgreed(userId: string)

Check if a user has agreed to the latest terms

Parameters:

{
  userId: string // Unique user ID provided by your application
}

Response:

{
  hasAgreed: boolean
}

CloudTerms().user.setAgreed(userId: string)

Set that a user has agreed to the latest terms

Parameters:

{
  userId: string // Unique user ID provided by your application
}

Response:

{
  userId: string
  applicationId: string
  lastAgreed: Date | null // Date the user last agreed to the terms, or null if they have never agreed
}
0.0.22

10 months ago

0.0.23

10 months ago

0.0.24

10 months ago

0.0.21

1 year ago

0.0.20

1 year ago

0.0.18

1 year ago

0.0.19

1 year ago

0.0.17

1 year ago

0.0.16

1 year ago

0.0.15

1 year ago

0.0.3

1 year ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago