class Firebase::Admin::Messaging::TopicManagementResponse
A response received from a topic management operation.
Attributes
errors[R]
@return [Array<ErrorInfo>] An array of {ErrorInfo} objects (possibly empty).
failure_count[R]
@return [Integer] The number of tokens that could not be subscribed or unsubscribed due to errors.
success_count[R]
@return [Integer] The number of tokens successfully subscribed or unsubscribed.
Public Class Methods
new(response)
click to toggle source
Initializes a {TopicManagementResponse}.
@param [Faraday::Response] response
The response received from the api.
# 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