Module: Flickr::Client::Requests

Included in:
Flickr::Client
Defined in:
lib/flickr/client/requests.rb

Instance Method Summary collapse

Instance Method Details

#delete(path, params = {}) ⇒ Object



17
18
19
# File 'lib/flickr/client/requests.rb', line 17

def delete(path, params = {})
  request :delete, path, params        
end

#get(path, params = {}) ⇒ Object



5
6
7
# File 'lib/flickr/client/requests.rb', line 5

def get(path, params = {})
  request :get, path, params
end

#post(path, params = {}) ⇒ Object



9
10
11
# File 'lib/flickr/client/requests.rb', line 9

def post(path, params = {})
  request :post, path, params        
end

#put(path, params = {}) ⇒ Object



13
14
15
# File 'lib/flickr/client/requests.rb', line 13

def put(path, params = {})
  request :put, path, params        
end

#request(method, path, params = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/flickr/client/requests.rb', line 21

def request(method, path, params = {})
  params = params.dup
  options = extract_connection_options(params)
  
  if method.to_sym == :get
    response = connection(options).send(method, build_rest_query(path, params))
  else
    response = connection(options).send(method, path, params)
  end
  
  if options[:normalize]
    options[:format].to_s == 'json' ? normalize_json(response.body) : normalize_xml(response.body)
  else
    response.body
  end
end