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
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Reversal.all
|
@@ -0,0 +1,36 @@
|
|
1
|
+
% if mode == 'definition':
|
2
|
+
Balanced::Reversal.all
|
3
|
+
|
4
|
+
% elif mode == 'request':
|
5
|
+
require 'balanced'
|
6
|
+
Balanced.configure('ak-test-1kvvievk0Qqw5wQPsrlM9g7wQwNe62cyc')
|
7
|
+
|
8
|
+
reversals = Balanced::Reversal.all
|
9
|
+
% elif mode == 'response':
|
10
|
+
[#<Balanced::Reversal:0x007fdc9b129420
|
11
|
+
@attributes=
|
12
|
+
{"amount"=>3000,
|
13
|
+
"created_at"=>"2014-01-27T22:58:21.214829Z",
|
14
|
+
"currency"=>"USD",
|
15
|
+
"description"=>"Reversal for Order #1111",
|
16
|
+
"failure_reason"=>nil,
|
17
|
+
"failure_reason_code"=>nil,
|
18
|
+
"href"=>"/reversals/RV42n8M9XZWna427oPDDi4RG",
|
19
|
+
"id"=>"RV42n8M9XZWna427oPDDi4RG",
|
20
|
+
"links"=>{"credit"=>"CR40neytmVG2HDBp1opfF7sY", "order"=>nil},
|
21
|
+
"meta"=>
|
22
|
+
{"fulfillment.item.condition"=>"OK",
|
23
|
+
"merchant.feedback"=>"positive",
|
24
|
+
"user.refund_reason"=>"not happy with product"},
|
25
|
+
"status"=>"succeeded",
|
26
|
+
"transaction_number"=>"RV219-169-0008",
|
27
|
+
"updated_at"=>"2014-01-27T22:58:22.190749Z"},
|
28
|
+
@hyperlinks=
|
29
|
+
{"credit"=>
|
30
|
+
#<Proc:0x007fdc9b103c48/lib/balanced/resources/resource.rb:60 (lambda)>,
|
31
|
+
"events"=>
|
32
|
+
#<Proc:0x007fdc9b0aef68/lib/balanced/utils.rb:6 (lambda)>,
|
33
|
+
"order"=>
|
34
|
+
#<Proc:0x007fdc9b09f4c8/lib/balanced/utils.rb:6 (lambda)>}>]
|
35
|
+
|
36
|
+
% endif
|
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Reversal.fetch
|
@@ -0,0 +1,37 @@
|
|
1
|
+
% if mode == 'definition':
|
2
|
+
Balanced::Reversal.fetch
|
3
|
+
|
4
|
+
% elif mode == 'request':
|
5
|
+
require 'balanced'
|
6
|
+
Balanced.configure('ak-test-1kvvievk0Qqw5wQPsrlM9g7wQwNe62cyc')
|
7
|
+
|
8
|
+
reversal = Balanced::Reversal.fetch('/reversals/RV42n8M9XZWna427oPDDi4RG')
|
9
|
+
|
10
|
+
% elif mode == 'response':
|
11
|
+
#<Balanced::Reversal:0x007fdc9b047d18
|
12
|
+
@attributes=
|
13
|
+
{"amount"=>3000,
|
14
|
+
"created_at"=>"2014-01-27T22:58:21.214829Z",
|
15
|
+
"currency"=>"USD",
|
16
|
+
"description"=>"Reversal for Order #1111",
|
17
|
+
"failure_reason"=>nil,
|
18
|
+
"failure_reason_code"=>nil,
|
19
|
+
"href"=>"/reversals/RV42n8M9XZWna427oPDDi4RG",
|
20
|
+
"id"=>"RV42n8M9XZWna427oPDDi4RG",
|
21
|
+
"links"=>{"credit"=>"CR40neytmVG2HDBp1opfF7sY", "order"=>nil},
|
22
|
+
"meta"=>
|
23
|
+
{"fulfillment.item.condition"=>"OK",
|
24
|
+
"merchant.feedback"=>"positive",
|
25
|
+
"user.refund_reason"=>"not happy with product"},
|
26
|
+
"status"=>"succeeded",
|
27
|
+
"transaction_number"=>"RV219-169-0008",
|
28
|
+
"updated_at"=>"2014-01-27T22:58:22.190749Z"},
|
29
|
+
@hyperlinks=
|
30
|
+
{"credit"=>
|
31
|
+
#<Proc:0x007fdc9b03d2f0/lib/balanced/resources/resource.rb:60 (lambda)>,
|
32
|
+
"events"=>
|
33
|
+
#<Proc:0x007fdc9b02f510/lib/balanced/utils.rb:6 (lambda)>,
|
34
|
+
"order"=>
|
35
|
+
#<Proc:0x007fdc9b02efc0/lib/balanced/utils.rb:6 (lambda)>}>
|
36
|
+
|
37
|
+
% endif
|
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Reversal.save
|
@@ -0,0 +1,44 @@
|
|
1
|
+
% if mode == 'definition':
|
2
|
+
Balanced::Reversal.save
|
3
|
+
|
4
|
+
% elif mode == 'request':
|
5
|
+
require 'balanced'
|
6
|
+
Balanced.configure('ak-test-1kvvievk0Qqw5wQPsrlM9g7wQwNe62cyc')
|
7
|
+
|
8
|
+
reversal = Balanced::Reversal.fetch('/reversals/RV42n8M9XZWna427oPDDi4RG')
|
9
|
+
reversal.description = 'update this description'
|
10
|
+
reversal.meta = {
|
11
|
+
'refund.reason' => 'user not happy with product',
|
12
|
+
'user.notes' => 'very polite on the phone',
|
13
|
+
'user.satisfaction' => '6'
|
14
|
+
}
|
15
|
+
reversal.save
|
16
|
+
|
17
|
+
% elif mode == 'response':
|
18
|
+
#<Balanced::Reversal:0x007fdc9e82cd50
|
19
|
+
@attributes=
|
20
|
+
{"amount"=>3000,
|
21
|
+
"created_at"=>"2014-01-27T22:58:21.214829Z",
|
22
|
+
"currency"=>"USD",
|
23
|
+
"description"=>"update this description",
|
24
|
+
"failure_reason"=>nil,
|
25
|
+
"failure_reason_code"=>nil,
|
26
|
+
"href"=>"/reversals/RV42n8M9XZWna427oPDDi4RG",
|
27
|
+
"id"=>"RV42n8M9XZWna427oPDDi4RG",
|
28
|
+
"links"=>{"credit"=>"CR40neytmVG2HDBp1opfF7sY", "order"=>nil},
|
29
|
+
"meta"=>
|
30
|
+
{"refund.reason"=>"user not happy with product",
|
31
|
+
"user.notes"=>"very polite on the phone",
|
32
|
+
"user.satisfaction"=>"6"},
|
33
|
+
"status"=>"succeeded",
|
34
|
+
"transaction_number"=>"RV219-169-0008",
|
35
|
+
"updated_at"=>"2014-01-27T22:58:27.354488Z"},
|
36
|
+
@hyperlinks=
|
37
|
+
{"credit"=>
|
38
|
+
#<Proc:0x007fdc9e827440/lib/balanced/resources/resource.rb:60 (lambda)>,
|
39
|
+
"events"=>
|
40
|
+
#<Proc:0x007fdc9e825078/lib/balanced/utils.rb:6 (lambda)>,
|
41
|
+
"order"=>
|
42
|
+
#<Proc:0x007fdc9e8245b0/lib/balanced/utils.rb:6 (lambda)>}>
|
43
|
+
|
44
|
+
% endif
|
data/spec/balanced/error_spec.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Balanced::Error, '#response' do
|
4
|
-
it
|
4
|
+
it 'sets the response in the initializer' do
|
5
5
|
response = {:status => 200}
|
6
6
|
Balanced::Error.new(response).response.should == response
|
7
7
|
end
|
@@ -14,13 +14,13 @@ describe Balanced::Error, '#body' do
|
|
14
14
|
error.body.should == response[:body]
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it 'defaults to an empty hash when no body is passed' do
|
18
18
|
Balanced::Error.new({}).body.should == {}
|
19
19
|
end
|
20
20
|
|
21
|
-
describe
|
21
|
+
describe 'generating methods from response keys' do
|
22
22
|
before do
|
23
|
-
response = {:body => {:foo => 'bar'}}
|
23
|
+
response = {:body => {:errors => [{:foo => 'bar'}]}}
|
24
24
|
@error = Balanced::Error.new(response)
|
25
25
|
end
|
26
26
|
|
@@ -44,13 +44,13 @@ describe Balanced::StandardError do
|
|
44
44
|
end
|
45
45
|
|
46
46
|
describe Balanced::UnassociatedCardError do
|
47
|
-
let(:card) { Balanced::Card.new(:
|
47
|
+
let(:card) { Balanced::Card.new(:href => '/v1/marketplaces/123/cards/235') }
|
48
48
|
|
49
49
|
subject do
|
50
50
|
Balanced::UnassociatedCardError.new(card)
|
51
51
|
end
|
52
52
|
|
53
53
|
its(:message) do
|
54
|
-
should == "The Balanced::Card with uri=#{card.attributes['uri']} is not associated to
|
54
|
+
should == "The Balanced::Card with uri=#{card.attributes['uri']} is not associated to a customer"
|
55
55
|
end
|
56
|
-
end
|
56
|
+
end
|
data/spec/balanced/pager_spec.rb
CHANGED
@@ -1,40 +1,40 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Balanced::Pager do
|
4
|
-
describe
|
5
|
-
subject { Balanced::Pager.new 'a uri'}
|
4
|
+
describe '#adjust_pagination_params' do
|
5
|
+
subject { Balanced::Pager.new 'a uri' }
|
6
6
|
|
7
|
-
it
|
7
|
+
it 'sets limit based on per' do
|
8
8
|
params = subject.send(:adjust_pagination_params, :per => 5)
|
9
9
|
params[:limit].should == 5
|
10
10
|
end
|
11
11
|
|
12
|
-
it
|
12
|
+
it 'sets offset based on page and default limit' do
|
13
13
|
params = subject.send(:adjust_pagination_params, :page => 2)
|
14
14
|
params[:offset].should == 10
|
15
15
|
end
|
16
16
|
|
17
|
-
it
|
17
|
+
it 'sets offset based on page and per' do
|
18
18
|
params = subject.send(:adjust_pagination_params, :page => 2, :per => 4)
|
19
19
|
params[:offset].should == 4
|
20
20
|
end
|
21
21
|
|
22
|
-
it
|
22
|
+
it 'prefers per to limit' do
|
23
23
|
params = subject.send(:adjust_pagination_params, :per => 5, :limit => 10)
|
24
24
|
params[:limit].should == 5
|
25
25
|
end
|
26
26
|
|
27
|
-
it
|
27
|
+
it 'falls back to limit' do
|
28
28
|
params = subject.send(:adjust_pagination_params, :limit => 3)
|
29
29
|
params[:limit].should == 3
|
30
30
|
end
|
31
31
|
|
32
|
-
it
|
32
|
+
it 'prefers page to offset' do
|
33
33
|
params = subject.send(:adjust_pagination_params, :page => 2, :offset => 0)
|
34
34
|
params[:offset].should == 10
|
35
35
|
end
|
36
36
|
|
37
|
-
it
|
37
|
+
it 'falls back to offset' do
|
38
38
|
params = subject.send(:adjust_pagination_params, :offset => 6)
|
39
39
|
params[:offset].should == 6
|
40
40
|
end
|
@@ -1,48 +1,19 @@
|
|
1
|
-
require
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Balanced::ApiKey do
|
4
|
-
|
4
|
+
|
5
|
+
describe 'attributes', :vcr do
|
6
|
+
|
5
7
|
before do
|
6
8
|
@key = Balanced::ApiKey.new.save
|
7
9
|
end
|
8
|
-
|
10
|
+
|
11
|
+
describe '#secret' do
|
9
12
|
subject { @key.secret }
|
10
13
|
it { should_not be_nil }
|
11
14
|
it { should_not be_empty }
|
12
15
|
end
|
13
16
|
|
14
|
-
describe "#merchant" do
|
15
|
-
subject { @key.merchant }
|
16
|
-
it { should_not be_nil }
|
17
|
-
it { should be_instance_of Balanced::Merchant }
|
18
|
-
end
|
19
17
|
end
|
20
18
|
|
21
|
-
describe "new key", :vcr do
|
22
|
-
describe "before configure", :vcr do
|
23
|
-
before do
|
24
|
-
@new_key = Balanced::ApiKey.new.save
|
25
|
-
end
|
26
|
-
describe "#merchant", :vcr do
|
27
|
-
subject { @new_key.merchant }
|
28
|
-
it { should_not be_nil }
|
29
|
-
it { should be_instance_of Balanced::Merchant }
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
describe "after configure", :vcr do
|
34
|
-
before do
|
35
|
-
@new_key = Balanced::ApiKey.new.save
|
36
|
-
Balanced.configure @new_key.secret
|
37
|
-
@new_key = Balanced::ApiKey.new.save
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "#merchant", :vcr do
|
41
|
-
subject { @new_key.merchant }
|
42
|
-
it { should_not be_nil }
|
43
|
-
it { should be_instance_of Balanced::Merchant }
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
19
|
end
|
@@ -1,252 +1,157 @@
|
|
1
|
-
require
|
2
|
-
|
3
|
-
describe Balanced::BankAccount, :vcr do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
)
|
14
|
-
# An initial balance for the marketplace
|
15
|
-
@buyer = @marketplace.create_buyer(
|
16
|
-
:email_address => 'buyer@example.org',
|
17
|
-
:card_uri => card.uri
|
18
|
-
)
|
19
|
-
@buyer.debit :amount => 10000000
|
20
|
-
|
21
|
-
@incomplete_bank_account_hash = {
|
22
|
-
:account_number => "0987654321",
|
23
|
-
:bank_code => "321174851",
|
24
|
-
:name => "Timmy T. McTimmerson"
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Balanced::BankAccount, :vcr => true, :marketplace => true do
|
4
|
+
|
5
|
+
context 'after successful creation' do
|
6
|
+
subject(:bank_account) {
|
7
|
+
Balanced::BankAccount.new(
|
8
|
+
:name => 'William Henry Cavendish III',
|
9
|
+
:routing_number => '321174851',
|
10
|
+
:account_number => '0987654321',
|
11
|
+
:type => 'checking'
|
12
|
+
).save
|
25
13
|
}
|
14
|
+
its(:id) { subject.id.should_not be_nil }
|
15
|
+
its(:href) { subject.href.should eq("/bank_accounts/#{subject.id}") }
|
16
|
+
its(:account_type) { should eq('checking') }
|
17
|
+
its(:routing_number) { should eq('321174851') }
|
18
|
+
its(:account_number) { should end_with('4321') }
|
19
|
+
its(:name) { should eq('William Henry Cavendish III') }
|
20
|
+
its(:fingerprint) { should_not be_nil }
|
21
|
+
its(:customer) { should be_nil }
|
26
22
|
end
|
27
23
|
|
28
|
-
|
29
|
-
it 'should not create without a
|
24
|
+
context 'create invalid' do
|
25
|
+
it 'should not create without a routing_number field' do
|
30
26
|
lambda { Balanced::BankAccount.new(
|
31
|
-
:account_number =>
|
32
|
-
:
|
33
|
-
:
|
27
|
+
:account_number => '0987654321',
|
28
|
+
:name => 'Timmy T. McTimmerson',
|
29
|
+
:type => 'checking'
|
34
30
|
).save }.should raise_error(Balanced::BadRequest)
|
35
31
|
end
|
36
|
-
end
|
37
32
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
:
|
42
|
-
:
|
43
|
-
|
44
|
-
:type => "checking"
|
45
|
-
)
|
33
|
+
it 'should not create without a account_number field' do
|
34
|
+
lambda { Balanced::BankAccount.new(
|
35
|
+
:routing_number => '321174851',
|
36
|
+
:name => 'Timmy T. McTimmerson',
|
37
|
+
:type => 'checking'
|
38
|
+
).save }.should raise_error(Balanced::BadRequest)
|
46
39
|
end
|
47
40
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
subject { @bank_account.has_account? }
|
56
|
-
it { should be_false }
|
57
|
-
|
58
|
-
end
|
41
|
+
it 'should not create without a type field' do
|
42
|
+
lambda { Balanced::BankAccount.new(
|
43
|
+
:account_number => '0987654321',
|
44
|
+
:bank_code => '321174851',
|
45
|
+
:name => 'Timmy T. McTimmerson'
|
46
|
+
).save }.should raise_error(Balanced::BadRequest)
|
59
47
|
end
|
48
|
+
end
|
60
49
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
@account.add_bank_account(bank_account.uri)
|
71
|
-
@bank_account_two = bank_account.reload
|
72
|
-
end
|
73
|
-
|
74
|
-
describe 'has_account?' do
|
75
|
-
subject { @bank_account_two.has_account? }
|
76
|
-
it { should be_true }
|
77
|
-
end
|
78
|
-
|
50
|
+
context 'successful verification' do
|
51
|
+
subject(:verification) do
|
52
|
+
@bank_account = Balanced::BankAccount.new(
|
53
|
+
:name => 'William Henry Cavendish III',
|
54
|
+
:routing_number => '321174851',
|
55
|
+
:account_number => '0987654321',
|
56
|
+
:type => 'checking'
|
57
|
+
).save
|
58
|
+
@verification = @bank_account.verify
|
79
59
|
end
|
80
60
|
|
81
|
-
|
82
|
-
subject
|
83
|
-
|
61
|
+
it 'verification#attributes' do
|
62
|
+
subject.bank_account.href.should eql(@bank_account.href)
|
63
|
+
subject.attempts_remaining.should eql(3)
|
64
|
+
subject.verification_status.should eql('pending')
|
84
65
|
end
|
85
66
|
|
86
|
-
|
87
|
-
|
88
|
-
|
67
|
+
it 'confirmation#attributes' do
|
68
|
+
confirmation = subject.confirm(1, 1)
|
69
|
+
confirmation.bank_account.href.should eql(subject.bank_account.href)
|
70
|
+
subject.attempts_remaining.should eql(2)
|
71
|
+
subject.verification_status.should eql('succeeded')
|
89
72
|
end
|
90
73
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
:name => "Timmy T. McTimmerson",
|
97
|
-
:type => "checking"
|
98
|
-
)
|
99
|
-
@account = @marketplace.create_account
|
100
|
-
@account.add_bank_account(@bank_account.uri)
|
101
|
-
@bank_account = @account.bank_accounts[0]
|
102
|
-
@bank_account.save
|
103
|
-
end
|
104
|
-
|
105
|
-
subject { @bank_account.is_valid }
|
106
|
-
it { should be_true }
|
74
|
+
it 'successfully debits' do
|
75
|
+
subject.confirm(1, 1)
|
76
|
+
subject.verification_status.should eql('succeeded')
|
77
|
+
debit = subject.bank_account.debit(:amount => 1000)
|
78
|
+
debit.status.should eql('succeeded')
|
107
79
|
end
|
108
80
|
|
109
|
-
describe 'credit', :vcr do
|
110
|
-
before do
|
111
|
-
@credit = @bank_account.credit(
|
112
|
-
:amount => 50,
|
113
|
-
:description => 'Blah'
|
114
|
-
)
|
115
|
-
end
|
116
|
-
|
117
|
-
describe 'bank_account' do
|
118
|
-
subject { @credit.bank_account }
|
119
|
-
its(:account_number) { should end_with '4321' }
|
120
|
-
its(:routing_number) { should eql '321174851' }
|
121
|
-
end
|
122
|
-
|
123
|
-
describe 'without an account', :vcr do
|
124
|
-
before do
|
125
|
-
@bank_account = @marketplace.create_bank_account(
|
126
|
-
:account_number => "1234567890111",
|
127
|
-
:bank_code => "021000021",
|
128
|
-
:name => "Timmy T. McTimmerson",
|
129
|
-
:type => "checking"
|
130
|
-
)
|
131
|
-
end
|
132
|
-
|
133
|
-
describe 'with appears_on_statement_as', :vcr do
|
134
|
-
before do
|
135
|
-
@credit = @bank_account.credit(:amount => 1000, :description => "Testing", :appears_on_statement_as => "Test Company")
|
136
|
-
end
|
137
|
-
|
138
|
-
subject { @credit }
|
139
|
-
its(:appears_on_statement_as) { should eql 'Test Company' }
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
describe 'with an account', :vcr do
|
144
|
-
before do
|
145
|
-
@bank_account = @marketplace.create_bank_account(
|
146
|
-
:account_number => "1234567890111",
|
147
|
-
:bank_code => "021000021",
|
148
|
-
:name => "Timmy T. McTimmerson",
|
149
|
-
:type => "checking"
|
150
|
-
)
|
151
|
-
@account = @marketplace.create_account
|
152
|
-
@account.add_bank_account(@bank_account.uri)
|
153
|
-
@bank_account.reload
|
154
|
-
end
|
155
|
-
|
156
|
-
describe 'with appears_on_statement_as', :vcr do
|
157
|
-
before do
|
158
|
-
@credit = @bank_account.credit(
|
159
|
-
:amount => 1000,
|
160
|
-
:description => "Blahblahblah",
|
161
|
-
:appears_on_statement_as => "Test Company"
|
162
|
-
)
|
163
|
-
end
|
164
|
-
|
165
|
-
subject { @credit }
|
166
|
-
it { should respond_to :account }
|
167
|
-
it { should be_instance_of Balanced::Credit }
|
168
|
-
its(:appears_on_statement_as) { should eql 'Test Company' }
|
169
|
-
end
|
170
|
-
|
171
|
-
describe 'without appears_on_statement_as', :vcr do
|
172
|
-
before do
|
173
|
-
@credit = @bank_account.credit(
|
174
|
-
:amount => 1000,
|
175
|
-
:description => "Testing"
|
176
|
-
)
|
177
|
-
end
|
178
|
-
|
179
|
-
subject { @credit }
|
180
|
-
it { should respond_to :account }
|
181
|
-
it { should be_instance_of Balanced::Credit }
|
182
|
-
its(:appears_on_statement_as) { should eql 'example.com' }
|
183
|
-
end
|
184
|
-
end
|
185
|
-
end
|
186
81
|
end
|
187
82
|
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
)
|
198
|
-
@account = @marketplace.create_account
|
199
|
-
@account.add_bank_account(@bank_account.uri)
|
200
|
-
end
|
201
|
-
|
202
|
-
it do
|
203
|
-
lambda {
|
204
|
-
@account.debit(:amount => 100)
|
205
|
-
}.should raise_error(Balanced::Conflict)
|
206
|
-
end
|
83
|
+
context 'fails' do
|
84
|
+
before do
|
85
|
+
@bank_account = Balanced::BankAccount.new(
|
86
|
+
:name => 'Karl Malone',
|
87
|
+
:routing_number => '021000021',
|
88
|
+
:account_number => '9900000002',
|
89
|
+
:type => 'checking'
|
90
|
+
).save
|
91
|
+
@verification = @bank_account.verify
|
207
92
|
end
|
208
93
|
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
)
|
217
|
-
@account = @marketplace.create_account
|
218
|
-
@account.add_bank_account(@bank_account.uri)
|
94
|
+
it 'throws error on invalid amounts' do
|
95
|
+
3.times do
|
96
|
+
expect {
|
97
|
+
@verification.confirm(2, 3)
|
98
|
+
}.to raise_error(Balanced::BankAccountVerificationFailure) { |exc|
|
99
|
+
expect(exc.description).to start_with 'Authentication amounts do not match'
|
100
|
+
}
|
219
101
|
end
|
102
|
+
end
|
220
103
|
|
221
|
-
|
104
|
+
it 'fails to debit' do
|
105
|
+
expect {
|
106
|
+
@verification.confirm(2, 3)
|
107
|
+
}.to raise_error(Balanced::BankAccountVerificationFailure) { |exc|
|
108
|
+
expect(exc.description).to start_with 'Authentication amounts do not match'
|
109
|
+
}
|
110
|
+
expect {
|
111
|
+
@bank_account.debit(:amount => 1000)
|
112
|
+
}.to raise_exception(Balanced::Conflict) { |exc|
|
113
|
+
expect(exc.description).to start_with 'Funding instrument cannot be debited'
|
114
|
+
}
|
115
|
+
end
|
222
116
|
|
223
|
-
|
224
|
-
authentication.confirm(1, 1)
|
117
|
+
end
|
225
118
|
|
226
|
-
|
227
|
-
|
119
|
+
describe '#debit' do
|
120
|
+
before do
|
121
|
+
@bank_account = Balanced::BankAccount.new(
|
122
|
+
:name => 'William Henry Cavendish III',
|
123
|
+
:routing_number => '321174851',
|
124
|
+
:account_number => '0987654321',
|
125
|
+
:type => 'checking'
|
126
|
+
).save
|
127
|
+
@verification = @bank_account.verify
|
128
|
+
@verification.confirm(1, 1)
|
228
129
|
end
|
229
130
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
:name => "Timmy T. McTimmerson",
|
236
|
-
:type => "checking"
|
237
|
-
)
|
238
|
-
@account = @marketplace.create_account
|
239
|
-
@account.add_bank_account(@bank_account.uri)
|
240
|
-
end
|
241
|
-
|
242
|
-
it do
|
131
|
+
it 'succeeds' do
|
132
|
+
debit = @bank_account.debit(:amount => 1000)
|
133
|
+
debit.status.should eql('succeeded')
|
134
|
+
end
|
135
|
+
end
|
243
136
|
|
244
|
-
|
137
|
+
describe '#credit' do
|
138
|
+
before do
|
139
|
+
@bank_account = Balanced::BankAccount.new(
|
140
|
+
:name => 'William Henry Cavendish III',
|
141
|
+
:routing_number => '321174851',
|
142
|
+
:account_number => '0987654321',
|
143
|
+
:type => 'checking'
|
144
|
+
).save
|
145
|
+
end
|
245
146
|
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
147
|
+
it 'succeeds', :vcr => {:record => :new_episodes} do
|
148
|
+
before = Balanced::Marketplace.mine.in_escrow
|
149
|
+
@credit = @bank_account.credit(:amount => 1000)
|
150
|
+
@credit.should be_instance_of Balanced::Credit
|
151
|
+
@credit.status.should eql('succeeded')
|
152
|
+
@credit.destination.href.should eql(@bank_account.href)
|
153
|
+
after = Balanced::Marketplace.mine.in_escrow
|
154
|
+
after.should eql(before - @credit.amount)
|
250
155
|
end
|
251
156
|
end
|
252
157
|
end
|