Module: RestClientPlus::Requests

Defined in:
lib/requests.rb

Class Method Summary collapse

Class Method Details

.get_json_from_url(input_url) ⇒ Object



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

def self.get_json_from_url input_url
  parse_response(RestClient.get(input_url))
end

.parse_response(response) ⇒ Object



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

def self.parse_response(response)
  response.respond_to?(:reverse) ? JSON.parse(response) : response
end

.post_json_to_url(input_url, json_body) ⇒ Object



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

def self.post_json_to_url input_url, json_body
  parse_response(RestClient.post(input_url, json_body, :content_type => 'application/json'))
end

.put_json_to_url(input_url, json_body) ⇒ Object



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

def self.put_json_to_url input_url, json_body
  parse_response(RestClient.put(input_url, json_body, :content_type => 'application/json'))
end