Class: RubyPushNotifications::GCM::GCMResponse
- Inherits:
-
Object
- Object
- RubyPushNotifications::GCM::GCMResponse
- Defined in:
- lib/ruby-push-notifications/gcm/gcm_response.rb
Overview
This class encapsulates a response received from the GCM 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/gcm/server-ref.html#table4).
-
#failed ⇒ Integer
readonly
The number of failed notifications.
-
#results ⇒ Array
(also: #individual_results)
readonly
Array of a GCMResult 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) ⇒ GCMResponse
constructor
Initializes the GCMResponse and runs response parsing.
Constructor Details
#initialize(code, body) ⇒ GCMResponse
Initializes the GCMResponse and runs response parsing
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/ruby-push-notifications/gcm/gcm_response.rb', line 34 def initialize(code, body) case code when 200 parse_response body when 400 raise MalformedGCMJSONError, body when 401 raise GCMAuthError, body when 500..599 raise GCMInternalError, body else raise UnexpectedGCMResponseError, code end end |
Instance Attribute Details
#canonical_ids ⇒ Integer (readonly)
Returns the number of received canonical IDS (developer.android.com/google/gcm/server-ref.html#table4).
19 20 21 |
# File 'lib/ruby-push-notifications/gcm/gcm_response.rb', line 19 def canonical_ids @canonical_ids end |
#failed ⇒ Integer (readonly)
Returns the number of failed notifications.
15 16 17 |
# File 'lib/ruby-push-notifications/gcm/gcm_response.rb', line 15 def failed @failed end |
#results ⇒ Array (readonly) Also known as: individual_results
Returns Array of a GCMResult for every receiver of the notification sent indicating the result of the operation.
23 24 25 |
# File 'lib/ruby-push-notifications/gcm/gcm_response.rb', line 23 def results @results end |
#success ⇒ Integer (readonly)
Returns the number of successfully sent notifications.
12 13 14 |
# File 'lib/ruby-push-notifications/gcm/gcm_response.rb', line 12 def success @success end |
Instance Method Details
#==(other) ⇒ Object
49 50 51 52 53 54 55 |
# File 'lib/ruby-push-notifications/gcm/gcm_response.rb', line 49 def ==(other) (other.is_a?(GCMResponse) && success == other.success && failed == other.failed && canonical_ids == other.canonical_ids && results == other.results) || super(other) end |