class Innologix::DeviceType
Attributes
client[RW]
created_at[RW]
error[RW]
id[RW]
name[RW]
protocol[RW]
supervisor_id[RW]
updated_at[RW]
Public Class Methods
new(h = {})
click to toggle source
# File lib/innologix/device_type.rb, line 14 def initialize(h = {}) h.each { |k, v| public_send("#{k}=", v) } @client = Client.default end
Public Instance Methods
create()
click to toggle source
# File lib/innologix/device_type.rb, line 54 def create path = '/device_types' method = 'post' options = {form_params: {device_type: {name: name, supervisor_id: supervisor_id, protocol: protocol, tags: tags}}} result = client.call_api(path, method, options) if result[:error].nil? from_hash(result) else RequestError.new(result) end end
delete()
click to toggle source
# File lib/innologix/device_type.rb, line 78 def delete path = '/device_types/' + id.to_s method = 'delete' result = client.call_api(path, method) if result[:error].nil? from_hash(result) else RequestError.new(result) end end
from_hash(attributes)
click to toggle source
# File lib/innologix/device_type.rb, line 89 def from_hash(attributes) device_type = Innologix::DeviceType.new device_type.id = attributes[:id] device_type.name = attributes[:name] device_type.supervisor_id = attributes[:supervisor_id] device_type.protocol = attributes[:protocol] device_type.tags = attributes[:tags] device_type.created_at = attributes[:created_at] device_type.updated_at = attributes[:updated_at] device_type end
get(id)
click to toggle source
# File lib/innologix/device_type.rb, line 43 def get(id) path = '/device_types/' + id.to_s method = 'get' result = client.call_api(path, method) if result[:error].nil? from_hash(result) else RequestError.new(result) end end
list(offset = 0, limit = 10)
click to toggle source
# File lib/innologix/device_type.rb, line 19 def list(offset = 0, limit = 10) path = '/device_types' method = 'get' options = {query_params: {offset: offset, limit: limit}} result = client.call_api(path, method, options) if result[:error].nil? list =[] result[:device_types].each do |device_type| list.push(from_hash(device_type)) end meta = OpenStruct.new meta.offset = result[:meta][:offset] meta.limit = result[:meta][:limit] meta.total = result[:meta][:total] result = OpenStruct.new result.device_types = list result.meta = meta result else RequestError.new(result) end end
update()
click to toggle source
# File lib/innologix/device_type.rb, line 66 def update path = '/device_types/' + id.to_s method = 'put' options = {form_params: {device_type: {name: name, supervisor_id: supervisor_id, protocol: protocol, tags: tags}}} result = client.call_api(path, method, options) if result[:error].nil? from_hash(result) else RequestError.new(result) end end