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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 66a60458d86bd0fe40aeb014e233fddeca12d627
|
4
|
+
data.tar.gz: 486418ed6ee7bac939ec7dcb6a036bebb3ef861c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb2dbf84c8740fde03b2cacd09b0a8b2b4a39613e7cb60862f78cb8907cad67f9cc1af5a8ec79215fc8c7edae3992c4fd50fbae2c8b243b0ee91034701d76091
|
7
|
+
data.tar.gz: a92899108421c79d1353e72c2fa2411f082158116a03ebe24b7fff4b0ea8bb5bd21cc7b1d2dbcc41433d218586f83439fad26f35fba15bbf2f9d8500cf660fb0
|
data/.rbenv-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.9.
|
1
|
+
1.9.3-p194
|
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
1.8.7-p370
|
data/Gemfile
CHANGED
@@ -2,17 +2,21 @@ source 'https://rubygems.org'
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in balanced.gemspec
|
4
4
|
|
5
|
-
|
5
|
+
gem "faraday"
|
6
|
+
gem "faraday_middleware"
|
7
|
+
gem "addressable"
|
8
|
+
gem "json"
|
6
9
|
|
7
10
|
group :development do
|
8
11
|
gem "yard"
|
9
12
|
gem "guard", '~> 1.6.2'
|
13
|
+
gem "listen", "~> 1.3.1" # 2.x requires celluloid, not 1.8.7 friendly
|
10
14
|
gem "guard-rspec", '~> 2.4.1'
|
11
15
|
end
|
12
16
|
|
13
17
|
group :test do
|
14
18
|
gem 'net-http-persistent'
|
15
|
-
gem "rspec", '~> 2.
|
19
|
+
gem "rspec", '~> 2.14.1'
|
16
20
|
gem "rake", '~> 10.0.3'
|
17
21
|
gem "vcr", '~> 2.4.0'
|
18
|
-
end
|
22
|
+
end
|
data/README.md
CHANGED
@@ -21,9 +21,9 @@ Or install it yourself as:
|
|
21
21
|
|
22
22
|
## Documentation & Usage
|
23
23
|
|
24
|
-
* [Balanced Overview](https://
|
24
|
+
* [Balanced Overview](https://docs.balancedpayments.com/?language=ruby)
|
25
25
|
* [RDoc](http://rubydoc.info/gems/balanced)
|
26
|
-
* [Balanced API with Ruby examples](https://
|
26
|
+
* [Balanced API with Ruby examples](https://docs.balancedpayments.com/api?language=ruby)
|
27
27
|
* [Example scripts](https://github.com/balanced/balanced-ruby/tree/master/examples)
|
28
28
|
|
29
29
|
## Contributing
|
@@ -64,14 +64,6 @@ All issues should be documented at
|
|
64
64
|
[balanced-ruby/issues](https://github.com/balanced/balanced-ruby/issues)
|
65
65
|
|
66
66
|
|
67
|
-
### Building Documentation
|
68
|
-
|
69
|
-
Documentation is built using YARD - http://rubydoc.info/docs/yard
|
70
|
-
|
71
|
-
export AMAZON_ACCESS_KEY_ID='xxx'
|
72
|
-
export AMAZON_SECRET_ACCESS_KEY='yyy'
|
73
|
-
./upload_docs.rb
|
74
|
-
|
75
67
|
### Scenarios
|
76
68
|
|
77
69
|
####Render
|
data/Rakefile
CHANGED
@@ -6,24 +6,10 @@ require "bundler/gem_tasks"
|
|
6
6
|
require 'rspec'
|
7
7
|
|
8
8
|
desc "Run spec suite"
|
9
|
-
RSpec::Core::RakeTask.new(:spec)
|
9
|
+
RSpec::Core::RakeTask.new(:spec) do |task|
|
10
|
+
file_list = FileList['spec/**/*_spec.rb']
|
11
|
+
task.pattern = file_list
|
12
|
+
end
|
10
13
|
|
11
14
|
desc "Default the task to run the spec"
|
12
15
|
task :default => [:spec]
|
13
|
-
|
14
|
-
desc "Render template files"
|
15
|
-
task :render_executables do
|
16
|
-
ruby File.dirname(__FILE__) + "/scenarios/render.rb"
|
17
|
-
end
|
18
|
-
|
19
|
-
desc "delete executables"
|
20
|
-
task :delete_executables do
|
21
|
-
ruby File.dirname(__FILE__) + "/scenarios/delete.rb"
|
22
|
-
end
|
23
|
-
|
24
|
-
desc "render one template file"
|
25
|
-
task :render_one, :name do
|
26
|
-
name = ENV['NAME']
|
27
|
-
file = File.dirname(__FILE__) + "/scenarios/render_one.rb"
|
28
|
-
ruby file, name
|
29
|
-
end
|
data/balanced.gemspec
CHANGED
@@ -4,17 +4,15 @@ require "base64"
|
|
4
4
|
require File.expand_path('../lib/balanced/version', __FILE__)
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
|
-
gem.authors = ["
|
8
|
-
gem.email = ["
|
9
|
-
gem.description = %q{Balanced is the payments platform for marketplaces.
|
10
|
-
|
11
|
-
|
12
|
-
}
|
13
|
-
gem.summary = %q{Sign up on https://balancedpayments.com/}
|
14
|
-
gem.homepage = "https://balancedpayments.com"
|
7
|
+
gem.authors = ["Balanced"]
|
8
|
+
gem.email = ["ZGV2QGJhbGFuY2VkcGF5bWVudHMuY29t"].map { |i| Base64.decode64(i) }
|
9
|
+
gem.description = %q{Balanced is the payments platform for marketplaces. }
|
10
|
+
gem.summary = %q{https://docs.balancedpayments.com/}
|
11
|
+
gem.homepage = "https://www.balancedpayments.com"
|
15
12
|
|
16
|
-
gem.add_dependency("faraday", '
|
13
|
+
gem.add_dependency("faraday", '>= 0.8.6')
|
17
14
|
gem.add_dependency("faraday_middleware", '~> 0.9.0')
|
15
|
+
gem.add_dependency("addressable", '~> 2.3.5')
|
18
16
|
|
19
17
|
gem.files = `git ls-files`.split($\)
|
20
18
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -22,4 +20,4 @@ Gem::Specification.new do |gem|
|
|
22
20
|
gem.name = "balanced"
|
23
21
|
gem.require_paths = %w(lib)
|
24
22
|
gem.version = Balanced::VERSION
|
25
|
-
end
|
23
|
+
end
|
data/lib/balanced.rb
CHANGED
@@ -5,7 +5,6 @@ require 'uri'
|
|
5
5
|
require 'balanced/version' unless defined? Balanced::VERSION
|
6
6
|
require 'balanced/client'
|
7
7
|
require 'balanced/utils'
|
8
|
-
require 'balanced/resources'
|
9
8
|
require 'balanced/error'
|
10
9
|
|
11
10
|
module Balanced
|
@@ -13,16 +12,18 @@ module Balanced
|
|
13
12
|
@client = nil
|
14
13
|
@config = {
|
15
14
|
:scheme => 'https',
|
16
|
-
|
17
15
|
:host => 'api.balancedpayments.com',
|
18
16
|
:port => 443,
|
19
|
-
:version => '1',
|
17
|
+
:version => '1.1',
|
20
18
|
}
|
21
19
|
|
20
|
+
@hypermedia_registry = {}
|
21
|
+
|
22
22
|
class << self
|
23
23
|
|
24
24
|
attr_accessor :client
|
25
25
|
attr_accessor :config
|
26
|
+
attr_accessor :hypermedia_registry
|
26
27
|
|
27
28
|
def configure(api_key=nil, options={})
|
28
29
|
@config = @config.merge(options)
|
@@ -33,34 +34,29 @@ module Balanced
|
|
33
34
|
!@client.api_key.nil?
|
34
35
|
end
|
35
36
|
|
36
|
-
def
|
37
|
-
URI.parse(
|
37
|
+
def split_the_href(href)
|
38
|
+
URI.parse(href).path.sub(/\/$/, '').split('/')
|
38
39
|
end
|
39
40
|
|
40
|
-
def
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
#
|
45
|
-
class_name = Balanced::Utils.classify(split_uri[-1])
|
46
|
-
begin
|
47
|
-
klass = Balanced.const_get class_name
|
48
|
-
rescue NameError
|
49
|
-
class_name = Utils.classify(split_uri[-2])
|
50
|
-
klass = Balanced.const_get(class_name)
|
41
|
+
def from_hypermedia_registry(resource_name)
|
42
|
+
cls = Balanced.hypermedia_registry[resource_name]
|
43
|
+
if cls.nil?
|
44
|
+
raise 'OH SHIT'
|
51
45
|
end
|
52
|
-
|
46
|
+
cls
|
53
47
|
end
|
54
48
|
|
55
|
-
def
|
56
|
-
split_uri =
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
rescue NameError
|
61
|
-
return false
|
49
|
+
def from_href(href)
|
50
|
+
split_uri = split_the_href(href)
|
51
|
+
split_uri.reverse!.each do |resource|
|
52
|
+
cls = Balanced.hypermedia_registry[resource]
|
53
|
+
return cls unless cls.nil?
|
62
54
|
end
|
63
|
-
|
55
|
+
end
|
56
|
+
|
57
|
+
def is_collection(href)
|
58
|
+
split_uri = split_the_href(href)
|
59
|
+
Balanced.hypermedia_registry.has_key?(split_uri.last)
|
64
60
|
end
|
65
61
|
|
66
62
|
def get(*args, &block)
|
@@ -75,13 +71,17 @@ module Balanced
|
|
75
71
|
self.client.put *args
|
76
72
|
end
|
77
73
|
|
78
|
-
def
|
79
|
-
self.client.
|
74
|
+
def unstore(*args, &block)
|
75
|
+
self.client.unstore *args
|
80
76
|
end
|
81
|
-
|
77
|
+
alias_method :delete, :unstore
|
82
78
|
end
|
83
79
|
|
84
80
|
# configure on import so we don't have to configure for creating
|
85
81
|
# an api key
|
86
82
|
configure
|
87
83
|
end
|
84
|
+
|
85
|
+
# require all the balanced resources! this is needed at the end because
|
86
|
+
# the Balanced module needs to be defined first, as it contains the registry
|
87
|
+
require 'balanced/resources'
|
data/lib/balanced/client.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
require 'logger'
|
2
|
+
require 'uri'
|
3
|
+
require 'faraday'
|
4
|
+
require 'faraday_middleware'
|
5
|
+
require 'balanced_exception_middleware'
|
6
6
|
|
7
7
|
|
8
8
|
module Balanced
|
@@ -18,7 +18,8 @@ module Balanced
|
|
18
18
|
:read_timeout => 60,
|
19
19
|
:logger => nil,
|
20
20
|
:ssl_verify => true,
|
21
|
-
:faraday_adapter => Faraday.default_adapter
|
21
|
+
:faraday_adapter => Faraday.default_adapter,
|
22
|
+
:accept_type => 'application/vnd.api+json'
|
22
23
|
}
|
23
24
|
|
24
25
|
attr_reader :conn
|
@@ -61,6 +62,8 @@ module Balanced
|
|
61
62
|
end
|
62
63
|
conn.path_prefix = '/'
|
63
64
|
conn.headers['User-Agent'] = "balanced-ruby/#{Balanced::VERSION}"
|
65
|
+
conn.headers['Content-Type'] = "application/json;revision=#{@config[:version]}"
|
66
|
+
conn.headers['Accept'] = "#{@config[:accept_type]};revision=#{@config[:version]}"
|
64
67
|
end
|
65
68
|
|
66
69
|
#def inspect # :nodoc:
|
@@ -75,6 +78,12 @@ module Balanced
|
|
75
78
|
:scheme => config[:scheme]})
|
76
79
|
end
|
77
80
|
|
81
|
+
# alias_method doesn't work with method_missing, so we manually
|
82
|
+
# delegate
|
83
|
+
def unstore(*args, &block)
|
84
|
+
delete(*args, &block)
|
85
|
+
end
|
86
|
+
|
78
87
|
def method_missing(method, *args, &block)
|
79
88
|
if is_http_method? method
|
80
89
|
conn.basic_auth(api_key, '') unless api_key.nil?
|
data/lib/balanced/error.rb
CHANGED
@@ -14,25 +14,33 @@ module Balanced
|
|
14
14
|
def body
|
15
15
|
@body ||= begin
|
16
16
|
return {} unless response[:body]
|
17
|
-
Utils.
|
17
|
+
Utils.indifferent_read_access(response[:body])
|
18
18
|
end
|
19
19
|
end
|
20
20
|
|
21
21
|
def error_message
|
22
22
|
set_attrs
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
23
|
+
errors = body.fetch('errors', nil)
|
24
|
+
unless errors.nil?
|
25
|
+
error = body[:errors][0]
|
26
|
+
extra = error[:additional] ? " -- #{error[:additional]}" : ""
|
27
|
+
"#{self.class.name}(#{response[:status]})::#{error[:status]}:: "\
|
28
|
+
"#{response[:method].to_s.upcase} #{response[:url].to_s}: "\
|
29
|
+
"#{error[:category_code]}: #{error[:description]} #{extra}"
|
30
|
+
end
|
27
31
|
end
|
28
32
|
|
29
33
|
private
|
30
34
|
def set_attrs
|
31
|
-
body.
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
35
|
+
errors = body.fetch('errors', nil)
|
36
|
+
unless errors.nil?
|
37
|
+
error = errors[0]
|
38
|
+
error.keys.each do |name|
|
39
|
+
self.class.instance_eval {
|
40
|
+
define_method(name) { error[name] } # Get.
|
41
|
+
define_method("#{name}?") { !!error[name] } # Present.
|
42
|
+
}
|
43
|
+
end
|
36
44
|
end
|
37
45
|
end
|
38
46
|
end
|
@@ -49,7 +57,8 @@ module Balanced
|
|
49
57
|
end
|
50
58
|
end
|
51
59
|
|
52
|
-
# Raised when attempted to create a debit or hold for a card not associated
|
60
|
+
# Raised when attempted to create a debit or hold for a card not associated
|
61
|
+
# to a customer.
|
53
62
|
class UnassociatedCardError < StandardError
|
54
63
|
# @param [Balanced::Card] card
|
55
64
|
def initialize(card)
|
@@ -58,7 +67,7 @@ module Balanced
|
|
58
67
|
end
|
59
68
|
|
60
69
|
def error_message
|
61
|
-
"The Balanced::Card with uri=#{@card.attributes['uri']} is not associated to
|
70
|
+
"The Balanced::Card with uri=#{@card.attributes['uri']} is not associated to a customer"
|
62
71
|
end
|
63
72
|
end
|
64
73
|
|
data/lib/balanced/pager.rb
CHANGED
@@ -7,6 +7,9 @@ module Balanced
|
|
7
7
|
|
8
8
|
include Enumerable
|
9
9
|
|
10
|
+
attr_accessor :href
|
11
|
+
attr_accessor :options
|
12
|
+
|
10
13
|
# A pager for paginating through resource records.
|
11
14
|
#
|
12
15
|
# @param [String] uri the uri of the resource
|
@@ -14,8 +17,8 @@ module Balanced
|
|
14
17
|
# @option options [Integer] limit
|
15
18
|
# @option options [Integer] offset
|
16
19
|
# @option options [Integer] per an alias for the :limit option
|
17
|
-
def initialize
|
18
|
-
@
|
20
|
+
def initialize(href, options = {})
|
21
|
+
@href = href
|
19
22
|
@options = options
|
20
23
|
@page = nil
|
21
24
|
@resource_class = nil
|
@@ -24,34 +27,47 @@ module Balanced
|
|
24
27
|
def resource_class
|
25
28
|
return @resource_class unless @resource_class.nil?
|
26
29
|
load! unless @page
|
27
|
-
@resource_class
|
30
|
+
@resource_class
|
28
31
|
end
|
29
32
|
|
30
33
|
def first
|
31
34
|
load! unless @page
|
32
|
-
items.first.nil?
|
35
|
+
if items.first.nil?
|
36
|
+
nil
|
37
|
+
else
|
38
|
+
envelope = {
|
39
|
+
:meta => @page[:meta],
|
40
|
+
:links => @page[:links],
|
41
|
+
@resource_class.collection_name.to_sym => [items.first]
|
42
|
+
}
|
43
|
+
resource_class.construct_from_response(envelope)
|
44
|
+
end
|
33
45
|
end
|
34
46
|
|
35
47
|
def total
|
36
48
|
load! unless @page
|
37
|
-
@page[:total]
|
49
|
+
@page[:meta][:total]
|
38
50
|
end
|
39
51
|
|
40
52
|
def limit
|
41
53
|
load! unless @page
|
42
|
-
@page[:limit]
|
54
|
+
@page[:meta][:limit]
|
43
55
|
end
|
44
56
|
alias limit_value limit
|
45
57
|
|
46
58
|
def offset
|
47
59
|
load! unless @page
|
48
|
-
@page[:offset]
|
60
|
+
@page[:meta][:offset]
|
49
61
|
end
|
50
62
|
alias offset_value offset
|
51
63
|
|
52
64
|
def items
|
53
65
|
load! unless @page
|
54
|
-
@
|
66
|
+
if @resource_class.nil?
|
67
|
+
[]
|
68
|
+
else
|
69
|
+
@page[@resource_class.collection_name]
|
70
|
+
end
|
55
71
|
end
|
56
72
|
|
57
73
|
def current_page
|
@@ -71,19 +87,24 @@ module Balanced
|
|
71
87
|
|
72
88
|
load! unless @page
|
73
89
|
loop do
|
74
|
-
|
75
|
-
|
90
|
+
items.each do |r|
|
91
|
+
envelope = {
|
92
|
+
:meta => @page[:meta],
|
93
|
+
:links => @page[:links],
|
94
|
+
@resource_class.collection_name.to_sym => [r]
|
95
|
+
}
|
96
|
+
yield resource_class.construct_from_response(envelope)
|
76
97
|
end
|
77
|
-
raise StopIteration if @page[:
|
98
|
+
raise StopIteration if @page[:meta][:next].nil?
|
78
99
|
self.next
|
79
100
|
end
|
80
101
|
end
|
81
102
|
|
82
103
|
# @return [nil]
|
83
|
-
# @see Resource.
|
104
|
+
# @see Resource.fetch_each
|
84
105
|
# @yield [record]
|
85
|
-
def
|
86
|
-
return enum_for :
|
106
|
+
def fetch_each
|
107
|
+
return enum_for :fetch_each unless block_given?
|
87
108
|
begin
|
88
109
|
each { |record| yield record }
|
89
110
|
end while self.next
|
@@ -93,7 +114,7 @@ module Balanced
|
|
93
114
|
# the next page.
|
94
115
|
def next
|
95
116
|
load! unless @page
|
96
|
-
next_uri = @page[:
|
117
|
+
next_uri = @page[:meta][:next]
|
97
118
|
load_from next_uri, nil unless next_uri.nil?
|
98
119
|
end
|
99
120
|
|
@@ -101,7 +122,7 @@ module Balanced
|
|
101
122
|
# the previous page.
|
102
123
|
def prev
|
103
124
|
load! unless @page
|
104
|
-
prev_uri = @page[:
|
125
|
+
prev_uri = @page[:meta][:prev]
|
105
126
|
load_from prev_uri, nil unless prev_uri.nil?
|
106
127
|
end
|
107
128
|
|
@@ -109,21 +130,21 @@ module Balanced
|
|
109
130
|
# the first page.
|
110
131
|
def start
|
111
132
|
load! unless @page
|
112
|
-
first_page = @page[:
|
133
|
+
first_page = @page[:meta][:first]
|
113
134
|
load_from first_page, nil unless first_page.nil?
|
114
135
|
end
|
115
136
|
|
116
137
|
# @return [Array, nil] Load (or reload) the pager's collection from the
|
117
138
|
# original, supplied options.
|
118
139
|
def load!
|
119
|
-
load_from @
|
140
|
+
load_from @href, @options
|
120
141
|
end
|
121
142
|
alias reload load!
|
122
143
|
|
123
144
|
# @return [Pager] Duplicates the pager, updating it with the options
|
124
145
|
# supplied. Useful for resource scopes.
|
125
146
|
# @see #initialize
|
126
|
-
def paginate
|
147
|
+
def paginate(options = {})
|
127
148
|
dup.instance_eval {
|
128
149
|
@page = nil
|
129
150
|
@options.update options and self
|
@@ -132,23 +153,35 @@ module Balanced
|
|
132
153
|
alias scoped paginate
|
133
154
|
alias where paginate
|
134
155
|
|
135
|
-
def all
|
156
|
+
def all(options = {})
|
136
157
|
paginate(options).to_a
|
137
158
|
end
|
138
159
|
|
139
|
-
def
|
160
|
+
def fetch(uri)
|
140
161
|
if resource_class.respond_to? :find
|
141
162
|
raise NoMethodError,
|
142
163
|
"#find must be called on #{resource_class} directly"
|
143
164
|
end
|
144
165
|
|
145
|
-
resource_class.
|
166
|
+
resource_class.fetch uri
|
167
|
+
end
|
168
|
+
|
169
|
+
def create(options={})
|
170
|
+
opts = Balanced::Utils.indifferent_read_access options
|
171
|
+
opts[:href] = @href
|
172
|
+
# if we don't have a media type for the href,
|
173
|
+
# let's try to inspect the url to look it up from the
|
174
|
+
# registry
|
175
|
+
if @resource_class.nil?
|
176
|
+
@resource_class = Balanced.from_href(@href)
|
177
|
+
end
|
178
|
+
@resource_class.new(opts).save
|
146
179
|
end
|
147
180
|
|
148
181
|
|
149
182
|
private
|
150
183
|
|
151
|
-
def load_from
|
184
|
+
def load_from(uri, params)
|
152
185
|
parsed_uri = URI.parse(uri)
|
153
186
|
|
154
187
|
params ||= {}
|
@@ -167,8 +200,16 @@ module Balanced
|
|
167
200
|
end
|
168
201
|
|
169
202
|
response = Balanced.get parsed_uri.to_s, params
|
170
|
-
@page = Balanced::Utils.
|
171
|
-
|
203
|
+
@page = Balanced::Utils.indifferent_read_access response.body
|
204
|
+
|
205
|
+
@href = @page[:meta][:href]
|
206
|
+
# resource_class?
|
207
|
+
hypermedia_key = (@page.keys.map{|k| k.to_sym } - [:meta, :links]).first
|
208
|
+
unless hypermedia_key.nil?
|
209
|
+
@resource_class = Balanced.from_hypermedia_registry(hypermedia_key.to_s)
|
210
|
+
end
|
211
|
+
|
212
|
+
@page
|
172
213
|
end
|
173
214
|
|
174
215
|
def adjust_pagination_params(original)
|