Home

Knowledge Anywhere LMS API SDK

Build Status Coverage Status

SDK for Interacting with the Knowledge Anywhere LMS API.

contact support@knowledgeanywhere.com if you would like more information.

Documentation

Installation and Getting Started

  • You will need Audience and Secret keys for authorization. These can be obtained by going to into the admin panel for your LMS and navigating to Site > External API keys.
  • run the cmd npm i knowledgeanywhere --save to get the package.
  • The SDK expects the constants LMS_AUDIENCE, LMS_SECRET to be present as process variables. The easiest way to accomplish this is to use an .env file that is loaded via Foreman or dotenv. If you are directed to use a different API url, use the LMS_API_URL environment variable.

Usage

  • Refer to Documentation to see available method calls.
  • All methods. return a promise and are async/await friendly.

Issues

  • Bugs related to the SDK should be filed under this Github Repository. Be sure to include your Node version and any relevant error information.
  • Issues with the LMS API itself should be emailed to support@knowledgeanywhere.com

Contributing

  • Clone repo onto your machine
  • Create a .env file with LMS_AUDIENCE, LMS_SECRET keys. Fill in LMS_AUDIENCE and LMS_SECRET from the values that are attained in the admin section of your LMS under the Site Menu. Set environment to stage.
  • Run npm install
  • To run tests run npm tests

To update documentation, run npm run-script generate-docs

Debugging in VS Code

The recommended editor for working on the SDK is Visual Studio code, which is has a debug configuration already setup. In the specs folder, modify the file manual-tests.js to run through the code you desire to debug. When you're ready, select the "debug" icon in the pane and click "launch program" and it will hit any breakpoints you set.

See also: Visual Studio Code - Debugger Documentation

Pull Requests will not be considered until public availability

http://www.knowledgeanywhere.com

User

Most fields are optional. Only required fields are externalId, email, lastName, FirstName.

User

Type: User

Properties
externalId (string) : The unique identifier from the system calling the API for this user
email (string) : The email for the user.
lastName (string) : The last name for the user
firstName (string) : The first name for the user
password (string) : Plain text password (optional). There is a minimum length requirement of 6 characters.
ssoId (string) : Unique identifier utilized by the Single Sign-on system integrated with the LMS used to uniquely identify this user for sign-on. If Provisioning and SSO are handled by the same system this could be the same data passed for externalId.
active (boolean) : Make user active/inactive in the LMS
siteName (string) : The name of the microsite.
sendInitialEmail (boolean) : Send the user an email with a link to the LMS. Defaults to false
forcePasswordChange (boolean) : Make the user change thier passowrd on next login. Defaults to false
locale (string) : The 4 letter language code. If the code is not active in the LMS the user will be defaulted to the default LMS value. In most cases this is EN-US. Defaults to EN-US. If a invalid locale is passed in, the operation will continue, but will return a warning.
registrationCode (string) : If your LMS uses registration codes for users to self register use this field to assign that code to the user. The value passed in must match a value in the LMS, if no match is found the request will result in a 400 bad request.
phoneNumber (string) : The phone number for this user
businessName (string) : The company name for this user
address1 (string) : The street address, P.O. Box for this user
address2 (string) : The apartment, suite, unit building, floor, etc for this user
city (string) : The city for the user
state (string) : The 2 or 3 letter state/province abbrevation for the user.
postalCode (string) : The zip or postal code for the user
country (string) : The 2 or 3 letter ISO country code country for the user. See https://www.iso.org/iso-3166-country-codes.html for the list of valid country codes. Defaults to the country specified in your LMS configuration. If a invalid country is specified, the operation will continue, but a warning will be thrown.
customFields (Array<CustomField>)

Token

Model representing a Token

Token

Type: Token

Parameters
token (object) Response from auth server to serialize into a Token.
Properties
accessToken (string) : Access Token, used to make requests.
issued (date) : Issue date
expires (date) : Expiry date
expiresIn (number) : Seconds till expiration. Epcoch Unix Timestamp
tokenType (string) : Type of token. (Bearer)
authorization (string) : Authorization header content. Example Bearer xxxxxxxxx
isValid (boolean) : Checks to see if the token is "fresh" or expired
Instance Members
get()

CustomField

Model representing a Custom Field

CustomField

Type: CustomField

Parameters
cfd (any)
CustomFieldDefinition (object) Object containing the Custom Field Definition
Properties
name (string) : String containing the name of the custom field. If the property is not matched to an existing value in the system, it will be created.
value (string) : String containing the value of the custom field. The value can be a single value or a comma seperated string. If the property is not matched to an existing value, it will be created.

LMSAPI

This module is available for use and is used by all other modules to call the API in a consistent way and handles authentication. Use the methods to manually make a request to the API using an endpoint.

new LMSAPI()
Example
`lms.api.post('v1/users', data)`
Instance Members
get(endpoint)
post(endpoint, data, JSON)
put(endpoint, data, JSON)
delete(endpoint, data)

Ping

The ping module is a utility class used to determine service availability. WARNING: This module may be deprecated or subject to change. It's primary usage at this stage is for testing. Documentation will most certainly be dropped beyond the initial full release.

Ping

Extends LMSAPI

Instance Members
checkHealth()

Auth

Methods for handling authentication. Usage of this module may not be needed. When making calls to the API using other modules in this sdk, authorization is handeled for you. This module is available if you would like to use it to make standard restful calls to the API outside of the SDK.

Auth
Instance Members
token()

Users

The users module contains functions related to creating, reading, updating and deactivating users.

Users

Extends LMSAPI

Instance Members
find(searchParams)
findById(externalId)
create(user)
update(user)
deactivate(externalId, user)