Class: HelperModule::RichBodyContent
Instance Method Summary
collapse
#add_headers, #get_request_klass, #initialize
Instance Method Details
#add_parameters(params = {}, type = 'json') ⇒ Object
143
144
145
146
147
148
149
150
151
|
# File 'lib/helpers/simple_http_helper.rb', line 143
def add_parameters(params = {}, type = 'json')
if type == 'json'
@body = params.to_json
@content_type = 'application/json'
@type = type
else
raise NotImplementedError, "only support json, #{type} is not supported"
end
end
|
#add_url_parameters(params = {}) ⇒ Object
153
154
155
|
# File 'lib/helpers/simple_http_helper.rb', line 153
def add_url_parameters(params = {})
@uri.query = URI.encode_www_form(params)
end
|
#get_request ⇒ Object
131
132
133
134
135
136
137
138
139
140
141
|
# File 'lib/helpers/simple_http_helper.rb', line 131
def get_request
_request = self.get_request_klass.new(@uri)
_request.body = @body if @body
_request.content_type = @content_type if @content_type
@headers.each_pair do |key, value|
_request.add_field(key, value)
end
_request
end
|