module OEHClient::Helper::Request
Constants
- API_URI_PART
- API_VERSION
- ONE_PROTOCOL
- ONE_URI_PART
- POST_METHOD
- PUT_METHOD
- THUNDERHEAD_DOMAIN
Public Class Methods
default_JSON_header()
click to toggle source
default_JSON_header
is the default header that is passed to any OEH Request
if not provided explicitly by the
calling methods
# File lib/oehclient/helper.rb, line 40 def self.default_JSON_header() {'Accept' => 'application/json' , 'dataMimeType' => 'application/json','Content-Type' =>'application/json', 'X-Requested-With' => 'XMLHttpRequest' } end
format_url(url, params)
click to toggle source
request_url builds the target request URL with the passed parameters, URL encoding the parameters
as necessary to create a valid request
# File lib/oehclient/helper.rb, line 21 def self.format_url(url, params) # for each of the parameters, build a single query parameter string parameter_part = "" params.each do |key, value| # if there is more than one argument, add the apppropriate separator (&) between # query parameters parameter_part << "&" if (parameter_part.length > 0) # URL Encode the value of the property parameter_part << "#{key.to_s}=#{ERB::Util.url_encode(value)}" end # return the fully-qualified URL with parameters (if passsed) (parameter_part.length > 0 ? "#{url}?#{parameter_part}" : "#{url}") end