module FlowAccount::Request

Public Instance Methods

delete(path, options={}, raw=false, no_response_wrapper=no_response_wrapper()) click to toggle source
# File lib/flow_account/request.rb, line 16
def delete(path, options={}, raw=false, no_response_wrapper=no_response_wrapper())
  request(:delete, path, options, raw, no_response_wrapper)
end
get(path, options={}, raw=false, no_response_wrapper=no_response_wrapper()) click to toggle source
# File lib/flow_account/request.rb, line 8
def get(path, options={}, raw=false, no_response_wrapper=no_response_wrapper())
  request(:get, path, options, raw, no_response_wrapper)
end
post(path, options={}, raw=false, no_response_wrapper=no_response_wrapper()) click to toggle source
# File lib/flow_account/request.rb, line 4
def post(path, options={}, raw=false, no_response_wrapper=no_response_wrapper())
  request(:post, path, options, raw, no_response_wrapper)
end
put(path, options={}, raw=false, no_response_wrapper=no_response_wrapper()) click to toggle source
# File lib/flow_account/request.rb, line 12
def put(path, options={}, raw=false, no_response_wrapper=no_response_wrapper())
  request(:put, path, options, raw, no_response_wrapper)
end

Private Instance Methods

request(method, path, options, raw=false, no_response_wrapper=false) click to toggle source
# File lib/flow_account/request.rb, line 21
def request(method, path, options, raw=false, no_response_wrapper=false)
  response = connection(raw).send(method) do |request|
    case method
    when :get, :delete
      request.url(URI.encode(path), options)
    when :post, :put
      request.path = URI.encode(path)
      request.body = options unless options.empty?
    end
  end
  return response if raw
  return response.body if no_response_wrapper
  return Response.create(response.body)
end