{"size": 8755, "ext": "js", "max_stars_repo_path": "nodejs/node_modules/twilio/lib/rest/accounts/v1/authTokenPromotion.js", "max_stars_repo_name": "YungSamzy/MN-Remind-Pub", "max_stars_repo_stars_event_min_datetime": "2015-01-05T05:53:39.000Z", "max_stars_repo_stars_event_max_datetime": "2022-03-31T08:48:26.000Z", "max_issues_repo_path": "nodejs/node_modules/twilio/lib/rest/accounts/v1/authTokenPromotion.js", "max_issues_repo_name": "YungSamzy/MN-Remind-Pub", "max_issues_repo_issues_event_min_datetime": "2015-01-05T06:03:20.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-30T22:15:38.000Z", "max_forks_repo_path": "nodejs/node_modules/twilio/lib/rest/accounts/v1/authTokenPromotion.js", "max_forks_repo_name": "YungSamzy/MN-Remind-Pub", "max_forks_repo_forks_event_min_datetime": "2015-01-03T22:31:03.000Z", "max_forks_repo_forks_event_max_datetime": "2022-03-27T03:03:01.000Z"}
{"max_stars_count": 1055, "max_issues_count": 521, "max_forks_count": 499, "avg_line_length": 27.61829653, "max_line_length": 93, "alphanum_fraction": 0.7071387778}
'use strict';

/* jshint ignore:start */
/**
 * This code was generated by
 * \ / _    _  _|   _  _
 *  | (_)\/(_)(_|\/| |(/_  v1.0.0
 *       /       /
 */
/* jshint ignore:end */

var Q = require('q');  /* jshint ignore:line */
var _ = require('lodash');  /* jshint ignore:line */
var util = require('util');  /* jshint ignore:line */
var Page = require('../../../base/Page');  /* jshint ignore:line */
var deserialize = require(
    '../../../base/deserialize');  /* jshint ignore:line */
var values = require('../../../base/values');  /* jshint ignore:line */

var AuthTokenPromotionList;
var AuthTokenPromotionPage;
var AuthTokenPromotionInstance;
var AuthTokenPromotionContext;

/* jshint ignore:start */
/**
 * Initialize the AuthTokenPromotionList
 *
 * @constructor Twilio.Accounts.V1.AuthTokenPromotionList
 *
 * @param {Twilio.Accounts.V1} version - Version of the resource
 */
/* jshint ignore:end */
AuthTokenPromotionList = function AuthTokenPromotionList(version) {
  /* jshint ignore:start */
  /**
   * @function authTokenPromotion
   * @memberof Twilio.Accounts.V1#
   *
   * @param {string} sid - sid of instance
   *
   * @returns {Twilio.Accounts.V1.AuthTokenPromotionContext}
   */
  /* jshint ignore:end */
  function AuthTokenPromotionListInstance(sid) {
    return AuthTokenPromotionListInstance.get(sid);
  }

  AuthTokenPromotionListInstance._version = version;
  // Path Solution
  AuthTokenPromotionListInstance._solution = {};
  /* jshint ignore:start */
  /**
   * Constructs a auth_token_promotion
   *
   * @function get
   * @memberof Twilio.Accounts.V1.AuthTokenPromotionList#
   *
   * @returns {Twilio.Accounts.V1.AuthTokenPromotionContext}
   */
  /* jshint ignore:end */
  AuthTokenPromotionListInstance.get = function get() {
    return new AuthTokenPromotionContext(this._version);
  };

  /* jshint ignore:start */
  /**
   * Provide a user-friendly representation
   *
   * @function toJSON
   * @memberof Twilio.Accounts.V1.AuthTokenPromotionList#
   *
   * @returns Object
   */
  /* jshint ignore:end */
  AuthTokenPromotionListInstance.toJSON = function toJSON() {
    return this._solution;
  };

  AuthTokenPromotionListInstance[util.inspect.custom] = function inspect(depth,
      options) {
    return util.inspect(this.toJSON(), options);
  };

  return AuthTokenPromotionListInstance;
};


/* jshint ignore:start */
/**
 * Initialize the AuthTokenPromotionPage
 *
 * @constructor Twilio.Accounts.V1.AuthTokenPromotionPage
 *
 * @param {V1} version - Version of the resource
 * @param {Response<string>} response - Response from the API
 * @param {AuthTokenPromotionSolution} solution - Path solution
 *
 * @returns AuthTokenPromotionPage
 */
/* jshint ignore:end */
AuthTokenPromotionPage = function AuthTokenPromotionPage(version, response,
                                                          solution) {
  // Path Solution
  this._solution = solution;

  Page.prototype.constructor.call(this, version, response, this._solution);
};

_.extend(AuthTokenPromotionPage.prototype, Page.prototype);
AuthTokenPromotionPage.prototype.constructor = AuthTokenPromotionPage;

/* jshint ignore:start */
/**
 * Build an instance of AuthTokenPromotionInstance
 *
 * @function getInstance
 * @memberof Twilio.Accounts.V1.AuthTokenPromotionPage#
 *
 * @param {AuthTokenPromotionPayload} payload - Payload response from the API
 *
 * @returns AuthTokenPromotionInstance
 */
/* jshint ignore:end */
AuthTokenPromotionPage.prototype.getInstance = function getInstance(payload) {
  return new AuthTokenPromotionInstance(this._version, payload);
};

/* jshint ignore:start */
/**
 * Provide a user-friendly representation
 *
 * @function toJSON
 * @memberof Twilio.Accounts.V1.AuthTokenPromotionPage#
 *
 * @returns Object
 */
/* jshint ignore:end */
AuthTokenPromotionPage.prototype.toJSON = function toJSON() {
  let clone = {};
  _.forOwn(this, function(value, key) {
    if (!_.startsWith(key, '_') && ! _.isFunction(value)) {
      clone[key] = value;
    }
  });
  return clone;
};

AuthTokenPromotionPage.prototype[util.inspect.custom] = function inspect(depth,
    options) {
  return util.inspect(this.toJSON(), options);
};


/* jshint ignore:start */
/**
 * Initialize the AuthTokenPromotionContext
 *
 * @constructor Twilio.Accounts.V1.AuthTokenPromotionInstance
 *
 * @property {string} accountSid -
 *          The SID of the Account that the secondary Auth Token was created for
 * @property {string} authToken - The promoted Auth Token
 * @property {Date} dateCreated -
 *          The ISO 8601 formatted date and time in UTC when the resource was created
 * @property {Date} dateUpdated -
 *          The ISO 8601 formatted date and time in UTC when the resource was last updated
 * @property {string} url -
 *          The URI for this resource, relative to `https://accounts.twilio.com`
 *
 * @param {V1} version - Version of the resource
 * @param {AuthTokenPromotionPayload} payload - The instance payload
 */
/* jshint ignore:end */
AuthTokenPromotionInstance = function AuthTokenPromotionInstance(version,
    payload) {
  this._version = version;

  // Marshaled Properties
  this.accountSid = payload.account_sid; // jshint ignore:line
  this.authToken = payload.auth_token; // jshint ignore:line
  this.dateCreated = deserialize.iso8601DateTime(payload.date_created); // jshint ignore:line
  this.dateUpdated = deserialize.iso8601DateTime(payload.date_updated); // jshint ignore:line
  this.url = payload.url; // jshint ignore:line

  // Context
  this._context = undefined;
  this._solution = {};
};

Object.defineProperty(AuthTokenPromotionInstance.prototype,
  '_proxy', {
    get: function() {
      if (!this._context) {
        this._context = new AuthTokenPromotionContext(this._version);
      }

      return this._context;
    }
});

/* jshint ignore:start */
/**
 * update a AuthTokenPromotionInstance
 *
 * @function update
 * @memberof Twilio.Accounts.V1.AuthTokenPromotionInstance#
 *
 * @param {function} [callback] - Callback to handle processed record
 *
 * @returns {Promise} Resolves to processed AuthTokenPromotionInstance
 */
/* jshint ignore:end */
AuthTokenPromotionInstance.prototype.update = function update(callback) {
  return this._proxy.update(callback);
};

/* jshint ignore:start */
/**
 * Provide a user-friendly representation
 *
 * @function toJSON
 * @memberof Twilio.Accounts.V1.AuthTokenPromotionInstance#
 *
 * @returns Object
 */
/* jshint ignore:end */
AuthTokenPromotionInstance.prototype.toJSON = function toJSON() {
  let clone = {};
  _.forOwn(this, function(value, key) {
    if (!_.startsWith(key, '_') && ! _.isFunction(value)) {
      clone[key] = value;
    }
  });
  return clone;
};

AuthTokenPromotionInstance.prototype[util.inspect.custom] = function
    inspect(depth, options) {
  return util.inspect(this.toJSON(), options);
};


/* jshint ignore:start */
/**
 * Initialize the AuthTokenPromotionContext
 *
 * @constructor Twilio.Accounts.V1.AuthTokenPromotionContext
 *
 * @param {V1} version - Version of the resource
 */
/* jshint ignore:end */
AuthTokenPromotionContext = function AuthTokenPromotionContext(version) {
  this._version = version;

  // Path Solution
  this._solution = {};
  this._uri = `/AuthTokens/Promote`;
};

/* jshint ignore:start */
/**
 * update a AuthTokenPromotionInstance
 *
 * @function update
 * @memberof Twilio.Accounts.V1.AuthTokenPromotionContext#
 *
 * @param {function} [callback] - Callback to handle processed record
 *
 * @returns {Promise} Resolves to processed AuthTokenPromotionInstance
 */
/* jshint ignore:end */
AuthTokenPromotionContext.prototype.update = function update(callback) {
  var deferred = Q.defer();
  var promise = this._version.update({uri: this._uri, method: 'POST'});

  promise = promise.then(function(payload) {
    deferred.resolve(new AuthTokenPromotionInstance(this._version, payload));
  }.bind(this));

  promise.catch(function(error) {
    deferred.reject(error);
  });

  if (_.isFunction(callback)) {
    deferred.promise.nodeify(callback);
  }

  return deferred.promise;
};

/* jshint ignore:start */
/**
 * Provide a user-friendly representation
 *
 * @function toJSON
 * @memberof Twilio.Accounts.V1.AuthTokenPromotionContext#
 *
 * @returns Object
 */
/* jshint ignore:end */
AuthTokenPromotionContext.prototype.toJSON = function toJSON() {
  return this._solution;
};

AuthTokenPromotionContext.prototype[util.inspect.custom] = function
    inspect(depth, options) {
  return util.inspect(this.toJSON(), options);
};

module.exports = {
  AuthTokenPromotionList: AuthTokenPromotionList,
  AuthTokenPromotionPage: AuthTokenPromotionPage,
  AuthTokenPromotionInstance: AuthTokenPromotionInstance,
  AuthTokenPromotionContext: AuthTokenPromotionContext
};
