Class: Tsks::Request

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

Class Method Summary collapse

Class Method Details

.base_uriObject



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