Class: Ondotori::WebAPI::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/ondotori/webapi/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(params = {}, uri: "") ⇒ Client

Returns a new instance of Client.



6
7
8
9
10
11
# File 'lib/ondotori/webapi/client.rb', line 6

def initialize(params = {}, uri: "")
  @param = Ondotori::WebAPI::Api::Param.new(params)
  @web_access = Ondotori::WebAPI::HttpWebAccess.new(30)
  @ondotori_uri = Ondotori::WebAPI::Api::URI.new(@param.)
  @uri = uri
end

Instance Attribute Details

#web_access=(value) ⇒ Object (writeonly)

Sets the attribute web_access

Parameters:

  • value

    the value to set the attribute web_access to.



50
51
52
# File 'lib/ondotori/webapi/client.rb', line 50

def web_access=(value)
  @web_access = value
end

Instance Method Details

#access_server(param, uri) ⇒ Object



13
14
15
16
17
# File 'lib/ondotori/webapi/client.rb', line 13

def access_server(param, uri)
  response = @web_access.access(uri, param.to_ondotori_param)
  ondotori_response = Ondotori::WebAPI::Api::Response.new(response)
  ondotori_response.result
end

#base_uriObject



44
45
46
47
48
# File 'lib/ondotori/webapi/client.rb', line 44

def base_uri
  return @uri unless @uri.empty?

  @ondotori_uri.uri
end

#current(remote_serial_list: [], base_serial_list: []) ⇒ Object



19
20
21
22
# File 'lib/ondotori/webapi/client.rb', line 19

def current(remote_serial_list: [], base_serial_list: [])
  param = Api::CurrentParams.new(@param, remote: remote_serial_list, base: base_serial_list)
  access_server(param, "#{base_uri}current")
end

#data(serial, data_range: nil) ⇒ Object



34
35
36
37
# File 'lib/ondotori/webapi/client.rb', line 34

def data(serial, data_range: nil)
  param = Api::DataParams.new(@param, serial, data_range: data_range)
  access_server(param, "#{base_uri}data")
end

#data_rtr500(base: "", remote: "", data_range: nil) ⇒ Object



39
40
41
42
# File 'lib/ondotori/webapi/client.rb', line 39

def data_rtr500(base: "", remote: "", data_range: nil)
  param = Api::DataRTR500Params.new(@param, remote, base, data_range: data_range)
  access_server(param, "#{base_uri}data-rtr500")
end

#latest_data(serial) ⇒ Object



24
25
26
27
# File 'lib/ondotori/webapi/client.rb', line 24

def latest_data(serial)
  param = Api::LatestDataParams.new(@param, serial: serial)
  access_server(param, "#{base_uri}latest-data")
end

#latest_data_rtr500(base: "", remote: "") ⇒ Object



29
30
31
32
# File 'lib/ondotori/webapi/client.rb', line 29

def latest_data_rtr500(base: "", remote: "")
  param = Api::LatestDataRTR500Params.new(@param, base: base, remote: remote)
  access_server(param, "#{base_uri}latest-data-rtr500")
end