Class: Firebase::Admin::Messaging::TopicManagementResponse
- Inherits:
-
Object
- Object
- Firebase::Admin::Messaging::TopicManagementResponse
- Defined in:
- lib/firebase/admin/messaging/topic_management_response.rb
Overview
A response received from a topic management operation.
Instance Attribute Summary collapse
-
#errors ⇒ Array<ErrorInfo>
readonly
An array of ErrorInfo objects (possibly empty).
-
#failure_count ⇒ Integer
readonly
The number of tokens that could not be subscribed or unsubscribed due to errors.
-
#success_count ⇒ Integer
readonly
The number of tokens successfully subscribed or unsubscribed.
Instance Method Summary collapse
-
#initialize(response) ⇒ TopicManagementResponse
constructor
Initializes a TopicManagementResponse.
Constructor Details
#initialize(response) ⇒ TopicManagementResponse
Initializes a Firebase::Admin::Messaging::TopicManagementResponse.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/firebase/admin/messaging/topic_management_response.rb', line 19 def initialize(response) unless response.body.is_a?(Hash) && response.body["results"].is_a?(Array) raise Error.new("Unexpected topic management response", response) end @success_count = 0 @failure_count = 0 @errors = [] results = response.body["results"] results.each_with_index do |result, i| if (reason = result["error"]) @failure_count += 1 @errors << ErrorInfo.new(index: i, reason: reason) else @success_count += 1 end end end |
Instance Attribute Details
#errors ⇒ Array<ErrorInfo> (readonly)
Returns An array of ErrorInfo objects (possibly empty).
13 14 15 |
# File 'lib/firebase/admin/messaging/topic_management_response.rb', line 13 def errors @errors end |
#failure_count ⇒ Integer (readonly)
Returns The number of tokens that could not be subscribed or unsubscribed due to errors.
10 11 12 |
# File 'lib/firebase/admin/messaging/topic_management_response.rb', line 10 def failure_count @failure_count end |
#success_count ⇒ Integer (readonly)
Returns The number of tokens successfully subscribed or unsubscribed.
7 8 9 |
# File 'lib/firebase/admin/messaging/topic_management_response.rb', line 7 def success_count @success_count end |