balanced-ach 0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. data/.idea/.name +1 -0
  2. data/.idea/.rakeTasks +7 -0
  3. data/.idea/balanced-ach.iml +9 -0
  4. data/.idea/encodings.xml +5 -0
  5. data/.idea/misc.xml +5 -0
  6. data/.idea/modules.xml +9 -0
  7. data/.idea/scopes/scope_settings.xml +5 -0
  8. data/.idea/vcs.xml +7 -0
  9. data/.idea/workspace.xml +561 -0
  10. data/CONTRIBUTORS +1 -0
  11. data/Gemfile +19 -0
  12. data/Gemfile.lock +64 -0
  13. data/Guardfile +7 -0
  14. data/LICENSE +22 -0
  15. data/README.md +64 -0
  16. data/Rakefile +12 -0
  17. data/balanced.gemspec +22 -0
  18. data/lib/balanced.rb +84 -0
  19. data/lib/balanced/client.rb +82 -0
  20. data/lib/balanced/error.rb +85 -0
  21. data/lib/balanced/pager.rb +201 -0
  22. data/lib/balanced/resources.rb +5 -0
  23. data/lib/balanced/resources/bank_account.rb +36 -0
  24. data/lib/balanced/resources/credit.rb +20 -0
  25. data/lib/balanced/resources/debit.rb +27 -0
  26. data/lib/balanced/resources/resource.rb +158 -0
  27. data/lib/balanced/response/balanced_exception_middleware.rb +33 -0
  28. data/lib/balanced/utils.rb +62 -0
  29. data/lib/balanced/version.rb +3 -0
  30. data/spec/balanced/pager_spec.rb +42 -0
  31. data/spec/balanced/resources/account_spec.rb +571 -0
  32. data/spec/balanced/resources/api_key_spec.rb +55 -0
  33. data/spec/balanced/resources/hold_spec.rb +55 -0
  34. data/spec/balanced/resources/marketplace_spec.rb +97 -0
  35. data/spec/balanced/resources/transactions_spec.rb +72 -0
  36. data/spec/balanced/response/balanced_exception_middleware_spec.rb +47 -0
  37. data/spec/balanced_spec.rb +77 -0
  38. data/spec/cassettes/Balanced/configure.yml +48 -0
  39. data/spec/cassettes/Balanced/configure/reconfigure_with_new_api_key.yml +48 -0
  40. data/spec/cassettes/Balanced_Account.yml +110 -0
  41. data/spec/cassettes/Balanced_Account/Account_uri/when_ApiKey_is_configured.yml +240 -0
  42. data/spec/cassettes/Balanced_Account/Account_uri/when_ApiKey_is_not_configured.yml +44 -0
  43. data/spec/cassettes/Balanced_Account/_find.yml +400 -0
  44. data/spec/cassettes/Balanced_Account/_find/_all_some_field_op_.yml +186 -0
  45. data/spec/cassettes/Balanced_Account/_find/_first_some_field_op_.yml +186 -0
  46. data/spec/cassettes/Balanced_Account/_find_by_email.yml +400 -0
  47. data/spec/cassettes/Balanced_Account/_find_by_email/email_address_does_not_exist.yml +175 -0
  48. data/spec/cassettes/Balanced_Account/_find_by_email/email_address_is_in_system.yml +186 -0
  49. data/spec/cassettes/Balanced_Account/buyer/_add_card/after_executing.yml +530 -0
  50. data/spec/cassettes/Balanced_Account/buyer/_add_card/when_executing.yml +455 -0
  51. data/spec/cassettes/Balanced_Account/buyer/_debit.yml +363 -0
  52. data/spec/cassettes/Balanced_Account/buyer/_promote_to_merchant/after_executing.yml +281 -0
  53. data/spec/cassettes/Balanced_Account/buyer/_promote_to_merchant/when_executing.yml +281 -0
  54. data/spec/cassettes/Balanced_Account/buyer/_save/after_save/attributes.yml +1013 -0
  55. data/spec/cassettes/Balanced_Account/buyer/_save/when_creating.yml +229 -0
  56. data/spec/cassettes/Balanced_Account/merchant/_add_bank_account/after_executing.yml +536 -0
  57. data/spec/cassettes/Balanced_Account/merchant/_add_bank_account/when_executing.yml +460 -0
  58. data/spec/cassettes/Balanced_Account/merchant/_save/after_save/attributes.yml +232 -0
  59. data/spec/cassettes/Balanced_Account/merchant/_save/when_creating.yml +232 -0
  60. data/spec/cassettes/Balanced_Account/merchant/new.yml +179 -0
  61. data/spec/cassettes/Balanced_ApiKey/attributes.yml +48 -0
  62. data/spec/cassettes/Balanced_ApiKey/new_key/after_configure.yml +93 -0
  63. data/spec/cassettes/Balanced_ApiKey/new_key/before_configure.yml +48 -0
  64. data/spec/cassettes/Balanced_Hold.yml +335 -0
  65. data/spec/cassettes/Balanced_Hold/_void.yml +62 -0
  66. data/spec/cassettes/Balanced_Hold/_void/after.yml +62 -0
  67. data/spec/cassettes/Balanced_Hold/_void/when_exception_is_thrown.yml +306 -0
  68. data/spec/cassettes/Balanced_Marketplace.yml +339 -0
  69. data/spec/cassettes/Balanced_Transaction.yml +1261 -0
  70. data/spec/cassettes/Balanced_Transaction/Transaction.yml +634 -0
  71. data/spec/cassettes/Balanced_Transaction/Transaction_paginate.yml +634 -0
  72. data/spec/client_spec.rb +12 -0
  73. data/spec/spec_helper.rb +31 -0
  74. data/spec/utils_spec.rb +8 -0
  75. data/upload_docs.rb +39 -0
  76. data/x.rb +22 -0
  77. metadata +199 -0
@@ -0,0 +1,12 @@
1
+ require "spec_helper"
2
+
3
+ describe "balanced client" do
4
+
5
+ it "should allow setting and reading of the api_key" do
6
+ client = Balanced::Client.new "miscreant"
7
+ client.api_key.should eq("miscreant")
8
+ client.api_key = "foo"
9
+ client.api_key.should eq("foo")
10
+ end
11
+
12
+ end
@@ -0,0 +1,31 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'balanced'
4
+ require 'vcr'
5
+
6
+ begin
7
+ require 'ruby-debug'
8
+ rescue LoadError
9
+ # ignored
10
+ end
11
+
12
+
13
+ VCR.configure do |c|
14
+ c.cassette_library_dir = 'spec/cassettes'
15
+ c.hook_into :faraday
16
+ end
17
+
18
+ RSpec.configure do |c|
19
+ c.extend VCR::RSpec::Macros
20
+ end
21
+
22
+
23
+ ACCOUNTS_URI_REGEX = /\/v1\/marketplaces\/TEST-\w*\/accounts/
24
+ MERCHANT_URI_REGEX = /\/v1\/marketplaces\/TEST-\w*\/accounts\/\w*/
25
+ HOLDS_URI_REGEX = /\/v1\/marketplaces\/TEST-\w*\/accounts\/\w*\/holds/
26
+ BANK_ACCOUNTS_URI_REGEX = /\/v1\/marketplaces\/TEST-\w*\/accounts\/\w*\/bank_accounts/
27
+ REFUNDS_URI_REGEX = /\/v1\/marketplaces\/TEST-\w*\/accounts\/\w*\/refunds/
28
+ DEBITS_URI_REGEX = /\/v1\/marketplaces\/TEST-\w*\/accounts\/\w*\/debits/
29
+ TRANSACTIONS_URI_REGEX = /\/v1\/marketplaces\/TEST-\w*\/accounts\/\w*\/transactions/
30
+ CREDITS_URI_REGEX = /\/v1\/marketplaces\/TEST-\w*\/accounts\/\w*\/credits/
31
+ CARDS_URI_REGEX = /\/v1\/marketplaces\/TEST-\w*\/accounts\/\w*\/cards/
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+
3
+ describe "the utils module" do
4
+ it "should correctly translate underscored names" do
5
+ result = Balanced::Utils.camelize "api_key"
6
+ result.should eq("ApiKey")
7
+ end
8
+ end
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'aws/s3'
4
+ require 'yard'
5
+
6
+ # cheap
7
+ args = [
8
+ 'doc',
9
+ '-e',
10
+ 'doc/balanced_plugin.rb',
11
+ '-p',
12
+ 'doc/balanced_templates/',
13
+ '--one-file',
14
+ '--query',
15
+ "object.to_s != 'Balanced::Account::MoreInformationRequiredError'",
16
+ 'lib/balanced/resources/account.rb',
17
+ 'lib/balanced/resources/api_key.rb',
18
+ 'lib/balanced/resources/bank_account.rb',
19
+ 'lib/balanced/resources/card.rb',
20
+ 'lib/balanced/resources/credit.rb',
21
+ 'lib/balanced/resources/debit.rb',
22
+ 'lib/balanced/resources/hold.rb',
23
+ 'lib/balanced/resources/marketplace.rb',
24
+ 'lib/balanced/resources/merchant.rb',
25
+ 'lib/balanced/resources/transaction.rb'
26
+ ]
27
+
28
+ YARD::CLI::CommandParser.run(*args)
29
+
30
+ AWS::S3::Base.establish_connection!(
31
+ :access_key_id => ENV['AWS_ACCESS_KEY_ID'],
32
+ :secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
33
+ )
34
+
35
+ puts AWS::S3::S3Object.store('docs/ruby_api_reference.html',
36
+ open('doc/index.html'),
37
+ 'justice.web',
38
+ :access => :public_read
39
+ )
data/x.rb ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+ require 'ruby-debug'
3
+
4
+ $:.unshift("/Users/mahmoud/code/poundpay/ruby/balanced-ach/lib")
5
+ require "balanced"
6
+ Balanced.configure(nil, {
7
+ :scheme => 'http',
8
+ :host => 'localhost',
9
+ :port => 9000,
10
+ :version => 'a0',
11
+ })
12
+ ba = Balanced::BankAccount.new(
13
+ :name => "Gottfried Leibniz",
14
+ :account_number => "3819372930",
15
+ :routing_number => "121042882",
16
+ :type => "checking"
17
+ ).save
18
+ credit = ba.credit(:amount => 1000)
19
+ p credit
20
+ debit = ba.debit(:amount => 1000)
21
+ p debit
22
+ p ba.unstore
metadata ADDED
@@ -0,0 +1,199 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: balanced-ach
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Mahmoud Abdelkader
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-09-27 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: faraday
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '0.8'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '0.8'
30
+ - !ruby/object:Gem::Dependency
31
+ name: faraday_middleware
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: 0.8.7
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 0.8.7
46
+ description: Balanced ACH experimental API
47
+ email:
48
+ - mahmoud@poundpay.com
49
+ executables: []
50
+ extensions: []
51
+ extra_rdoc_files: []
52
+ files:
53
+ - .idea/.name
54
+ - .idea/.rakeTasks
55
+ - .idea/balanced-ach.iml
56
+ - .idea/encodings.xml
57
+ - .idea/misc.xml
58
+ - .idea/modules.xml
59
+ - .idea/scopes/scope_settings.xml
60
+ - .idea/vcs.xml
61
+ - .idea/workspace.xml
62
+ - CONTRIBUTORS
63
+ - Gemfile
64
+ - Gemfile.lock
65
+ - Guardfile
66
+ - LICENSE
67
+ - README.md
68
+ - Rakefile
69
+ - balanced.gemspec
70
+ - lib/balanced.rb
71
+ - lib/balanced/client.rb
72
+ - lib/balanced/error.rb
73
+ - lib/balanced/pager.rb
74
+ - lib/balanced/resources.rb
75
+ - lib/balanced/resources/bank_account.rb
76
+ - lib/balanced/resources/credit.rb
77
+ - lib/balanced/resources/debit.rb
78
+ - lib/balanced/resources/resource.rb
79
+ - lib/balanced/response/balanced_exception_middleware.rb
80
+ - lib/balanced/utils.rb
81
+ - lib/balanced/version.rb
82
+ - spec/balanced/pager_spec.rb
83
+ - spec/balanced/resources/account_spec.rb
84
+ - spec/balanced/resources/api_key_spec.rb
85
+ - spec/balanced/resources/hold_spec.rb
86
+ - spec/balanced/resources/marketplace_spec.rb
87
+ - spec/balanced/resources/transactions_spec.rb
88
+ - spec/balanced/response/balanced_exception_middleware_spec.rb
89
+ - spec/balanced_spec.rb
90
+ - spec/cassettes/Balanced/configure.yml
91
+ - spec/cassettes/Balanced/configure/reconfigure_with_new_api_key.yml
92
+ - spec/cassettes/Balanced_Account.yml
93
+ - spec/cassettes/Balanced_Account/Account_uri/when_ApiKey_is_configured.yml
94
+ - spec/cassettes/Balanced_Account/Account_uri/when_ApiKey_is_not_configured.yml
95
+ - spec/cassettes/Balanced_Account/_find.yml
96
+ - spec/cassettes/Balanced_Account/_find/_all_some_field_op_.yml
97
+ - spec/cassettes/Balanced_Account/_find/_first_some_field_op_.yml
98
+ - spec/cassettes/Balanced_Account/_find_by_email.yml
99
+ - spec/cassettes/Balanced_Account/_find_by_email/email_address_does_not_exist.yml
100
+ - spec/cassettes/Balanced_Account/_find_by_email/email_address_is_in_system.yml
101
+ - spec/cassettes/Balanced_Account/buyer/_add_card/after_executing.yml
102
+ - spec/cassettes/Balanced_Account/buyer/_add_card/when_executing.yml
103
+ - spec/cassettes/Balanced_Account/buyer/_debit.yml
104
+ - spec/cassettes/Balanced_Account/buyer/_promote_to_merchant/after_executing.yml
105
+ - spec/cassettes/Balanced_Account/buyer/_promote_to_merchant/when_executing.yml
106
+ - spec/cassettes/Balanced_Account/buyer/_save/after_save/attributes.yml
107
+ - spec/cassettes/Balanced_Account/buyer/_save/when_creating.yml
108
+ - spec/cassettes/Balanced_Account/merchant/_add_bank_account/after_executing.yml
109
+ - spec/cassettes/Balanced_Account/merchant/_add_bank_account/when_executing.yml
110
+ - spec/cassettes/Balanced_Account/merchant/_save/after_save/attributes.yml
111
+ - spec/cassettes/Balanced_Account/merchant/_save/when_creating.yml
112
+ - spec/cassettes/Balanced_Account/merchant/new.yml
113
+ - spec/cassettes/Balanced_ApiKey/attributes.yml
114
+ - spec/cassettes/Balanced_ApiKey/new_key/after_configure.yml
115
+ - spec/cassettes/Balanced_ApiKey/new_key/before_configure.yml
116
+ - spec/cassettes/Balanced_Hold.yml
117
+ - spec/cassettes/Balanced_Hold/_void.yml
118
+ - spec/cassettes/Balanced_Hold/_void/after.yml
119
+ - spec/cassettes/Balanced_Hold/_void/when_exception_is_thrown.yml
120
+ - spec/cassettes/Balanced_Marketplace.yml
121
+ - spec/cassettes/Balanced_Transaction.yml
122
+ - spec/cassettes/Balanced_Transaction/Transaction.yml
123
+ - spec/cassettes/Balanced_Transaction/Transaction_paginate.yml
124
+ - spec/client_spec.rb
125
+ - spec/spec_helper.rb
126
+ - spec/utils_spec.rb
127
+ - upload_docs.rb
128
+ - x.rb
129
+ homepage: https://balancedpayments.com
130
+ licenses: []
131
+ post_install_message:
132
+ rdoc_options: []
133
+ require_paths:
134
+ - lib
135
+ required_ruby_version: !ruby/object:Gem::Requirement
136
+ none: false
137
+ requirements:
138
+ - - ! '>='
139
+ - !ruby/object:Gem::Version
140
+ version: '0'
141
+ required_rubygems_version: !ruby/object:Gem::Requirement
142
+ none: false
143
+ requirements:
144
+ - - ! '>='
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 1.8.23
150
+ signing_key:
151
+ specification_version: 3
152
+ summary: Sign up on https://balancedpayments.com/
153
+ test_files:
154
+ - spec/balanced/pager_spec.rb
155
+ - spec/balanced/resources/account_spec.rb
156
+ - spec/balanced/resources/api_key_spec.rb
157
+ - spec/balanced/resources/hold_spec.rb
158
+ - spec/balanced/resources/marketplace_spec.rb
159
+ - spec/balanced/resources/transactions_spec.rb
160
+ - spec/balanced/response/balanced_exception_middleware_spec.rb
161
+ - spec/balanced_spec.rb
162
+ - spec/cassettes/Balanced/configure.yml
163
+ - spec/cassettes/Balanced/configure/reconfigure_with_new_api_key.yml
164
+ - spec/cassettes/Balanced_Account.yml
165
+ - spec/cassettes/Balanced_Account/Account_uri/when_ApiKey_is_configured.yml
166
+ - spec/cassettes/Balanced_Account/Account_uri/when_ApiKey_is_not_configured.yml
167
+ - spec/cassettes/Balanced_Account/_find.yml
168
+ - spec/cassettes/Balanced_Account/_find/_all_some_field_op_.yml
169
+ - spec/cassettes/Balanced_Account/_find/_first_some_field_op_.yml
170
+ - spec/cassettes/Balanced_Account/_find_by_email.yml
171
+ - spec/cassettes/Balanced_Account/_find_by_email/email_address_does_not_exist.yml
172
+ - spec/cassettes/Balanced_Account/_find_by_email/email_address_is_in_system.yml
173
+ - spec/cassettes/Balanced_Account/buyer/_add_card/after_executing.yml
174
+ - spec/cassettes/Balanced_Account/buyer/_add_card/when_executing.yml
175
+ - spec/cassettes/Balanced_Account/buyer/_debit.yml
176
+ - spec/cassettes/Balanced_Account/buyer/_promote_to_merchant/after_executing.yml
177
+ - spec/cassettes/Balanced_Account/buyer/_promote_to_merchant/when_executing.yml
178
+ - spec/cassettes/Balanced_Account/buyer/_save/after_save/attributes.yml
179
+ - spec/cassettes/Balanced_Account/buyer/_save/when_creating.yml
180
+ - spec/cassettes/Balanced_Account/merchant/_add_bank_account/after_executing.yml
181
+ - spec/cassettes/Balanced_Account/merchant/_add_bank_account/when_executing.yml
182
+ - spec/cassettes/Balanced_Account/merchant/_save/after_save/attributes.yml
183
+ - spec/cassettes/Balanced_Account/merchant/_save/when_creating.yml
184
+ - spec/cassettes/Balanced_Account/merchant/new.yml
185
+ - spec/cassettes/Balanced_ApiKey/attributes.yml
186
+ - spec/cassettes/Balanced_ApiKey/new_key/after_configure.yml
187
+ - spec/cassettes/Balanced_ApiKey/new_key/before_configure.yml
188
+ - spec/cassettes/Balanced_Hold.yml
189
+ - spec/cassettes/Balanced_Hold/_void.yml
190
+ - spec/cassettes/Balanced_Hold/_void/after.yml
191
+ - spec/cassettes/Balanced_Hold/_void/when_exception_is_thrown.yml
192
+ - spec/cassettes/Balanced_Marketplace.yml
193
+ - spec/cassettes/Balanced_Transaction.yml
194
+ - spec/cassettes/Balanced_Transaction/Transaction.yml
195
+ - spec/cassettes/Balanced_Transaction/Transaction_paginate.yml
196
+ - spec/client_spec.rb
197
+ - spec/spec_helper.rb
198
+ - spec/utils_spec.rb
199
+ has_rdoc: