Skip to content

Instantly share code, notes, and snippets.

@bowbahdoe
Created December 21, 2016 19:11
Show Gist options
  • Save bowbahdoe/9a3ca914146c190f55421456e9cfa85b to your computer and use it in GitHub Desktop.
Save bowbahdoe/9a3ca914146c190f55421456e9cfa85b to your computer and use it in GitHub Desktop.
export class Camera extends Fixture{
constructor(data,metadata={}) {
this._structure_id = ...
}
getCurrentImage() {...}
}
// Interface to work with genral Fixtures and to reason about the different types in a collection
export class Fixture{
getLocation() {...}
getRawMetaData() {...}
getType() {...}
}
import fs from 'fs'
import { Structure } from './'
....SETUP....
export class Nest {
constructor(opts = {}) {
check_required(opts, ['email', 'password'])
const {
email,
password,
cache = false
} = opts
this.email = email
this.password = password
this.cache = {}
if(cache) {
try {
this.cache = JSON.parse(fs.readFileSync('./cache.json', 'utf8'))
} catch (err) {}
}
}
getUser() {...}
getAllFixtures(where_id=none) {...}
getCameras(where_id=none) {
if (where_id){...}
else{...}
}
getCamera(camera_id) { ... }
getThermostats(where_id=none) {
if (where_id){...}
else{...}
}
getThermostat(thermostat_id) {...}
getBucket(key) {...}
appLaunch() {...}
login() {...}
getSession() {...}
storeCache() {...}
}
export class Thermostat extends Fixture{
constructor(data,metadata={}) {
this._structure_id = ...
}
getCurrentTemperature() {...}
}
import {Nest} from "Nest"
function yay_i_have_a_decent_api(){
var api = Nest(email, username,..)
var why_would_my_image_recognition_program_care_about_the_fucking_temperature = api.getCameras(where_id="office)
for(camera: cameras){
look_for_faces(camera.getCurrentImage)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment