Class: Kameleoon::Network::Request
- Inherits:
-
Object
- Object
- Kameleoon::Network::Request
- Defined in:
- lib/kameleoon/network/request.rb
Overview
Request represents HTTP request.
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#content_type ⇒ Object
readonly
Returns the value of attribute content_type.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#extra_headers ⇒ Object
readonly
Returns the value of attribute extra_headers.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#timeout ⇒ Object
readonly
Returns the value of attribute timeout.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #authorize(access_token) ⇒ Object
-
#initialize(method, url, content_type, timeout, extra_headers: nil, data: nil) ⇒ Request
constructor
A new instance of Request.
- #to_s ⇒ Object
Constructor Details
#initialize(method, url, content_type, timeout, extra_headers: nil, data: nil) ⇒ Request
Returns a new instance of Request.
22 23 24 25 26 27 28 29 |
# File 'lib/kameleoon/network/request.rb', line 22 def initialize(method, url, content_type, timeout, extra_headers: nil, data: nil) @method = method @url = url @content_type = content_type @timeout = timeout @extra_headers = extra_headers @data = !data.nil? && data.is_a?(String) ? data.encode('UTF-8') : data end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
8 9 10 |
# File 'lib/kameleoon/network/request.rb', line 8 def access_token @access_token end |
#content_type ⇒ Object (readonly)
Returns the value of attribute content_type.
8 9 10 |
# File 'lib/kameleoon/network/request.rb', line 8 def content_type @content_type end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
8 9 10 |
# File 'lib/kameleoon/network/request.rb', line 8 def data @data end |
#extra_headers ⇒ Object (readonly)
Returns the value of attribute extra_headers.
8 9 10 |
# File 'lib/kameleoon/network/request.rb', line 8 def extra_headers @extra_headers end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
8 9 10 |
# File 'lib/kameleoon/network/request.rb', line 8 def method @method end |
#timeout ⇒ Object (readonly)
Returns the value of attribute timeout.
8 9 10 |
# File 'lib/kameleoon/network/request.rb', line 8 def timeout @timeout end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
8 9 10 |
# File 'lib/kameleoon/network/request.rb', line 8 def url @url end |
Instance Method Details
#authorize(access_token) ⇒ Object
31 32 33 |
# File 'lib/kameleoon/network/request.rb', line 31 def (access_token) @access_token = access_token end |
#to_s ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/kameleoon/network/request.rb', line 10 def to_s body = 'null' unless @data.nil? if @data.is_a?(String) body = @data.start_with?('grant_type=client_credentials') ? '****' : @data else body = @data end end "HttpRequest{Method:'#{@method}',Url:'#{@url}',Headers:#{@extra_headers},Body:'#{body}'}" end |