Class: Innologix::DeviceLog

Inherits:
Object
  • Object
show all
Defined in:
lib/innologix/device_log.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(h = {}) ⇒ DeviceLog

Returns a new instance of DeviceLog.



10
11
12
13
# File 'lib/innologix/device_log.rb', line 10

def initialize(h = {})
  h.each { |k, v| public_send("#{k}=", v) }
  @client = Client.default
end

Instance Attribute Details

#clientObject

Returns the value of attribute client.



7
8
9
# File 'lib/innologix/device_log.rb', line 7

def client
  @client
end

#created_atObject

Returns the value of attribute created_at.



4
5
6
# File 'lib/innologix/device_log.rb', line 4

def created_at
  @created_at
end

#errorObject

Returns the value of attribute error.



8
9
10
# File 'lib/innologix/device_log.rb', line 8

def error
  @error
end

#idObject

Returns the value of attribute id.



3
4
5
# File 'lib/innologix/device_log.rb', line 3

def id
  @id
end

#updated_atObject

Returns the value of attribute updated_at.



5
6
7
# File 'lib/innologix/device_log.rb', line 5

def updated_at
  @updated_at
end

Instance Method Details

#get_total_logs(device_ids, from_time, to_time) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/innologix/device_log.rb', line 58

def get_total_logs(device_ids, from_time, to_time)
  path = '/device_logs/get_total_logs'
  method = 'post'
  options = {query_params: {from_time: from_time, to_time: to_time, device_ids: device_ids}}
  result = client.call_api(path, method, options)
  if result[:error] == 0
    result[:devices]
  else
    {}
  end
end

#statistic_minutes(from_time, to_time, arrange, supervisor_id = 0) ⇒ Object



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/innologix/device_log.rb', line 37

def statistic_minutes(from_time, to_time, arrange, supervisor_id = 0)
  path = '/device_logs/statistic_minutes'
  method = 'get'
  options = {query_params: {from_time: from_time, to_time: to_time, arrange: arrange, supervisor_id: supervisor_id}}
  result = client.call_api(path, method, options)
  if result[:error] == 0
    list = []
    result[:statistics].each do |statistic|
      _statistic = OpenStruct.new
      _statistic.timestamp = statistic[:timestamp]
      _statistic.messages = statistic[:messages]
      _statistic.size = statistic[:size]
      _statistic.failures = statistic[:failures]
      list.push(_statistic)
    end
    list
  else
    []
  end
end

#statistics(from_time, to_time) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/innologix/device_log.rb', line 15

def statistics(from_time, to_time)
  path = '/device_logs/statistics'
  method = 'get'
  options = {query_params: {from_time: from_time, to_time: to_time}}
  result = client.call_api(path, method, options)
  if result[:error] == 0
    messages = result[:statistics][:messages]
    size = result[:statistics][:size]
    failures = result[:statistics][:failures]
    result = OpenStruct.new
    result.messages = messages
    result.size = size
    result.failures = failures
    result
  else
    result = OpenStruct.new
    result.messages = 0
    result.size = 0
    result
  end
end