Class: RubyPushNotifications::FCM::FCMResponse
- Inherits:
-
Object
- Object
- RubyPushNotifications::FCM::FCMResponse
- Defined in:
- lib/ruby-push-notifications/fcm/fcm_response.rb
Overview
This class encapsulates a response received from the FCM service and helps parsing and understanding the received meesages/codes.
Instance Attribute Summary collapse
-
#canonical_ids ⇒ Integer
readonly
The number of received canonical IDS (developer.android.com/google/fcm/server-ref.html#table4).
-
#failed ⇒ Integer
readonly
The number of failed notifications.
-
#results ⇒ Array
(also: #individual_results)
readonly
Array of a FCMResult for every receiver of the notification sent indicating the result of the operation.
-
#success ⇒ Integer
readonly
The number of successfully sent notifications.
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(code, body) ⇒ FCMResponse
constructor
Initializes the FCMResponse and runs response parsing.
Constructor Details
#initialize(code, body) ⇒ FCMResponse
Initializes the FCMResponse and runs response parsing
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/ruby-push-notifications/fcm/fcm_response.rb', line 35 def initialize(code, body) case code when 200 parse_response body when 400 raise MalformedFCMJSONError, body when 401 raise FCMAuthError, body when 500..599 raise FCMInternalError, body else raise UnexpectedFCMResponseError, code end end |
Instance Attribute Details
#canonical_ids ⇒ Integer (readonly)
Returns the number of received canonical IDS (developer.android.com/google/fcm/server-ref.html#table4).
20 21 22 |
# File 'lib/ruby-push-notifications/fcm/fcm_response.rb', line 20 def canonical_ids @canonical_ids end |
#failed ⇒ Integer (readonly)
Returns the number of failed notifications.
16 17 18 |
# File 'lib/ruby-push-notifications/fcm/fcm_response.rb', line 16 def failed @failed end |
#results ⇒ Array (readonly) Also known as: individual_results
Returns Array of a FCMResult for every receiver of the notification sent indicating the result of the operation.
24 25 26 |
# File 'lib/ruby-push-notifications/fcm/fcm_response.rb', line 24 def results @results end |
#success ⇒ Integer (readonly)
Returns the number of successfully sent notifications.
13 14 15 |
# File 'lib/ruby-push-notifications/fcm/fcm_response.rb', line 13 def success @success end |
Instance Method Details
#==(other) ⇒ Object
50 51 52 53 54 55 56 |
# File 'lib/ruby-push-notifications/fcm/fcm_response.rb', line 50 def ==(other) (other.is_a?(FCMResponse) && success == other.success && failed == other.failed && canonical_ids == other.canonical_ids && results == other.results) || super(other) end |