Class: Expo::Push::Receipts
- Inherits:
-
Object
- Object
- Expo::Push::Receipts
- Defined in:
- lib/push/receipts.rb
Overview
Receipts represent a single call to the receipts endpoint. It holds both the successfully retrieved receipts, as well as the still unresolved IDs.
You MUST iterate #each_error and first check if its an Error, which would be the case if the entire call failed. Otherwise, it will iterate through each receipt that indicates a failed push.
Keep calling the receipts endpoint until #unresolved_ids is empty, or a day has passed at least.
Instance Method Summary collapse
- #each ⇒ Object
- #each_error ⇒ Object
-
#initialize(results:, requested_ids:) ⇒ Receipts
constructor
A new instance of Receipts.
- #unresolved_ids ⇒ Object
Constructor Details
#initialize(results:, requested_ids:) ⇒ Receipts
Returns a new instance of Receipts.
67 68 69 70 |
# File 'lib/push/receipts.rb', line 67 def initialize(results:, requested_ids:) self.results = results self.requested_ids = requested_ids end |
Instance Method Details
#each ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/push/receipts.rb', line 72 def each results.each do |receipt| next unless receipt.ok? yield receipt end end |
#each_error ⇒ Object
80 81 82 83 84 85 86 87 |
# File 'lib/push/receipts.rb', line 80 def each_error results.each do |receipt| next yield receipt if receipt.is_a?(Error) next unless receipt.error? yield receipt end end |
#unresolved_ids ⇒ Object
89 90 91 |
# File 'lib/push/receipts.rb', line 89 def unresolved_ids requested_ids - results.map(&:receipt_id) end |