class WireClient::Abstract::WireBatch
Base class for sending batched Wire transfer transactions to various providers
Public Class Methods
arguments()
click to toggle source
@return [Array] A list of arguments to use in the initializer, and as instance attributes
# File lib/wire_client/providers/base/wire_batch.rb, line 54 def self.arguments [ :transaction_type ] end
new(*arguments)
click to toggle source
@param transaction_type [WireClient::TransactionTypes::TransactionType] debit or credit
# File lib/wire_client/providers/base/wire_batch.rb, line 65 def initialize(*arguments) args = arguments.extract_options! self.class.arguments.each do |param| self.instance_variable_set( "@#{param}".to_sym, args[param] ) end if @transaction_type == WireClient::TransactionTypes::Credit initialize_payment_initiation(CreditTransfer) elsif @transaction_type == WireClient::TransactionTypes::Debit initialize_payment_initiation(DirectDebit) else raise InvalidWireTransactionTypeError, 'Transaction type should be explicitly defined' end end
Public Instance Methods
add_transaction(transaction_options)
click to toggle source
# File lib/wire_client/providers/base/wire_batch.rb, line 83 def add_transaction(transaction_options) @payment_initiation.add_transaction(transaction_options) end
do_send_batch()
click to toggle source
Implementation of sending the Wire transfer batch to the provider, to be
implemented by the subclass
# File lib/wire_client/providers/base/wire_batch.rb, line 101 def do_send_batch raise AbstractMethodError end
send_batch()
click to toggle source
Sends the batch to the provider. Useful to check transaction status
before sending any data (consistency, validation, etc.)
# File lib/wire_client/providers/base/wire_batch.rb, line 90 def send_batch if @payment_initiation.valid? do_send_batch else raise InvalidWireTransactionError, "invalid wire transfer: #{@payment_initiation.error_messages}" end end
Private Instance Methods
initialize_payment_initiation(klass)
click to toggle source
# File lib/wire_client/providers/base/wire_batch.rb, line 107 def initialize_payment_initiation(klass) if self.class.initiator_iban @payment_initiation = klass.new( name: self.class.initiator_name, bic: self.class.initiator_bic, iban: self.class.initiator_iban, identifier: self.class.initiator_identifier, postal_code: self.class.initiator_postal_code, address_line: self.class.initiator_address_line, city: self.class.initiator_city, country_subdivision: self.class.initiator_country_subdivision, country: self.class.initiator_country ) else @payment_initiation = klass.new( name: self.class.initiator_name, wire_routing_number: self.class.initiator_wire_routing_number, account_number: self.class.initiator_account_number, identifier: self.class.initiator_identifier, postal_code: self.class.initiator_postal_code, address_line: self.class.initiator_address_line, city: self.class.initiator_city, country_subdivision: self.class.initiator_country_subdivision, country: self.class.initiator_country ) end end