class PaymentRails::BatchGateway

Public Class Methods

new(client) click to toggle source
# File lib/paymentrails/gateways/BatchGateway.rb, line 8
def initialize(client)
  @client = client
end

Public Instance Methods

all() click to toggle source
# File lib/paymentrails/gateways/BatchGateway.rb, line 17
def all
  response = @client.get('/v1/batches/')
  batch_list_builder(response)
end
batch_builder(response) click to toggle source
# File lib/paymentrails/gateways/BatchGateway.rb, line 52
def batch_builder(response)
  batch = Batch.new
  data = JSON.parse(response)
  data.each do |key, value|
    next unless key === 'batch'
    loosely_hydrate_model(batch, value)
  end
  batch
end
batch_list_builder(response) click to toggle source
# File lib/paymentrails/gateways/BatchGateway.rb, line 73
def batch_list_builder(response)
  batches = []
  data = JSON.parse(response)

  data.each do |key, value|
    next unless key === 'batches'
    value.each do |newKey, _newValue|
      batches.push(
        loosely_hydrate_model(Batch.new, newKey)
      )
    end
  end
  batches
end
create(body) click to toggle source
# File lib/paymentrails/gateways/BatchGateway.rb, line 22
def create(body)
  response = @client.post('/v1/batches/', body)
  batch_builder(response)
end
delete(batch_id) click to toggle source
# File lib/paymentrails/gateways/BatchGateway.rb, line 32
def delete(batch_id)
  @client.delete('/v1/batches/' + batch_id)
  true
end
find(batch_id) click to toggle source
# File lib/paymentrails/gateways/BatchGateway.rb, line 12
def find(batch_id)
  response = @client.get('/v1/batches/' + batch_id)
  batch_builder(response)
end
generate_quote(batch_id) click to toggle source
# File lib/paymentrails/gateways/BatchGateway.rb, line 37
def generate_quote(batch_id)
  response = @client.post('/v1/batches/' + batch_id + '/generate-quote', {})
  batch_builder(response)
end
start_processing(batch_id) click to toggle source
# File lib/paymentrails/gateways/BatchGateway.rb, line 42
def start_processing(batch_id)
  response = @client.post('/v1/batches/' + batch_id + '/start-processing', {})
  batch_builder(response)
end
summary(batch_id) click to toggle source
# File lib/paymentrails/gateways/BatchGateway.rb, line 62
def summary(batch_id)
  response = @client.get('/v1/batches/' + batch_id + '/summary')
  summary = BatchSummary.new
  data = JSON.parse(response)
  data.each do |key, value|
    next unless key === 'batchSummary'
    loosely_hydrate_model(summary, value)
  end
  summary
end
update(batch_id, body) click to toggle source
# File lib/paymentrails/gateways/BatchGateway.rb, line 27
def update(batch_id, body)
  @client.patch('/v1/batches/' + batch_id, body)
  true
end