Class: Bambora::BatchUpload::SendSingleBatch

Inherits:
Object
  • Object
show all
Defined in:
lib/bambora/batch_upload/send_single_batch.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path, process_date) ⇒ SendSingleBatch

Returns a new instance of SendSingleBatch.



10
11
12
13
# 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

Instance Attribute Details

#file_pathObject

Returns the value of attribute file_path.



7
8
9
# File 'lib/bambora/batch_upload/send_single_batch.rb', line 7

def file_path
  @file_path
end

#process_dateObject

Returns the value of attribute process_date.



8
9
10
# File 'lib/bambora/batch_upload/send_single_batch.rb', line 8

def process_date
  @process_date
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# 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