Module: ExternalParamValidator

Defined in:
lib/external_param_validator.rb,
lib/external_param_validator/version.rb

Constant Summary collapse

VERSION =
"0.1.4"

Instance Method Summary collapse

Instance Method Details

#check_external_paramObject



13
14
15
16
17
18
19
20
21
22
# File 'lib/external_param_validator.rb', line 13

def check_external_param()
  if request.headers["Device-id"]
    device =  HTTParty.get(url_string(request.headers["Device-id"]))
    if device.present?
      device
    else
      render nothing: true, status: :not_found
    end
  end
end

#url_string(device_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/external_param_validator.rb', line 5

def url_string(device_id)
    if ENV["URL_DEVICE_AUTH"]
      "#{ENV["URL_DEVICE_AUTH"]}/#{device_id}"
    else
      "http://localhost:3001/api/v1/terminals/#{device_id}"
    end
end