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::Order.save
|
@@ -0,0 +1,50 @@
|
|
1
|
+
% if mode == 'definition':
|
2
|
+
Balanced::Order.save
|
3
|
+
|
4
|
+
% elif mode == 'request':
|
5
|
+
require 'balanced'
|
6
|
+
Balanced.configure('ak-test-1kvvievk0Qqw5wQPsrlM9g7wQwNe62cyc')
|
7
|
+
|
8
|
+
order = Balanced::Order.fetch('/orders/OR3FOihZa7lMHdAP5p8BJZVY')
|
9
|
+
order.description = 'New description for order'
|
10
|
+
order.meta = {
|
11
|
+
'anykey' => 'valuegoeshere',
|
12
|
+
'product.id' => '1234567890'
|
13
|
+
}
|
14
|
+
order.save
|
15
|
+
|
16
|
+
% elif mode == 'response':
|
17
|
+
#<Balanced::Order:0x007fdc9c11c5a8
|
18
|
+
@attributes=
|
19
|
+
{"amount"=>0,
|
20
|
+
"amount_escrowed"=>0,
|
21
|
+
"created_at"=>"2014-01-27T22:58:01.115720Z",
|
22
|
+
"currency"=>"USD",
|
23
|
+
"delivery_address"=>
|
24
|
+
{"city"=>nil,
|
25
|
+
"country_code"=>nil,
|
26
|
+
"line1"=>nil,
|
27
|
+
"line2"=>nil,
|
28
|
+
"postal_code"=>nil,
|
29
|
+
"state"=>nil},
|
30
|
+
"description"=>"New description for order",
|
31
|
+
"href"=>"/orders/OR3FOihZa7lMHdAP5p8BJZVY",
|
32
|
+
"id"=>"OR3FOihZa7lMHdAP5p8BJZVY",
|
33
|
+
"links"=>{"merchant"=>"CU3eeasZ9yQ86uzzIYZkrPGg"},
|
34
|
+
"meta"=>{"anykey"=>"valuegoeshere", "product.id"=>"1234567890"},
|
35
|
+
"updated_at"=>"2014-01-27T22:58:05.657463Z"},
|
36
|
+
@hyperlinks=
|
37
|
+
{"buyers"=>
|
38
|
+
#<Proc:0x007fdc9c114470/lib/balanced/utils.rb:6 (lambda)>,
|
39
|
+
"credits"=>
|
40
|
+
#<Proc:0x007fdc9c10e700/lib/balanced/utils.rb:6 (lambda)>,
|
41
|
+
"debits"=>
|
42
|
+
#<Proc:0x007fdc9c10c0b8/lib/balanced/utils.rb:6 (lambda)>,
|
43
|
+
"merchant"=>
|
44
|
+
#<Proc:0x007fdc9c106988/lib/balanced/resources/resource.rb:60 (lambda)>,
|
45
|
+
"refunds"=>
|
46
|
+
#<Proc:0x007fdc9c104200/lib/balanced/utils.rb:6 (lambda)>,
|
47
|
+
"reversals"=>
|
48
|
+
#<Proc:0x007fdc9c0f67b8/lib/balanced/utils.rb:6 (lambda)>}>
|
49
|
+
|
50
|
+
% endif
|
@@ -1 +1 @@
|
|
1
|
-
Balanced::Debit.refund
|
1
|
+
Balanced::Debit.refund
|
@@ -1,6 +1,7 @@
|
|
1
1
|
<%= boiler_plate %>
|
2
|
-
debit = Balanced::Debit.
|
2
|
+
debit = Balanced::Debit.fetch('<%= request['debit_href'] %>')
|
3
3
|
debit.refund(
|
4
|
+
:amount => <%= payload['amount'] %>,
|
4
5
|
:description => '<%= payload['description'] %>',
|
5
6
|
:meta => {
|
6
7
|
<%= params_to_hash_for_args.call(payload['meta']).indent(2) %>
|
@@ -1,12 +1,12 @@
|
|
1
1
|
% if mode == 'definition':
|
2
|
-
Balanced::Debit.refund
|
3
|
-
|
4
|
-
% else:
|
2
|
+
Balanced::Debit.refund
|
3
|
+
% elif mode == 'request':
|
5
4
|
require 'balanced'
|
6
|
-
Balanced.configure('
|
5
|
+
Balanced.configure('ak-test-1kvvievk0Qqw5wQPsrlM9g7wQwNe62cyc')
|
7
6
|
|
8
|
-
debit = Balanced::Debit.
|
7
|
+
debit = Balanced::Debit.fetch('/debits/WD3MKNxNTKBGgA7mX50yogiu')
|
9
8
|
debit.refund(
|
9
|
+
:amount => 3000,
|
10
10
|
:description => 'Refund for Order #1111',
|
11
11
|
:meta => {
|
12
12
|
'fulfillment.item.condition' => 'OK',
|
@@ -15,4 +15,32 @@ debit.refund(
|
|
15
15
|
}
|
16
16
|
)
|
17
17
|
|
18
|
+
% elif mode == 'response':
|
19
|
+
#<Balanced::Refund:0x007fdc9c0e1958
|
20
|
+
@attributes=
|
21
|
+
{"amount"=>3000,
|
22
|
+
"created_at"=>"2014-01-27T22:58:11.375665Z",
|
23
|
+
"currency"=>"USD",
|
24
|
+
"description"=>"Refund for Order #1111",
|
25
|
+
"href"=>"/refunds/RF3RklPuFgsgI50UuYtr4g6I",
|
26
|
+
"id"=>"RF3RklPuFgsgI50UuYtr4g6I",
|
27
|
+
"links"=>
|
28
|
+
{"debit"=>"WD3MKNxNTKBGgA7mX50yogiu", "dispute"=>nil, "order"=>nil},
|
29
|
+
"meta"=>
|
30
|
+
{"fulfillment.item.condition"=>"OK",
|
31
|
+
"merchant.feedback"=>"positive",
|
32
|
+
"user.refund_reason"=>"not happy with product"},
|
33
|
+
"status"=>"succeeded",
|
34
|
+
"transaction_number"=>"RF383-088-7077",
|
35
|
+
"updated_at"=>"2014-01-27T22:58:12.115131Z"},
|
36
|
+
@hyperlinks=
|
37
|
+
{"debit"=>
|
38
|
+
#<Proc:0x007fdc9c0d6eb8/lib/balanced/resources/resource.rb:60 (lambda)>,
|
39
|
+
"dispute"=>
|
40
|
+
#<Proc:0x007fdc9c0d5798/lib/balanced/utils.rb:6 (lambda)>,
|
41
|
+
"events"=>
|
42
|
+
#<Proc:0x007fdc9c0cf938/lib/balanced/utils.rb:6 (lambda)>,
|
43
|
+
"order"=>
|
44
|
+
#<Proc:0x007fdc9c0cebf0/lib/balanced/utils.rb:6 (lambda)>}>
|
45
|
+
|
18
46
|
% endif
|
@@ -1,11 +1,37 @@
|
|
1
1
|
% if mode == 'definition':
|
2
2
|
Balanced::Refund.all
|
3
3
|
|
4
|
-
%
|
4
|
+
% elif mode == 'request':
|
5
5
|
require 'balanced'
|
6
|
-
Balanced.configure('
|
6
|
+
Balanced.configure('ak-test-1kvvievk0Qqw5wQPsrlM9g7wQwNe62cyc')
|
7
7
|
|
8
|
-
|
8
|
+
refunds = Balanced::Refund.all
|
9
|
+
% elif mode == 'response':
|
10
|
+
[#<Balanced::Refund:0x007fdc9c09f788
|
11
|
+
@attributes=
|
12
|
+
{"amount"=>3000,
|
13
|
+
"created_at"=>"2014-01-27T22:58:11.375665Z",
|
14
|
+
"currency"=>"USD",
|
15
|
+
"description"=>"Refund for Order #1111",
|
16
|
+
"href"=>"/refunds/RF3RklPuFgsgI50UuYtr4g6I",
|
17
|
+
"id"=>"RF3RklPuFgsgI50UuYtr4g6I",
|
18
|
+
"links"=>
|
19
|
+
{"debit"=>"WD3MKNxNTKBGgA7mX50yogiu", "dispute"=>nil, "order"=>nil},
|
20
|
+
"meta"=>
|
21
|
+
{"fulfillment.item.condition"=>"OK",
|
22
|
+
"merchant.feedback"=>"positive",
|
23
|
+
"user.refund_reason"=>"not happy with product"},
|
24
|
+
"status"=>"succeeded",
|
25
|
+
"transaction_number"=>"RF383-088-7077",
|
26
|
+
"updated_at"=>"2014-01-27T22:58:12.115131Z"},
|
27
|
+
@hyperlinks=
|
28
|
+
{"debit"=>
|
29
|
+
#<Proc:0x007fdc9c097d58/lib/balanced/resources/resource.rb:60 (lambda)>,
|
30
|
+
"dispute"=>
|
31
|
+
#<Proc:0x007fdc9c097290/lib/balanced/utils.rb:6 (lambda)>,
|
32
|
+
"events"=>
|
33
|
+
#<Proc:0x007fdc9c0945b8/lib/balanced/utils.rb:6 (lambda)>,
|
34
|
+
"order"=>
|
35
|
+
#<Proc:0x007fdc9c08c890/lib/balanced/utils.rb:6 (lambda)>}>]
|
9
36
|
|
10
|
-
refunds = Balanced::Refund.all(:limit => 2)
|
11
37
|
% endif
|
@@ -1 +1 @@
|
|
1
|
-
Balanced::Refund.
|
1
|
+
Balanced::Refund.fetch
|
@@ -1,2 +1,2 @@
|
|
1
1
|
<%= boiler_plate %>
|
2
|
-
refund = Balanced::Refund.
|
2
|
+
refund = Balanced::Refund.fetch('<%= request['uri'] %>')
|
@@ -1,10 +1,38 @@
|
|
1
1
|
% if mode == 'definition':
|
2
|
-
Balanced::Refund.
|
2
|
+
Balanced::Refund.fetch
|
3
3
|
|
4
|
-
%
|
4
|
+
% elif mode == 'request':
|
5
5
|
require 'balanced'
|
6
|
-
Balanced.configure('
|
6
|
+
Balanced.configure('ak-test-1kvvievk0Qqw5wQPsrlM9g7wQwNe62cyc')
|
7
7
|
|
8
|
-
refund = Balanced::Refund.
|
8
|
+
refund = Balanced::Refund.fetch('/refunds/RF3RklPuFgsgI50UuYtr4g6I')
|
9
|
+
|
10
|
+
% elif mode == 'response':
|
11
|
+
#<Balanced::Refund:0x007fdc9b1cd250
|
12
|
+
@attributes=
|
13
|
+
{"amount"=>3000,
|
14
|
+
"created_at"=>"2014-01-27T22:58:11.375665Z",
|
15
|
+
"currency"=>"USD",
|
16
|
+
"description"=>"Refund for Order #1111",
|
17
|
+
"href"=>"/refunds/RF3RklPuFgsgI50UuYtr4g6I",
|
18
|
+
"id"=>"RF3RklPuFgsgI50UuYtr4g6I",
|
19
|
+
"links"=>
|
20
|
+
{"debit"=>"WD3MKNxNTKBGgA7mX50yogiu", "dispute"=>nil, "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"=>"RF383-088-7077",
|
27
|
+
"updated_at"=>"2014-01-27T22:58:12.115131Z"},
|
28
|
+
@hyperlinks=
|
29
|
+
{"debit"=>
|
30
|
+
#<Proc:0x007fdc9b1c5f28/lib/balanced/resources/resource.rb:60 (lambda)>,
|
31
|
+
"dispute"=>
|
32
|
+
#<Proc:0x007fdc9b1c4c18/lib/balanced/utils.rb:6 (lambda)>,
|
33
|
+
"events"=>
|
34
|
+
#<Proc:0x007fdc9b1a3d88/lib/balanced/utils.rb:6 (lambda)>,
|
35
|
+
"order"=>
|
36
|
+
#<Proc:0x007fdc9b198320/lib/balanced/utils.rb:6 (lambda)>}>
|
9
37
|
|
10
38
|
% endif
|
@@ -1 +1 @@
|
|
1
|
-
Balanced::Refund.save
|
1
|
+
Balanced::Refund.save
|
@@ -1,5 +1,5 @@
|
|
1
1
|
<%= boiler_plate %>
|
2
|
-
refund = Balanced::Refund.
|
2
|
+
refund = Balanced::Refund.fetch('<%= request['uri'] %>')
|
3
3
|
refund.description = '<%= payload['description'] %>'
|
4
4
|
refund.meta = {
|
5
5
|
<%= params_to_hash_for_args.call(payload['meta']).indent(2) %>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
% if mode == 'definition':
|
2
|
-
Balanced::Refund.save
|
2
|
+
Balanced::Refund.save
|
3
3
|
|
4
|
-
%
|
4
|
+
% elif mode == 'request':
|
5
5
|
require 'balanced'
|
6
|
-
Balanced.configure('
|
6
|
+
Balanced.configure('ak-test-1kvvievk0Qqw5wQPsrlM9g7wQwNe62cyc')
|
7
7
|
|
8
|
-
refund = Balanced::Refund.
|
8
|
+
refund = Balanced::Refund.fetch('/refunds/RF3RklPuFgsgI50UuYtr4g6I')
|
9
9
|
refund.description = 'update this description'
|
10
10
|
refund.meta = {
|
11
11
|
'refund.reason' => 'user not happy with product',
|
@@ -14,4 +14,32 @@ refund.meta = {
|
|
14
14
|
}
|
15
15
|
refund.save
|
16
16
|
|
17
|
+
% elif mode == 'response':
|
18
|
+
#<Balanced::Refund:0x007fdc9c0149f8
|
19
|
+
@attributes=
|
20
|
+
{"amount"=>3000,
|
21
|
+
"created_at"=>"2014-01-27T22:58:11.375665Z",
|
22
|
+
"currency"=>"USD",
|
23
|
+
"description"=>"update this description",
|
24
|
+
"href"=>"/refunds/RF3RklPuFgsgI50UuYtr4g6I",
|
25
|
+
"id"=>"RF3RklPuFgsgI50UuYtr4g6I",
|
26
|
+
"links"=>
|
27
|
+
{"debit"=>"WD3MKNxNTKBGgA7mX50yogiu", "dispute"=>nil, "order"=>nil},
|
28
|
+
"meta"=>
|
29
|
+
{"refund.reason"=>"user not happy with product",
|
30
|
+
"user.notes"=>"very polite on the phone",
|
31
|
+
"user.refund.count"=>"3"},
|
32
|
+
"status"=>"succeeded",
|
33
|
+
"transaction_number"=>"RF383-088-7077",
|
34
|
+
"updated_at"=>"2014-01-27T22:58:17.950799Z"},
|
35
|
+
@hyperlinks=
|
36
|
+
{"debit"=>
|
37
|
+
#<Proc:0x007fdc9c00d838/lib/balanced/resources/resource.rb:60 (lambda)>,
|
38
|
+
"dispute"=>
|
39
|
+
#<Proc:0x007fdc9c00cb18/lib/balanced/utils.rb:6 (lambda)>,
|
40
|
+
"events"=>
|
41
|
+
#<Proc:0x007fdc9b865018/lib/balanced/utils.rb:6 (lambda)>,
|
42
|
+
"order"=>
|
43
|
+
#<Proc:0x007fdc9b85ff78/lib/balanced/utils.rb:6 (lambda)>}>
|
44
|
+
|
17
45
|
% endif
|
data/scenarios/render_mako.rb
CHANGED
@@ -1,9 +1,52 @@
|
|
1
|
+
require 'rubygems'
|
1
2
|
require 'erb'
|
2
3
|
require 'json'
|
3
|
-
require 'ruby-debug'
|
4
|
-
|
4
|
+
#require 'ruby-debug'
|
5
|
+
require './scenarios/helpers'
|
6
|
+
require './lib/balanced'
|
7
|
+
require 'pp'
|
8
|
+
require 'json'
|
9
|
+
|
10
|
+
class BalancedResourceObject
|
11
|
+
include Balanced::Resource
|
12
|
+
include Balanced::Resource::ClassMethods
|
13
|
+
end
|
14
|
+
|
15
|
+
def construct_resource(key, payload, links, meta)
|
16
|
+
cls = Balanced.from_hypermedia_registry(key)
|
17
|
+
instance = cls.new payload
|
18
|
+
instance.hydrate(links, meta)
|
19
|
+
instance
|
20
|
+
end
|
5
21
|
|
6
|
-
|
22
|
+
def construct_from_response(payload)
|
23
|
+
payload = Balanced::Utils.indifferent_read_access payload
|
24
|
+
|
25
|
+
links = payload.delete('links') || {}
|
26
|
+
meta = payload.delete('meta') || {}
|
27
|
+
|
28
|
+
payload.each do |key, value|
|
29
|
+
if key != 'errors'
|
30
|
+
if meta['first'] != nil #value.length > 1
|
31
|
+
instances = Array.new
|
32
|
+
value.first(2).each do |v|
|
33
|
+
instances << construct_resource(key, v, links, meta)
|
34
|
+
end
|
35
|
+
return instances
|
36
|
+
else
|
37
|
+
return construct_resource(key, value.first, links, meta)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def tidy_response(response)
|
44
|
+
#@/Users/ben/Development/ruby/balanced-ruby/lib/balanced/utils.rb:6
|
45
|
+
return if ! response
|
46
|
+
return response.gsub(/@\S(.*?)\Sbalanced-ruby/, '')
|
47
|
+
end
|
48
|
+
|
49
|
+
parsed_data = JSON.parse(File.read('scenario.cache'))
|
7
50
|
|
8
51
|
Dir.chdir("./scenarios")
|
9
52
|
subdir_list = Dir["*"].reject { |o| not File.directory?(o) }
|
@@ -14,6 +57,7 @@ boiler_plate = "require 'balanced'\nBalanced.configure('#{api_key}')\n"
|
|
14
57
|
|
15
58
|
params_to_hash = @helpers[:params_to_hash]
|
16
59
|
params_to_hash_for_args = @helpers[:params_to_hash_for_args]
|
60
|
+
params_to_key_word_arguments = @helpers[:params_to_key_word_arguments]
|
17
61
|
subdir_list.each do |scenario|
|
18
62
|
begin
|
19
63
|
definition = File.read("./#{scenario}/definition.rb")
|
@@ -21,6 +65,11 @@ subdir_list.each do |scenario|
|
|
21
65
|
# generate new erb template file from each request.rb file
|
22
66
|
erb = ERB.new(template)
|
23
67
|
request = parsed_data[scenario]['request']
|
68
|
+
response = nil
|
69
|
+
if parsed_data[scenario]['response'] != nil
|
70
|
+
parsed_response = JSON.parse(parsed_data[scenario]['response'])
|
71
|
+
response = PP.pp(construct_from_response(parsed_response), "")
|
72
|
+
end
|
24
73
|
payload = request['payload']
|
25
74
|
# render erb file passing in all local variables
|
26
75
|
executable = erb.result(binding)
|
@@ -29,14 +78,20 @@ subdir_list.each do |scenario|
|
|
29
78
|
f.write("\n")
|
30
79
|
f.write(definition)
|
31
80
|
f.write("\n")
|
32
|
-
f.write("%
|
81
|
+
f.write("% elif mode == 'request':")
|
33
82
|
f.write("\n")
|
34
83
|
f.write(executable)
|
35
84
|
f.write("\n")
|
85
|
+
f.write("% elif mode == 'response':")
|
86
|
+
f.write("\n")
|
87
|
+
f.write(tidy_response(response))
|
88
|
+
f.write("\n")
|
36
89
|
f.write("% endif")
|
37
90
|
f.write("\n")
|
38
91
|
end
|
39
92
|
rescue Exception => e
|
93
|
+
puts e
|
94
|
+
puts e.backtrace
|
40
95
|
puts "Error rendering #{scenario}'s mako"
|
41
96
|
end
|
42
97
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Credit.reverse
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%= boiler_plate %>
|
2
|
+
reversal = Balanced::Credit.fetch('<%= request['credit_href'] %>')
|
3
|
+
credit.reverse(
|
4
|
+
:amount => <%= payload['amount'] %>,
|
5
|
+
:description => '<%= payload['description'] %>',
|
6
|
+
:meta => {
|
7
|
+
<%= params_to_hash_for_args.call(payload['meta']).indent(2) %>
|
8
|
+
}
|
9
|
+
)
|
@@ -0,0 +1,45 @@
|
|
1
|
+
% if mode == 'definition':
|
2
|
+
Balanced::Credit.reverse
|
3
|
+
% elif mode == 'request':
|
4
|
+
require 'balanced'
|
5
|
+
Balanced.configure('ak-test-1kvvievk0Qqw5wQPsrlM9g7wQwNe62cyc')
|
6
|
+
|
7
|
+
reversal = Balanced::Credit.fetch('/credits/CR40neytmVG2HDBp1opfF7sY')
|
8
|
+
credit.reverse(
|
9
|
+
:amount => 3000,
|
10
|
+
:description => 'Reversal for Order #1111',
|
11
|
+
:meta => {
|
12
|
+
'fulfillment.item.condition' => 'OK',
|
13
|
+
'merchant.feedback' => 'positive',
|
14
|
+
'user.refund_reason' => 'not happy with product'
|
15
|
+
}
|
16
|
+
)
|
17
|
+
|
18
|
+
% elif mode == 'response':
|
19
|
+
#<Balanced::Reversal:0x007fdc9b8048d0
|
20
|
+
@attributes=
|
21
|
+
{"amount"=>3000,
|
22
|
+
"created_at"=>"2014-01-27T22:58:21.214829Z",
|
23
|
+
"currency"=>"USD",
|
24
|
+
"description"=>"Reversal for Order #1111",
|
25
|
+
"failure_reason"=>nil,
|
26
|
+
"failure_reason_code"=>nil,
|
27
|
+
"href"=>"/reversals/RV42n8M9XZWna427oPDDi4RG",
|
28
|
+
"id"=>"RV42n8M9XZWna427oPDDi4RG",
|
29
|
+
"links"=>{"credit"=>"CR40neytmVG2HDBp1opfF7sY", "order"=>nil},
|
30
|
+
"meta"=>
|
31
|
+
{"fulfillment.item.condition"=>"OK",
|
32
|
+
"merchant.feedback"=>"positive",
|
33
|
+
"user.refund_reason"=>"not happy with product"},
|
34
|
+
"status"=>"succeeded",
|
35
|
+
"transaction_number"=>"RV219-169-0008",
|
36
|
+
"updated_at"=>"2014-01-27T22:58:22.190749Z"},
|
37
|
+
@hyperlinks=
|
38
|
+
{"credit"=>
|
39
|
+
#<Proc:0x007fdc9b190b20/lib/balanced/resources/resource.rb:60 (lambda)>,
|
40
|
+
"events"=>
|
41
|
+
#<Proc:0x007fdc9b188380/lib/balanced/utils.rb:6 (lambda)>,
|
42
|
+
"order"=>
|
43
|
+
#<Proc:0x007fdc9b1818c8/lib/balanced/utils.rb:6 (lambda)>}>
|
44
|
+
|
45
|
+
% endif
|