balanced 0.8.2 → 1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rbenv-version +1 -1
- data/.ruby-version +1 -1
- data/Gemfile +7 -3
- data/README.md +2 -10
- data/Rakefile +4 -18
- data/balanced.gemspec +8 -10
- data/lib/balanced.rb +28 -28
- data/lib/balanced/client.rb +15 -6
- data/lib/balanced/error.rb +21 -12
- data/lib/balanced/pager.rb +66 -25
- data/lib/balanced/resources.rb +18 -17
- data/lib/balanced/resources/api_key.rb +4 -0
- data/lib/balanced/resources/bank_account.rb +26 -75
- data/lib/balanced/resources/callback.rb +2 -0
- data/lib/balanced/resources/card.rb +15 -65
- data/lib/balanced/resources/card_hold.rb +38 -0
- data/lib/balanced/resources/credit.rb +6 -50
- data/lib/balanced/resources/customer.rb +33 -71
- data/lib/balanced/resources/debit.rb +6 -14
- data/lib/balanced/resources/event.rb +6 -0
- data/lib/balanced/resources/funding_instrument.rb +11 -0
- data/lib/balanced/resources/hypermedia.rb +28 -0
- data/lib/balanced/resources/marketplace.rb +5 -203
- data/lib/balanced/resources/order.rb +71 -0
- data/lib/balanced/resources/refund.rb +2 -7
- data/lib/balanced/resources/resource.rb +169 -106
- data/lib/balanced/resources/reversal.rb +2 -8
- data/lib/balanced/resources/transfer.rb +11 -0
- data/lib/balanced/response/balanced_exception_middleware.rb +2 -2
- data/lib/balanced/utils.rb +47 -14
- data/lib/balanced/version.rb +1 -1
- data/scenario.cache +526 -380
- data/scenarios/api_key_create/definition.rb +1 -0
- data/scenarios/api_key_create/request.rb +2 -0
- data/scenarios/api_key_create/ruby.mako +21 -0
- data/scenarios/api_key_delete/definition.rb +1 -0
- data/scenarios/api_key_delete/request.rb +3 -0
- data/scenarios/api_key_delete/ruby.mako +12 -0
- data/scenarios/api_key_list/definition.rb +1 -0
- data/scenarios/api_key_list/request.rb +2 -0
- data/scenarios/api_key_list/ruby.mako +28 -0
- data/scenarios/api_key_show/definition.rb +1 -0
- data/scenarios/api_key_show/request.rb +2 -0
- data/scenarios/api_key_show/ruby.mako +18 -0
- data/scenarios/{customer_add_bank_account → bank_account_associate_to_customer}/definition.rb +0 -0
- data/scenarios/bank_account_associate_to_customer/request.rb +3 -0
- data/scenarios/bank_account_associate_to_customer/ruby.mako +49 -0
- data/scenarios/bank_account_create/definition.rb +1 -1
- data/scenarios/bank_account_create/request.rb +1 -1
- data/scenarios/bank_account_create/ruby.mako +44 -7
- data/scenarios/{credit_create_existing_bank_account → bank_account_credit}/definition.rb +0 -0
- data/scenarios/bank_account_credit/request.rb +3 -0
- data/scenarios/bank_account_credit/ruby.mako +42 -0
- data/scenarios/bank_account_debit/definition.rb +1 -0
- data/scenarios/bank_account_debit/request.rb +5 -0
- data/scenarios/bank_account_debit/ruby.mako +50 -0
- data/scenarios/bank_account_delete/request.rb +1 -1
- data/scenarios/bank_account_delete/ruby.mako +5 -3
- data/scenarios/bank_account_list/ruby.mako +76 -2
- data/scenarios/bank_account_show/definition.rb +1 -1
- data/scenarios/bank_account_show/request.rb +1 -1
- data/scenarios/bank_account_show/ruby.mako +41 -5
- data/scenarios/bank_account_update/definition.rb +1 -0
- data/scenarios/bank_account_update/request.rb +6 -0
- data/scenarios/bank_account_update/ruby.mako +56 -0
- data/scenarios/bank_account_verification_create/request.rb +1 -1
- data/scenarios/bank_account_verification_create/ruby.mako +20 -3
- data/scenarios/bank_account_verification_show/definition.rb +1 -1
- data/scenarios/bank_account_verification_show/request.rb +1 -1
- data/scenarios/bank_account_verification_show/ruby.mako +21 -4
- data/scenarios/bank_account_verification_update/definition.rb +1 -1
- data/scenarios/bank_account_verification_update/request.rb +5 -5
- data/scenarios/bank_account_verification_update/ruby.mako +24 -8
- data/scenarios/callback_create/definition.rb +1 -1
- data/scenarios/callback_create/request.rb +2 -2
- data/scenarios/callback_create/ruby.mako +22 -0
- data/scenarios/callback_delete/definition.rb +1 -1
- data/scenarios/callback_delete/request.rb +2 -2
- data/scenarios/callback_delete/ruby.mako +12 -0
- data/scenarios/callback_list/definition.rb +1 -1
- data/scenarios/callback_list/request.rb +1 -2
- data/scenarios/callback_list/ruby.mako +20 -0
- data/scenarios/callback_show/definition.rb +1 -1
- data/scenarios/callback_show/request.rb +1 -1
- data/scenarios/callback_show/ruby.mako +20 -0
- data/scenarios/{customer_add_card → card_associate_to_customer}/definition.rb +0 -0
- data/scenarios/card_associate_to_customer/request.rb +3 -0
- data/scenarios/card_associate_to_customer/ruby.mako +49 -0
- data/scenarios/card_create/request.rb +1 -2
- data/scenarios/card_create/ruby.mako +44 -7
- data/scenarios/card_debit/definition.rb +1 -0
- data/scenarios/card_debit/request.rb +5 -0
- data/scenarios/card_debit/ruby.mako +49 -0
- data/scenarios/card_delete/request.rb +1 -1
- data/scenarios/card_delete/ruby.mako +5 -3
- data/scenarios/card_hold_capture/definition.rb +1 -0
- data/scenarios/card_hold_capture/request.rb +5 -0
- data/scenarios/card_hold_capture/ruby.mako +49 -0
- data/scenarios/card_hold_create/definition.rb +1 -0
- data/scenarios/card_hold_create/request.rb +5 -0
- data/scenarios/card_hold_create/ruby.mako +38 -0
- data/scenarios/card_hold_list/definition.rb +1 -0
- data/scenarios/card_hold_list/request.rb +2 -0
- data/scenarios/card_hold_list/ruby.mako +60 -0
- data/scenarios/card_hold_show/definition.rb +1 -0
- data/scenarios/card_hold_show/request.rb +2 -0
- data/scenarios/card_hold_show/ruby.mako +36 -0
- data/scenarios/card_hold_update/definition.rb +1 -0
- data/scenarios/card_hold_update/request.rb +7 -0
- data/scenarios/card_hold_update/ruby.mako +42 -0
- data/scenarios/card_hold_void/definition.rb +1 -0
- data/scenarios/card_hold_void/request.rb +3 -0
- data/scenarios/card_hold_void/ruby.mako +36 -0
- data/scenarios/card_list/definition.rb +1 -1
- data/scenarios/card_list/request.rb +1 -1
- data/scenarios/card_list/ruby.mako +78 -5
- data/scenarios/card_show/definition.rb +1 -1
- data/scenarios/card_show/request.rb +1 -1
- data/scenarios/card_show/ruby.mako +42 -4
- data/scenarios/card_update/definition.rb +1 -1
- data/scenarios/card_update/request.rb +1 -1
- data/scenarios/card_update/ruby.mako +45 -4
- data/scenarios/credit_list/request.rb +1 -3
- data/scenarios/credit_list/ruby.mako +34 -4
- data/scenarios/{credit_bank_account_list → credit_list_bank_account}/definition.rb +0 -0
- data/scenarios/credit_list_bank_account/request.rb +3 -0
- data/scenarios/credit_list_bank_account/ruby.mako +13 -0
- data/scenarios/credit_show/definition.rb +1 -1
- data/scenarios/credit_show/request.rb +1 -3
- data/scenarios/credit_show/ruby.mako +35 -5
- data/scenarios/{credit_create_new_bank_account → credit_update}/definition.rb +0 -0
- data/scenarios/credit_update/request.rb +7 -0
- data/scenarios/credit_update/ruby.mako +48 -0
- data/scenarios/customer_create/request.rb +4 -1
- data/scenarios/customer_create/ruby.mako +60 -3
- data/scenarios/customer_delete/request.rb +1 -1
- data/scenarios/customer_delete/ruby.mako +4 -2
- data/scenarios/customer_list/definition.rb +1 -0
- data/scenarios/customer_list/request.rb +2 -0
- data/scenarios/customer_list/ruby.mako +105 -0
- data/scenarios/customer_show/definition.rb +1 -0
- data/scenarios/customer_show/request.rb +2 -0
- data/scenarios/customer_show/ruby.mako +58 -0
- data/scenarios/customer_update/definition.rb +1 -0
- data/scenarios/customer_update/request.rb +7 -0
- data/scenarios/customer_update/ruby.mako +64 -0
- data/scenarios/debit_list/request.rb +1 -3
- data/scenarios/debit_list/ruby.mako +70 -4
- data/scenarios/debit_show/definition.rb +1 -1
- data/scenarios/debit_show/request.rb +1 -1
- data/scenarios/debit_show/ruby.mako +39 -4
- data/scenarios/debit_update/definition.rb +1 -1
- data/scenarios/debit_update/request.rb +1 -1
- data/scenarios/debit_update/ruby.mako +39 -4
- data/scenarios/event_list/definition.rb +1 -1
- data/scenarios/event_list/request.rb +1 -2
- data/scenarios/event_list/ruby.mako +54 -5
- data/scenarios/event_show/definition.rb +1 -1
- data/scenarios/event_show/request.rb +1 -1
- data/scenarios/event_show/ruby.mako +54 -4
- data/scenarios/helpers.rb +29 -2
- data/scenarios/order_create/definition.rb +1 -0
- data/scenarios/order_create/request.rb +5 -0
- data/scenarios/order_create/ruby.mako +46 -0
- data/scenarios/order_list/definition.rb +1 -0
- data/scenarios/order_list/request.rb +2 -0
- data/scenarios/order_list/ruby.mako +42 -0
- data/scenarios/order_show/definition.rb +1 -0
- data/scenarios/order_show/request.rb +2 -0
- data/scenarios/order_show/ruby.mako +44 -0
- data/scenarios/order_update/definition.rb +1 -0
- data/scenarios/order_update/request.rb +7 -0
- data/scenarios/order_update/ruby.mako +50 -0
- data/scenarios/refund_create/definition.rb +1 -1
- data/scenarios/refund_create/request.rb +2 -1
- data/scenarios/refund_create/ruby.mako +33 -5
- data/scenarios/refund_list/request.rb +1 -3
- data/scenarios/refund_list/ruby.mako +30 -4
- data/scenarios/refund_show/definition.rb +1 -1
- data/scenarios/refund_show/request.rb +1 -1
- data/scenarios/refund_show/ruby.mako +32 -4
- data/scenarios/refund_update/definition.rb +1 -1
- data/scenarios/refund_update/request.rb +1 -1
- data/scenarios/refund_update/ruby.mako +32 -4
- data/scenarios/render_mako.rb +59 -4
- data/scenarios/reversal_create/definition.rb +1 -0
- data/scenarios/reversal_create/request.rb +9 -0
- data/scenarios/reversal_create/ruby.mako +45 -0
- data/scenarios/reversal_list/definition.rb +1 -0
- data/scenarios/reversal_list/request.rb +2 -0
- data/scenarios/reversal_list/ruby.mako +36 -0
- data/scenarios/reversal_show/definition.rb +1 -0
- data/scenarios/reversal_show/request.rb +2 -0
- data/scenarios/reversal_show/ruby.mako +37 -0
- data/scenarios/reversal_update/definition.rb +1 -0
- data/scenarios/reversal_update/request.rb +7 -0
- data/scenarios/reversal_update/ruby.mako +44 -0
- data/spec/balanced/error_spec.rb +7 -7
- data/spec/balanced/pager_spec.rb +10 -10
- data/spec/balanced/resources/api_key_spec.rb +6 -35
- data/spec/balanced/resources/bank_account_spec.rb +123 -218
- data/spec/balanced/resources/callback_spec.rb +12 -13
- data/spec/balanced/resources/card_hold_spec.rb +103 -0
- data/spec/balanced/resources/card_spec.rb +101 -27
- data/spec/balanced/resources/credit_spec.rb +69 -35
- data/spec/balanced/resources/customer_spec.rb +91 -271
- data/spec/balanced/resources/debit_spec.rb +95 -0
- data/spec/balanced/resources/marketplace_spec.rb +17 -170
- data/spec/balanced/resources/order_spec.rb +364 -0
- data/spec/balanced/resources/resource_spec.rb +25 -32
- data/spec/balanced_spec.rb +18 -36
- data/spec/client_spec.rb +7 -7
- data/spec/spec_helper.rb +19 -18
- data/spec/utils_spec.rb +5 -5
- metadata +123 -165
- data/examples/bank_account_debits.rb +0 -57
- data/examples/customers.rb +0 -114
- data/examples/events_and_callbacks.rb +0 -81
- data/examples/examples.rb +0 -162
- data/examples/exception_handling.rb +0 -44
- data/lib/balanced/resources/account.rb +0 -179
- data/lib/balanced/resources/hold.rb +0 -61
- data/lib/balanced/resources/invoice.rb +0 -11
- data/lib/balanced/resources/merchant.rb +0 -21
- data/lib/balanced/resources/transaction.rb +0 -17
- data/scenarios/account_add_card/definition.rb +0 -1
- data/scenarios/account_add_card/request.rb +0 -3
- data/scenarios/account_add_card/ruby.mako +0 -11
- data/scenarios/account_capture_hold/definition.rb +0 -1
- data/scenarios/account_capture_hold/request.rb +0 -3
- data/scenarios/account_capture_hold/ruby.mako +0 -11
- data/scenarios/account_create/definition.rb +0 -1
- data/scenarios/account_create/request.rb +0 -2
- data/scenarios/account_create/ruby.mako +0 -10
- data/scenarios/account_create_buyer/definition.rb +0 -1
- data/scenarios/account_create_buyer/request.rb +0 -5
- data/scenarios/account_create_buyer/ruby.mako +0 -13
- data/scenarios/account_create_debit/definition.rb +0 -1
- data/scenarios/account_create_debit/request.rb +0 -3
- data/scenarios/account_create_debit/ruby.mako +0 -11
- data/scenarios/account_create_hold/definition.rb +0 -1
- data/scenarios/account_create_hold/request.rb +0 -3
- data/scenarios/account_create_hold/ruby.mako +0 -11
- data/scenarios/account_create_merchant/definition.rb +0 -1
- data/scenarios/account_create_merchant/request.rb +0 -3
- data/scenarios/account_create_merchant/ruby.mako +0 -11
- data/scenarios/account_underwrite_business/definition.rb +0 -1
- data/scenarios/account_underwrite_business/request.rb +0 -17
- data/scenarios/account_underwrite_business/ruby.mako +0 -37
- data/scenarios/account_underwrite_person/definition.rb +0 -1
- data/scenarios/account_underwrite_person/request.rb +0 -18
- data/scenarios/account_underwrite_person/ruby.mako +0 -31
- data/scenarios/bank_account_find_and_credit/definition.rb +0 -1
- data/scenarios/bank_account_find_and_credit/request.rb +0 -5
- data/scenarios/bank_account_find_and_credit/ruby.mako +0 -13
- data/scenarios/bank_account_find_and_delete/definition.rb +0 -1
- data/scenarios/bank_account_find_and_delete/request.rb +0 -3
- data/scenarios/bank_account_find_and_delete/ruby.mako +0 -10
- data/scenarios/bank_account_invalid_routing_number/definition.rb +0 -1
- data/scenarios/bank_account_invalid_routing_number/request.rb +0 -11
- data/scenarios/bank_account_invalid_routing_number/ruby.mako +0 -16
- data/scenarios/card_invalidate/definition.rb +0 -1
- data/scenarios/card_invalidate/request.rb +0 -3
- data/scenarios/card_invalidate/ruby.mako +0 -10
- data/scenarios/credit_account_list/definition.rb +0 -1
- data/scenarios/credit_account_list/request.rb +0 -3
- data/scenarios/credit_account_list/ruby.mako +0 -10
- data/scenarios/credit_account_merchant_create/definition.rb +0 -1
- data/scenarios/credit_account_merchant_create/request.rb +0 -5
- data/scenarios/credit_account_merchant_create/ruby.mako +0 -12
- data/scenarios/credit_bank_account_list/request.rb +0 -5
- data/scenarios/credit_bank_account_list/ruby.mako +0 -12
- data/scenarios/credit_create_existing_bank_account/request.rb +0 -5
- data/scenarios/credit_create_existing_bank_account/ruby.mako +0 -12
- data/scenarios/credit_create_new_bank_account/request.rb +0 -10
- data/scenarios/credit_create_new_bank_account/ruby.mako +0 -21
- data/scenarios/credit_customer_list/definition.rb +0 -1
- data/scenarios/credit_customer_list/request.rb +0 -4
- data/scenarios/credit_customer_list/ruby.mako +0 -12
- data/scenarios/credit_failed_state/definition.rb +0 -1
- data/scenarios/credit_failed_state/request.rb +0 -10
- data/scenarios/credit_failed_state/ruby.mako +0 -18
- data/scenarios/credit_paid_state/definition.rb +0 -1
- data/scenarios/credit_paid_state/request.rb +0 -11
- data/scenarios/credit_paid_state/ruby.mako +0 -19
- data/scenarios/credit_pending_state/definition.rb +0 -1
- data/scenarios/credit_pending_state/request.rb +0 -9
- data/scenarios/credit_pending_state/ruby.mako +0 -17
- data/scenarios/customer_add_bank_account/request.rb +0 -3
- data/scenarios/customer_add_bank_account/ruby.mako +0 -11
- data/scenarios/customer_add_card/request.rb +0 -3
- data/scenarios/customer_add_card/ruby.mako +0 -11
- data/scenarios/customer_capture_hold/definition.rb +0 -1
- data/scenarios/customer_capture_hold/request.rb +0 -3
- data/scenarios/customer_capture_hold/ruby.mako +0 -0
- data/scenarios/customer_create_debit/definition.rb +0 -1
- data/scenarios/customer_create_debit/request.rb +0 -3
- data/scenarios/customer_create_debit/ruby.mako +0 -11
- data/scenarios/customer_create_hold/definition.rb +0 -1
- data/scenarios/customer_create_hold/request.rb +0 -3
- data/scenarios/customer_create_hold/ruby.mako +0 -11
- data/scenarios/customer_credit/definition.rb +0 -1
- data/scenarios/customer_credit/request.rb +0 -2
- data/scenarios/customer_credit/ruby.mako +0 -8
- data/scenarios/debit_account_list/definition.rb +0 -1
- data/scenarios/debit_account_list/request.rb +0 -3
- data/scenarios/debit_account_list/ruby.mako +0 -10
- data/scenarios/debit_create/definition.rb +0 -1
- data/scenarios/debit_create/request.rb +0 -5
- data/scenarios/debit_create/ruby.mako +0 -15
- data/scenarios/debit_customer_list/definition.rb +0 -1
- data/scenarios/debit_customer_list/request.rb +0 -4
- data/scenarios/debit_customer_list/ruby.mako +0 -12
- data/scenarios/debit_refund/definition.rb +0 -1
- data/scenarios/debit_refund/request.rb +0 -3
- data/scenarios/debit_refund/ruby.mako +0 -10
- data/scenarios/delete.rb +0 -7
- data/scenarios/event_replay/definition.rb +0 -0
- data/scenarios/event_replay/request.rb +0 -1
- data/scenarios/event_replay/ruby.mako +0 -0
- data/scenarios/execute.rb +0 -27
- data/scenarios/hold_account_list/definition.rb +0 -1
- data/scenarios/hold_account_list/request.rb +0 -3
- data/scenarios/hold_account_list/ruby.mako +0 -10
- data/scenarios/hold_capture/definition.rb +0 -1
- data/scenarios/hold_capture/request.rb +0 -5
- data/scenarios/hold_capture/ruby.mako +0 -15
- data/scenarios/hold_create/definition.rb +0 -1
- data/scenarios/hold_create/request.rb +0 -5
- data/scenarios/hold_create/ruby.mako +0 -14
- data/scenarios/hold_customer_list/definition.rb +0 -1
- data/scenarios/hold_customer_list/request.rb +0 -3
- data/scenarios/hold_customer_list/ruby.mako +0 -11
- data/scenarios/hold_list/definition.rb +0 -1
- data/scenarios/hold_list/request.rb +0 -4
- data/scenarios/hold_list/ruby.mako +0 -11
- data/scenarios/hold_show/definition.rb +0 -1
- data/scenarios/hold_show/request.rb +0 -2
- data/scenarios/hold_show/ruby.mako +0 -10
- data/scenarios/hold_update/definition.rb +0 -1
- data/scenarios/hold_update/request.rb +0 -7
- data/scenarios/hold_update/ruby.mako +0 -16
- data/scenarios/hold_void/definition.rb +0 -1
- data/scenarios/hold_void/request.rb +0 -3
- data/scenarios/hold_void/ruby.mako +0 -10
- data/scenarios/refund_account_list/definition.rb +0 -1
- data/scenarios/refund_account_list/request.rb +0 -3
- data/scenarios/refund_account_list/ruby.mako +0 -10
- data/scenarios/refund_customer_list/definition.rb +0 -1
- data/scenarios/refund_customer_list/request.rb +0 -3
- data/scenarios/refund_customer_list/ruby.mako +0 -11
- data/scenarios/render.rb +0 -32
- data/scenarios/render_one.rb +0 -32
- data/spec/balanced/resources/account_spec.rb +0 -636
- data/spec/balanced/resources/hold_spec.rb +0 -48
- data/spec/balanced/resources/merchant_spec.rb +0 -6
- data/spec/scenarios_spec.rb +0 -39
- data/upload_docs.rb +0 -40
@@ -1,10 +0,0 @@
|
|
1
|
-
% if mode == 'definition':
|
2
|
-
Balanced::Hold.void()
|
3
|
-
|
4
|
-
% else:
|
5
|
-
require 'balanced'
|
6
|
-
Balanced.configure('8c3aeeb80e9e11e38901026ba7f8ec28')
|
7
|
-
|
8
|
-
hold = Balanced::Hold.find('/v1/marketplaces/TEST-MP4h8BxozeLxe7VAllP6b5gj/holds/HL15SKbacqwCIDMvoCQx3GbB')
|
9
|
-
hold.void
|
10
|
-
% endif
|
@@ -1 +0,0 @@
|
|
1
|
-
Balanced::Account.refunds
|
@@ -1 +0,0 @@
|
|
1
|
-
Balanced::Customer.refunds
|
@@ -1,11 +0,0 @@
|
|
1
|
-
% if mode == 'definition':
|
2
|
-
Balanced::Customer.refunds
|
3
|
-
|
4
|
-
% else:
|
5
|
-
require 'balanced'
|
6
|
-
Balanced.configure('8c3aeeb80e9e11e38901026ba7f8ec28')
|
7
|
-
|
8
|
-
customer = Balanced::Customer.find('/v1/customers/ACO702cHD2tPiOCRSKYzVf1')
|
9
|
-
refunds = customer.refunds
|
10
|
-
|
11
|
-
% endif
|
data/scenarios/render.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
require 'json'
|
3
|
-
require File.expand_path('../helpers', __FILE__)
|
4
|
-
|
5
|
-
parsed_data = JSON.parse(File.read('./scenario.cache'))
|
6
|
-
|
7
|
-
Dir.chdir("./scenarios")
|
8
|
-
subdir_list = Dir["*"].reject { |o| not File.directory?(o) }
|
9
|
-
|
10
|
-
api_key = parsed_data["api_key"]
|
11
|
-
# boiler plate configuration code used in all scenarios
|
12
|
-
boiler_plate = "require 'balanced'\nBalanced.configure('#{api_key}')\n"
|
13
|
-
|
14
|
-
params_to_hash = @helpers[:params_to_hash]
|
15
|
-
params_to_hash_for_args = @helpers[:params_to_hash_for_args]
|
16
|
-
|
17
|
-
subdir_list.each do |scenario|
|
18
|
-
begin
|
19
|
-
template = File.read("./#{scenario}/request.rb")
|
20
|
-
# generate new erb template file from each request.rb file
|
21
|
-
erb = ERB.new(template)
|
22
|
-
request = parsed_data[scenario]['request']
|
23
|
-
payload = request['payload']
|
24
|
-
# render erb file passing in all local variables
|
25
|
-
executable = erb.result(binding)
|
26
|
-
File.open("./#{scenario}/executable.rb", "w") do |f|
|
27
|
-
f.write(executable)
|
28
|
-
end
|
29
|
-
rescue Exception => e
|
30
|
-
puts "Error rendering #{scenario}'s template"
|
31
|
-
end
|
32
|
-
end
|
data/scenarios/render_one.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'erb'
|
2
|
-
require 'json'
|
3
|
-
require 'net/https'
|
4
|
-
require_relative 'helpers'
|
5
|
-
|
6
|
-
# pull scenario.cache from Balanced Docs
|
7
|
-
parsed_data = JSON.parse(File.read('./scenario.cache'))
|
8
|
-
|
9
|
-
api_key = parsed_data["api_key"]
|
10
|
-
# boiler plate configuration code used in all scenarios
|
11
|
-
boiler_plate = "require 'balanced'\nBalanced.configure('#{api_key}')\n"
|
12
|
-
|
13
|
-
params_to_hash = @helpers[:params_to_hash]
|
14
|
-
params_to_hash_for_args = @helpers[:params_to_hash_for_args]
|
15
|
-
|
16
|
-
Dir.chdir("./scenarios")
|
17
|
-
scenario = ARGV[0]
|
18
|
-
# puts scenario
|
19
|
-
|
20
|
-
begin
|
21
|
-
template = File.read("./#{scenario}/request.rb")
|
22
|
-
# generate new erb template file from each request.rb file
|
23
|
-
erb = ERB.new(template)
|
24
|
-
request = parsed_data[scenario]['request']
|
25
|
-
payload = request['payload']
|
26
|
-
# render erb file passing in all local variables
|
27
|
-
executable = erb.result(binding)
|
28
|
-
STDOUT.write(executable)
|
29
|
-
rescue Exception => e
|
30
|
-
puts "#{scenario} does not contain a valid template file"
|
31
|
-
end
|
32
|
-
|
@@ -1,636 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Balanced::Account, :vcr do
|
4
|
-
before do
|
5
|
-
api_key = Balanced::ApiKey.new.save
|
6
|
-
Balanced.configure api_key.secret
|
7
|
-
@marketplace = Balanced::Marketplace.new.save
|
8
|
-
end
|
9
|
-
|
10
|
-
describe "Account.uri", :vcr do
|
11
|
-
context "when ApiKey is not configured", :vcr do
|
12
|
-
before do
|
13
|
-
Balanced::Marketplace.stub(:marketplace_uri) { nil }
|
14
|
-
Balanced.configure nil
|
15
|
-
end
|
16
|
-
|
17
|
-
it "throw an exception that it can not generate the URI" do
|
18
|
-
expect {
|
19
|
-
Balanced::Account.uri
|
20
|
-
}.to raise_error Balanced::Error
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
context "when ApiKey is configured", :vcr do
|
25
|
-
before do
|
26
|
-
api_key = Balanced::ApiKey.new.save
|
27
|
-
Balanced.configure api_key.secret
|
28
|
-
@marketplace = Balanced::Marketplace.new.save
|
29
|
-
end
|
30
|
-
|
31
|
-
it "it matches the resource's uri structure" do
|
32
|
-
uri = Balanced::Account.uri
|
33
|
-
uri.should_not be_nil
|
34
|
-
uri.should match ACCOUNTS_URI_REGEX
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "merchant", :vcr do
|
40
|
-
before do
|
41
|
-
@merchant_attributes = {
|
42
|
-
:type => "person",
|
43
|
-
:name => "Billy Jones",
|
44
|
-
:street_address => "801 High St.",
|
45
|
-
:postal_code => "94301",
|
46
|
-
:country => "USA",
|
47
|
-
:dob => "1842-01",
|
48
|
-
:phone_number => "+16505551234",
|
49
|
-
}
|
50
|
-
|
51
|
-
@card = Balanced::Card.new(
|
52
|
-
:card_number => "4111111111111111",
|
53
|
-
:expiration_month => "12",
|
54
|
-
:expiration_year => "2015"
|
55
|
-
).save
|
56
|
-
|
57
|
-
@buyer = Balanced::Account.new(
|
58
|
-
:uri => @marketplace.accounts_uri,
|
59
|
-
:email_address => "buyer7@example.org",
|
60
|
-
:card_uri => @card.uri,
|
61
|
-
:name => "Jack Q Buyer"
|
62
|
-
).save
|
63
|
-
|
64
|
-
@bank_account = @marketplace.create_bank_account(
|
65
|
-
:account_number => "1234567890",
|
66
|
-
:bank_code => "321174851",
|
67
|
-
:name => "Jack Q Merchant"
|
68
|
-
)
|
69
|
-
|
70
|
-
@merchant = Balanced::Account.new(
|
71
|
-
:uri => @marketplace.accounts_uri,
|
72
|
-
:email_address => "merchant@example.org",
|
73
|
-
:merchant => @merchant_attributes,
|
74
|
-
:bank_account_uri => @bank_account.uri,
|
75
|
-
:name => "Jack Q Merchant"
|
76
|
-
).save
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
-
|
81
|
-
describe "#hold", :vcr do
|
82
|
-
before do
|
83
|
-
@buyer.debit :amount => 1250
|
84
|
-
end
|
85
|
-
|
86
|
-
context "args passed by name via options hash" do
|
87
|
-
subject {
|
88
|
-
@buyer.hold(
|
89
|
-
amount: 1250,
|
90
|
-
description: "description",
|
91
|
-
meta: {},
|
92
|
-
destination_uri: @bank_account.uri
|
93
|
-
)
|
94
|
-
}
|
95
|
-
|
96
|
-
its(:amount) { should == 1250 }
|
97
|
-
its(:meta) { should == {} }
|
98
|
-
its(:description) { should == "description" }
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
describe "#credit", :vcr do
|
103
|
-
before do
|
104
|
-
@buyer.debit :amount => 1250
|
105
|
-
end
|
106
|
-
|
107
|
-
# WARNING: This test is deprecated
|
108
|
-
context "all args passed directly" do
|
109
|
-
subject {
|
110
|
-
@merchant.credit 1250, "description", {}, @bank_account.uri
|
111
|
-
}
|
112
|
-
|
113
|
-
its(:amount) { should == 1250 }
|
114
|
-
its(:meta) { should == {} }
|
115
|
-
its(:description) { should == "description" }
|
116
|
-
end
|
117
|
-
|
118
|
-
context "args passed by name via options hash" do
|
119
|
-
subject {
|
120
|
-
@merchant.credit(
|
121
|
-
:amount => 1250,
|
122
|
-
:description => "description",
|
123
|
-
:meta => {},
|
124
|
-
:destination_uri => @bank_account.uri
|
125
|
-
)
|
126
|
-
}
|
127
|
-
|
128
|
-
its(:amount) { should == 1250 }
|
129
|
-
its(:meta) { should == {} }
|
130
|
-
its(:description) { should == "description" }
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
describe "#save" do
|
135
|
-
describe "after #save" do
|
136
|
-
describe "attributes" do
|
137
|
-
describe "#id" do
|
138
|
-
subject { @merchant.id }
|
139
|
-
it { should_not be_nil }
|
140
|
-
it { should_not be_empty }
|
141
|
-
end
|
142
|
-
describe "#roles" do
|
143
|
-
subject { @merchant.roles }
|
144
|
-
it { should include("merchant") }
|
145
|
-
end
|
146
|
-
describe "#email_address" do
|
147
|
-
subject { @merchant.email_address }
|
148
|
-
it { should eql "merchant@example.org" }
|
149
|
-
end
|
150
|
-
describe "#name" do
|
151
|
-
subject { @merchant.name }
|
152
|
-
it { should eql "Jack Q Merchant" }
|
153
|
-
end
|
154
|
-
describe "#created_at" do
|
155
|
-
subject { @merchant.created_at }
|
156
|
-
it { should_not be_nil }
|
157
|
-
it { should_not be_empty }
|
158
|
-
end
|
159
|
-
describe "#uri" do
|
160
|
-
subject { @merchant.uri }
|
161
|
-
it { should match MERCHANT_URI_REGEX }
|
162
|
-
end
|
163
|
-
describe "#holds_uri" do
|
164
|
-
subject { @merchant.holds_uri }
|
165
|
-
it { should match HOLDS_URI_REGEX }
|
166
|
-
end
|
167
|
-
describe "#bank_accounts_uri" do
|
168
|
-
subject { @merchant.bank_accounts_uri }
|
169
|
-
it { should match BANK_ACCOUNTS_URI_REGEX }
|
170
|
-
end
|
171
|
-
describe "#refunds_uri" do
|
172
|
-
subject { @merchant.refunds_uri }
|
173
|
-
it { should match REFUNDS_URI_REGEX }
|
174
|
-
end
|
175
|
-
describe "#debits_uri" do
|
176
|
-
subject { @merchant.debits_uri }
|
177
|
-
it { should match DEBITS_URI_REGEX }
|
178
|
-
end
|
179
|
-
describe "#transactions_uri" do
|
180
|
-
subject { @merchant.transactions_uri }
|
181
|
-
it { should match TRANSACTIONS_URI_REGEX }
|
182
|
-
end
|
183
|
-
describe "#credits_uri" do
|
184
|
-
subject { @merchant.credits_uri }
|
185
|
-
it { should match CREDITS_URI_REGEX }
|
186
|
-
end
|
187
|
-
describe "#cards_uri" do
|
188
|
-
subject { @merchant.cards_uri }
|
189
|
-
it { should match CARDS_URI_REGEX }
|
190
|
-
end
|
191
|
-
end
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
describe "#add_bank_account using uri", :vcr do
|
196
|
-
before do
|
197
|
-
@new_bank_account = @marketplace.create_bank_account(
|
198
|
-
:account_number => "1234567890",
|
199
|
-
:bank_code => "321174851",
|
200
|
-
:name => "Jack Q Merchant"
|
201
|
-
)
|
202
|
-
end
|
203
|
-
|
204
|
-
describe "when executing" do
|
205
|
-
it { expect { @merchant.add_bank_account(@new_bank_account.uri) }.to_not raise_error }
|
206
|
-
end
|
207
|
-
|
208
|
-
describe "after executing", :vcr do
|
209
|
-
before do
|
210
|
-
@merchant.add_bank_account(@new_bank_account.uri)
|
211
|
-
@bank_accounts = Balanced::BankAccount.find(@merchant.bank_accounts_uri).items
|
212
|
-
end
|
213
|
-
|
214
|
-
subject { @bank_accounts.size }
|
215
|
-
it { should eql 2 }
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
describe "#add_bank_account using tokenized object", :vcr do
|
220
|
-
before do
|
221
|
-
@new_bank_account = @marketplace.create_bank_account(
|
222
|
-
:account_number => "1234567890",
|
223
|
-
:bank_code => "321174851",
|
224
|
-
:name => "Jack Q Merchant"
|
225
|
-
)
|
226
|
-
end
|
227
|
-
|
228
|
-
describe "when executing" do
|
229
|
-
it { expect { @merchant.add_bank_account(@new_bank_account) }.to_not raise_error }
|
230
|
-
end
|
231
|
-
|
232
|
-
describe "after executing", :vcr do
|
233
|
-
before do
|
234
|
-
@merchant.add_bank_account(@new_bank_account)
|
235
|
-
@bank_accounts = Balanced::BankAccount.find(@merchant.bank_accounts_uri).items
|
236
|
-
end
|
237
|
-
|
238
|
-
subject { @bank_accounts.size }
|
239
|
-
it { should eql 2 }
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|
243
|
-
|
244
|
-
describe "buyer" do
|
245
|
-
describe "#save" do
|
246
|
-
describe "when creating", :vcr => { :record => :new_episodes } do
|
247
|
-
before do
|
248
|
-
card = Balanced::Card.new(
|
249
|
-
:card_number => "5105105105105100",
|
250
|
-
:expiration_month => "12",
|
251
|
-
:expiration_year => "2015"
|
252
|
-
).save
|
253
|
-
@buyer = Balanced::Account.new(
|
254
|
-
:uri => @marketplace.accounts_uri,
|
255
|
-
:email_address => "buyer@example.org",
|
256
|
-
:card_uri => card.uri,
|
257
|
-
:name => "Jack Q Buyer"
|
258
|
-
)
|
259
|
-
end
|
260
|
-
it { expect { @buyer.save }.to_not raise_error }
|
261
|
-
end
|
262
|
-
|
263
|
-
describe "after #save" do
|
264
|
-
describe "attributes", :vcr => { :record => :new_episodes } do
|
265
|
-
before do
|
266
|
-
card = Balanced::Card.new(
|
267
|
-
:card_number => "4111111111111111",
|
268
|
-
:expiration_month => "12",
|
269
|
-
:expiration_year => "2015"
|
270
|
-
).save
|
271
|
-
@buyer = Balanced::Account.new(
|
272
|
-
:uri => @marketplace.accounts_uri,
|
273
|
-
:email_address => "buyer2@example.org",
|
274
|
-
:card_uri => card.uri,
|
275
|
-
:name => "Jack Q Buyer"
|
276
|
-
).save
|
277
|
-
end
|
278
|
-
|
279
|
-
describe "#id" do
|
280
|
-
subject { @buyer.id }
|
281
|
-
it { should_not be_nil }
|
282
|
-
it { should_not be_empty }
|
283
|
-
end
|
284
|
-
describe "#roles" do
|
285
|
-
subject { @buyer.roles }
|
286
|
-
it { should include("buyer") }
|
287
|
-
it { should_not include("merchant") }
|
288
|
-
end
|
289
|
-
describe "#email_address" do
|
290
|
-
subject { @buyer.email_address }
|
291
|
-
it { should eql "buyer2@example.org" }
|
292
|
-
end
|
293
|
-
describe "#name" do
|
294
|
-
subject { @buyer.name }
|
295
|
-
it { should eql "Jack Q Buyer" }
|
296
|
-
end
|
297
|
-
describe "#created_at" do
|
298
|
-
subject { @buyer.created_at }
|
299
|
-
it { should_not be_nil }
|
300
|
-
it { should_not be_empty }
|
301
|
-
end
|
302
|
-
describe "#uri" do
|
303
|
-
subject { @buyer.uri }
|
304
|
-
it { should match MERCHANT_URI_REGEX }
|
305
|
-
end
|
306
|
-
describe "#holds_uri" do
|
307
|
-
subject { @buyer.holds_uri }
|
308
|
-
it { should match HOLDS_URI_REGEX }
|
309
|
-
end
|
310
|
-
describe "#bank_accounts_uri" do
|
311
|
-
subject { @buyer.bank_accounts_uri }
|
312
|
-
it { should match BANK_ACCOUNTS_URI_REGEX }
|
313
|
-
end
|
314
|
-
describe "#refunds_uri" do
|
315
|
-
subject { @buyer.refunds_uri }
|
316
|
-
it { should match REFUNDS_URI_REGEX }
|
317
|
-
end
|
318
|
-
describe "#debits_uri" do
|
319
|
-
subject { @buyer.debits_uri }
|
320
|
-
it { should match DEBITS_URI_REGEX }
|
321
|
-
end
|
322
|
-
describe "#transactions_uri" do
|
323
|
-
subject { @buyer.transactions_uri }
|
324
|
-
it { should match TRANSACTIONS_URI_REGEX }
|
325
|
-
end
|
326
|
-
describe "#credits_uri" do
|
327
|
-
subject { @buyer.credits_uri }
|
328
|
-
it { should match CREDITS_URI_REGEX }
|
329
|
-
end
|
330
|
-
describe "#cards_uri" do
|
331
|
-
subject { @buyer.cards_uri }
|
332
|
-
it { should match CARDS_URI_REGEX }
|
333
|
-
end
|
334
|
-
describe "#cards" do
|
335
|
-
subject { @buyer.cards }
|
336
|
-
it { should be_instance_of Array }
|
337
|
-
it { should_not be_empty }
|
338
|
-
it { subject.first.should be_instance_of Balanced::Card }
|
339
|
-
end
|
340
|
-
describe "#bank_accounts" do
|
341
|
-
subject { @buyer.bank_accounts }
|
342
|
-
it { should be_instance_of Array }
|
343
|
-
it { should be_empty }
|
344
|
-
end
|
345
|
-
end
|
346
|
-
end
|
347
|
-
end
|
348
|
-
|
349
|
-
describe "#add_card with uri" do
|
350
|
-
describe "when executing", :vcr do
|
351
|
-
before do
|
352
|
-
card = Balanced::Card.new(
|
353
|
-
:card_number => "4111111111111111",
|
354
|
-
:expiration_month => "12",
|
355
|
-
:expiration_year => "2015"
|
356
|
-
).save
|
357
|
-
@new_card = Balanced::Card.new(
|
358
|
-
:card_number => "4111111111111111",
|
359
|
-
:expiration_month => "1",
|
360
|
-
:expiration_year => "2015"
|
361
|
-
).save
|
362
|
-
@buyer = Balanced::Account.new(
|
363
|
-
:uri => @marketplace.accounts_uri,
|
364
|
-
:email_address => "buyer3@example.org",
|
365
|
-
:card_uri => card.uri,
|
366
|
-
:name => "Jack Q Buyer"
|
367
|
-
).save
|
368
|
-
end
|
369
|
-
it do
|
370
|
-
expect { @buyer.add_card(@new_card.uri) }.to_not raise_error
|
371
|
-
end
|
372
|
-
end
|
373
|
-
describe "after executing", :vcr do
|
374
|
-
before do
|
375
|
-
card = Balanced::Card.new(
|
376
|
-
:card_number => "4111111111111111",
|
377
|
-
:expiration_month => "12",
|
378
|
-
:expiration_year => "2015"
|
379
|
-
).save
|
380
|
-
@new_card = Balanced::Card.new(
|
381
|
-
:card_number => "5105105105105100",
|
382
|
-
:expiration_month => "1",
|
383
|
-
:expiration_year => "2017"
|
384
|
-
).save
|
385
|
-
@buyer = Balanced::Account.new(
|
386
|
-
:uri => @marketplace.accounts_uri,
|
387
|
-
:email_address => "buyer4@example.org",
|
388
|
-
:card_uri => card.uri,
|
389
|
-
:name => "Jack Q Buyer"
|
390
|
-
).save
|
391
|
-
@buyer.add_card(@new_card.uri)
|
392
|
-
@cards = Balanced::Card.find @buyer.cards_uri
|
393
|
-
end
|
394
|
-
subject { @cards.items.size }
|
395
|
-
it { should eql 2 }
|
396
|
-
end
|
397
|
-
end
|
398
|
-
|
399
|
-
describe "#add_card with tokenized object" do
|
400
|
-
describe "when executing", :vcr do
|
401
|
-
before do
|
402
|
-
card = Balanced::Card.new(
|
403
|
-
:card_number => "4111111111111111",
|
404
|
-
:expiration_month => "12",
|
405
|
-
:expiration_year => "2015"
|
406
|
-
).save
|
407
|
-
@new_card = Balanced::Card.new(
|
408
|
-
:card_number => "4111111111111111",
|
409
|
-
:expiration_month => "1",
|
410
|
-
:expiration_year => "2015"
|
411
|
-
).save
|
412
|
-
@buyer = Balanced::Account.new(
|
413
|
-
:uri => @marketplace.accounts_uri,
|
414
|
-
:email_address => "buyer3@example.org",
|
415
|
-
:card_uri => card.uri,
|
416
|
-
:name => "Jack Q Buyer"
|
417
|
-
).save
|
418
|
-
end
|
419
|
-
it do
|
420
|
-
expect { @buyer.add_card(@new_card) }.to_not raise_error
|
421
|
-
end
|
422
|
-
end
|
423
|
-
describe "after executing", :vcr do
|
424
|
-
before do
|
425
|
-
card = Balanced::Card.new(
|
426
|
-
:card_number => "4111111111111111",
|
427
|
-
:expiration_month => "12",
|
428
|
-
:expiration_year => "2015"
|
429
|
-
).save
|
430
|
-
@new_card = Balanced::Card.new(
|
431
|
-
:card_number => "5105105105105100",
|
432
|
-
:expiration_month => "1",
|
433
|
-
:expiration_year => "2017"
|
434
|
-
).save
|
435
|
-
@buyer = Balanced::Account.new(
|
436
|
-
:uri => @marketplace.accounts_uri,
|
437
|
-
:email_address => "buyer4@example.org",
|
438
|
-
:card_uri => card.uri,
|
439
|
-
:name => "Jack Q Buyer"
|
440
|
-
).save
|
441
|
-
@buyer.add_card(@new_card)
|
442
|
-
@cards = Balanced::Card.find @buyer.cards_uri
|
443
|
-
end
|
444
|
-
subject { @cards.items.size }
|
445
|
-
it { should eql 2 }
|
446
|
-
end
|
447
|
-
end
|
448
|
-
|
449
|
-
describe "#promote_to_merchant" do
|
450
|
-
describe "when executing", :vcr do
|
451
|
-
before do
|
452
|
-
@merchant_attributes = {
|
453
|
-
:type => "person",
|
454
|
-
:name => "Billy Jones",
|
455
|
-
:street_address => "801 High St.",
|
456
|
-
:postal_code => "94301",
|
457
|
-
:country => "USA",
|
458
|
-
:dob => "1842-01",
|
459
|
-
:phone_number => "+16505551234"
|
460
|
-
}
|
461
|
-
card = Balanced::Card.new(
|
462
|
-
:card_number => "4111111111111111",
|
463
|
-
:expiration_month => "12",
|
464
|
-
:expiration_year => "2015"
|
465
|
-
).save
|
466
|
-
@buyer = Balanced::Account.new(
|
467
|
-
:uri => @marketplace.accounts_uri,
|
468
|
-
:email_address => "buyer5@example.org",
|
469
|
-
:card_uri => card.uri,
|
470
|
-
:name => "Jack Q Buyer"
|
471
|
-
).save
|
472
|
-
end
|
473
|
-
|
474
|
-
it do
|
475
|
-
expect { @buyer.promote_to_merchant @merchant_attributes}.to_not raise_error
|
476
|
-
end
|
477
|
-
end
|
478
|
-
describe "after executing", :vcr do
|
479
|
-
before do
|
480
|
-
@merchant_attributes = {
|
481
|
-
:type => "person",
|
482
|
-
:name => "Billy Jones",
|
483
|
-
:street_address => "801 High St.",
|
484
|
-
:postal_code => "94301",
|
485
|
-
:country => "USA",
|
486
|
-
:dob => "1842-01",
|
487
|
-
:phone_number => "+16505551234"
|
488
|
-
}
|
489
|
-
card = Balanced::Card.new(
|
490
|
-
:card_number => "4111111111111111",
|
491
|
-
:expiration_month => "12",
|
492
|
-
:expiration_year => "2015"
|
493
|
-
).save
|
494
|
-
@buyer = Balanced::Account.new(
|
495
|
-
:uri => @marketplace.accounts_uri,
|
496
|
-
:email_address => "buyer6@example.org",
|
497
|
-
:card_uri => card.uri,
|
498
|
-
:name => "Jack Q Buyer"
|
499
|
-
).save
|
500
|
-
@buyer.promote_to_merchant @merchant_attributes
|
501
|
-
end
|
502
|
-
subject { @buyer.roles }
|
503
|
-
it { should include("merchant") }
|
504
|
-
end
|
505
|
-
|
506
|
-
end
|
507
|
-
|
508
|
-
describe "#debit", :vcr => { :match_requests_on => [:body], :record => :new_episodes } do
|
509
|
-
before do
|
510
|
-
card = Balanced::Card.new(
|
511
|
-
:card_number => "4111111111111111",
|
512
|
-
:expiration_month => "12",
|
513
|
-
:expiration_year => "2015"
|
514
|
-
).save
|
515
|
-
begin
|
516
|
-
@buyer = Balanced::Account.new(
|
517
|
-
:uri => @marketplace.accounts_uri,
|
518
|
-
:email_address => "buyer7@example.org",
|
519
|
-
:card_uri => card.uri,
|
520
|
-
:name => "Jack Q Buyer"
|
521
|
-
).save
|
522
|
-
rescue Balanced::Conflict => ex
|
523
|
-
@buyer = Balanced::Account.find(ex.extras[:account_uri])
|
524
|
-
end
|
525
|
-
end
|
526
|
-
it "takes optional parameters" do
|
527
|
-
debit = @buyer.debit(
|
528
|
-
:amount => 500,
|
529
|
-
:appears_on_statement_as => "BOBS BURGERS"
|
530
|
-
)
|
531
|
-
debit.should be_instance_of Balanced::Debit
|
532
|
-
debit.amount.should eql 500
|
533
|
-
debit.appears_on_statement_as.should eql "BOBS BURGERS"
|
534
|
-
end
|
535
|
-
it "accepts on_behalf_of parameter" do
|
536
|
-
merchant = Balanced::Account.new.save
|
537
|
-
debit = @buyer.debit(
|
538
|
-
:amount => 500,
|
539
|
-
:on_behalf_of => merchant
|
540
|
-
)
|
541
|
-
debit.should be_instance_of Balanced::Debit
|
542
|
-
debit.amount.should eql 500
|
543
|
-
# TODO: once the API returns on_behalf_of in the response, make sure it shows up. For now we just make sure the debit didn't fail.
|
544
|
-
end
|
545
|
-
it "accepts URI for on_behalf_of" do
|
546
|
-
merchant = Balanced::Account.new.save
|
547
|
-
debit = @buyer.debit(
|
548
|
-
:amount => 500,
|
549
|
-
:on_behalf_of => merchant.uri
|
550
|
-
)
|
551
|
-
debit.should be_instance_of Balanced::Debit
|
552
|
-
debit.amount.should eql 500
|
553
|
-
# TODO: once the API returns on_behalf_of in the response, make sure it shows up. For now we just make sure the debit didn't fail.
|
554
|
-
end
|
555
|
-
|
556
|
-
it "fails with bad on_behalf_of parameter" do
|
557
|
-
expect {
|
558
|
-
@buyer.debit(
|
559
|
-
:amount => 500,
|
560
|
-
:on_behalf_of => @buyer
|
561
|
-
)
|
562
|
-
}.to raise_error ArgumentError
|
563
|
-
end
|
564
|
-
|
565
|
-
# this is deprecated
|
566
|
-
it "takes positional parameters" do
|
567
|
-
debit = @buyer.debit(500, "FOO FIGHTER")
|
568
|
-
debit.should be_instance_of Balanced::Debit
|
569
|
-
debit.amount.should eql 500
|
570
|
-
debit.appears_on_statement_as.should eql "FOO FIGHTER"
|
571
|
-
end
|
572
|
-
|
573
|
-
end
|
574
|
-
end
|
575
|
-
|
576
|
-
describe ".find", :vcr do
|
577
|
-
before do
|
578
|
-
api_key = Balanced::ApiKey.new.save
|
579
|
-
Balanced.configure api_key.secret
|
580
|
-
@marketplace = Balanced::Marketplace.new.save
|
581
|
-
card = Balanced::Card.new(
|
582
|
-
:card_number => "5105105105105100",
|
583
|
-
:expiration_month => "12",
|
584
|
-
:expiration_year => "2015"
|
585
|
-
).save
|
586
|
-
Balanced::Marketplace.my_marketplace.create_buyer(
|
587
|
-
:email_address => "john.doe@example.com",
|
588
|
-
:card_uri => card.uri
|
589
|
-
)
|
590
|
-
end
|
591
|
-
|
592
|
-
context "(:all, :some_field => 'op')", :vcr do
|
593
|
-
it "should find the account by returning a page with items of one" do
|
594
|
-
response = Balanced::Account.find(:all, :email_address => "john.doe@example.com")
|
595
|
-
response.should be_instance_of Array
|
596
|
-
response[0].should be_instance_of Balanced::Account
|
597
|
-
end
|
598
|
-
end
|
599
|
-
|
600
|
-
context "(:first, :some_field => 'op')", :vcr do
|
601
|
-
it "should find the account by returning the first item" do
|
602
|
-
response = Balanced::Account.find(:first, :email_address => "john.doe@example.com")
|
603
|
-
response.should be_instance_of Balanced::Account
|
604
|
-
end
|
605
|
-
end
|
606
|
-
end
|
607
|
-
|
608
|
-
describe ".find_by_email", :vcr => { :record => :new_episodes } do
|
609
|
-
before do
|
610
|
-
api_key = Balanced::ApiKey.new.save
|
611
|
-
Balanced.configure api_key.secret
|
612
|
-
@marketplace = Balanced::Marketplace.new.save
|
613
|
-
card = Balanced::Card.new(
|
614
|
-
:card_number => "5105105105105100",
|
615
|
-
:expiration_month => "12",
|
616
|
-
:expiration_year => "2015"
|
617
|
-
).save
|
618
|
-
@buyer = Balanced::Marketplace.my_marketplace.create_buyer(
|
619
|
-
:email_address => "john.doe@example.com",
|
620
|
-
:card_uri => card.uri
|
621
|
-
)
|
622
|
-
end
|
623
|
-
|
624
|
-
context "email address is in system", :vcr => { :record => :new_episodes } do
|
625
|
-
it "should return account object" do
|
626
|
-
Balanced::Account.find_by_email("john.doe@example.com").should be_instance_of Balanced::Account
|
627
|
-
end
|
628
|
-
end
|
629
|
-
|
630
|
-
context "email address does not exist", :vcr => { :record => :new_episodes } do
|
631
|
-
it "should return nil" do
|
632
|
-
Balanced::Account.find_by_email("foo@bar.com").should be_nil
|
633
|
-
end
|
634
|
-
end
|
635
|
-
end
|
636
|
-
end
|