Class: Lono::Api::Client

Inherits:
Object
  • Object
show all
Extended by:
Memoist
Includes:
Repos, Verify
Defined in:
lib/lono/api/client.rb

Instance Method Summary collapse

Methods included from Repos

#repos

Methods included from Verify

#temp_key, #verify

Instance Method Details

#httpObject



7
8
9
# File 'lib/lono/api/client.rb', line 7

def http
  Proxy.new
end

#load_json(res) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/lono/api/client.rb', line 12

def load_json(res)
  if res.code == "200"
    data = JSON.load(res.body)
    case data
    when Array
      data.map(&:deep_symbolize_keys)
    when Hash
      data.deep_symbolize_keys
    end
  else
    if ENV['LONO_DEBUG_API']
      puts "Error: Non-successful http response status code: #{res.code}"
      puts "headers: #{res.each_header.to_h.inspect}"
    end
    nil
  end
end