Class: Expo::Push::Tickets
- Inherits:
-
Object
- Object
- Expo::Push::Tickets
- Defined in:
- lib/push/tickets.rb
Overview
Tickets are paged: each batch when sending the notifications is one tickets entry. Each tickets entry has many tickets.
To ease exploration and continuation of the tickets, use the folowing methods:
-
#batch_ids: slices all the receipts into chunks
-
#each: iterates over each single ticket that is NOT an error
-
#each_error: iterates over each errorered batch and failed ticket
You MUST handle each error, and you MUST first check if its an Error or not, because of the way an entire batch call can fail.
Instance Method Summary collapse
- #batch_ids ⇒ Object
- #each ⇒ Object
- #each_error ⇒ Object
- #ids ⇒ Object
-
#initialize(results) ⇒ Tickets
constructor
A new instance of Tickets.
Constructor Details
#initialize(results) ⇒ Tickets
Returns a new instance of Tickets.
73 74 75 |
# File 'lib/push/tickets.rb', line 73 def initialize(results) self.results = results end |
Instance Method Details
#batch_ids ⇒ Object
83 84 85 |
# File 'lib/push/tickets.rb', line 83 def batch_ids ids.each_slice(PUSH_NOTIFICATION_RECEIPT_CHUNK_LIMIT).to_a end |
#each ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/push/tickets.rb', line 87 def each results.each do |tickets| next if tickets.is_a?(Error) tickets.each do |ticket| next unless ticket.ok? yield ticket end end end |
#each_error ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/push/tickets.rb', line 99 def each_error results.each do |tickets| if tickets.is_a?(Error) yield tickets else tickets.each do |ticket| next unless ticket.error? yield ticket end end end end |
#ids ⇒ Object
77 78 79 80 81 |
# File 'lib/push/tickets.rb', line 77 def ids [].tap do |ids| each { |ticket| ids << ticket.id } end end |