module Polygon::Api::Request

Public Instance Methods

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

Private Instance Methods

request(method, path, options) click to toggle source
# File lib/polygon/api/request.rb, line 22
def request(method, path, options)
  path = [endpoint, path].join
  response = connection.send(method) do |request|
    case method
    when :get, :delete
      request.url(path, options)
    when :post, :put
      request.path = path
      request.body = options.to_json unless options.empty?
    end
    request.options.merge!(options.delete(:request)) if options.key?(:request)
  end
  response.body
end