Method: Lono::Api::Proxy#send_request

Defined in:
lib/lono/api/proxy.rb

#send_request(klass, url, data = {}) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/lono/api/proxy.rb', line 33

def send_request(klass, url, data={})
  data.merge!(
    lono_version: Lono::VERSION,
    lono_command: lono_command,
  )
  req = klass.new(url) # url includes query string and uri.path does not, must used url
  if [Net::HTTP::Post, Net::HTTP::Put].include?(klass)
    text = JSON.dump(data)
    req.body = text
    req.content_length = text.bytesize
  end
  req
end