index.js
function TuyaLinkWizard(options) {
  // Set to empty object if undefined
  options = options ? options : {};

  if (!options.email || !options.password) {
    throw new Error('Both email and password must be provided');
  }

  this.email = options.email;
  this.password = options.password;

  // Set defaults
  this.region = options.region ? options.region : 'AZ';
  this.timezone = options.timezone ? options.timezone : '-05:00';

  // Don't need to check key and secret for correct format as
  // tuyapi/cloud already does
  this.api = new Cloud({key: options.apiKey,
                        secret: options.apiSecret,
                        region: this.region});

  // Construct instance of TuyaLink
  this.device = new TuyaLink();
}
function TuyaLinkWizard(options) {
  // Set to empty object if undefined
  options = options ? options : {};

  if (!options.email || !options.password) {
    throw new Error('Both email and password must be provided');
  }

  this.email = options.email;
  this.password = options.password;

  // Set defaults
  this.region = options.region ? options.region : 'AZ';
  this.timezone = options.timezone ? options.timezone : '-05:00';

  // Don't need to check key and secret for correct format as
  // tuyapi/cloud already does
  this.api = new Cloud({key: options.apiKey,
                        secret: options.apiSecret,
                        region: this.region});

  // Construct instance of TuyaLink
  this.device = new TuyaLink();
}
function TuyaLinkWizard ( options ) { // Set to empty object if undefined options = options ? options : { } ; if ( ! options . email || ! options . password ) { throw new Error ( 'Both email and password must be provided' ) ; } this . email = options . email ; this . password = options . password ; // Set defaults this . region = options . region ? options . region : 'AZ' ; this . timezone = options . timezone ? options . timezone : '-05:00' ; // Don't need to check key and secret for correct format as // tuyapi/cloud already does this . api = new Cloud ( { key : options . apiKey , secret : options . apiSecret , region : this . region } ) ; // Construct instance of TuyaLink this . device = new TuyaLink ( ) ; }
A wrapper that combines `@tuyapi/cloud` and
`(@tuyapi/link).manual` (included in this package)
to make registration Just Work™️. Exported as
`(@tuyapi/link).wizard`.
@class
@param {Object} options construction options
@param {String} options.apiKey API key
@param {String} options.apiSecret API secret
@param {String} options.email user email
@param {String} options.password user password
@param {String} [options.region='AZ'] region (AZ=Americas, AY=Asia, EU=Europe)
@param {String} [options.timezone='-05:00'] timezone of device
@example
// Note: user account does not need to already exist
const register = new TuyaLink.wizard({key: 'your-api-key',
secret: 'your-api-secret',
email: 'example@example.com',
password: 'example-password'});
A wrapper that combines