<commit_before>/* jshint esversion: 6 */
/* jshint node: true */
/* jshint sub:true */
// This code uses ES2015 syntax that requires at least Node.js v4.
// For Node.js ES2015 support details, reference http://node.green/

"use strict";
var request = require('request-promise');

/**
* This translator class implements the "Hub" interface.
*/
class Translator {
    constructor(accessToken) {
        this._accessToken = accessToken;

        this._baseUrl = "https://api.wink.com";
        this._devicesPath = '/users/me/wink_devices';

        this._name = "Wink Hub"; // TODO: Can be pulled from OpenT2T global constants. This information is not available, at least, on wink hub.
    }

    /**
     * Get the list of devices discovered through the hub.
     */
    getHubResURI() {
        return this._makeRequest(this._devicesPath, 'GET').then((response) => {

            var toReturn = {};
            var devices = response.data;

            var filteredDevices = [];
            devices.forEach((winkDevice) => {
                // get the opent2t schema and translator for the wink device
                var opent2tInfo = this._getOpent2tInfo(winkDevice);

                if ((winkDevice.model_name !== 'HUB')  &&  // Skip hub itself. (WINK specific check, of course!)
                    opent2tInfo != undefined) // we support the device
                {
                    // we only need to return certain properties back
                    var device = {};
                    device.name = winkDevice.name;
<commit_msg>Hidding Wink devices with hidden_at properties<commit_after>/* jshint esversion: 6 */
/* jshint node: true */
/* jshint sub:true */
// This code uses ES2015 syntax that requires at least Node.js v4.
// For Node.js ES2015 support details, reference http://node.green/

"use strict";
var request = require('request-promise');

/**
* This translator class implements the "Hub" interface.
*/
class Translator {
    constructor(accessToken) {
        this._accessToken = accessToken;

        this._baseUrl = "https://api.wink.com";
        this._devicesPath = '/users/me/wink_devices';

        this._name = "Wink Hub"; // TODO: Can be pulled from OpenT2T global constants. This information is not available, at least, on wink hub.
    }

    /**
     * Get the list of devices discovered through the hub.
     */
    getHubResURI() {
        return this._makeRequest(this._devicesPath, 'GET').then((response) => {

            var toReturn = {};
            var devices = response.data;

            var filteredDevices = [];
            devices.forEach((winkDevice) => {
                // get the opent2t schema and translator for the wink device
                var opent2tInfo = this._getOpent2tInfo(winkDevice);

                // Do not return the physical hub device, nor any devices for which there are not translators.
                // Additionally, do not return devices that have been marked as hidden by Wink (hidden_at is a number)
                // This state is used by third party devices (such as a Nest Thermostat) that were connected to a
                // Wink account and then removed.  Wink keeps the connection, but marks them as hidden.
                if ((winkDevice.model_name !== 'HUB')  && 
                    opent2tInfo != undefined &&
                    (winkDevice.hidden_at == undefined || winkDevice.hidden_at == null))
                {
                    // &&
                    // isNaN(winkDevice.hidden_at)
                    // we only need to return certain properties back
                    var device = {};
                    device.name = winkDevice.name;

{'fraction_non_alphanumeric': 0.10180623973727422, 'fraction_numerical': 0.008210180623973728, 'mean_word_length': 2.013190436933223, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4231431', 'n_tokens_mistral': 1003, 'n_tokens_neox': 937, 'n_words': 327}