Class: FatSecret::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/fat_secret/connection.rb

Class Method Summary collapse

Class Method Details

.get(method, params) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fat_secret/connection.rb', line 10

def get(method, params)
  FatSecret.configuration.logger.debug(
    "FatSecret::Connection.get #{method} with #{params}"
  )

  params = default_parameters.merge(params).merge(method: method)
  params.each do |key, value|
    params[key] = CGI.escape(value) if value.is_a?(String)
  end
  uri = request_uri('GET', params)
  response = uri.read
  FatSecret.configuration.logger.debug(
    "FatSecret Response: #{response}"
  )
  JSON.parse(response)
end