Class: Ondotori::WebAPI::Api::CurrentParams

Inherits:
ParamsBase
  • Object
show all
Defined in:
lib/ondotori/webapi/api/params.rb

Instance Method Summary collapse

Constructor Details

#initialize(param, remote: [], base: []) ⇒ CurrentParams

Returns a new instance of CurrentParams.



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/ondotori/webapi/api/params.rb', line 22

def initialize(param, remote: [], base: [])
  super(param)

  if remote.length.positive? && base.length.positive?
    raise Ondotori::WebAPI::Api::Errors::InvaildParameter.new(
      "Both remote_serial_list and base_serial_list cannot be set.", 9998
    )
  end
  @remote_serial_list = remote
  @base_serial_list = base
end

Instance Method Details

#to_ondotori_paramObject



34
35
36
37
38
39
40
# File 'lib/ondotori/webapi/api/params.rb', line 34

def to_ondotori_param
  params = super
  params["remote-serial"] = @remote_serial_list if @remote_serial_list.length.positive?
  params["base-serial"] = @base_serial_list if @base_serial_list.length.positive?

  params
end