balanced 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -1
- data/.travis.yml +1 -0
- data/CONTRIBUTORS +3 -1
- data/README.md +19 -3
- data/Rakefile +17 -0
- data/examples/customers.rb +1 -1
- data/lib/balanced/resources.rb +1 -1
- data/lib/balanced/resources/credit.rb +18 -0
- data/lib/balanced/resources/invoice.rb +11 -0
- data/lib/balanced/resources/marketplace.rb +3 -1
- data/lib/balanced/resources/reversal.rb +20 -0
- data/lib/balanced/resources/transaction.rb +1 -2
- data/lib/balanced/version.rb +1 -1
- data/scenario.cache +540 -0
- data/scenarios/account_add_card/definition.rb +1 -0
- data/scenarios/account_add_card/request.rb +3 -0
- data/scenarios/account_add_card/ruby.mako +11 -0
- data/scenarios/account_capture_hold/definition.rb +1 -0
- data/scenarios/account_capture_hold/request.rb +3 -0
- data/scenarios/account_capture_hold/ruby.mako +11 -0
- data/scenarios/account_create/definition.rb +1 -0
- data/scenarios/account_create/request.rb +2 -0
- data/scenarios/account_create/ruby.mako +10 -0
- data/scenarios/account_create_buyer/definition.rb +1 -0
- data/scenarios/account_create_buyer/request.rb +4 -0
- data/scenarios/account_create_buyer/ruby.mako +12 -0
- data/scenarios/account_create_debit/definition.rb +1 -0
- data/scenarios/account_create_debit/request.rb +3 -0
- data/scenarios/account_create_debit/ruby.mako +11 -0
- data/scenarios/account_create_hold/definition.rb +1 -0
- data/scenarios/account_create_hold/request.rb +3 -0
- data/scenarios/account_create_hold/ruby.mako +11 -0
- data/scenarios/account_create_merchant/definition.rb +1 -0
- data/scenarios/account_create_merchant/request.rb +3 -0
- data/scenarios/account_create_merchant/ruby.mako +11 -0
- data/scenarios/account_underwrite_business/definition.rb +1 -0
- data/scenarios/account_underwrite_business/request.rb +19 -0
- data/scenarios/account_underwrite_business/ruby.mako +27 -0
- data/scenarios/account_underwrite_person/definition.rb +1 -0
- data/scenarios/account_underwrite_person/request.rb +18 -0
- data/scenarios/account_underwrite_person/ruby.mako +26 -0
- data/scenarios/bank_account_create/definition.rb +1 -0
- data/scenarios/bank_account_create/request.rb +4 -0
- data/scenarios/bank_account_create/ruby.mako +12 -0
- data/scenarios/bank_account_delete/definition.rb +1 -0
- data/scenarios/bank_account_delete/request.rb +3 -0
- data/scenarios/bank_account_delete/ruby.mako +11 -0
- data/scenarios/bank_account_find_and_credit/definition.rb +1 -0
- data/scenarios/bank_account_find_and_credit/request.rb +5 -0
- data/scenarios/bank_account_find_and_credit/ruby.mako +13 -0
- data/scenarios/bank_account_find_and_delete/definition.rb +1 -0
- data/scenarios/bank_account_find_and_delete/request.rb +3 -0
- data/scenarios/bank_account_find_and_delete/ruby.mako +10 -0
- data/scenarios/bank_account_invalid_routing_number/definition.rb +1 -0
- data/scenarios/bank_account_invalid_routing_number/request.rb +8 -0
- data/scenarios/bank_account_invalid_routing_number/ruby.mako +16 -0
- data/scenarios/bank_account_list/definition.rb +1 -0
- data/scenarios/bank_account_list/request.rb +2 -0
- data/scenarios/bank_account_list/ruby.mako +10 -0
- data/scenarios/bank_account_show/definition.rb +1 -0
- data/scenarios/bank_account_show/request.rb +2 -0
- data/scenarios/bank_account_show/ruby.mako +10 -0
- data/scenarios/bank_account_verification_create/definition.rb +1 -0
- data/scenarios/bank_account_verification_create/request.rb +3 -0
- data/scenarios/bank_account_verification_create/ruby.mako +11 -0
- data/scenarios/bank_account_verification_show/definition.rb +1 -0
- data/scenarios/bank_account_verification_show/request.rb +2 -0
- data/scenarios/bank_account_verification_show/ruby.mako +10 -0
- data/scenarios/bank_account_verification_update/definition.rb +1 -0
- data/scenarios/bank_account_verification_update/request.rb +7 -0
- data/scenarios/bank_account_verification_update/ruby.mako +17 -0
- data/scenarios/callback_create/definition.rb +1 -0
- data/scenarios/callback_create/request.rb +4 -0
- data/scenarios/callback_create/ruby.mako +0 -0
- data/scenarios/callback_delete/definition.rb +1 -0
- data/scenarios/callback_delete/request.rb +3 -0
- data/scenarios/callback_delete/ruby.mako +0 -0
- data/scenarios/callback_list/definition.rb +1 -0
- data/scenarios/callback_list/request.rb +3 -0
- data/scenarios/callback_list/ruby.mako +0 -0
- data/scenarios/callback_show/definition.rb +1 -0
- data/scenarios/callback_show/request.rb +2 -0
- data/scenarios/callback_show/ruby.mako +0 -0
- data/scenarios/card_create/definition.rb +1 -0
- data/scenarios/card_create/request.rb +5 -0
- data/scenarios/card_create/ruby.mako +13 -0
- data/scenarios/card_invalidate/definition.rb +1 -0
- data/scenarios/card_invalidate/request.rb +3 -0
- data/scenarios/card_invalidate/ruby.mako +10 -0
- data/scenarios/card_list/definition.rb +1 -0
- data/scenarios/card_list/request.rb +2 -0
- data/scenarios/card_list/ruby.mako +9 -0
- data/scenarios/card_show/definition.rb +1 -0
- data/scenarios/card_show/request.rb +2 -0
- data/scenarios/card_show/ruby.mako +9 -0
- data/scenarios/card_update/definition.rb +1 -0
- data/scenarios/card_update/request.rb +6 -0
- data/scenarios/card_update/ruby.mako +14 -0
- data/scenarios/credit_account_list/definition.rb +1 -0
- data/scenarios/credit_account_list/request.rb +3 -0
- data/scenarios/credit_account_list/ruby.mako +10 -0
- data/scenarios/credit_account_merchant_create/definition.rb +1 -0
- data/scenarios/credit_account_merchant_create/request.rb +5 -0
- data/scenarios/credit_account_merchant_create/ruby.mako +12 -0
- data/scenarios/credit_bank_account_list/definition.rb +1 -0
- data/scenarios/credit_bank_account_list/request.rb +5 -0
- data/scenarios/credit_bank_account_list/ruby.mako +12 -0
- data/scenarios/credit_create_existing_bank_account/definition.rb +1 -0
- data/scenarios/credit_create_existing_bank_account/request.rb +5 -0
- data/scenarios/credit_create_existing_bank_account/ruby.mako +12 -0
- data/scenarios/credit_create_new_bank_account/definition.rb +1 -0
- data/scenarios/credit_create_new_bank_account/request.rb +10 -0
- data/scenarios/credit_create_new_bank_account/ruby.mako +18 -0
- data/scenarios/credit_customer_list/definition.rb +1 -0
- data/scenarios/credit_customer_list/request.rb +4 -0
- data/scenarios/credit_customer_list/ruby.mako +12 -0
- data/scenarios/credit_failed_state/definition.rb +1 -0
- data/scenarios/credit_failed_state/request.rb +10 -0
- data/scenarios/credit_failed_state/ruby.mako +18 -0
- data/scenarios/credit_list/definition.rb +1 -0
- data/scenarios/credit_list/request.rb +4 -0
- data/scenarios/credit_list/ruby.mako +11 -0
- data/scenarios/credit_paid_state/definition.rb +1 -0
- data/scenarios/credit_paid_state/request.rb +11 -0
- data/scenarios/credit_paid_state/ruby.mako +19 -0
- data/scenarios/credit_pending_state/definition.rb +1 -0
- data/scenarios/credit_pending_state/request.rb +9 -0
- data/scenarios/credit_pending_state/ruby.mako +17 -0
- data/scenarios/credit_show/definition.rb +1 -0
- data/scenarios/credit_show/request.rb +4 -0
- data/scenarios/credit_show/ruby.mako +11 -0
- data/scenarios/customer_add_bank_account/definition.rb +1 -0
- data/scenarios/customer_add_bank_account/request.rb +3 -0
- data/scenarios/customer_add_bank_account/ruby.mako +11 -0
- data/scenarios/customer_add_card/definition.rb +1 -0
- data/scenarios/customer_add_card/request.rb +3 -0
- data/scenarios/customer_add_card/ruby.mako +11 -0
- data/scenarios/customer_capture_hold/definition.rb +1 -0
- data/scenarios/customer_capture_hold/request.rb +3 -0
- data/scenarios/customer_capture_hold/ruby.mako +0 -0
- data/scenarios/customer_create/definition.rb +1 -0
- data/scenarios/customer_create/request.rb +2 -0
- data/scenarios/customer_create/ruby.mako +10 -0
- data/scenarios/customer_create_debit/definition.rb +1 -0
- data/scenarios/customer_create_debit/request.rb +3 -0
- data/scenarios/customer_create_debit/ruby.mako +11 -0
- data/scenarios/customer_create_hold/definition.rb +1 -0
- data/scenarios/customer_create_hold/request.rb +3 -0
- data/scenarios/customer_create_hold/ruby.mako +11 -0
- data/scenarios/customer_credit/definition.rb +1 -0
- data/scenarios/customer_credit/request.rb +2 -0
- data/scenarios/customer_credit/ruby.mako +8 -0
- data/scenarios/debit_account_list/definition.rb +1 -0
- data/scenarios/debit_account_list/request.rb +3 -0
- data/scenarios/debit_account_list/ruby.mako +10 -0
- data/scenarios/debit_create/definition.rb +1 -0
- data/scenarios/debit_create/request.rb +3 -0
- data/scenarios/debit_create/ruby.mako +11 -0
- data/scenarios/debit_customer_list/definition.rb +1 -0
- data/scenarios/debit_customer_list/request.rb +4 -0
- data/scenarios/debit_customer_list/ruby.mako +12 -0
- data/scenarios/debit_list/definition.rb +1 -0
- data/scenarios/debit_list/request.rb +4 -0
- data/scenarios/debit_list/ruby.mako +11 -0
- data/scenarios/debit_refund/definition.rb +1 -0
- data/scenarios/debit_refund/request.rb +3 -0
- data/scenarios/debit_refund/ruby.mako +10 -0
- data/scenarios/debit_show/definition.rb +1 -0
- data/scenarios/debit_show/request.rb +2 -0
- data/scenarios/debit_show/ruby.mako +10 -0
- data/scenarios/debit_update/definition.rb +1 -0
- data/scenarios/debit_update/request.rb +5 -0
- data/scenarios/debit_update/ruby.mako +13 -0
- data/scenarios/delete.rb +7 -0
- data/scenarios/event_list/definition.rb +1 -0
- data/scenarios/event_list/request.rb +3 -0
- data/scenarios/event_list/ruby.mako +10 -0
- data/scenarios/event_replay/definition.rb +0 -0
- data/scenarios/event_replay/request.rb +1 -0
- data/scenarios/event_replay/ruby.mako +0 -0
- data/scenarios/event_show/definition.rb +1 -0
- data/scenarios/event_show/request.rb +2 -0
- data/scenarios/event_show/ruby.mako +10 -0
- data/scenarios/execute.rb +27 -0
- data/scenarios/helpers.rb +15 -0
- data/scenarios/hold_account_list/definition.rb +1 -0
- data/scenarios/hold_account_list/request.rb +3 -0
- data/scenarios/hold_account_list/ruby.mako +10 -0
- data/scenarios/hold_capture/definition.rb +1 -0
- data/scenarios/hold_capture/request.rb +5 -0
- data/scenarios/hold_capture/ruby.mako +13 -0
- data/scenarios/hold_create/definition.rb +1 -0
- data/scenarios/hold_create/request.rb +5 -0
- data/scenarios/hold_create/ruby.mako +13 -0
- data/scenarios/hold_customer_list/definition.rb +1 -0
- data/scenarios/hold_customer_list/request.rb +3 -0
- data/scenarios/hold_customer_list/ruby.mako +11 -0
- data/scenarios/hold_list/definition.rb +1 -0
- data/scenarios/hold_list/request.rb +4 -0
- data/scenarios/hold_list/ruby.mako +11 -0
- data/scenarios/hold_show/definition.rb +1 -0
- data/scenarios/hold_show/request.rb +2 -0
- data/scenarios/hold_show/ruby.mako +10 -0
- data/scenarios/hold_update/definition.rb +1 -0
- data/scenarios/hold_update/request.rb +5 -0
- data/scenarios/hold_update/ruby.mako +13 -0
- data/scenarios/hold_void/definition.rb +1 -0
- data/scenarios/hold_void/request.rb +3 -0
- data/scenarios/hold_void/ruby.mako +10 -0
- data/scenarios/refund_account_list/definition.rb +1 -0
- data/scenarios/refund_account_list/request.rb +3 -0
- data/scenarios/refund_account_list/ruby.mako +10 -0
- data/scenarios/refund_create/definition.rb +1 -0
- data/scenarios/refund_create/request.rb +6 -0
- data/scenarios/refund_create/ruby.mako +14 -0
- data/scenarios/refund_customer_list/definition.rb +1 -0
- data/scenarios/refund_customer_list/request.rb +3 -0
- data/scenarios/refund_list/definition.rb +1 -0
- data/scenarios/refund_list/request.rb +4 -0
- data/scenarios/refund_list/ruby.mako +11 -0
- data/scenarios/refund_show/definition.rb +1 -0
- data/scenarios/refund_show/request.rb +2 -0
- data/scenarios/refund_show/ruby.mako +10 -0
- data/scenarios/refund_update/definition.rb +1 -0
- data/scenarios/refund_update/request.rb +5 -0
- data/scenarios/refund_update/ruby.mako +13 -0
- data/scenarios/render.rb +32 -0
- data/scenarios/render_mako.rb +43 -0
- data/scenarios/render_one.rb +32 -0
- data/spec/balanced/resources/credit_spec.rb +23 -0
- data/spec/scenarios_spec.rb +39 -0
- data/spec/spec_helper.rb +2 -1
- metadata +237 -11
- checksums.yaml +0 -7
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Account.holds
|
@@ -0,0 +1,10 @@
|
|
1
|
+
% if mode == 'definition':
|
2
|
+
Balanced::Account.holds
|
3
|
+
|
4
|
+
% else:
|
5
|
+
require 'balanced'
|
6
|
+
Balanced.configure('8af725c6d54611e2bf5e026ba7f8ec28')
|
7
|
+
|
8
|
+
account = Balanced::Account.find('/v1/marketplaces/TEST-MP4erLnXCYoaeyr3tx95WSKc/accounts/AC4FqqEyFyTcd3eHhh2YXL4c')
|
9
|
+
holds = account.holds
|
10
|
+
% endif
|
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Hold.capture(...)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
% if mode == 'definition':
|
2
|
+
Balanced::Hold.capture(...)
|
3
|
+
|
4
|
+
% else:
|
5
|
+
require 'balanced'
|
6
|
+
Balanced.configure('8af725c6d54611e2bf5e026ba7f8ec28')
|
7
|
+
|
8
|
+
hold = Balanced::Hold.find('/v1/marketplaces/TEST-MP4erLnXCYoaeyr3tx95WSKc/holds/HL5m1WNF0ste8ap24cZ5bVU4')
|
9
|
+
debit = hold.capture(
|
10
|
+
{:appears_on_statement_as=>"ShowsUpOnStmt", :description=>"Some descriptive text for the debit in the dashboard", :hold_uri=>"/v1/marketplaces/TEST-MP4erLnXCYoaeyr3tx95WSKc/holds/HL5m1WNF0ste8ap24cZ5bVU4"}
|
11
|
+
)
|
12
|
+
|
13
|
+
% endif
|
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Account.hold(...)
|
@@ -0,0 +1,13 @@
|
|
1
|
+
% if mode == 'definition':
|
2
|
+
Balanced::Account.hold(...)
|
3
|
+
|
4
|
+
% else:
|
5
|
+
require 'balanced'
|
6
|
+
Balanced.configure('8af725c6d54611e2bf5e026ba7f8ec28')
|
7
|
+
|
8
|
+
buyer = Balanced::Account.find('/v1/marketplaces/TEST-MP4erLnXCYoaeyr3tx95WSKc/accounts/AC4FqqEyFyTcd3eHhh2YXL4c')
|
9
|
+
buyer.hold(
|
10
|
+
{:amount=>5000, :description=>"Some descriptive text for the debit in the dashboard"}
|
11
|
+
)
|
12
|
+
|
13
|
+
% endif
|
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Customer.holds
|
@@ -0,0 +1,11 @@
|
|
1
|
+
% if mode == 'definition':
|
2
|
+
Balanced::Customer.holds
|
3
|
+
|
4
|
+
% else:
|
5
|
+
require 'balanced'
|
6
|
+
Balanced.configure('c72cb360d3ae11e29593026ba7d31e6f')
|
7
|
+
|
8
|
+
customer = Balanced::Customer.find('/v1/customers/CU6W5pSk2CUXQxhENqyGRvQe')
|
9
|
+
holds = customer.holds
|
10
|
+
|
11
|
+
% endif
|
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Hold.all
|
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Hold.find()
|
@@ -0,0 +1,10 @@
|
|
1
|
+
% if mode == 'definition':
|
2
|
+
Balanced::Hold.find()
|
3
|
+
|
4
|
+
% else:
|
5
|
+
require 'balanced'
|
6
|
+
Balanced.configure('8af725c6d54611e2bf5e026ba7f8ec28')
|
7
|
+
|
8
|
+
hold = Balanced::Hold.find('/v1/marketplaces/TEST-MP4erLnXCYoaeyr3tx95WSKc/holds/HL5egN71JHX28fjIq5BbeR0s')
|
9
|
+
|
10
|
+
% endif
|
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Hold.save()
|
@@ -0,0 +1,13 @@
|
|
1
|
+
% if mode == 'definition':
|
2
|
+
Balanced::Hold.save()
|
3
|
+
|
4
|
+
% else:
|
5
|
+
require 'balanced'
|
6
|
+
Balanced.configure('8af725c6d54611e2bf5e026ba7f8ec28')
|
7
|
+
|
8
|
+
hold = Balanced::Hold.find('/v1/marketplaces/TEST-MP4erLnXCYoaeyr3tx95WSKc/holds/HL5egN71JHX28fjIq5BbeR0s')
|
9
|
+
hold.description = 'update this description'
|
10
|
+
hold.meta = {:"holding.for"=>"user1", :"meaningful.key"=>"some.value"}
|
11
|
+
hold.save
|
12
|
+
|
13
|
+
% endif
|
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Hold.void()
|
@@ -0,0 +1,10 @@
|
|
1
|
+
% if mode == 'definition':
|
2
|
+
Balanced::Hold.void()
|
3
|
+
|
4
|
+
% else:
|
5
|
+
require 'balanced'
|
6
|
+
Balanced.configure('8af725c6d54611e2bf5e026ba7f8ec28')
|
7
|
+
|
8
|
+
hold = Balanced::Hold.find('/v1/marketplaces/TEST-MP4erLnXCYoaeyr3tx95WSKc/holds/HL5ptvs6CKB2jsZOhuNNmGOA')
|
9
|
+
hold.void
|
10
|
+
% endif
|
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Account.refunds
|
@@ -0,0 +1,10 @@
|
|
1
|
+
% if mode == 'definition':
|
2
|
+
Balanced::Account.refunds
|
3
|
+
|
4
|
+
% else:
|
5
|
+
require 'balanced'
|
6
|
+
Balanced.configure('8af725c6d54611e2bf5e026ba7f8ec28')
|
7
|
+
|
8
|
+
buyer = Balanced::Account.find('/v1/marketplaces/TEST-MP4erLnXCYoaeyr3tx95WSKc/accounts/AC4FqqEyFyTcd3eHhh2YXL4c')
|
9
|
+
refunds = buyer.refunds
|
10
|
+
% endif
|
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Debit.refund()
|
@@ -0,0 +1,14 @@
|
|
1
|
+
% if mode == 'definition':
|
2
|
+
Balanced::Debit.refund()
|
3
|
+
|
4
|
+
% else:
|
5
|
+
require 'balanced'
|
6
|
+
Balanced.configure('8af725c6d54611e2bf5e026ba7f8ec28')
|
7
|
+
|
8
|
+
debit = Balanced::Debit.find('/v1/marketplaces/TEST-MP4erLnXCYoaeyr3tx95WSKc/debits/WD5uAv4hcfWPmB37xbtHkOTg')
|
9
|
+
debit.refund(
|
10
|
+
:description => 'Refund for Order #1111',
|
11
|
+
:meta => {:"fulfillment.item.condition"=>"OK", :"merchant.feedback"=>"positive", :"user.refund_reason"=>"not happy with product"}
|
12
|
+
)
|
13
|
+
|
14
|
+
% endif
|
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Customer.refunds
|
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Refund.all
|
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Refund.find()
|
@@ -0,0 +1,10 @@
|
|
1
|
+
% if mode == 'definition':
|
2
|
+
Balanced::Refund.find()
|
3
|
+
|
4
|
+
% else:
|
5
|
+
require 'balanced'
|
6
|
+
Balanced.configure('8af725c6d54611e2bf5e026ba7f8ec28')
|
7
|
+
|
8
|
+
refund = Balanced::Refund.find('/v1/marketplaces/TEST-MP4erLnXCYoaeyr3tx95WSKc/refunds/RF5vCZH6cVJzfoyqPDLVjBvU')
|
9
|
+
|
10
|
+
% endif
|
@@ -0,0 +1 @@
|
|
1
|
+
Balanced::Refund.save()
|
@@ -0,0 +1,13 @@
|
|
1
|
+
% if mode == 'definition':
|
2
|
+
Balanced::Refund.save()
|
3
|
+
|
4
|
+
% else:
|
5
|
+
require 'balanced'
|
6
|
+
Balanced.configure('8af725c6d54611e2bf5e026ba7f8ec28')
|
7
|
+
|
8
|
+
refund = Balanced::Refund.find('/v1/marketplaces/TEST-MP4erLnXCYoaeyr3tx95WSKc/refunds/RF5vCZH6cVJzfoyqPDLVjBvU')
|
9
|
+
refund.description = 'update this description'
|
10
|
+
refund.meta = {:"refund.reason"=>"user not happy with product", :"user.notes"=>"very polite on the phone", :"user.refund.count"=>"3"}
|
11
|
+
refund.save
|
12
|
+
|
13
|
+
% endif
|
data/scenarios/render.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'json'
|
3
|
+
require_relative 'helpers'
|
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
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'erb'
|
2
|
+
require 'json'
|
3
|
+
require 'ruby-debug'
|
4
|
+
require_relative 'helpers'
|
5
|
+
|
6
|
+
parsed_data = JSON.parse(File.read('./scenario.cache'))
|
7
|
+
|
8
|
+
Dir.chdir("./scenarios")
|
9
|
+
subdir_list = Dir["*"].reject { |o| not File.directory?(o) }
|
10
|
+
|
11
|
+
api_key = parsed_data["api_key"]
|
12
|
+
# boiler plate configuration code used in all scenarios
|
13
|
+
boiler_plate = "require 'balanced'\nBalanced.configure('#{api_key}')\n"
|
14
|
+
|
15
|
+
params_to_hash = @helpers[:params_to_hash]
|
16
|
+
params_to_hash_for_args = @helpers[:params_to_hash_for_args]
|
17
|
+
subdir_list.each do |scenario|
|
18
|
+
begin
|
19
|
+
definition = File.read("./#{scenario}/definition.rb")
|
20
|
+
template = File.read("./#{scenario}/request.rb")
|
21
|
+
# generate new erb template file from each request.rb file
|
22
|
+
erb = ERB.new(template)
|
23
|
+
request = parsed_data[scenario]['request']
|
24
|
+
payload = request['payload']
|
25
|
+
# render erb file passing in all local variables
|
26
|
+
executable = erb.result(binding)
|
27
|
+
File.open("./#{scenario}/ruby.mako", "w") do |f|
|
28
|
+
f.write("% if mode == 'definition':")
|
29
|
+
f.write("\n")
|
30
|
+
f.write(definition)
|
31
|
+
f.write("\n")
|
32
|
+
f.write("% else:")
|
33
|
+
f.write("\n")
|
34
|
+
f.write(executable)
|
35
|
+
f.write("\n")
|
36
|
+
f.write("% endif")
|
37
|
+
f.write("\n")
|
38
|
+
end
|
39
|
+
rescue Exception => e
|
40
|
+
puts "Error rendering #{scenario}'s mako"
|
41
|
+
puts e
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,32 @@
|
|
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
|
+
|
@@ -48,4 +48,27 @@ describe Balanced::Credit, :vcr do
|
|
48
48
|
its(:account_number) { should end_with '4321' }
|
49
49
|
end
|
50
50
|
end
|
51
|
+
|
52
|
+
describe "#reverse", :vcr do
|
53
|
+
before do
|
54
|
+
@credit = Balanced::Credit.new(
|
55
|
+
:amount => 5000,
|
56
|
+
:description => "A sweet ride",
|
57
|
+
:bank_account => {
|
58
|
+
:account_number => "0987654321",
|
59
|
+
:bank_code => "321174851",
|
60
|
+
:name => "Timmy T. McTimmerson",
|
61
|
+
:type => "savings"
|
62
|
+
}
|
63
|
+
).save
|
64
|
+
@reverse = @credit.reverse
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
describe 'amount', :vcr do
|
69
|
+
subject { @reverse.amount }
|
70
|
+
it { should == 5000 }
|
71
|
+
end
|
72
|
+
|
73
|
+
end
|
51
74
|
end
|