class Bambora::BatchUpload::SendSingleBatch

Attributes

file_path[RW]
process_date[RW]

Public Class Methods

new(file_path,process_date) click to toggle source
# File lib/bambora/batch_upload/send_single_batch.rb, line 10
def initialize(file_path,process_date) 
  @file_path    = file_path
  @process_date = process_date
end

Public Instance Methods

call() { |batch_id| ... } click to toggle source
# File lib/bambora/batch_upload/send_single_batch.rb, line 15
def call
  begin
    service          = BeanstreamSendBatch.new(file_path,
                                               process_date,
                                               process_now)
    batch_id         = service.send
    unless batch_id.nil?
      yield(batch_id) if block_given? 
    end
  rescue BatchUploadError #reraise error
    raise
  rescue JSON::ParserError => err
    raise ConnectionError, "JSON parse Error: #{err.message}"
  rescue => err #most likely api connection error
    raise ConnectionError, "#{err.class}: #{err.message}"
  end
end

Private Instance Methods

process_now() click to toggle source
# File lib/bambora/batch_upload/send_single_batch.rb, line 35
def process_now
  if process_date
    0
  else
    1
  end
end