class Stormpath::Http::Request
Attributes
api_key[RW]
body[RW]
href[RW]
http_headers[RW]
http_method[RW]
query_string[RW]
Public Class Methods
new(http_method, href, query_string, http_headers, body, api_key)
click to toggle source
# File lib/stormpath-sdk/http/request.rb 23 def initialize(http_method, href, query_string, http_headers, body, api_key) 24 splitted = href.split '?' 25 26 @query_string = query_string || {} 27 28 if splitted && splitted.length > 1 29 @href = splitted[0] 30 query_string_str = splitted[1] 31 query_string_arr = query_string_str.split '&' 32 query_string_arr.each do |pair| 33 pair_arr = pair.split '=' 34 @query_string.store pair_arr[0], pair_arr[1] 35 end 36 else 37 @href = href 38 end 39 40 @http_method = http_method.upcase 41 @http_headers = http_headers 42 @body = body 43 @api_key = api_key 44 45 @http_headers.store 'Content-Length', @body.bytesize if body 46 end
Public Instance Methods
camelize(key)
click to toggle source
# File lib/stormpath-sdk/http/request.rb 68 def camelize(key) 69 custom_data_params?(key) ? key : key.camelize(:lower) 70 end
custom_data_params?(key)
click to toggle source
# File lib/stormpath-sdk/http/request.rb 72 def custom_data_params?(key) 73 key.starts_with?('customData.') 74 end
resource_uri()
click to toggle source
# File lib/stormpath-sdk/http/request.rb 48 def resource_uri 49 URI href 50 end
to_s_query_string(canonical)
click to toggle source
# File lib/stormpath-sdk/http/request.rb 52 def to_s_query_string(canonical) 53 result = '' 54 55 unless @query_string.empty? 56 Hash[@query_string.sort_by(&:to_s)].each do |key, value| 57 enc_key = encode_url key, false, canonical 58 enc_value = encode_url value, false, canonical 59 60 result << '&' unless result.empty? 61 result << camelize(enc_key) << '=' << enc_value 62 end 63 end 64 65 result 66 end