module Eol::Request
Defines HTTP request methods
Public Instance Methods
delete(path, options = {})
click to toggle source
Perform an HTTP DELETE request
# File lib/eol/request.rb, line 22 def delete(path, options = {}) request(:delete, path, options) end
get(path, options = {})
click to toggle source
Perform an HTTP GET request
# File lib/eol/request.rb, line 7 def get(path, options = {}) request(:get, path, options) end
post(path, options = {})
click to toggle source
Perform an HTTP POST request
# File lib/eol/request.rb, line 12 def post(path, options = {}) request(:post, path, options) end
put(path, options = {})
click to toggle source
Perform an HTTP PUT request
# File lib/eol/request.rb, line 17 def put(path, options = {}) request(:put, path, options) end
Private Instance Methods
add_headers(options = {})
click to toggle source
# File lib/eol/request.rb, line 37 def add_headers(options = {}) content_type = options[:content_type] || "application/#{response_format}" headers = {} headers["Content-Type"] = content_type headers["Accept"] = content_type headers["Authorization"] = "Bearer #{access_token}" if access_token headers end
build_path(path, options)
click to toggle source
# File lib/eol/request.rb, line 28 def build_path(path, options) unless options[:use_raw_path] path = "#{division}/#{path}" unless options[:no_division] path = "#{endpoint}/#{path}" unless options[:no_endpoint] path = "#{options[:url] || base_url}/#{path}" end path end
request(method, path, options = {})
click to toggle source
Perform an HTTP request
# File lib/eol/request.rb, line 47 def request(method, path, options = {}) path = build_path(path, options) response = connection.send(method) do |request| case method when :post, :put request.url path request.body = options[:body] || options[:params].to_json when :get, :delete request.url path end request.headers = add_headers(options) end Response.new(response) end