Method: PostageApp::FailedRequest.resend_all
- Defined in:
- lib/postageapp/failed_request.rb
.resend_all ⇒ Object
Attempting to resend failed requests
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/postageapp/failed_request.rb', line 18 def self.resend_all return false if !store_path Dir.foreach(store_path) do |filename| next if !filename.match /^\w{40}$/ request = initialize_request(filename) receipt_response = PostageApp::Request.new(:get_message_receipt, :uid => filename).send(true) if receipt_response.fail? return elsif receipt_response.ok? PostageApp.logger.info "NOT RESENDING FAILED REQUEST [#{filename}]" File.delete(file_path(filename)) rescue nil elsif receipt_response.not_found? PostageApp.logger.info "RESENDING FAILED REQUEST [#{filename}]" response = request.send(true) # Not a fail, so we can remove this file, if it was then # there will be another attempt to resend File.delete(file_path(filename)) rescue nil if !response.fail? else PostageApp.logger.info "NOT RESENDING FAILED REQUEST [#{filename}], RECEIPT CANNOT BE PROCESSED" File.delete(file_path(filename)) rescue nil end end return end |