homey-api
Version:
64 lines (53 loc) • 1.11 kB
JavaScript
/* eslint-disable camelcase */
'use strict';
/**
* An OAuth2 Token for {@link AthomCloudAPI}.
* @class
* @hideconstructor
* @memberof AthomCloudAPI
*/
class Token {
constructor({
token_type,
access_token,
refresh_token,
expires_in,
grant_type,
}) {
/**
* The token type, usually `bearer`.
* @type {string}
*/
this.token_type = token_type;
/**
* Access Token
* @type {string}
*/
this.access_token = access_token;
/**
* Refresh Token
* @type {string}
*/
this.refresh_token = refresh_token;
/**
* Amount of seconds until the token expires
* @type {number}
*/
this.expires_in = expires_in;
/**
* The grant type, e.g. `authorization_code` or `client_credentials`.
* @type {string}
*/
this.grant_type = grant_type;
}
toJSON() {
return {
token_type: this.token_type,
access_token: this.access_token,
refresh_token: this.refresh_token,
expires_in: this.expires_in,
grant_type: this.grant_type,
};
}
}
module.exports = Token;