/rentdynamics-js

JavaScript API Helper Library

Primary LanguageTypeScriptMIT LicenseMIT

Rent Dynamics JS

Circle CI Badge codecov Dependency Status Dev Dependency Status Peer Dependency Status NPM Version MIT License

CDN

Include jsSHA and our CDN

<script src="https://cdnjs.cloudflare.com/ajax/libs/jsSHA/2.3.1/sha.js"></script>
<script src="https://cdnjs.rentdynamics.com/rentdynamics.latest.js"></script>
var options = {
  apiKey: '<insert-key-here>',
  apiSecretKey: '<insert-secret-key-here>'
};
var rdClient = new RentDynamics.Client(options);
rdClient.login('<username>', '<password>').then(function(result) {
  ...
});
// Then you can make api calls
rdClient.get('/data').then(function(result) {
  ...
});

NPM

Install with npm: npm install rentdynamics

import { Client } from 'rentdynamics';

let options = {
  apiKey: '<insert-key-here>',
  apiSecretKey: '<insert-secret-key-here>'
};
let rdClient = new Client(options);
rdClient.login('<username>', '<password>').then((result: object) => {
  ...
});
// Then you can make api calls
rdClient.get('/data').then((result: array | object) => {
  ...
});

Values

ClientOptions

  • apiKey: string (default is undefined)
  • apiSecretKey: string (default is undefined)
  • authToken: string (default is undefined)
  • development: boolean (default is false)
  • service: string (default is undefined)
  • developmentUrl: string (default is undefined) (This will only be used if development is set to true)
  • baseUrl: string (default is undefined) (This will only be used if development is set to false)

Client (requires a ClientOptions to be passed in)

  • get(endpoint: string): Promise<any>
  • put(endpoint: string, payload: object): Promise<any>
  • post(endpoint: string, payload: object): Promise<any>
  • delete(endpoint: string): Promise<any>
  • login(username: string, password: string): Promise<any>
  • logout(): Promise<any>

Available Endpoints

  • appointmentTimes for a given community group

Examples

There are 4 different ways to format the response.

  1. only the time, no date (this is the default when the 'dateFormat' argument is omitted)
rdClient.get(`/appointmentTimes/${communityGroupId}?appointmentDate=10/31/2019&dateFormat=timeonly`).then(function(result) {
  // result is a list of local appointmentTimes
  // Example: ["10:00 AM","10:15 AM",...,"05:15 PM","05:30 PM"]
});
  1. utc
rdClient.get(`/appointmentTimes/${communityGroupId}?appointmentDate=10/31/2019&dateFormat=utc`).then(function(result) {
  // result is a list of appointmentTimes in utc
  // Example: ["2020-01-05T17:00:00Z","2020-01-05T17:15:00Z",...,"2020-01-06T00:15:00Z","2020-01-06T05:30:00Z"]
});
  1. the local time of the property without an offset
rdClient.get(`/appointmentTimes/${communityGroupId}?appointmentDate=10/31/2019&dateFormat=localWithoutOffset`).then(function(result) {
  // result is a list of appointment dates & times in local time without any offset information
  // Example: ["2020-01-05T10:00:00","2020-01-05T10:15:00",...,"2020-01-05T17:15:00","2020-01-05T17:30:00"]
});
  1. the local time of the property with an offset
rdClient.get(`/appointmentTimes/${communityGroupId}?appointmentDate=10/31/2019&dateFormat=localWithOffset`).then(function(result) {
  // result is a list of appointment dates & times in local time with the timezone offset of the property
  // Example: ["2020-01-05T10:00:00-0700","2020-01-05T10:15:00-0700",...,"2020-01-05T17:15:00-0700","2020-01-05T17:30:00-0700"]
});

Testing

  • npm test > Runs all the tests and checks the code coverage.