class Botvac::Cli
Constants
- ENDPOINT
Attributes
token[RW]
Public Instance Methods
connection()
click to toggle source
# File lib/botvac/cli.rb, line 29 def connection Faraday.new(ENDPOINT) do |faraday| faraday.response :json faraday.request :json faraday.headers["Accept"]= 'application/vnd.neato.nucleo.v1' faraday.headers["Authorization"]= "Token token=#{token}" if token faraday.adapter Faraday.default_adapter end end
login()
click to toggle source
# File lib/botvac/cli.rb, line 12 def login email = ask("Email:").to_s password = ask("Pasword:", echo: false).to_s self.token = connection.post('/sessions', { platform: "ios", email: email, token: SecureRandom.hex(32), password: password }).body['access_token'] end
robots()
click to toggle source
# File lib/botvac/cli.rb, line 20 def robots login unless token puts '' connection.get('/dashboard').body['robots'].each do |bot| puts "#{bot['name']} (#{bot['model']}) => Serial: #{bot['serial']} Secret: #{bot['secret_key']}" end end