Class: SpreeCmCommissioner::PaymentReferences::AbaCsvImportService
- Inherits:
-
Object
- Object
- SpreeCmCommissioner::PaymentReferences::AbaCsvImportService
- Defined in:
- app/services/spree_cm_commissioner/payment_references/aba_csv_import_service.rb
Constant Summary collapse
- DEFAULT_BATCH_SIZE =
500- DATETIME_FORMATS =
[ '%m/%d/%Y %I:%M:%S %p', '%d/%m/%Y %I:%M:%S %p', '%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M' ].freeze
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(csv_content:, import_record: nil) ⇒ AbaCsvImportService
constructor
A new instance of AbaCsvImportService.
Constructor Details
#initialize(csv_content:, import_record: nil) ⇒ AbaCsvImportService
Returns a new instance of AbaCsvImportService.
16 17 18 19 |
# File 'app/services/spree_cm_commissioner/payment_references/aba_csv_import_service.rb', line 16 def initialize(csv_content:, import_record: nil) @csv_content = csv_content @import_record = import_record end |
Instance Method Details
#call ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/services/spree_cm_commissioner/payment_references/aba_csv_import_service.rb', line 21 def call failed_rows = [] = Time.zone.now CSV.parse(@csv_content.to_s, headers: true, header_converters: :symbol) .each_slice(batch_size) .with_index do |rows, batch_index| process_batch(rows, batch_index, failed_rows, ) end store_failures(failed_rows) failed_rows end |