Class: Youlend::Response
- Inherits:
-
Object
- Object
- Youlend::Response
- Extended by:
- Forwardable
- Defined in:
- lib/youlend/response.rb
Instance Attribute Summary collapse
-
#http_response ⇒ Object
readonly
Returns the value of attribute http_response.
Instance Method Summary collapse
- #data ⇒ Object
- #errors ⇒ Object
-
#initialize(http_response) ⇒ Response
constructor
A new instance of Response.
- #token_expired? ⇒ Boolean
- #unauthorized? ⇒ Boolean
Constructor Details
#initialize(http_response) ⇒ Response
Returns a new instance of Response.
12 13 14 |
# File 'lib/youlend/response.rb', line 12 def initialize(http_response) @http_response = http_response end |
Instance Attribute Details
#http_response ⇒ Object (readonly)
Returns the value of attribute http_response.
9 10 11 |
# File 'lib/youlend/response.rb', line 9 def http_response @http_response end |
Instance Method Details
#data ⇒ Object
34 35 36 |
# File 'lib/youlend/response.rb', line 34 def data @http_response.body end |
#errors ⇒ Object
28 29 30 31 32 |
# File 'lib/youlend/response.rb', line 28 def errors return [] unless || token_expired? @http_response.body end |
#token_expired? ⇒ Boolean
20 21 22 23 24 25 26 |
# File 'lib/youlend/response.rb', line 20 def token_expired? auth_header = @http_response.headers['www-authenticate'] return false unless auth_header auth_header.match?(/.*token is expired.*/) end |
#unauthorized? ⇒ Boolean
16 17 18 |
# File 'lib/youlend/response.rb', line 16 def status == 401 end |