Class: Braintree::MerchantAccountGateway
- Inherits:
-
Object
- Object
- Braintree::MerchantAccountGateway
show all
- Includes:
- BaseModule
- Defined in:
- lib/braintree/merchant_account_gateway.rb
Instance Method Summary
collapse
Methods included from BaseModule
included
#copy_instance_variables_from_object, #return_object_or_raise, #set_instance_variables_from_hash, #singleton_class
Constructor Details
Returns a new instance of MerchantAccountGateway.
5
6
7
8
9
|
# File 'lib/braintree/merchant_account_gateway.rb', line 5
def initialize(gateway)
@gateway = gateway
@config = gateway.config
@config.assert_has_access_token_or_keys
end
|
Instance Method Details
#_create_for_currency(params) ⇒ Object
35
36
37
38
39
40
41
42
43
44
45
46
47
|
# File 'lib/braintree/merchant_account_gateway.rb', line 35
def _create_for_currency(params)
response = @config.http.post("#{@config.base_merchant_path}/merchant_accounts/create_for_currency", :merchant_account => params)
if response.has_key?(:response) && response[:response][:merchant_account]
Braintree::SuccessfulResult.new(
:merchant_account => MerchantAccount._new(@gateway, response[:response][:merchant_account]),
)
elsif response[:api_error_response]
ErrorResult.new(@gateway, response[:api_error_response])
else
raise UnexpectedError, "expected :merchant or :api_error_response"
end
end
|
#_fetch_merchant_accounts(page_number) ⇒ Object
16
17
18
19
20
21
|
# File 'lib/braintree/merchant_account_gateway.rb', line 16
def _fetch_merchant_accounts(page_number)
response = @config.http.get("#{@config.base_merchant_path}/merchant_accounts?page=#{page_number}")
body = response[:merchant_accounts]
merchant_accounts = Util.(body, :merchant_account).map { |merchant_account| MerchantAccount._new(@gateway, merchant_account) }
PaginatedResult.new(body[:total_items], body[:page_size], merchant_accounts)
end
|
#create_for_currency(params) ⇒ Object
31
32
33
|
# File 'lib/braintree/merchant_account_gateway.rb', line 31
def create_for_currency(params)
_create_for_currency(params)
end
|
#find(merchant_account_id) ⇒ Object
23
24
25
26
27
28
29
|
# File 'lib/braintree/merchant_account_gateway.rb', line 23
def find(merchant_account_id)
raise ArgumentError if merchant_account_id.nil? || merchant_account_id.to_s.strip == ""
response = @config.http.get("#{@config.base_merchant_path}/merchant_accounts/#{merchant_account_id}")
MerchantAccount._new(@gateway, response[:merchant_account])
rescue NotFoundError
raise NotFoundError, "Merchant account with id #{merchant_account_id} not found"
end
|