Class: IletiMerkezi::Response
- Inherits:
-
Object
- Object
- IletiMerkezi::Response
- Extended by:
- Forwardable
- Defined in:
- lib/ileti_merkezi/response.rb
Overview
Response
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#code ⇒ Object
readonly
Returns the value of attribute code.
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Instance Method Summary collapse
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #status ⇒ Object
- #to_h ⇒ Object (also: #to_hash)
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
14 15 16 17 18 |
# File 'lib/ileti_merkezi/response.rb', line 14 def initialize(response) @response = response @code = response.code.to_i @body = response.body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
12 13 14 |
# File 'lib/ileti_merkezi/response.rb', line 12 def body @body end |
#code ⇒ Object (readonly)
Returns the value of attribute code.
12 13 14 |
# File 'lib/ileti_merkezi/response.rb', line 12 def code @code end |
#response ⇒ Object (readonly)
Returns the value of attribute response.
12 13 14 |
# File 'lib/ileti_merkezi/response.rb', line 12 def response @response end |
Instance Method Details
#status ⇒ Object
20 21 22 |
# File 'lib/ileti_merkezi/response.rb', line 20 def status Status.find(code) end |
#to_h ⇒ Object Also known as: to_hash
24 25 26 27 28 29 30 31 32 |
# File 'lib/ileti_merkezi/response.rb', line 24 def to_h hash = Ox.load( body.force_encoding('utf-8'), mode: :hash ) hash.fetch(:response, hash) rescue Ox::ParseError {} end |