Module: Bambora::BatchUpload

Defined in:
lib/bambora/batch_upload.rb,
lib/bambora/batch_upload/version.rb,
lib/bambora/batch_upload/exceptions.rb,
lib/bambora/batch_upload/create_batch_file.rb,
lib/bambora/batch_upload/send_single_batch.rb,
lib/bambora/batch_upload/beanstream_send_batch.rb

Defined Under Namespace

Classes: BatchUploadError, BeanstreamSendBatch, ConnectionError, CreateBatchFile, MakeArray, SendSingleBatch

Constant Summary collapse

VERSION =
"0.2.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.batch_file_pathObject

optional



17
18
19
# File 'lib/bambora/batch_upload.rb', line 17

def batch_file_path
  @batch_file_path
end

.batch_upload_api_keyObject

Returns the value of attribute batch_upload_api_key.



15
16
17
# File 'lib/bambora/batch_upload.rb', line 15

def batch_upload_api_key
  @batch_upload_api_key
end

.batch_upload_api_urlObject

Returns the value of attribute batch_upload_api_url.



18
19
20
# File 'lib/bambora/batch_upload.rb', line 18

def batch_upload_api_url
  @batch_upload_api_url
end

.file_pathObject

file name



20
21
22
# File 'lib/bambora/batch_upload.rb', line 20

def file_path
  @file_path
end

.merchant_idObject

must be provided by user



14
15
16
# File 'lib/bambora/batch_upload.rb', line 14

def merchant_id
  @merchant_id
end

Class Method Details

.configure {|_self| ... } ⇒ Object

Yields:

  • (_self)

Yield Parameters:

Raises:

  • (ArgumentError)


45
46
47
48
# File 'lib/bambora/batch_upload.rb', line 45

def self.configure &block
  raise ArgumentError unless block_given?
  yield(self)
end

.create_array(txn_type) {|reader| ... } ⇒ Object

Yields:

  • (reader)


50
51
52
53
54
# File 'lib/bambora/batch_upload.rb', line 50

def self.create_array txn_type, &block
  reader = MakeArray.new txn_type
  yield(reader)
  reader.array
end

.create_file(txn_type, &block) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'lib/bambora/batch_upload.rb', line 27

def self.create_file txn_type, &block
  raise "provide a block" unless block_given?
  @file_path = CreateBatchFile.new(create_array(txn_type,&block)).call
  if @file_path.nil?
    raise "No file generated!!!" 
  else
    @file_path
  end
end

.do_upload(process_date = Date.next_business_day, &block) ⇒ Object



22
23
24
25
# File 'lib/bambora/batch_upload.rb', line 22

def self.do_upload(process_date=Date.next_business_day,&block)
  raise "Configure Merchant ID and Upload API key" unless config_complete 
  SendSingleBatch.new(file_path,process_date).call(&block) 
end

.get_batch_file_pathObject



41
42
43
# File 'lib/bambora/batch_upload.rb', line 41

def self.get_batch_file_path
  batch_file_path || @default_batch_file_path 
end

.get_batch_upload_api_urlObject



37
38
39
# File 'lib/bambora/batch_upload.rb', line 37

def self.get_batch_upload_api_url
  batch_upload_api_url || @default_batch_upload_api_url
end