Module: OEHClient::Helper::Request

Defined in:
lib/oehclient/helper.rb

Constant Summary collapse

ONE_PROTOCOL =
"https://"
THUNDERHEAD_DOMAIN =
".thunderhead.com"
ONE_URI_PART =
"/one/oauth1"
API_URI_PART =
"/rt/api"
API_VERSION =
"/2.0"
POST_METHOD =
"post"
PUT_METHOD =
"put"

Class Method Summary collapse

Class Method Details

.default_JSON_headerObject

default_JSON_header is the default header that is passed to any OEH Request if not provided explicitly by the

calling methods
[View source]

40
41
42
# 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) ⇒ Object

request_url builds the target request URL with the passed parameters, URL encoding the parameters

as necessary to create a valid request
[View source]

21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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