Class: Maia::FCM::Response
- Inherits:
-
Object
- Object
- Maia::FCM::Response
- Defined in:
- lib/maia/fcm/response.rb
Instance Method Summary collapse
- #body ⇒ Object
- #error ⇒ Object
- #fail? ⇒ Boolean
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #status ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
4 5 6 |
# File 'lib/maia/fcm/response.rb', line 4 def initialize(response) @response = response end |
Instance Method Details
#body ⇒ Object
8 9 10 |
# File 'lib/maia/fcm/response.rb', line 8 def body @response.body end |
#error ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/maia/fcm/response.rb', line 24 def error case json.dig('error', 'status') when 'UNREGISTERED' Maia::Error::Unregistered.new else Maia::Error::Generic.new json.dig('error', 'message') end end |
#fail? ⇒ Boolean
20 21 22 |
# File 'lib/maia/fcm/response.rb', line 20 def fail? !success? end |
#status ⇒ Object
12 13 14 |
# File 'lib/maia/fcm/response.rb', line 12 def status @response.code.to_i end |
#success? ⇒ Boolean
16 17 18 |
# File 'lib/maia/fcm/response.rb', line 16 def success? (200..399).cover? status end |