balanced-ach 0.1 → 0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +29 -0
- data/Gemfile +1 -1
- data/balanced.gemspec +1 -1
- data/lib/{balanced.rb → balanced_ach.rb} +7 -7
- data/lib/{balanced → balanced_ach}/client.rb +1 -1
- data/lib/{balanced → balanced_ach}/error.rb +0 -0
- data/lib/{balanced → balanced_ach}/pager.rb +2 -2
- data/lib/{balanced → balanced_ach}/resources.rb +1 -1
- data/lib/{balanced → balanced_ach}/resources/bank_account.rb +0 -0
- data/lib/{balanced → balanced_ach}/resources/credit.rb +0 -0
- data/lib/{balanced → balanced_ach}/resources/debit.rb +0 -0
- data/lib/{balanced → balanced_ach}/resources/resource.rb +0 -0
- data/lib/{balanced → balanced_ach}/response/balanced_exception_middleware.rb +1 -1
- data/lib/{balanced → balanced_ach}/utils.rb +0 -0
- data/lib/{balanced → balanced_ach}/version.rb +1 -1
- data/x.rb +2 -7
- metadata +15 -114
- data/.idea/.name +0 -1
- data/.idea/.rakeTasks +0 -7
- data/.idea/balanced-ach.iml +0 -9
- data/.idea/encodings.xml +0 -5
- data/.idea/misc.xml +0 -5
- data/.idea/modules.xml +0 -9
- data/.idea/scopes/scope_settings.xml +0 -5
- data/.idea/vcs.xml +0 -7
- data/.idea/workspace.xml +0 -561
- data/spec/balanced/pager_spec.rb +0 -42
- data/spec/balanced/resources/account_spec.rb +0 -571
- data/spec/balanced/resources/api_key_spec.rb +0 -55
- data/spec/balanced/resources/hold_spec.rb +0 -55
- data/spec/balanced/resources/marketplace_spec.rb +0 -97
- data/spec/balanced/resources/transactions_spec.rb +0 -72
- data/spec/balanced/response/balanced_exception_middleware_spec.rb +0 -47
- data/spec/balanced_spec.rb +0 -77
- data/spec/cassettes/Balanced/configure.yml +0 -48
- data/spec/cassettes/Balanced/configure/reconfigure_with_new_api_key.yml +0 -48
- data/spec/cassettes/Balanced_Account.yml +0 -110
- data/spec/cassettes/Balanced_Account/Account_uri/when_ApiKey_is_configured.yml +0 -240
- data/spec/cassettes/Balanced_Account/Account_uri/when_ApiKey_is_not_configured.yml +0 -44
- data/spec/cassettes/Balanced_Account/_find.yml +0 -400
- data/spec/cassettes/Balanced_Account/_find/_all_some_field_op_.yml +0 -186
- data/spec/cassettes/Balanced_Account/_find/_first_some_field_op_.yml +0 -186
- data/spec/cassettes/Balanced_Account/_find_by_email.yml +0 -400
- data/spec/cassettes/Balanced_Account/_find_by_email/email_address_does_not_exist.yml +0 -175
- data/spec/cassettes/Balanced_Account/_find_by_email/email_address_is_in_system.yml +0 -186
- data/spec/cassettes/Balanced_Account/buyer/_add_card/after_executing.yml +0 -530
- data/spec/cassettes/Balanced_Account/buyer/_add_card/when_executing.yml +0 -455
- data/spec/cassettes/Balanced_Account/buyer/_debit.yml +0 -363
- data/spec/cassettes/Balanced_Account/buyer/_promote_to_merchant/after_executing.yml +0 -281
- data/spec/cassettes/Balanced_Account/buyer/_promote_to_merchant/when_executing.yml +0 -281
- data/spec/cassettes/Balanced_Account/buyer/_save/after_save/attributes.yml +0 -1013
- data/spec/cassettes/Balanced_Account/buyer/_save/when_creating.yml +0 -229
- data/spec/cassettes/Balanced_Account/merchant/_add_bank_account/after_executing.yml +0 -536
- data/spec/cassettes/Balanced_Account/merchant/_add_bank_account/when_executing.yml +0 -460
- data/spec/cassettes/Balanced_Account/merchant/_save/after_save/attributes.yml +0 -232
- data/spec/cassettes/Balanced_Account/merchant/_save/when_creating.yml +0 -232
- data/spec/cassettes/Balanced_Account/merchant/new.yml +0 -179
- data/spec/cassettes/Balanced_ApiKey/attributes.yml +0 -48
- data/spec/cassettes/Balanced_ApiKey/new_key/after_configure.yml +0 -93
- data/spec/cassettes/Balanced_ApiKey/new_key/before_configure.yml +0 -48
- data/spec/cassettes/Balanced_Hold.yml +0 -335
- data/spec/cassettes/Balanced_Hold/_void.yml +0 -62
- data/spec/cassettes/Balanced_Hold/_void/after.yml +0 -62
- data/spec/cassettes/Balanced_Hold/_void/when_exception_is_thrown.yml +0 -306
- data/spec/cassettes/Balanced_Marketplace.yml +0 -339
- data/spec/cassettes/Balanced_Transaction.yml +0 -1261
- data/spec/cassettes/Balanced_Transaction/Transaction.yml +0 -634
- data/spec/cassettes/Balanced_Transaction/Transaction_paginate.yml +0 -634
- data/spec/client_spec.rb +0 -12
- data/spec/spec_helper.rb +0 -31
- data/spec/utils_spec.rb +0 -8
- data/upload_docs.rb +0 -39
data/spec/balanced/pager_spec.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Balanced::Pager do
|
4
|
-
describe "#adjust_pagination_params" do
|
5
|
-
subject { Balanced::Pager.new 'a uri'}
|
6
|
-
|
7
|
-
it "sets limit based on per" do
|
8
|
-
params = subject.send(:adjust_pagination_params, per: 5)
|
9
|
-
params[:limit].should == 5
|
10
|
-
end
|
11
|
-
|
12
|
-
it "sets offset based on page and default limit" do
|
13
|
-
params = subject.send(:adjust_pagination_params, page: 2)
|
14
|
-
params[:offset].should == 10
|
15
|
-
end
|
16
|
-
|
17
|
-
it "sets offset based on page and per" do
|
18
|
-
params = subject.send(:adjust_pagination_params, page: 2, per: 4)
|
19
|
-
params[:offset].should == 4
|
20
|
-
end
|
21
|
-
|
22
|
-
it "prefers per to limit" do
|
23
|
-
params = subject.send(:adjust_pagination_params, per: 5, limit: 10)
|
24
|
-
params[:limit].should == 5
|
25
|
-
end
|
26
|
-
|
27
|
-
it "falls back to limit" do
|
28
|
-
params = subject.send(:adjust_pagination_params, limit: 3)
|
29
|
-
params[:limit].should == 3
|
30
|
-
end
|
31
|
-
|
32
|
-
it "prefers page to offset" do
|
33
|
-
params = subject.send(:adjust_pagination_params, page: 2, offset: 0)
|
34
|
-
params[:offset].should == 10
|
35
|
-
end
|
36
|
-
|
37
|
-
it "falls back to offset" do
|
38
|
-
params = subject.send(:adjust_pagination_params, offset: 6)
|
39
|
-
params[:offset].should == 6
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
@@ -1,571 +0,0 @@
|
|
1
|
-
require "spec_helper"
|
2
|
-
|
3
|
-
describe Balanced::Account 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
|
-
end
|
10
|
-
|
11
|
-
describe "Account.uri" do
|
12
|
-
use_vcr_cassette
|
13
|
-
|
14
|
-
context "when ApiKey is not configured" do
|
15
|
-
use_vcr_cassette
|
16
|
-
before do
|
17
|
-
Balanced.configure nil
|
18
|
-
end
|
19
|
-
|
20
|
-
it "throw an exception that it can not generate the URI" do
|
21
|
-
expect {
|
22
|
-
Balanced::Account.uri
|
23
|
-
}.to raise_error Balanced::Error
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context "when ApiKey is configured" do
|
28
|
-
use_vcr_cassette
|
29
|
-
before do
|
30
|
-
api_key = Balanced::ApiKey.new.save
|
31
|
-
Balanced.configure api_key.secret
|
32
|
-
@marketplace = Balanced::Marketplace.new.save
|
33
|
-
end
|
34
|
-
|
35
|
-
it "it matches the resource's uri structure" do
|
36
|
-
uri = Balanced::Account.uri
|
37
|
-
uri.should_not be_nil
|
38
|
-
uri.should match ACCOUNTS_URI_REGEX
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
describe "merchant" do
|
44
|
-
use_vcr_cassette
|
45
|
-
|
46
|
-
before do
|
47
|
-
@merchant_attributes = {
|
48
|
-
:type => "person",
|
49
|
-
:name => "Billy Jones",
|
50
|
-
:street_address => "801 High St.",
|
51
|
-
:postal_code => "94301",
|
52
|
-
:country => "USA",
|
53
|
-
:dob => "1842-01",
|
54
|
-
:phone_number => "+16505551234",
|
55
|
-
}
|
56
|
-
end
|
57
|
-
|
58
|
-
describe "new" do
|
59
|
-
use_vcr_cassette
|
60
|
-
before do
|
61
|
-
@bank_account = Balanced::BankAccount.new(
|
62
|
-
:account_number => "1234567890",
|
63
|
-
:bank_code => "321174851",
|
64
|
-
:name => "Jack Q Merchant"
|
65
|
-
).save
|
66
|
-
end
|
67
|
-
it do
|
68
|
-
-> do
|
69
|
-
@merchant = Balanced::Account.new(
|
70
|
-
:uri => @marketplace.accounts_uri,
|
71
|
-
:email_address => "merchant@example.org",
|
72
|
-
:merchant => @merchant_attributes,
|
73
|
-
:bank_account_uri => @bank_account.uri,
|
74
|
-
:name => "Jack Q Merchant"
|
75
|
-
)
|
76
|
-
end.should_not raise_error
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "#save" do
|
81
|
-
|
82
|
-
describe "when creating" do
|
83
|
-
use_vcr_cassette
|
84
|
-
before do
|
85
|
-
bank_account = Balanced::BankAccount.new(
|
86
|
-
:account_number => "1234567890",
|
87
|
-
:bank_code => "321174851",
|
88
|
-
:name => "Jack Q Merchant"
|
89
|
-
).save
|
90
|
-
@merchant = Balanced::Account.new(
|
91
|
-
:uri => @marketplace.accounts_uri,
|
92
|
-
:email_address => "merchant@example.org",
|
93
|
-
:merchant => @merchant_attributes,
|
94
|
-
:bank_account_uri => bank_account.uri,
|
95
|
-
:name => "Jack Q Merchant"
|
96
|
-
)
|
97
|
-
end
|
98
|
-
it { -> { @merchant.save }.should_not raise_error }
|
99
|
-
end
|
100
|
-
|
101
|
-
describe "after #save" do
|
102
|
-
describe "attributes" do
|
103
|
-
use_vcr_cassette
|
104
|
-
before do
|
105
|
-
bank_account = Balanced::BankAccount.new(
|
106
|
-
:account_number => "1234567890",
|
107
|
-
:bank_code => "321174851",
|
108
|
-
:name => "Jack Q Merchant"
|
109
|
-
).save
|
110
|
-
@merchant = Balanced::Account.new(
|
111
|
-
:uri => @marketplace.accounts_uri,
|
112
|
-
:email_address => "merchant2@example.org",
|
113
|
-
:merchant => @merchant_attributes,
|
114
|
-
:bank_account_uri => bank_account.uri,
|
115
|
-
:name => "Jack Q Merchant"
|
116
|
-
).save
|
117
|
-
end
|
118
|
-
|
119
|
-
describe "#id" do
|
120
|
-
subject { @merchant.id }
|
121
|
-
it { should_not be_nil }
|
122
|
-
it { should_not be_empty }
|
123
|
-
end
|
124
|
-
describe "#roles" do
|
125
|
-
subject { @merchant.roles }
|
126
|
-
it { should include("merchant") }
|
127
|
-
end
|
128
|
-
describe "#email_address" do
|
129
|
-
subject { @merchant.email_address }
|
130
|
-
it { should eql "merchant2@example.org" }
|
131
|
-
end
|
132
|
-
describe "#name" do
|
133
|
-
subject { @merchant.name }
|
134
|
-
it { should eql "Jack Q Merchant" }
|
135
|
-
end
|
136
|
-
describe "#created_at" do
|
137
|
-
subject { @merchant.created_at }
|
138
|
-
it { should_not be_nil }
|
139
|
-
it { should_not be_empty }
|
140
|
-
end
|
141
|
-
describe "#uri" do
|
142
|
-
subject { @merchant.uri }
|
143
|
-
it { should match MERCHANT_URI_REGEX }
|
144
|
-
end
|
145
|
-
describe "#holds_uri" do
|
146
|
-
subject { @merchant.holds_uri }
|
147
|
-
it { should match HOLDS_URI_REGEX }
|
148
|
-
end
|
149
|
-
describe "#bank_accounts_uri" do
|
150
|
-
subject { @merchant.bank_accounts_uri }
|
151
|
-
it { should match BANK_ACCOUNTS_URI_REGEX }
|
152
|
-
end
|
153
|
-
describe "#refunds_uri" do
|
154
|
-
subject { @merchant.refunds_uri }
|
155
|
-
it { should match REFUNDS_URI_REGEX }
|
156
|
-
end
|
157
|
-
describe "#debits_uri" do
|
158
|
-
subject { @merchant.debits_uri }
|
159
|
-
it { should match DEBITS_URI_REGEX }
|
160
|
-
end
|
161
|
-
describe "#transactions_uri" do
|
162
|
-
subject { @merchant.transactions_uri }
|
163
|
-
it { should match TRANSACTIONS_URI_REGEX }
|
164
|
-
end
|
165
|
-
describe "#credits_uri" do
|
166
|
-
subject { @merchant.credits_uri }
|
167
|
-
it { should match CREDITS_URI_REGEX }
|
168
|
-
end
|
169
|
-
describe "#cards_uri" do
|
170
|
-
subject { @merchant.cards_uri }
|
171
|
-
it { should match CARDS_URI_REGEX }
|
172
|
-
end
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
describe "#add_bank_account" do
|
178
|
-
describe "when executing" do
|
179
|
-
use_vcr_cassette
|
180
|
-
|
181
|
-
before do
|
182
|
-
@bank_account = Balanced::BankAccount.new(
|
183
|
-
:account_number => "1234567890",
|
184
|
-
:bank_code => "321174851",
|
185
|
-
:name => "Jack Q Merchant"
|
186
|
-
).save
|
187
|
-
|
188
|
-
@merchant = Balanced::Account.new(
|
189
|
-
:uri => @marketplace.accounts_uri,
|
190
|
-
:email_address => "merchant1@example.org",
|
191
|
-
:merchant => @merchant_attributes,
|
192
|
-
:bank_account_uri => @bank_account.uri,
|
193
|
-
:name => "Jack Q Merchant"
|
194
|
-
).save
|
195
|
-
|
196
|
-
@new_bank_account = Balanced::BankAccount.new(
|
197
|
-
:account_number => "53434533",
|
198
|
-
:bank_code => "12345678",
|
199
|
-
:name => "Jack Q Merchant"
|
200
|
-
).save
|
201
|
-
end
|
202
|
-
it { -> { @merchant.add_bank_account(@new_bank_account.uri) }.should_not raise_error }
|
203
|
-
end
|
204
|
-
|
205
|
-
describe "after executing" do
|
206
|
-
use_vcr_cassette
|
207
|
-
before do
|
208
|
-
@bank_account = Balanced::BankAccount.new(
|
209
|
-
:account_number => "12345678901",
|
210
|
-
:bank_code => "321174851",
|
211
|
-
:name => "Jack Q Merchant"
|
212
|
-
).save
|
213
|
-
|
214
|
-
@merchant = Balanced::Account.new(
|
215
|
-
:uri => @marketplace.accounts_uri,
|
216
|
-
:email_address => "merchant4@example.org",
|
217
|
-
:merchant => @merchant_attributes,
|
218
|
-
:bank_account_uri => @bank_account.uri,
|
219
|
-
:name => "Jack Q Merchant"
|
220
|
-
).save
|
221
|
-
|
222
|
-
@new_bank_account = Balanced::BankAccount.new(
|
223
|
-
:account_number => "53434533",
|
224
|
-
:bank_code => "12345678",
|
225
|
-
:name => "Jack Q Merchant"
|
226
|
-
).save
|
227
|
-
@merchant.add_bank_account(@new_bank_account.uri)
|
228
|
-
@bank_accounts = Balanced::BankAccount.find(@merchant.bank_accounts_uri).items
|
229
|
-
end
|
230
|
-
|
231
|
-
subject { @bank_accounts.size }
|
232
|
-
it { should eql 2 }
|
233
|
-
end
|
234
|
-
|
235
|
-
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
describe "buyer" do
|
240
|
-
describe "#save" do
|
241
|
-
describe "when creating" do
|
242
|
-
use_vcr_cassette :record => :new_episodes
|
243
|
-
before do
|
244
|
-
card = Balanced::Card.new(
|
245
|
-
:card_number => "5105105105105100",
|
246
|
-
:expiration_month => "12",
|
247
|
-
:expiration_year => "2015",
|
248
|
-
).save
|
249
|
-
@buyer = Balanced::Account.new(
|
250
|
-
:uri => @marketplace.accounts_uri,
|
251
|
-
:email_address => "buyer@example.org",
|
252
|
-
:card_uri => card.uri,
|
253
|
-
:name => "Jack Q Buyer"
|
254
|
-
)
|
255
|
-
end
|
256
|
-
it { -> { @buyer.save }.should_not raise_error }
|
257
|
-
end
|
258
|
-
|
259
|
-
describe "after #save" do
|
260
|
-
describe "attributes" do
|
261
|
-
use_vcr_cassette :record => :new_episodes
|
262
|
-
before do
|
263
|
-
card = Balanced::Card.new(
|
264
|
-
:card_number => "4111111111111111",
|
265
|
-
:expiration_month => "12",
|
266
|
-
:expiration_year => "2015",
|
267
|
-
).save
|
268
|
-
@buyer = Balanced::Account.new(
|
269
|
-
:uri => @marketplace.accounts_uri,
|
270
|
-
:email_address => "buyer2@example.org",
|
271
|
-
:card_uri => card.uri,
|
272
|
-
:name => "Jack Q Buyer"
|
273
|
-
).save
|
274
|
-
end
|
275
|
-
|
276
|
-
describe "#id" do
|
277
|
-
subject { @buyer.id }
|
278
|
-
it { should_not be_nil }
|
279
|
-
it { should_not be_empty }
|
280
|
-
end
|
281
|
-
describe "#roles" do
|
282
|
-
subject { @buyer.roles }
|
283
|
-
it { should include("buyer") }
|
284
|
-
it { should_not include("merchant") }
|
285
|
-
end
|
286
|
-
describe "#email_address" do
|
287
|
-
subject { @buyer.email_address }
|
288
|
-
it { should eql "buyer2@example.org" }
|
289
|
-
end
|
290
|
-
describe "#name" do
|
291
|
-
subject { @buyer.name }
|
292
|
-
it { should eql "Jack Q Buyer" }
|
293
|
-
end
|
294
|
-
describe "#created_at" do
|
295
|
-
subject { @buyer.created_at }
|
296
|
-
it { should_not be_nil }
|
297
|
-
it { should_not be_empty }
|
298
|
-
end
|
299
|
-
describe "#uri" do
|
300
|
-
subject { @buyer.uri }
|
301
|
-
it { should match MERCHANT_URI_REGEX }
|
302
|
-
end
|
303
|
-
describe "#holds_uri" do
|
304
|
-
subject { @buyer.holds_uri }
|
305
|
-
it { should match HOLDS_URI_REGEX }
|
306
|
-
end
|
307
|
-
describe "#bank_accounts_uri" do
|
308
|
-
subject { @buyer.bank_accounts_uri }
|
309
|
-
it { should match BANK_ACCOUNTS_URI_REGEX }
|
310
|
-
end
|
311
|
-
describe "#refunds_uri" do
|
312
|
-
subject { @buyer.refunds_uri }
|
313
|
-
it { should match REFUNDS_URI_REGEX }
|
314
|
-
end
|
315
|
-
describe "#debits_uri" do
|
316
|
-
subject { @buyer.debits_uri }
|
317
|
-
it { should match DEBITS_URI_REGEX }
|
318
|
-
end
|
319
|
-
describe "#transactions_uri" do
|
320
|
-
subject { @buyer.transactions_uri }
|
321
|
-
it { should match TRANSACTIONS_URI_REGEX }
|
322
|
-
end
|
323
|
-
describe "#credits_uri" do
|
324
|
-
subject { @buyer.credits_uri }
|
325
|
-
it { should match CREDITS_URI_REGEX }
|
326
|
-
end
|
327
|
-
describe "#cards_uri" do
|
328
|
-
subject { @buyer.cards_uri }
|
329
|
-
it { should match CARDS_URI_REGEX }
|
330
|
-
end
|
331
|
-
describe "#cards" do
|
332
|
-
subject { @buyer.cards }
|
333
|
-
it { should be_instance_of Array }
|
334
|
-
it { should_not be_empty }
|
335
|
-
it { subject.first.should be_instance_of Balanced::Card }
|
336
|
-
end
|
337
|
-
describe "#bank_accounts" do
|
338
|
-
subject { @buyer.bank_accounts }
|
339
|
-
it { should be_instance_of Array }
|
340
|
-
it { should be_empty }
|
341
|
-
end
|
342
|
-
end
|
343
|
-
end
|
344
|
-
end
|
345
|
-
|
346
|
-
describe "#add_card" do
|
347
|
-
|
348
|
-
describe "when executing" do
|
349
|
-
use_vcr_cassette
|
350
|
-
before do
|
351
|
-
card = Balanced::Card.new(
|
352
|
-
:card_number => "4111111111111111",
|
353
|
-
:expiration_month => "12",
|
354
|
-
:expiration_year => "2015",
|
355
|
-
).save
|
356
|
-
@new_card = Balanced::Card.new(
|
357
|
-
:card_number => "4111111111111111",
|
358
|
-
:expiration_month => "1",
|
359
|
-
:expiration_year => "2015",
|
360
|
-
).save
|
361
|
-
@buyer = Balanced::Account.new(
|
362
|
-
:uri => @marketplace.accounts_uri,
|
363
|
-
:email_address => "buyer3@example.org",
|
364
|
-
:card_uri => card.uri,
|
365
|
-
:name => "Jack Q Buyer"
|
366
|
-
).save
|
367
|
-
end
|
368
|
-
it do
|
369
|
-
-> { @buyer.add_card(@new_card.uri) }.should_not raise_error
|
370
|
-
end
|
371
|
-
end
|
372
|
-
describe "after executing" do
|
373
|
-
use_vcr_cassette
|
374
|
-
|
375
|
-
before do
|
376
|
-
card = Balanced::Card.new(
|
377
|
-
:card_number => "4111111111111111",
|
378
|
-
:expiration_month => "12",
|
379
|
-
:expiration_year => "2015",
|
380
|
-
).save
|
381
|
-
@new_card = Balanced::Card.new(
|
382
|
-
:card_number => "5105105105105100",
|
383
|
-
:expiration_month => "1",
|
384
|
-
:expiration_year => "2017",
|
385
|
-
).save
|
386
|
-
@buyer = Balanced::Account.new(
|
387
|
-
:uri => @marketplace.accounts_uri,
|
388
|
-
:email_address => "buyer4@example.org",
|
389
|
-
:card_uri => card.uri,
|
390
|
-
:name => "Jack Q Buyer"
|
391
|
-
).save
|
392
|
-
@buyer.add_card(@new_card.uri)
|
393
|
-
@cards = Balanced::Card.find @buyer.cards_uri
|
394
|
-
end
|
395
|
-
subject { @cards.items.size }
|
396
|
-
it { should eql 2 }
|
397
|
-
end
|
398
|
-
end
|
399
|
-
|
400
|
-
describe "#promote_to_merchant" do
|
401
|
-
|
402
|
-
describe "when executing" do
|
403
|
-
use_vcr_cassette
|
404
|
-
before do
|
405
|
-
|
406
|
-
@merchant_attributes = {
|
407
|
-
:type => "person",
|
408
|
-
:name => "Billy Jones",
|
409
|
-
:street_address => "801 High St.",
|
410
|
-
:postal_code => "94301",
|
411
|
-
:country => "USA",
|
412
|
-
:dob => "1842-01",
|
413
|
-
:phone_number => "+16505551234",
|
414
|
-
}
|
415
|
-
card = Balanced::Card.new(
|
416
|
-
:card_number => "4111111111111111",
|
417
|
-
:expiration_month => "12",
|
418
|
-
:expiration_year => "2015",
|
419
|
-
).save
|
420
|
-
@buyer = Balanced::Account.new(
|
421
|
-
:uri => @marketplace.accounts_uri,
|
422
|
-
:email_address => "buyer5@example.org",
|
423
|
-
:card_uri => card.uri,
|
424
|
-
:name => "Jack Q Buyer"
|
425
|
-
).save
|
426
|
-
end
|
427
|
-
|
428
|
-
it do
|
429
|
-
-> { @buyer.promote_to_merchant @merchant_attributes}.should_not raise_error
|
430
|
-
end
|
431
|
-
end
|
432
|
-
describe "after executing" do
|
433
|
-
use_vcr_cassette
|
434
|
-
|
435
|
-
before do
|
436
|
-
@merchant_attributes = {
|
437
|
-
:type => "person",
|
438
|
-
:name => "Billy Jones",
|
439
|
-
:street_address => "801 High St.",
|
440
|
-
:postal_code => "94301",
|
441
|
-
:country => "USA",
|
442
|
-
:dob => "1842-01",
|
443
|
-
:phone_number => "+16505551234",
|
444
|
-
}
|
445
|
-
card = Balanced::Card.new(
|
446
|
-
:card_number => "4111111111111111",
|
447
|
-
:expiration_month => "12",
|
448
|
-
:expiration_year => "2015",
|
449
|
-
).save
|
450
|
-
@buyer = Balanced::Account.new(
|
451
|
-
:uri => @marketplace.accounts_uri,
|
452
|
-
:email_address => "buyer6@example.org",
|
453
|
-
:card_uri => card.uri,
|
454
|
-
:name => "Jack Q Buyer"
|
455
|
-
).save
|
456
|
-
@buyer.promote_to_merchant @merchant_attributes
|
457
|
-
end
|
458
|
-
subject { @buyer.roles }
|
459
|
-
it { should include("merchant") }
|
460
|
-
end
|
461
|
-
|
462
|
-
end
|
463
|
-
|
464
|
-
describe "#debit" do
|
465
|
-
use_vcr_cassette :match_requests_on => [:body], :record => :new_episodes
|
466
|
-
before do
|
467
|
-
card = Balanced::Card.new(
|
468
|
-
:card_number => "4111111111111111",
|
469
|
-
:expiration_month => "12",
|
470
|
-
:expiration_year => "2015",
|
471
|
-
).save
|
472
|
-
begin
|
473
|
-
@buyer = Balanced::Account.new(
|
474
|
-
:uri => @marketplace.accounts_uri,
|
475
|
-
:email_address => "buyer7@example.org",
|
476
|
-
:card_uri => card.uri,
|
477
|
-
:name => "Jack Q Buyer"
|
478
|
-
).save
|
479
|
-
rescue Balanced::Conflict => ex
|
480
|
-
@buyer = Balanced::Account.find(ex.extras[:account_uri])
|
481
|
-
end
|
482
|
-
end
|
483
|
-
it "takes optional parameters" do
|
484
|
-
debit = @buyer.debit(
|
485
|
-
:amount => 500,
|
486
|
-
:appears_on_statement_as => "BOBS BURGERS",
|
487
|
-
)
|
488
|
-
debit.should be_instance_of Balanced::Debit
|
489
|
-
debit.amount.should eql 500
|
490
|
-
debit.appears_on_statement_as.should eql "BOBS BURGERS"
|
491
|
-
end
|
492
|
-
it "takes positional parameters" do
|
493
|
-
debit = @buyer.debit(500, "FOO FIGHTER")
|
494
|
-
debit.should be_instance_of Balanced::Debit
|
495
|
-
debit.amount.should eql 500
|
496
|
-
debit.appears_on_statement_as.should eql "FOO FIGHTER"
|
497
|
-
end
|
498
|
-
|
499
|
-
end
|
500
|
-
end
|
501
|
-
|
502
|
-
describe ".find" do
|
503
|
-
use_vcr_cassette
|
504
|
-
|
505
|
-
before do
|
506
|
-
api_key = Balanced::ApiKey.new.save
|
507
|
-
Balanced.configure api_key.secret
|
508
|
-
@marketplace = Balanced::Marketplace.new.save
|
509
|
-
card = Balanced::Card.new(
|
510
|
-
:card_number => "5105105105105100",
|
511
|
-
:expiration_month => "12",
|
512
|
-
:expiration_year => "2015",
|
513
|
-
).save
|
514
|
-
Balanced::Marketplace.my_marketplace.create_buyer(
|
515
|
-
"john.doe@example.com",
|
516
|
-
card.uri
|
517
|
-
)
|
518
|
-
end
|
519
|
-
|
520
|
-
context "(:all, :some_field => 'op')" do
|
521
|
-
use_vcr_cassette
|
522
|
-
it "should find the account by returning a page with items of one" do
|
523
|
-
response = Balanced::Account.find(:all, :email_address => "john.doe@example.com")
|
524
|
-
response.should be_instance_of Array
|
525
|
-
response[0].should be_instance_of Balanced::Account
|
526
|
-
end
|
527
|
-
end
|
528
|
-
|
529
|
-
context "(:first, :some_field => 'op')" do
|
530
|
-
use_vcr_cassette
|
531
|
-
it "should find the account by returning the first item" do
|
532
|
-
response = Balanced::Account.find(:first, :email_address => "john.doe@example.com")
|
533
|
-
response.should be_instance_of Balanced::Account
|
534
|
-
end
|
535
|
-
end
|
536
|
-
|
537
|
-
|
538
|
-
end
|
539
|
-
|
540
|
-
describe ".find_by_email" do
|
541
|
-
use_vcr_cassette :record => :new_episodes
|
542
|
-
before do
|
543
|
-
api_key = Balanced::ApiKey.new.save
|
544
|
-
Balanced.configure api_key.secret
|
545
|
-
@marketplace = Balanced::Marketplace.new.save
|
546
|
-
card = Balanced::Card.new(
|
547
|
-
:card_number => "5105105105105100",
|
548
|
-
:expiration_month => "12",
|
549
|
-
:expiration_year => "2015",
|
550
|
-
).save
|
551
|
-
buyer = Balanced::Marketplace.my_marketplace.create_buyer(
|
552
|
-
"john.doe@example.com",
|
553
|
-
card.uri
|
554
|
-
)
|
555
|
-
end
|
556
|
-
|
557
|
-
context "email address is in system" do
|
558
|
-
use_vcr_cassette :record => :new_episodes
|
559
|
-
it "should return account object" do
|
560
|
-
Balanced::Account.find_by_email("john.doe@example.com").should be_instance_of Balanced::Account
|
561
|
-
end
|
562
|
-
end
|
563
|
-
|
564
|
-
context "email address does not exist" do
|
565
|
-
use_vcr_cassette :record => :new_episodes
|
566
|
-
it "should return nil" do
|
567
|
-
Balanced::Account.find_by_email("foo@bar.com").should be_nil
|
568
|
-
end
|
569
|
-
end
|
570
|
-
end
|
571
|
-
end
|