Class: HTTPWrapper::Request
- Inherits:
-
Object
- Object
- HTTPWrapper::Request
- Defined in:
- lib/http_wrapper/request.rb
Constant Summary collapse
- KNOWN_PARAMS_KEYS =
[:headers, :query, :cookie, :auth, :body, :user_agent, :content_type, :multipart].freeze
Instance Attribute Summary collapse
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #create ⇒ Object
-
#initialize(url, method, params = {}) ⇒ Request
constructor
A new instance of Request.
Constructor Details
#initialize(url, method, params = {}) ⇒ Request
Returns a new instance of Request.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/http_wrapper/request.rb', line 7 def initialize(url, method, params = {}) validate_parameters params self.uri = url @headers = params[:headers] || {} @query = params[:query] || {} @cookie = params[:cookie] || @headers[HEADER::COOKIE] @login = params[:auth] && params[:auth].fetch(:login) @password = params[:auth] && params[:auth].fetch(:password) @method = method @method_class = Net::HTTP.const_get(method.to_s.capitalize) @body = params[:body] @user_agent = params[:user_agent] @content_type = params[:content_type] @multipart_data = params[:multipart] || [] initialize_headers end |
Instance Attribute Details
#uri ⇒ Object
Returns the value of attribute uri.
30 31 32 |
# File 'lib/http_wrapper/request.rb', line 30 def uri @uri end |
Instance Method Details
#create ⇒ Object
41 42 43 44 45 |
# File 'lib/http_wrapper/request.rb', line 41 def create rebuild_uri_query_params convert_symbol_headers_to_string create_http_request end |