class Thron::Gateway::Device

Constants

PACKAGE

Public Class Methods

routes() click to toggle source
# File lib/thron/gateway/device.rb, line 11
def self.routes
  @routes ||= {
    connect_device: Route::factory(name: 'connect', package: PACKAGE),
    disconnect_device: Route::factory(name: 'disconnect', package: PACKAGE),
    get_device: Route::factory(name: 'get', package: PACKAGE, verb: Route::Verbs::GET, params: [client_id])
  }
end

Public Instance Methods

connect_device(options = {}) click to toggle source
# File lib/thron/gateway/device.rb, line 19
def connect_device(options = {})
  device_id = options[:device_id]
  ik = options[:ik]
  contact_name = options[:contact_name]
  body = { 
    clientId: client_id,
    deviceId: device_id,
    ik: ik,
    contactName: contact_name
  }
  route(to: __callee__, body: body, token_id: token_id) do |response|
    response.body = Entity::Base::factory(response.body)
  end
end
disconnect_device(options = {}) click to toggle source
# File lib/thron/gateway/device.rb, line 34
def disconnect_device(options = {})
  device_id = options[:device_id]
  contact_id = options[:contact_id]
  body = { 
    clientId: client_id,
    deviceId: device_id,
    contactId: contact_id
  }
  route(to: __callee__, body: body, token_id: token_id) do |response|
    response.body = Entity::Base::factory(response.body)
  end
end
get_device(options = {}) click to toggle source
# File lib/thron/gateway/device.rb, line 47
def get_device(options = {})
  device_id = options[:device_id]
  query = { 
    deviceId: device_id,
  }
  route(to: __callee__, query: query, token_id: token_id) do |response|
    response.body = Entity::Base::factory(response.body)
  end
end