Module: Fleetly::Request

Included in:
Client
Defined in:
lib/fleetly/request.rb

Instance Method Summary collapse

Instance Method Details

#get(path, options) ⇒ Object



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

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

#post(path, options) ⇒ Object



11
12
13
# File 'lib/fleetly/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/fleetly/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 = MultiJson.encode(options) unless options.empty?
    end
  end

  response.body
end