Module: Veeqo::Request::ClassMethods

Defined in:
lib/veeqo/request.rb

Instance Method Summary collapse

Instance Method Details

#delete(path, params = {}) ⇒ Object



51
52
53
54
55
# File 'lib/veeqo/request.rb', line 51

def delete(path, params = {})
  response = raw_request(:delete, path, params)
  return response.body if response.body.empty?
  build_response_object response
end

#get(path, params = {}) ⇒ Object



46
47
48
49
# File 'lib/veeqo/request.rb', line 46

def get(path, params = {})
  response = raw_request(:get, path, params)
  build_response_object response
end

#post(path, params = {}) ⇒ Object



57
58
59
60
# File 'lib/veeqo/request.rb', line 57

def post(path, params = {})
  response = raw_request(:post, path, params)
  build_response_object response
end

#put(path, params = {}) ⇒ Object



62
63
64
65
# File 'lib/veeqo/request.rb', line 62

def put(path, params = {})
  response = raw_request(:put, path, params)
  build_response_object response
end

#quantity(path, params = {}) ⇒ Object



67
68
69
70
# File 'lib/veeqo/request.rb', line 67

def quantity(path, params = {})
  response = raw_request(:get, path, params)
  response.headers['X-Total-Count'].to_i
end

#raw_request(method, path, params = {}) ⇒ Object



72
73
74
75
# File 'lib/veeqo/request.rb', line 72

def raw_request(method, path, params = {})
  client = params.delete(:connection) || Veeqo.api
  client.send(method, path.to_s, params)
end