Class: CodePicnic::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/codepicnic/request.rb

Class Method Summary collapse

Class Method Details

.get(url) ⇒ Object


6
7
8
# File 'lib/codepicnic/request.rb', line 6

def get(url)
  JSON.parse(RestClient.get "#{url}.json", {'Authorization' => "Bearer #{CodePicnic.token}", "Content-Type" => "application/json; charset=utf-8"})
end

.post(url, params = {}) ⇒ Object


10
11
12
# File 'lib/codepicnic/request.rb', line 10

def post(url, params = {})
  JSON.parse(RestClient.post "#{url}.json", params.to_json, {'Authorization' => "Bearer #{CodePicnic.token}", "Content-Type" => "application/json; charset=utf-8"})
end

.post_form(url, params = {}) ⇒ Object


14
15
16
# File 'lib/codepicnic/request.rb', line 14

def post_form(url, params = {})
  JSON.parse(RestClient.post "#{url}.json", params, {'Authorization' => "Bearer #{CodePicnic.token}", "Content-Type" => "application/x-www-form-urlencoded; charset=utf-8"})
end