text: '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 Page = require('../../../../../base/Page');  /* jshint ignore:line */
  var deserialize = require(
      '../../../../../base/deserialize');  /* jshint ignore:line */
  var values = require('../../../../../base/values');  /* jshint ignore:line */
  
  var TaskQueueRealTimeStatisticsList;
  var TaskQueueRealTimeStatisticsPage;
  var TaskQueueRealTimeStatisticsInstance;
  var TaskQueueRealTimeStatisticsContext;
  
  /* jshint ignore:start */
  /**
   * @constructor Twilio.Taskrouter.V1.WorkspaceContext.TaskQueueContext.TaskQueueRealTimeStatisticsList
   * @description Initialize the TaskQueueRealTimeStatisticsList
   *
   * @param {Twilio.Taskrouter.V1} version - Version of the resource
   * @param {string} workspaceSid - The workspace_sid
   * @param {string} taskQueueSid - The task_queue_sid
   */
  /* jshint ignore:end */
  TaskQueueRealTimeStatisticsList = function
      TaskQueueRealTimeStatisticsList(version, workspaceSid, taskQueueSid) {
    /* jshint ignore:start */
    /**
     * @function realTimeStatistics
     * @memberof Twilio.Taskrouter.V1.WorkspaceContext.TaskQueueContext
     * @instance
     *
     * @param {string} sid - sid of instance
     *
     * @returns {Twilio.Taskrouter.V1.WorkspaceContext.TaskQueueContext.TaskQueueRealTimeStatisticsContext}
     */
    /* jshint ignore:end */
    function TaskQueueRealTimeStatisticsListInstance(sid) {
      return TaskQueueRealTimeStatisticsListInstance.get(sid);
    }
  
    TaskQueueRealTimeStatisticsListInstance._version = version;
    // Path Solution
    TaskQueueRealTimeStatisticsListInstance._solution = {
      workspaceSid: workspaceSid,
      taskQueueSid: taskQueueSid
    };
    /* jshint ignore:start */
    /**
     * Constructs a task_queue_real_time_statistics
     *
     * @function get
     * @memberof Twilio.Taskrouter.V1.WorkspaceContext.TaskQueueContext.TaskQueueRealTimeStatisticsList
     * @instance
     *
     * @returns {Twilio.Taskrouter.V1.WorkspaceContext.TaskQueueContext.TaskQueueRealTimeStatisticsContext}
     */
    /* jshint ignore:end */
    TaskQueueRealTimeStatisticsListInstance.get = function get() {
      return new TaskQueueRealTimeStatisticsContext(
        this._version,
        this._solution.workspaceSid,
        this._solution.taskQueueSid
      );
    };
  
    return TaskQueueRealTimeStatisticsListInstance;
  };
  
  
  /* jshint ignore:start */
  /**
   * @constructor Twilio.Taskrouter.V1.WorkspaceContext.TaskQueueContext.TaskQueueRealTimeStatisticsPage
   * @augments Page
   * @description Initialize the TaskQueueRealTimeStatisticsPage
   *
   * @param {Twilio.Taskrouter.V1} version - Version of the resource
   * @param {object} response - Response from the API
   * @param {object} solution - Path solution
   *
   * @returns TaskQueueRealTimeStatisticsPage
   */
  /* jshint ignore:end */
  TaskQueueRealTimeStatisticsPage = function
      TaskQueueRealTimeStatisticsPage(version, response, solution) {
    // Path Solution
    this._solution = solution;
  
    Page.prototype.constructor.call(this, version, response, this._solution);
  };
  
  _.extend(TaskQueueRealTimeStatisticsPage.prototype, Page.prototype);
  TaskQueueRealTimeStatisticsPage.prototype.constructor = TaskQueueRealTimeStatisticsPage;
  
  /* jshint ignore:start */
  /**
   * Build an instance of TaskQueueRealTimeStatisticsInstance
   *
   * @function getInstance
   * @memberof Twilio.Taskrouter.V1.WorkspaceContext.TaskQueueContext.TaskQueueRealTimeStatisticsPage
   * @instance
   *
   * @param {object} payload - Payload response from the API
   *
   * @returns TaskQueueRealTimeStatisticsInstance
   */
  /* jshint ignore:end */
  TaskQueueRealTimeStatisticsPage.prototype.getInstance = function
      getInstance(payload) {
    return new TaskQueueRealTimeStatisticsInstance(
      this._version,
      payload,
      this._solution.workspaceSid,
      this._solution.taskQueueSid
    );
  };
  
  
  /* jshint ignore:start */
  /**
   * @constructor Twilio.Taskrouter.V1.WorkspaceContext.TaskQueueContext.TaskQueueRealTimeStatisticsInstance
   * @description Initialize the TaskQueueRealTimeStatisticsContext
   *
   * @property {string} accountSid - The account_sid
   * @property {string} activityStatistics -
   *          The current Worker status count breakdown by Activity
   * @property {number} longestTaskWaitingAge - The age of the longest waiting Task
   * @property {string} taskQueueSid - The task_queue_sid
   * @property {string} tasksByPriority - The Tasks broken down by priority
   * @property {string} tasksByStatus - The Tasks broken down by status
   * @property {number} totalAvailableWorkers -
   *          The total number of Workers available for Tasks in this TaskQueue
   * @property {number} totalEligibleWorkers -
   *          The total number of Workers eligible for Tasks in this TaskQueue, irrespective of Activity state.
   * @property {number} totalTasks - The total number of Tasks
   * @property {string} workspaceSid - The workspace_sid
   * @property {string} url - The url
   *
   * @param {Twilio.Taskrouter.V1} version - Version of the resource
   * @param {object} payload - The instance payload
   * @param {sid} workspaceSid - The workspace_sid
   * @param {sid} taskQueueSid - The task_queue_sid
   */
  /* jshint ignore:end */
  TaskQueueRealTimeStatisticsInstance = function
      TaskQueueRealTimeStatisticsInstance(version, payload, workspaceSid,
      taskQueueSid) {
    this._version = version;
  
    // Marshaled Properties
    this.accountSid = payload.account_sid; // jshint ignore:line
    this.activityStatistics = payload.activity_statistics; // jshint ignore:line
    this.longestTaskWaitingAge = deserialize.integer(payload.longest_task_waiting_age); // jshint ignore:line
    this.taskQueueSid = payload.task_queue_sid; // jshint ignore:line
    this.tasksByPriority = payload.tasks_by_priority; // jshint ignore:line
    this.tasksByStatus = payload.tasks_by_status; // jshint ignore:line
    this.totalAvailableWorkers = deserialize.integer(payload.total_available_workers); // jshint ignore:line
    this.totalEligibleWorkers = deserialize.integer(payload.total_eligible_workers); // jshint ignore:line
    this.totalTasks = deserialize.integer(payload.total_tasks); // jshint ignore:line
    this.workspaceSid = payload.workspace_sid; // jshint ignore:line
    this.url = payload.url; // jshint ignore:line
  
    // Context
    this._context = undefined;
    this._solution = {workspaceSid: workspaceSid, taskQueueSid: taskQueueSid, };
  };
  
  Object.defineProperty(TaskQueueRealTimeStatisticsInstance.prototype,
    '_proxy', {
    get: function() {
      if (!this._context) {
        this._context = new TaskQueueRealTimeStatisticsContext(
          this._version,
          this._solution.workspaceSid,
          this._solution.taskQueueSid
        );
      }
  
      return this._context;
    }
  });
  
  /* jshint ignore:start */
  /**
   * fetch a TaskQueueRealTimeStatisticsInstance
   *
   * @function fetch
   * @memberof Twilio.Taskrouter.V1.WorkspaceContext.TaskQueueContext.TaskQueueRealTimeStatisticsInstance
   * @instance
   *
   * @param {object|function} opts - ...
   * @param {string} [opts.taskChannel] -
   *          Filter real-time and cumulative statistics by TaskChannel.
   * @param {function} [callback] - Callback to handle processed record
   *
   * @returns {Promise} Resolves to processed TaskQueueRealTimeStatisticsInstance
   */
  /* jshint ignore:end */
  TaskQueueRealTimeStatisticsInstance.prototype.fetch = function fetch(opts,
      callback) {
    return this._proxy.fetch(opts, callback);
  };
  
  /* jshint ignore:start */
  /**
   * Produce a plain JSON object version of the TaskQueueRealTimeStatisticsInstance for serialization.
   * Removes any circular references in the object.
   *
   * @function toJSON
   * @memberof Twilio.Taskrouter.V1.WorkspaceContext.TaskQueueContext.TaskQueueRealTimeStatisticsInstance
   * @instance
   *
   * @returns Object
   */
  /* jshint ignore:end */
  TaskQueueRealTimeStatisticsInstance.prototype.toJSON = function toJSON() {
    let clone = {};
    _.forOwn(this, function(value, key) {
      if (!_.startsWith(key, '_') && ! _.isFunction(value)) {
        clone[key] = value;
      }
    });
    return clone;
  };
  
  
  /* jshint ignore:start */
  /**
   * @constructor Twilio.Taskrouter.V1.WorkspaceContext.TaskQueueContext.TaskQueueRealTimeStatisticsContext
   * @description Initialize the TaskQueueRealTimeStatisticsContext
   *
   * @param {Twilio.Taskrouter.V1} version - Version of the resource
   * @param {sid} workspaceSid - The workspace_sid
   * @param {sid} taskQueueSid - The task_queue_sid
   */
  /* jshint ignore:end */
  TaskQueueRealTimeStatisticsContext = function
      TaskQueueRealTimeStatisticsContext(version, workspaceSid, taskQueueSid) {
    this._version = version;
  
    // Path Solution
    this._solution = {workspaceSid: workspaceSid, taskQueueSid: taskQueueSid, };
    this._uri = _.template(
      '/Workspaces/<%= workspaceSid %>/TaskQueues/<%= taskQueueSid %>/RealTimeStatistics' // jshint ignore:line
    )(this._solution);
  };
  
  /* jshint ignore:start */
  /**
   * fetch a TaskQueueRealTimeStatisticsInstance
   *
   * @function fetch
   * @memberof Twilio.Taskrouter.V1.WorkspaceContext.TaskQueueContext.TaskQueueRealTimeStatisticsContext
   * @instance
   *
   * @param {object|function} opts - ...
   * @param {string} [opts.taskChannel] -
   *          Filter real-time and cumulative statistics by TaskChannel.
   * @param {function} [callback] - Callback to handle processed record
   *
   * @returns {Promise} Resolves to processed TaskQueueRealTimeStatisticsInstance
   */
  /* jshint ignore:end */
  TaskQueueRealTimeStatisticsContext.prototype.fetch = function fetch(opts,
      callback) {
    if (_.isFunction(opts)) {
      callback = opts;
      opts = {};
    }
    opts = opts || {};
  
    var deferred = Q.defer();
    var data = values.of({'TaskChannel': _.get(opts, 'taskChannel')});
  
    var promise = this._version.fetch({uri: this._uri, method: 'GET', params: data});
  
    promise = promise.then(function(payload) {
      deferred.resolve(new TaskQueueRealTimeStatisticsInstance(
        this._version,
        payload,
        this._solution.workspaceSid,
        this._solution.taskQueueSid
      ));
    }.bind(this));
  
    promise.catch(function(error) {
      deferred.reject(error);
    });
  
    if (_.isFunction(callback)) {
      deferred.promise.nodeify(callback);
    }
  
    return deferred.promise;
  };
  
  module.exports = {
    TaskQueueRealTimeStatisticsList: TaskQueueRealTimeStatisticsList,
    TaskQueueRealTimeStatisticsPage: TaskQueueRealTimeStatisticsPage,
    TaskQueueRealTimeStatisticsInstance: TaskQueueRealTimeStatisticsInstance,
    TaskQueueRealTimeStatisticsContext: TaskQueueRealTimeStatisticsContext
  };
  