Class: Braintree::SettlementBatchSummaryGateway

Inherits:
Object
  • Object
show all
Includes:
BaseModule
Defined in:
lib/braintree/settlement_batch_summary_gateway.rb

Instance Method Summary collapse

Methods included from BaseModule

included

Methods included from BaseModule::Methods

#copy_instance_variables_from_object, #return_object_or_raise, #set_instance_variables_from_hash, #singleton_class

Constructor Details

#initialize(gateway) ⇒ SettlementBatchSummaryGateway

Returns a new instance of SettlementBatchSummaryGateway.



5
6
7
8
9
# File 'lib/braintree/settlement_batch_summary_gateway.rb', line 5

def initialize(gateway)
  @gateway = gateway
  @config = gateway.config
  @config.assert_has_access_token_or_keys
end

Instance Method Details

#_signatureObject



23
24
25
# File 'lib/braintree/settlement_batch_summary_gateway.rb', line 23

def _signature
  [:settlement_date, :group_by_custom_field]
end

#generate(criteria) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/braintree/settlement_batch_summary_gateway.rb', line 11

def generate(criteria)
  Util.verify_keys(_signature, criteria)
  response = @config.http.post("#{@config.base_merchant_path}/settlement_batch_summary", :settlement_batch_summary => criteria)
  if response[:settlement_batch_summary]
    SuccessfulResult.new(:settlement_batch_summary => SettlementBatchSummary._new(@gateway, response[:settlement_batch_summary]))
  elsif response[:api_error_response]
    ErrorResult.new(@gateway, response[:api_error_response])
  else
    raise UnexpectedError, "expected :settlement_batch_summary or :api_error_response"
  end
end