Class: Wes::Data::API::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/wes/data/api/request.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.get(path) ⇒ Object



9
10
11
# File 'lib/wes/data/api/request.rb', line 9

def self.get(path)
  new.get path
end

.post(path, options = {}) ⇒ Object



13
14
15
# File 'lib/wes/data/api/request.rb', line 13

def self.post(path, options = {})
  new.post(path, options)
end

.put(path, options = {}) ⇒ Object



17
18
19
# File 'lib/wes/data/api/request.rb', line 17

def self.put(path, options = {})
  new.put(path, options)
end

Instance Method Details

#get(path) ⇒ Object



21
22
23
24
25
26
# File 'lib/wes/data/api/request.rb', line 21

def get(path)
  connection.get do |r|
    r.url complete_path(path)
    r.options.timeout = TIMEOUT
  end
end

#post(path, options) ⇒ Object



28
29
30
31
32
33
34
35
# File 'lib/wes/data/api/request.rb', line 28

def post(path, options)
  connection.post do |r|
    r.body = options.to_json
    r.headers["Content-Type"] = "application/json"
    r.url complete_path(path)
    r.options.timeout = TIMEOUT
  end
end

#put(path, options) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/wes/data/api/request.rb', line 37

def put(path, options)
  connection.put do |r|
    r.body = options.to_json
    r.headers["Content-Type"] = "application/json"
    r.url complete_path(path)
    r.options.timeout = TIMEOUT
  end
end