Module: Gerry::Api::Request
- Included in:
- Client
- Defined in:
- lib/gerry/api/request.rb
Overview
:nodoc:
Defined Under Namespace
Classes: RequestError
Instance Method Summary collapse
- #auth_url(url) ⇒ Object
- #delete(url) ⇒ Object
- #get(url) ⇒ Object
-
#map_options(options) ⇒ String
Get the mapped options.
- #post(url, body, is_json = true) ⇒ Object
- #put(url, body = nil, is_json = true) ⇒ Object
Instance Method Details
#auth_url(url) ⇒ Object
26 27 28 |
# File 'lib/gerry/api/request.rb', line 26 def auth_url(url) (@username && @password) ? "/a#{url}" : url end |
#delete(url) ⇒ Object
40 41 42 43 |
# File 'lib/gerry/api/request.rb', line 40 def delete(url) response = perform_request(:delete, auth_url(url)) parse(response) end |
#get(url) ⇒ Object
21 22 23 24 |
# File 'lib/gerry/api/request.rb', line 21 def get(url) response = perform_request(:get, auth_url(url)) parse(response) end |
#map_options(options) ⇒ String
Get the mapped options.
13 14 15 16 17 18 19 |
# File 'lib/gerry/api/request.rb', line 13 def () if .is_a?(Array) .map { |v| "#{v}" }.join('&') elsif .is_a?(Hash) .map { |k,v| "#{k}=#{v.join(',')}" }.join('&') end end |
#post(url, body, is_json = true) ⇒ Object
35 36 37 38 |
# File 'lib/gerry/api/request.rb', line 35 def post(url, body, is_json = true) response = perform_request(:post, auth_url(url), body, is_json) parse(response) end |
#put(url, body = nil, is_json = true) ⇒ Object
30 31 32 33 |
# File 'lib/gerry/api/request.rb', line 30 def put(url, body = nil, is_json = true) response = perform_request(:put, auth_url(url), body, is_json) parse(response) end |