balanced-ach 0.1 → 0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. data/.gitignore +29 -0
  2. data/Gemfile +1 -1
  3. data/balanced.gemspec +1 -1
  4. data/lib/{balanced.rb → balanced_ach.rb} +7 -7
  5. data/lib/{balanced → balanced_ach}/client.rb +1 -1
  6. data/lib/{balanced → balanced_ach}/error.rb +0 -0
  7. data/lib/{balanced → balanced_ach}/pager.rb +2 -2
  8. data/lib/{balanced → balanced_ach}/resources.rb +1 -1
  9. data/lib/{balanced → balanced_ach}/resources/bank_account.rb +0 -0
  10. data/lib/{balanced → balanced_ach}/resources/credit.rb +0 -0
  11. data/lib/{balanced → balanced_ach}/resources/debit.rb +0 -0
  12. data/lib/{balanced → balanced_ach}/resources/resource.rb +0 -0
  13. data/lib/{balanced → balanced_ach}/response/balanced_exception_middleware.rb +1 -1
  14. data/lib/{balanced → balanced_ach}/utils.rb +0 -0
  15. data/lib/{balanced → balanced_ach}/version.rb +1 -1
  16. data/x.rb +2 -7
  17. metadata +15 -114
  18. data/.idea/.name +0 -1
  19. data/.idea/.rakeTasks +0 -7
  20. data/.idea/balanced-ach.iml +0 -9
  21. data/.idea/encodings.xml +0 -5
  22. data/.idea/misc.xml +0 -5
  23. data/.idea/modules.xml +0 -9
  24. data/.idea/scopes/scope_settings.xml +0 -5
  25. data/.idea/vcs.xml +0 -7
  26. data/.idea/workspace.xml +0 -561
  27. data/spec/balanced/pager_spec.rb +0 -42
  28. data/spec/balanced/resources/account_spec.rb +0 -571
  29. data/spec/balanced/resources/api_key_spec.rb +0 -55
  30. data/spec/balanced/resources/hold_spec.rb +0 -55
  31. data/spec/balanced/resources/marketplace_spec.rb +0 -97
  32. data/spec/balanced/resources/transactions_spec.rb +0 -72
  33. data/spec/balanced/response/balanced_exception_middleware_spec.rb +0 -47
  34. data/spec/balanced_spec.rb +0 -77
  35. data/spec/cassettes/Balanced/configure.yml +0 -48
  36. data/spec/cassettes/Balanced/configure/reconfigure_with_new_api_key.yml +0 -48
  37. data/spec/cassettes/Balanced_Account.yml +0 -110
  38. data/spec/cassettes/Balanced_Account/Account_uri/when_ApiKey_is_configured.yml +0 -240
  39. data/spec/cassettes/Balanced_Account/Account_uri/when_ApiKey_is_not_configured.yml +0 -44
  40. data/spec/cassettes/Balanced_Account/_find.yml +0 -400
  41. data/spec/cassettes/Balanced_Account/_find/_all_some_field_op_.yml +0 -186
  42. data/spec/cassettes/Balanced_Account/_find/_first_some_field_op_.yml +0 -186
  43. data/spec/cassettes/Balanced_Account/_find_by_email.yml +0 -400
  44. data/spec/cassettes/Balanced_Account/_find_by_email/email_address_does_not_exist.yml +0 -175
  45. data/spec/cassettes/Balanced_Account/_find_by_email/email_address_is_in_system.yml +0 -186
  46. data/spec/cassettes/Balanced_Account/buyer/_add_card/after_executing.yml +0 -530
  47. data/spec/cassettes/Balanced_Account/buyer/_add_card/when_executing.yml +0 -455
  48. data/spec/cassettes/Balanced_Account/buyer/_debit.yml +0 -363
  49. data/spec/cassettes/Balanced_Account/buyer/_promote_to_merchant/after_executing.yml +0 -281
  50. data/spec/cassettes/Balanced_Account/buyer/_promote_to_merchant/when_executing.yml +0 -281
  51. data/spec/cassettes/Balanced_Account/buyer/_save/after_save/attributes.yml +0 -1013
  52. data/spec/cassettes/Balanced_Account/buyer/_save/when_creating.yml +0 -229
  53. data/spec/cassettes/Balanced_Account/merchant/_add_bank_account/after_executing.yml +0 -536
  54. data/spec/cassettes/Balanced_Account/merchant/_add_bank_account/when_executing.yml +0 -460
  55. data/spec/cassettes/Balanced_Account/merchant/_save/after_save/attributes.yml +0 -232
  56. data/spec/cassettes/Balanced_Account/merchant/_save/when_creating.yml +0 -232
  57. data/spec/cassettes/Balanced_Account/merchant/new.yml +0 -179
  58. data/spec/cassettes/Balanced_ApiKey/attributes.yml +0 -48
  59. data/spec/cassettes/Balanced_ApiKey/new_key/after_configure.yml +0 -93
  60. data/spec/cassettes/Balanced_ApiKey/new_key/before_configure.yml +0 -48
  61. data/spec/cassettes/Balanced_Hold.yml +0 -335
  62. data/spec/cassettes/Balanced_Hold/_void.yml +0 -62
  63. data/spec/cassettes/Balanced_Hold/_void/after.yml +0 -62
  64. data/spec/cassettes/Balanced_Hold/_void/when_exception_is_thrown.yml +0 -306
  65. data/spec/cassettes/Balanced_Marketplace.yml +0 -339
  66. data/spec/cassettes/Balanced_Transaction.yml +0 -1261
  67. data/spec/cassettes/Balanced_Transaction/Transaction.yml +0 -634
  68. data/spec/cassettes/Balanced_Transaction/Transaction_paginate.yml +0 -634
  69. data/spec/client_spec.rb +0 -12
  70. data/spec/spec_helper.rb +0 -31
  71. data/spec/utils_spec.rb +0 -8
  72. data/upload_docs.rb +0 -39
@@ -1,55 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Balanced::ApiKey do
4
- describe "attributes" do
5
- use_vcr_cassette
6
- before do
7
- @key = Balanced::ApiKey.new.save
8
- end
9
- describe "#secret" do
10
- subject { @key.secret }
11
- it { should_not be_nil }
12
- it { should_not be_empty }
13
- end
14
-
15
- describe "#merchant" do
16
- subject { @key.merchant }
17
- it { should_not be_nil }
18
- it { should be_instance_of Balanced::Merchant }
19
- end
20
- end
21
-
22
- describe "new key" do
23
- use_vcr_cassette
24
-
25
- describe "before configure" do
26
- use_vcr_cassette
27
- before do
28
- @new_key = Balanced::ApiKey.new.save
29
- end
30
- describe "#merchant" do
31
- use_vcr_cassette
32
- subject { @new_key.merchant }
33
- it { should_not be_nil }
34
- it { should be_instance_of Balanced::Merchant }
35
- end
36
- end
37
-
38
- describe "after configure" do
39
- use_vcr_cassette
40
- before do
41
- @new_key = Balanced::ApiKey.new.save
42
- Balanced.configure @new_key.secret
43
- @new_key = Balanced::ApiKey.new.save
44
- end
45
-
46
- describe "#merchant" do
47
- use_vcr_cassette
48
- subject { @new_key.merchant }
49
- it { should_not be_nil }
50
- it { should be_instance_of Balanced::Merchant }
51
- end
52
- end
53
-
54
- end
55
- end
@@ -1,55 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Balanced::Hold do
4
- use_vcr_cassette
5
- before do
6
- api_key = Balanced::ApiKey.new.save
7
- Balanced.configure api_key.secret
8
- @marketplace = Balanced::Marketplace.new.save
9
- card = Balanced::Card.new(
10
- :card_number => "5105105105105100",
11
- :expiration_month => "12",
12
- :expiration_year => "2015"
13
- ).save
14
- @buyer = @marketplace.create_buyer("buyer@example.org", card.uri)
15
- end
16
-
17
- describe "#void" do
18
- use_vcr_cassette
19
-
20
- before do
21
- @hold = @buyer.hold 100
22
- end
23
-
24
- describe 'before' do
25
- use_vcr_cassette
26
- subject { @hold.is_void }
27
- it { should be_false }
28
- end
29
-
30
- describe 'after' do
31
- use_vcr_cassette
32
- before { @hold.void }
33
-
34
- subject { @hold.is_void }
35
- it { should be_true }
36
- end
37
-
38
- describe 'when exception is thrown' do
39
- use_vcr_cassette
40
- before do
41
- @hold = @buyer.hold 150
42
- @debit = @hold.capture
43
- end
44
-
45
- it "should not change void state since its captured" do
46
- lambda { @hold.void }.should raise_error(Balanced::Conflict)
47
- @hold.is_void.should be_false
48
- end
49
- # void here.
50
-
51
-
52
- end
53
-
54
- end
55
- end
@@ -1,97 +0,0 @@
1
- require "spec_helper"
2
-
3
-
4
- describe Balanced::Marketplace do
5
- use_vcr_cassette
6
- before do
7
- api_key = Balanced::ApiKey.new.save
8
- Balanced.configure api_key.secret
9
- @marketplace = Balanced::Marketplace.new.save
10
- @bank_account = Balanced::BankAccount.new(
11
- :account_number => "1234567890",
12
- :bank_code => "321174851",
13
- :name => "Jack Q Merchant"
14
- ).save
15
- @merchant = @marketplace.create_merchant(
16
- "merchant@example.org",
17
- {
18
- :type => "person",
19
- :name => "Billy Jones",
20
- :street_address => "801 High St.",
21
- :postal_code => "94301",
22
- :country => "USA",
23
- :dob => "1842-01",
24
- :phone_number => "+16505551234",
25
- },
26
- @bank_account.uri,
27
- "Jack Q Merchant",
28
- )
29
- end
30
-
31
- describe "create_merchant" do
32
- use_vcr_cassette
33
-
34
- describe "class" do
35
- subject { @merchant }
36
- it { should be_instance_of Balanced::Account }
37
- end
38
-
39
- describe "attributes" do
40
- describe "#id" do
41
- subject { @merchant.id }
42
- it { should_not be_nil }
43
- it { should_not be_empty }
44
- end
45
- describe "#roles" do
46
- subject { @merchant.roles }
47
- it { should include("merchant") }
48
- end
49
- describe "#email_address" do
50
- subject { @merchant.email_address }
51
- it { should eql "merchant@example.org" }
52
- end
53
- describe "#name" do
54
- subject { @merchant.name }
55
- it { should eql "Jack Q Merchant" }
56
- end
57
- describe "#created_at" do
58
- subject { @merchant.created_at }
59
- it { should_not be_nil }
60
- it { should_not be_empty }
61
- end
62
- describe "#uri" do
63
- subject { @merchant.uri }
64
- it { should match MERCHANT_URI_REGEX }
65
- end
66
- describe "#holds_uri" do
67
- subject { @merchant.holds_uri }
68
- it { should match HOLDS_URI_REGEX }
69
- end
70
- describe "#bank_accounts_uri" do
71
- subject { @merchant.bank_accounts_uri }
72
- it { should match BANK_ACCOUNTS_URI_REGEX }
73
- end
74
- describe "#refunds_uri" do
75
- subject { @merchant.refunds_uri }
76
- it { should match REFUNDS_URI_REGEX }
77
- end
78
- describe "#debits_uri" do
79
- subject { @merchant.debits_uri }
80
- it { should match DEBITS_URI_REGEX }
81
- end
82
- describe "#transactions_uri" do
83
- subject { @merchant.transactions_uri }
84
- it { should match TRANSACTIONS_URI_REGEX }
85
- end
86
- describe "#credits_uri" do
87
- subject { @merchant.credits_uri }
88
- it { should match CREDITS_URI_REGEX }
89
- end
90
- describe "#cards_uri" do
91
- subject { @merchant.cards_uri }
92
- it { should match CARDS_URI_REGEX }
93
- end
94
- end
95
- end
96
- end
97
-
@@ -1,72 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Balanced::Transaction do
4
-
5
- use_vcr_cassette
6
-
7
- before do
8
- api_key = Balanced::ApiKey.new.save
9
- Balanced.configure api_key.secret
10
- @marketplace = Balanced::Marketplace.new.save
11
- @merchant_attributes = {
12
- :type => "person",
13
- :name => "Billy Jones",
14
- :street_address => "801 High St.",
15
- :postal_code => "94301",
16
- :country => "USA",
17
- :dob => "1842-01",
18
- :phone_number => "+16505551234",
19
- }
20
- bank_account = Balanced::BankAccount.new(
21
- :account_number => "1234567890",
22
- :bank_code => "321174851",
23
- :name => "Jack Q Merchant"
24
- ).save
25
- card = Balanced::Card.new(
26
- :card_number => "4111111111111111",
27
- :expiration_month => "1",
28
- :expiration_year => "2015",
29
- ).save
30
- @merchant = @marketplace.create_merchant(
31
- :email_address => "merchant@example.org",
32
- :merchant => @merchant_attributes,
33
- :bank_account_uri => bank_account.uri,
34
- :name => "Jack Q Merchant"
35
- )
36
- @buyer = @marketplace.create_buyer(
37
- :email_address => "buyer+transactions@example.org",
38
- :card_uri => card.uri,
39
- :name => "Jack Q Buyer"
40
- ).save
41
- 1.upto 5 do |n|
42
- @buyer.debit(1000, :description => "Transaction ##{n}")
43
- @merchant.credit(500, :description => "Credit from Debit ##{n}")
44
- end
45
- end
46
-
47
- describe "Transaction" do
48
- use_vcr_cassette
49
-
50
- it "#all" do
51
- Balanced::Transaction.all.length.should eql(15)
52
- end
53
-
54
- describe "#paginate" do
55
- use_vcr_cassette
56
-
57
- it "#total" do
58
- Balanced::Transaction.paginate.total.should eql(15)
59
- end
60
-
61
- it "#each" do
62
- counter = 0
63
- Balanced::Transaction.paginate.each do |transaction|
64
- counter += 1
65
- end
66
- counter.should eql(15)
67
- end
68
-
69
- end
70
-
71
- end
72
- end
@@ -1,47 +0,0 @@
1
- require "spec_helper"
2
- require "faraday"
3
-
4
- describe Faraday::Response::RaiseBalancedError, :type => :response do
5
- context "when used" do
6
- let(:raise_server_error) { described_class.new }
7
- end
8
-
9
- context "integration test" do
10
-
11
- before(:each) do
12
- Faraday.register_middleware :response,
13
- :handle_balanced_errors => lambda { described_class }
14
- VCR.turn_off!
15
- end
16
-
17
- after(:each) do
18
- VCR.turn_on!
19
- end
20
-
21
- let(:stubs) { Faraday::Adapter::Test::Stubs.new }
22
- let(:connection) do
23
- Faraday::Connection.new do |builder|
24
- builder.response :handle_balanced_errors
25
- builder.response :json
26
- builder.adapter :test, stubs
27
- end
28
- end
29
-
30
- it "should raise exceptions on bad request errors" do
31
- stubs.get("/error") {
32
- [400, {}, JSON.dump({
33
- :status =>"Bad Request",
34
- :status_code =>400,
35
- :description => "Missing expected field expiration_year Your request "\
36
- "id is OHM62bf258abfea11e1aaba026ba7e5e72e.",
37
- :request_id => "OHM62bf258abfea11e1aaba026ba7e5e72e"
38
- })]
39
- }
40
-
41
- lambda {
42
- connection.get('/error')
43
- }.should raise_error(Balanced::BadRequest)
44
- end
45
-
46
- end
47
- end
@@ -1,77 +0,0 @@
1
- require "spec_helper"
2
-
3
- describe Balanced do
4
- describe "configure" do
5
- use_vcr_cassette
6
- before do
7
- @api_key = Balanced::ApiKey.new.save
8
-
9
- Balanced.configure @api_key.secret
10
- end
11
-
12
- describe "api key" do
13
- describe "merchant" do
14
- subject { @api_key.merchant }
15
- it { should_not be_nil }
16
- end
17
- end
18
-
19
- describe "#client" do
20
- subject { Balanced.client }
21
- it { should_not be_nil }
22
-
23
- describe "#connection" do
24
- subject { Balanced.client.conn }
25
- it { should_not be_nil }
26
- end
27
-
28
- describe "#api_key" do
29
- subject { Balanced.client.api_key }
30
- it { should eql @api_key.secret }
31
- end
32
-
33
- describe "#url" do
34
- subject { Balanced.client.url.to_s }
35
- it { should eql "https://api.balancedpayments.com" }
36
- end
37
- end
38
-
39
- describe "reconfigure with new api key" do
40
- use_vcr_cassette
41
- before do
42
- @new_api_key = Balanced::ApiKey.new.save
43
- Balanced.configure @new_api_key.secret
44
- end
45
-
46
- describe "api key" do
47
- describe "merchant" do
48
- use_vcr_cassette
49
- subject { @api_key.merchant }
50
- it { should_not be_nil }
51
- end
52
- end
53
-
54
- describe "#client" do
55
- describe "#api_key" do
56
- subject { Balanced.client.api_key }
57
- it { should_not eql @api_key.secret }
58
- it { should eql @new_api_key.secret }
59
- end
60
- end
61
-
62
- describe "new api key" do
63
- describe "secret" do
64
- subject { @new_api_key.secret }
65
- it { should_not be_nil }
66
-
67
- end
68
- describe "merchant" do
69
- use_vcr_cassette
70
-
71
- subject { @new_api_key.merchant }
72
- it { should_not be_nil }
73
- end
74
- end
75
- end
76
- end
77
- end
@@ -1,48 +0,0 @@
1
- ---
2
- http_interactions:
3
- - request:
4
- method: post
5
- uri: https://api.balancedpayments.com/v1/api_keys
6
- body:
7
- encoding: UTF-8
8
- string: ! '{}'
9
- headers:
10
- User-Agent:
11
- - balanced-ruby/0.3.5
12
- Content-Type:
13
- - application/json
14
- response:
15
- status:
16
- code: 201
17
- message: !!null
18
- headers:
19
- content-type:
20
- - application/json
21
- date:
22
- - Fri, 06 Jul 2012 04:22:45 GMT
23
- server:
24
- - nginx/1.0.14
25
- x-balanced-guru:
26
- - OHM3c57a2b6c72211e1a29c026ba7e5e72e
27
- x-balanced-version:
28
- - ''
29
- content-length:
30
- - '854'
31
- connection:
32
- - Close
33
- body:
34
- encoding: US-ASCII
35
- string: ! "{\n \"merchant\": {\n \"phone_number\": \"+16505551212\", \n
36
- \ \"city\": \"Nowhere\", \n \"marketplace\": null, \n \"name\": \"William
37
- Henry Cavendish III\", \n \"email_address\": \"whc@example.org\", \n \"created_at\":
38
- \"2012-07-06T04:22:45.622860Z\", \n \"uri\": \"/v1/merchants/TEST-MR1Qdkfd3s1CdsDYpIyE1clM\",
39
- \n \"accounts_uri\": \"/v1/merchants/TEST-MR1Qdkfd3s1CdsDYpIyE1clM/accounts\",
40
- \n \"meta\": {}, \n \"postal_code\": \"90210\", \n \"country_code\":
41
- \"USA\", \n \"type\": \"person\", \n \"balance\": 0, \n \"api_keys_uri\":
42
- \"/v1/merchants/TEST-MR1Qdkfd3s1CdsDYpIyE1clM/api_keys\", \n \"id\": \"TEST-MR1Qdkfd3s1CdsDYpIyE1clM\",
43
- \n \"street_address\": \"123 Fake St\"\n }, \n \"secret\": \"3cac2eb2c72211e1a29c026ba7e5e72e\",
44
- \n \"meta\": {}, \n \"created_at\": \"2012-07-06T04:22:45.865186Z\", \n
45
- \ \"uri\": \"/v1/api_keys/AK1QufqsOoGwey1DmEmOBMho\", \n \"id\": \"AK1QufqsOoGwey1DmEmOBMho\"\n}"
46
- http_version: !!null
47
- recorded_at: Fri, 06 Jul 2012 04:22:46 GMT
48
- recorded_with: VCR 2.2.2