Class: Lorkhan::Response
- Inherits:
-
Object
- Object
- Lorkhan::Response
- Defined in:
- lib/lorkhan/response.rb
Overview
A wrapper around the HTTP/2 response from Apple
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
Instance Method Summary collapse
-
#apns_id ⇒ Object
Get the APNS id for the notification.
-
#initialize(raw) ⇒ Response
constructor
This class should never be instantiated directly.
-
#ok? ⇒ Boolean
Convenience method to check if the status is 200.
-
#status ⇒ Object
Get the HTTP status.
Constructor Details
#initialize(raw) ⇒ Response
This class should never be instantiated directly.
11 12 13 14 15 16 |
# File 'lib/lorkhan/response.rb', line 11 def initialize(raw) @headers = raw.headers @body = JSON.parse(raw.body) rescue JSON::ParserError @body = nil end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
8 9 10 |
# File 'lib/lorkhan/response.rb', line 8 def body @body end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
8 9 10 |
# File 'lib/lorkhan/response.rb', line 8 def headers @headers end |
Instance Method Details
#apns_id ⇒ Object
Get the APNS id for the notification
35 36 37 |
# File 'lib/lorkhan/response.rb', line 35 def apns_id headers['apns-id'] end |
#ok? ⇒ Boolean
Convenience method to check if the status is 200
21 22 23 |
# File 'lib/lorkhan/response.rb', line 21 def ok? status == 200 end |
#status ⇒ Object
Get the HTTP status
28 29 30 |
# File 'lib/lorkhan/response.rb', line 28 def status headers[':status'].to_i end |