Module: Vercellus::Utils::Request
- Defined in:
- lib/vercellus/utils/request.rb
Overview
Utility request module for Vercellus
Class Method Summary collapse
- .delete(url, params = {}) ⇒ Object
- .get(url, params = {}) ⇒ Object
- .post(url, params = {}, body = {}) ⇒ Object
Class Method Details
.delete(url, params = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/vercellus/utils/request.rb', line 37 def delete(url, params = {}) response = Faraday.delete( "https://api.vercel.com/#{url}", params: params, headers: { 'Content-Type': "application/json", 'Authorization': "Bearer #{Vercellus.configuration.token}" } ) JSON.parse(response.body) end |
.get(url, params = {}) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/vercellus/utils/request.rb', line 10 def get(url, params = {}) response = Faraday.get( "https://api.vercel.com/#{url}", params: params, headers: { 'Content-Type': "application/json", 'Authorization': "Bearer #{Vercellus.configuration.token}" } ) JSON.parse(response.body) end |
.post(url, params = {}, body = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/vercellus/utils/request.rb', line 23 def post(url, params = {}, body = {}) response = Faraday.post( "https://api.vercel.com/#{url}", body: body.to_json, params: params, headers: { 'Content-Type': "application/json", 'Authorization': "Bearer #{Vercellus.configuration.token}" } ) JSON.parse(response.body) end |