Class: Tsks::Request
- Inherits:
-
Object
- Object
- Tsks::Request
- Defined in:
- lib/tsks/request.rb
Class Method Summary collapse
- .base_uri ⇒ Object
- .delete(endpoint, token) ⇒ Object
- .get(endpoint, token) ⇒ Object
- .post(endpoint, token = nil, body) ⇒ Object
Class Method Details
.base_uri ⇒ Object
8 9 10 |
# File 'lib/tsks/request.rb', line 8 def self.base_uri @base_uri end |
.delete(endpoint, token) ⇒ Object
31 32 33 34 35 |
# File 'lib/tsks/request.rb', line 31 def self.delete endpoint, token uri = URI "#{Request.base_uri}#{endpoint}" res = HTTParty.delete uri, headers: {authorization: "Bearer #{token}"} parsed_res = parse_response res.body end |
.get(endpoint, token) ⇒ Object
25 26 27 28 29 |
# File 'lib/tsks/request.rb', line 25 def self.get endpoint, token uri = URI "#{Request.base_uri}#{endpoint}" res = HTTParty.get uri, headers: {authorization: "Bearer #{token}"} parsed_res = parse_response res.body end |
.post(endpoint, token = nil, body) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/tsks/request.rb', line 12 def self.post endpoint, token=nil, body uri = URI "#{Request.base_uri}#{endpoint}" if token res = HTTParty.post uri, body: body, headers: {authorization: "Bearer #{token}"} else res = HTTParty.post uri, body: body end parsed_res = parse_response res.body end |