Module: ViglinkApi::Request

Included in:
Client, Purchases
Defined in:
lib/viglink_api/request.rb

Instance Method Summary collapse

Instance Method Details

#get(path, options) ⇒ Object



7
8
9
# File 'lib/viglink_api/request.rb', line 7

def get(path, options)
  request(:get, path, options)
end

#post(path, options) ⇒ Object



11
12
13
# File 'lib/viglink_api/request.rb', line 11

def post(path, options)
  request(:post, path, options)
end

#request(method, path, options) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/viglink_api/request.rb', line 15

def request(method, path, options)
  response = connection.send(method) do |request|
  case method
    when :get
      request.url(path, options)
    when :put, :post
      request.path = path
      request.body = options.to_xml unless options.empty?
    end
  end

  response.body
end