balanced 0.8.2 → 1.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (359) hide show
  1. checksums.yaml +4 -4
  2. data/.rbenv-version +1 -1
  3. data/.ruby-version +1 -1
  4. data/Gemfile +7 -3
  5. data/README.md +2 -10
  6. data/Rakefile +4 -18
  7. data/balanced.gemspec +8 -10
  8. data/lib/balanced.rb +28 -28
  9. data/lib/balanced/client.rb +15 -6
  10. data/lib/balanced/error.rb +21 -12
  11. data/lib/balanced/pager.rb +66 -25
  12. data/lib/balanced/resources.rb +18 -17
  13. data/lib/balanced/resources/api_key.rb +4 -0
  14. data/lib/balanced/resources/bank_account.rb +26 -75
  15. data/lib/balanced/resources/callback.rb +2 -0
  16. data/lib/balanced/resources/card.rb +15 -65
  17. data/lib/balanced/resources/card_hold.rb +38 -0
  18. data/lib/balanced/resources/credit.rb +6 -50
  19. data/lib/balanced/resources/customer.rb +33 -71
  20. data/lib/balanced/resources/debit.rb +6 -14
  21. data/lib/balanced/resources/event.rb +6 -0
  22. data/lib/balanced/resources/funding_instrument.rb +11 -0
  23. data/lib/balanced/resources/hypermedia.rb +28 -0
  24. data/lib/balanced/resources/marketplace.rb +5 -203
  25. data/lib/balanced/resources/order.rb +71 -0
  26. data/lib/balanced/resources/refund.rb +2 -7
  27. data/lib/balanced/resources/resource.rb +169 -106
  28. data/lib/balanced/resources/reversal.rb +2 -8
  29. data/lib/balanced/resources/transfer.rb +11 -0
  30. data/lib/balanced/response/balanced_exception_middleware.rb +2 -2
  31. data/lib/balanced/utils.rb +47 -14
  32. data/lib/balanced/version.rb +1 -1
  33. data/scenario.cache +526 -380
  34. data/scenarios/api_key_create/definition.rb +1 -0
  35. data/scenarios/api_key_create/request.rb +2 -0
  36. data/scenarios/api_key_create/ruby.mako +21 -0
  37. data/scenarios/api_key_delete/definition.rb +1 -0
  38. data/scenarios/api_key_delete/request.rb +3 -0
  39. data/scenarios/api_key_delete/ruby.mako +12 -0
  40. data/scenarios/api_key_list/definition.rb +1 -0
  41. data/scenarios/api_key_list/request.rb +2 -0
  42. data/scenarios/api_key_list/ruby.mako +28 -0
  43. data/scenarios/api_key_show/definition.rb +1 -0
  44. data/scenarios/api_key_show/request.rb +2 -0
  45. data/scenarios/api_key_show/ruby.mako +18 -0
  46. data/scenarios/{customer_add_bank_account → bank_account_associate_to_customer}/definition.rb +0 -0
  47. data/scenarios/bank_account_associate_to_customer/request.rb +3 -0
  48. data/scenarios/bank_account_associate_to_customer/ruby.mako +49 -0
  49. data/scenarios/bank_account_create/definition.rb +1 -1
  50. data/scenarios/bank_account_create/request.rb +1 -1
  51. data/scenarios/bank_account_create/ruby.mako +44 -7
  52. data/scenarios/{credit_create_existing_bank_account → bank_account_credit}/definition.rb +0 -0
  53. data/scenarios/bank_account_credit/request.rb +3 -0
  54. data/scenarios/bank_account_credit/ruby.mako +42 -0
  55. data/scenarios/bank_account_debit/definition.rb +1 -0
  56. data/scenarios/bank_account_debit/request.rb +5 -0
  57. data/scenarios/bank_account_debit/ruby.mako +50 -0
  58. data/scenarios/bank_account_delete/request.rb +1 -1
  59. data/scenarios/bank_account_delete/ruby.mako +5 -3
  60. data/scenarios/bank_account_list/ruby.mako +76 -2
  61. data/scenarios/bank_account_show/definition.rb +1 -1
  62. data/scenarios/bank_account_show/request.rb +1 -1
  63. data/scenarios/bank_account_show/ruby.mako +41 -5
  64. data/scenarios/bank_account_update/definition.rb +1 -0
  65. data/scenarios/bank_account_update/request.rb +6 -0
  66. data/scenarios/bank_account_update/ruby.mako +56 -0
  67. data/scenarios/bank_account_verification_create/request.rb +1 -1
  68. data/scenarios/bank_account_verification_create/ruby.mako +20 -3
  69. data/scenarios/bank_account_verification_show/definition.rb +1 -1
  70. data/scenarios/bank_account_verification_show/request.rb +1 -1
  71. data/scenarios/bank_account_verification_show/ruby.mako +21 -4
  72. data/scenarios/bank_account_verification_update/definition.rb +1 -1
  73. data/scenarios/bank_account_verification_update/request.rb +5 -5
  74. data/scenarios/bank_account_verification_update/ruby.mako +24 -8
  75. data/scenarios/callback_create/definition.rb +1 -1
  76. data/scenarios/callback_create/request.rb +2 -2
  77. data/scenarios/callback_create/ruby.mako +22 -0
  78. data/scenarios/callback_delete/definition.rb +1 -1
  79. data/scenarios/callback_delete/request.rb +2 -2
  80. data/scenarios/callback_delete/ruby.mako +12 -0
  81. data/scenarios/callback_list/definition.rb +1 -1
  82. data/scenarios/callback_list/request.rb +1 -2
  83. data/scenarios/callback_list/ruby.mako +20 -0
  84. data/scenarios/callback_show/definition.rb +1 -1
  85. data/scenarios/callback_show/request.rb +1 -1
  86. data/scenarios/callback_show/ruby.mako +20 -0
  87. data/scenarios/{customer_add_card → card_associate_to_customer}/definition.rb +0 -0
  88. data/scenarios/card_associate_to_customer/request.rb +3 -0
  89. data/scenarios/card_associate_to_customer/ruby.mako +49 -0
  90. data/scenarios/card_create/request.rb +1 -2
  91. data/scenarios/card_create/ruby.mako +44 -7
  92. data/scenarios/card_debit/definition.rb +1 -0
  93. data/scenarios/card_debit/request.rb +5 -0
  94. data/scenarios/card_debit/ruby.mako +49 -0
  95. data/scenarios/card_delete/request.rb +1 -1
  96. data/scenarios/card_delete/ruby.mako +5 -3
  97. data/scenarios/card_hold_capture/definition.rb +1 -0
  98. data/scenarios/card_hold_capture/request.rb +5 -0
  99. data/scenarios/card_hold_capture/ruby.mako +49 -0
  100. data/scenarios/card_hold_create/definition.rb +1 -0
  101. data/scenarios/card_hold_create/request.rb +5 -0
  102. data/scenarios/card_hold_create/ruby.mako +38 -0
  103. data/scenarios/card_hold_list/definition.rb +1 -0
  104. data/scenarios/card_hold_list/request.rb +2 -0
  105. data/scenarios/card_hold_list/ruby.mako +60 -0
  106. data/scenarios/card_hold_show/definition.rb +1 -0
  107. data/scenarios/card_hold_show/request.rb +2 -0
  108. data/scenarios/card_hold_show/ruby.mako +36 -0
  109. data/scenarios/card_hold_update/definition.rb +1 -0
  110. data/scenarios/card_hold_update/request.rb +7 -0
  111. data/scenarios/card_hold_update/ruby.mako +42 -0
  112. data/scenarios/card_hold_void/definition.rb +1 -0
  113. data/scenarios/card_hold_void/request.rb +3 -0
  114. data/scenarios/card_hold_void/ruby.mako +36 -0
  115. data/scenarios/card_list/definition.rb +1 -1
  116. data/scenarios/card_list/request.rb +1 -1
  117. data/scenarios/card_list/ruby.mako +78 -5
  118. data/scenarios/card_show/definition.rb +1 -1
  119. data/scenarios/card_show/request.rb +1 -1
  120. data/scenarios/card_show/ruby.mako +42 -4
  121. data/scenarios/card_update/definition.rb +1 -1
  122. data/scenarios/card_update/request.rb +1 -1
  123. data/scenarios/card_update/ruby.mako +45 -4
  124. data/scenarios/credit_list/request.rb +1 -3
  125. data/scenarios/credit_list/ruby.mako +34 -4
  126. data/scenarios/{credit_bank_account_list → credit_list_bank_account}/definition.rb +0 -0
  127. data/scenarios/credit_list_bank_account/request.rb +3 -0
  128. data/scenarios/credit_list_bank_account/ruby.mako +13 -0
  129. data/scenarios/credit_show/definition.rb +1 -1
  130. data/scenarios/credit_show/request.rb +1 -3
  131. data/scenarios/credit_show/ruby.mako +35 -5
  132. data/scenarios/{credit_create_new_bank_account → credit_update}/definition.rb +0 -0
  133. data/scenarios/credit_update/request.rb +7 -0
  134. data/scenarios/credit_update/ruby.mako +48 -0
  135. data/scenarios/customer_create/request.rb +4 -1
  136. data/scenarios/customer_create/ruby.mako +60 -3
  137. data/scenarios/customer_delete/request.rb +1 -1
  138. data/scenarios/customer_delete/ruby.mako +4 -2
  139. data/scenarios/customer_list/definition.rb +1 -0
  140. data/scenarios/customer_list/request.rb +2 -0
  141. data/scenarios/customer_list/ruby.mako +105 -0
  142. data/scenarios/customer_show/definition.rb +1 -0
  143. data/scenarios/customer_show/request.rb +2 -0
  144. data/scenarios/customer_show/ruby.mako +58 -0
  145. data/scenarios/customer_update/definition.rb +1 -0
  146. data/scenarios/customer_update/request.rb +7 -0
  147. data/scenarios/customer_update/ruby.mako +64 -0
  148. data/scenarios/debit_list/request.rb +1 -3
  149. data/scenarios/debit_list/ruby.mako +70 -4
  150. data/scenarios/debit_show/definition.rb +1 -1
  151. data/scenarios/debit_show/request.rb +1 -1
  152. data/scenarios/debit_show/ruby.mako +39 -4
  153. data/scenarios/debit_update/definition.rb +1 -1
  154. data/scenarios/debit_update/request.rb +1 -1
  155. data/scenarios/debit_update/ruby.mako +39 -4
  156. data/scenarios/event_list/definition.rb +1 -1
  157. data/scenarios/event_list/request.rb +1 -2
  158. data/scenarios/event_list/ruby.mako +54 -5
  159. data/scenarios/event_show/definition.rb +1 -1
  160. data/scenarios/event_show/request.rb +1 -1
  161. data/scenarios/event_show/ruby.mako +54 -4
  162. data/scenarios/helpers.rb +29 -2
  163. data/scenarios/order_create/definition.rb +1 -0
  164. data/scenarios/order_create/request.rb +5 -0
  165. data/scenarios/order_create/ruby.mako +46 -0
  166. data/scenarios/order_list/definition.rb +1 -0
  167. data/scenarios/order_list/request.rb +2 -0
  168. data/scenarios/order_list/ruby.mako +42 -0
  169. data/scenarios/order_show/definition.rb +1 -0
  170. data/scenarios/order_show/request.rb +2 -0
  171. data/scenarios/order_show/ruby.mako +44 -0
  172. data/scenarios/order_update/definition.rb +1 -0
  173. data/scenarios/order_update/request.rb +7 -0
  174. data/scenarios/order_update/ruby.mako +50 -0
  175. data/scenarios/refund_create/definition.rb +1 -1
  176. data/scenarios/refund_create/request.rb +2 -1
  177. data/scenarios/refund_create/ruby.mako +33 -5
  178. data/scenarios/refund_list/request.rb +1 -3
  179. data/scenarios/refund_list/ruby.mako +30 -4
  180. data/scenarios/refund_show/definition.rb +1 -1
  181. data/scenarios/refund_show/request.rb +1 -1
  182. data/scenarios/refund_show/ruby.mako +32 -4
  183. data/scenarios/refund_update/definition.rb +1 -1
  184. data/scenarios/refund_update/request.rb +1 -1
  185. data/scenarios/refund_update/ruby.mako +32 -4
  186. data/scenarios/render_mako.rb +59 -4
  187. data/scenarios/reversal_create/definition.rb +1 -0
  188. data/scenarios/reversal_create/request.rb +9 -0
  189. data/scenarios/reversal_create/ruby.mako +45 -0
  190. data/scenarios/reversal_list/definition.rb +1 -0
  191. data/scenarios/reversal_list/request.rb +2 -0
  192. data/scenarios/reversal_list/ruby.mako +36 -0
  193. data/scenarios/reversal_show/definition.rb +1 -0
  194. data/scenarios/reversal_show/request.rb +2 -0
  195. data/scenarios/reversal_show/ruby.mako +37 -0
  196. data/scenarios/reversal_update/definition.rb +1 -0
  197. data/scenarios/reversal_update/request.rb +7 -0
  198. data/scenarios/reversal_update/ruby.mako +44 -0
  199. data/spec/balanced/error_spec.rb +7 -7
  200. data/spec/balanced/pager_spec.rb +10 -10
  201. data/spec/balanced/resources/api_key_spec.rb +6 -35
  202. data/spec/balanced/resources/bank_account_spec.rb +123 -218
  203. data/spec/balanced/resources/callback_spec.rb +12 -13
  204. data/spec/balanced/resources/card_hold_spec.rb +103 -0
  205. data/spec/balanced/resources/card_spec.rb +101 -27
  206. data/spec/balanced/resources/credit_spec.rb +69 -35
  207. data/spec/balanced/resources/customer_spec.rb +91 -271
  208. data/spec/balanced/resources/debit_spec.rb +95 -0
  209. data/spec/balanced/resources/marketplace_spec.rb +17 -170
  210. data/spec/balanced/resources/order_spec.rb +364 -0
  211. data/spec/balanced/resources/resource_spec.rb +25 -32
  212. data/spec/balanced_spec.rb +18 -36
  213. data/spec/client_spec.rb +7 -7
  214. data/spec/spec_helper.rb +19 -18
  215. data/spec/utils_spec.rb +5 -5
  216. metadata +123 -165
  217. data/examples/bank_account_debits.rb +0 -57
  218. data/examples/customers.rb +0 -114
  219. data/examples/events_and_callbacks.rb +0 -81
  220. data/examples/examples.rb +0 -162
  221. data/examples/exception_handling.rb +0 -44
  222. data/lib/balanced/resources/account.rb +0 -179
  223. data/lib/balanced/resources/hold.rb +0 -61
  224. data/lib/balanced/resources/invoice.rb +0 -11
  225. data/lib/balanced/resources/merchant.rb +0 -21
  226. data/lib/balanced/resources/transaction.rb +0 -17
  227. data/scenarios/account_add_card/definition.rb +0 -1
  228. data/scenarios/account_add_card/request.rb +0 -3
  229. data/scenarios/account_add_card/ruby.mako +0 -11
  230. data/scenarios/account_capture_hold/definition.rb +0 -1
  231. data/scenarios/account_capture_hold/request.rb +0 -3
  232. data/scenarios/account_capture_hold/ruby.mako +0 -11
  233. data/scenarios/account_create/definition.rb +0 -1
  234. data/scenarios/account_create/request.rb +0 -2
  235. data/scenarios/account_create/ruby.mako +0 -10
  236. data/scenarios/account_create_buyer/definition.rb +0 -1
  237. data/scenarios/account_create_buyer/request.rb +0 -5
  238. data/scenarios/account_create_buyer/ruby.mako +0 -13
  239. data/scenarios/account_create_debit/definition.rb +0 -1
  240. data/scenarios/account_create_debit/request.rb +0 -3
  241. data/scenarios/account_create_debit/ruby.mako +0 -11
  242. data/scenarios/account_create_hold/definition.rb +0 -1
  243. data/scenarios/account_create_hold/request.rb +0 -3
  244. data/scenarios/account_create_hold/ruby.mako +0 -11
  245. data/scenarios/account_create_merchant/definition.rb +0 -1
  246. data/scenarios/account_create_merchant/request.rb +0 -3
  247. data/scenarios/account_create_merchant/ruby.mako +0 -11
  248. data/scenarios/account_underwrite_business/definition.rb +0 -1
  249. data/scenarios/account_underwrite_business/request.rb +0 -17
  250. data/scenarios/account_underwrite_business/ruby.mako +0 -37
  251. data/scenarios/account_underwrite_person/definition.rb +0 -1
  252. data/scenarios/account_underwrite_person/request.rb +0 -18
  253. data/scenarios/account_underwrite_person/ruby.mako +0 -31
  254. data/scenarios/bank_account_find_and_credit/definition.rb +0 -1
  255. data/scenarios/bank_account_find_and_credit/request.rb +0 -5
  256. data/scenarios/bank_account_find_and_credit/ruby.mako +0 -13
  257. data/scenarios/bank_account_find_and_delete/definition.rb +0 -1
  258. data/scenarios/bank_account_find_and_delete/request.rb +0 -3
  259. data/scenarios/bank_account_find_and_delete/ruby.mako +0 -10
  260. data/scenarios/bank_account_invalid_routing_number/definition.rb +0 -1
  261. data/scenarios/bank_account_invalid_routing_number/request.rb +0 -11
  262. data/scenarios/bank_account_invalid_routing_number/ruby.mako +0 -16
  263. data/scenarios/card_invalidate/definition.rb +0 -1
  264. data/scenarios/card_invalidate/request.rb +0 -3
  265. data/scenarios/card_invalidate/ruby.mako +0 -10
  266. data/scenarios/credit_account_list/definition.rb +0 -1
  267. data/scenarios/credit_account_list/request.rb +0 -3
  268. data/scenarios/credit_account_list/ruby.mako +0 -10
  269. data/scenarios/credit_account_merchant_create/definition.rb +0 -1
  270. data/scenarios/credit_account_merchant_create/request.rb +0 -5
  271. data/scenarios/credit_account_merchant_create/ruby.mako +0 -12
  272. data/scenarios/credit_bank_account_list/request.rb +0 -5
  273. data/scenarios/credit_bank_account_list/ruby.mako +0 -12
  274. data/scenarios/credit_create_existing_bank_account/request.rb +0 -5
  275. data/scenarios/credit_create_existing_bank_account/ruby.mako +0 -12
  276. data/scenarios/credit_create_new_bank_account/request.rb +0 -10
  277. data/scenarios/credit_create_new_bank_account/ruby.mako +0 -21
  278. data/scenarios/credit_customer_list/definition.rb +0 -1
  279. data/scenarios/credit_customer_list/request.rb +0 -4
  280. data/scenarios/credit_customer_list/ruby.mako +0 -12
  281. data/scenarios/credit_failed_state/definition.rb +0 -1
  282. data/scenarios/credit_failed_state/request.rb +0 -10
  283. data/scenarios/credit_failed_state/ruby.mako +0 -18
  284. data/scenarios/credit_paid_state/definition.rb +0 -1
  285. data/scenarios/credit_paid_state/request.rb +0 -11
  286. data/scenarios/credit_paid_state/ruby.mako +0 -19
  287. data/scenarios/credit_pending_state/definition.rb +0 -1
  288. data/scenarios/credit_pending_state/request.rb +0 -9
  289. data/scenarios/credit_pending_state/ruby.mako +0 -17
  290. data/scenarios/customer_add_bank_account/request.rb +0 -3
  291. data/scenarios/customer_add_bank_account/ruby.mako +0 -11
  292. data/scenarios/customer_add_card/request.rb +0 -3
  293. data/scenarios/customer_add_card/ruby.mako +0 -11
  294. data/scenarios/customer_capture_hold/definition.rb +0 -1
  295. data/scenarios/customer_capture_hold/request.rb +0 -3
  296. data/scenarios/customer_capture_hold/ruby.mako +0 -0
  297. data/scenarios/customer_create_debit/definition.rb +0 -1
  298. data/scenarios/customer_create_debit/request.rb +0 -3
  299. data/scenarios/customer_create_debit/ruby.mako +0 -11
  300. data/scenarios/customer_create_hold/definition.rb +0 -1
  301. data/scenarios/customer_create_hold/request.rb +0 -3
  302. data/scenarios/customer_create_hold/ruby.mako +0 -11
  303. data/scenarios/customer_credit/definition.rb +0 -1
  304. data/scenarios/customer_credit/request.rb +0 -2
  305. data/scenarios/customer_credit/ruby.mako +0 -8
  306. data/scenarios/debit_account_list/definition.rb +0 -1
  307. data/scenarios/debit_account_list/request.rb +0 -3
  308. data/scenarios/debit_account_list/ruby.mako +0 -10
  309. data/scenarios/debit_create/definition.rb +0 -1
  310. data/scenarios/debit_create/request.rb +0 -5
  311. data/scenarios/debit_create/ruby.mako +0 -15
  312. data/scenarios/debit_customer_list/definition.rb +0 -1
  313. data/scenarios/debit_customer_list/request.rb +0 -4
  314. data/scenarios/debit_customer_list/ruby.mako +0 -12
  315. data/scenarios/debit_refund/definition.rb +0 -1
  316. data/scenarios/debit_refund/request.rb +0 -3
  317. data/scenarios/debit_refund/ruby.mako +0 -10
  318. data/scenarios/delete.rb +0 -7
  319. data/scenarios/event_replay/definition.rb +0 -0
  320. data/scenarios/event_replay/request.rb +0 -1
  321. data/scenarios/event_replay/ruby.mako +0 -0
  322. data/scenarios/execute.rb +0 -27
  323. data/scenarios/hold_account_list/definition.rb +0 -1
  324. data/scenarios/hold_account_list/request.rb +0 -3
  325. data/scenarios/hold_account_list/ruby.mako +0 -10
  326. data/scenarios/hold_capture/definition.rb +0 -1
  327. data/scenarios/hold_capture/request.rb +0 -5
  328. data/scenarios/hold_capture/ruby.mako +0 -15
  329. data/scenarios/hold_create/definition.rb +0 -1
  330. data/scenarios/hold_create/request.rb +0 -5
  331. data/scenarios/hold_create/ruby.mako +0 -14
  332. data/scenarios/hold_customer_list/definition.rb +0 -1
  333. data/scenarios/hold_customer_list/request.rb +0 -3
  334. data/scenarios/hold_customer_list/ruby.mako +0 -11
  335. data/scenarios/hold_list/definition.rb +0 -1
  336. data/scenarios/hold_list/request.rb +0 -4
  337. data/scenarios/hold_list/ruby.mako +0 -11
  338. data/scenarios/hold_show/definition.rb +0 -1
  339. data/scenarios/hold_show/request.rb +0 -2
  340. data/scenarios/hold_show/ruby.mako +0 -10
  341. data/scenarios/hold_update/definition.rb +0 -1
  342. data/scenarios/hold_update/request.rb +0 -7
  343. data/scenarios/hold_update/ruby.mako +0 -16
  344. data/scenarios/hold_void/definition.rb +0 -1
  345. data/scenarios/hold_void/request.rb +0 -3
  346. data/scenarios/hold_void/ruby.mako +0 -10
  347. data/scenarios/refund_account_list/definition.rb +0 -1
  348. data/scenarios/refund_account_list/request.rb +0 -3
  349. data/scenarios/refund_account_list/ruby.mako +0 -10
  350. data/scenarios/refund_customer_list/definition.rb +0 -1
  351. data/scenarios/refund_customer_list/request.rb +0 -3
  352. data/scenarios/refund_customer_list/ruby.mako +0 -11
  353. data/scenarios/render.rb +0 -32
  354. data/scenarios/render_one.rb +0 -32
  355. data/spec/balanced/resources/account_spec.rb +0 -636
  356. data/spec/balanced/resources/hold_spec.rb +0 -48
  357. data/spec/balanced/resources/merchant_spec.rb +0 -6
  358. data/spec/scenarios_spec.rb +0 -39
  359. data/upload_docs.rb +0 -40
@@ -1,36 +1,35 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Balanced::Callback, :vcr do
4
4
  before do
5
5
  api_key = Balanced::ApiKey.new.save
6
6
  Balanced.configure api_key.secret
7
-
8
7
  @marketplace = Balanced::Marketplace.new.save
9
8
  end
10
9
 
11
- describe "create", :vcr do
10
+ describe 'create', :vcr do
12
11
  before do
13
- @callback = @marketplace.create_callback(
14
- :url => "http://www.example.com/balanced_callback"
15
- )
12
+ @callback = Balanced::Callback.new(
13
+ :url => 'http://www.example.com/balanced_callback'
14
+ ).save
16
15
  end
17
16
 
18
17
  context 'check url' do
19
- subject { @callback.url}
20
- it { should eql "http://www.example.com/balanced_callback" }
18
+ subject { @callback.url }
19
+ it { should eql 'http://www.example.com/balanced_callback' }
21
20
  end
22
21
 
23
22
  end
24
23
 
25
- describe "delete", :vcr do
24
+ describe 'delete', :vcr do
26
25
  before do
27
- @callback = @marketplace.create_callback(
28
- :url => "http://www.example.com/balanced_callback"
29
- )
26
+ @callback = Balanced::Callback.new(
27
+ :url => 'http://www.example.com/balanced_callback'
28
+ ).save
30
29
  end
31
30
 
32
31
  context 'delete' do
33
- it "should delete without an error" do
32
+ it 'should delete without an error' do
34
33
  @callback.destroy
35
34
  end
36
35
  end
@@ -0,0 +1,103 @@
1
+ require 'spec_helper'
2
+
3
+ describe Balanced::CardHold, :vcr => true, :skip => true do
4
+
5
+ before(:all) 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
+ :number => '5105105105105100',
11
+ :expiration_month => '12',
12
+ :expiration_year => '2015'
13
+ ).save
14
+ end
15
+
16
+ describe '#create', :vcr do
17
+
18
+ subject do
19
+ @card_hold = Balanced::CardHold.new(
20
+ :href => @card.holds.href,
21
+ :amount => 100,
22
+ :currency => 'USD',
23
+ :appears_on_statement_as => 'My Market.Place-13',
24
+ :description => 'I be holding',
25
+ :meta => {
26
+ :campaign_id => SecureRandom.hex
27
+ }
28
+ ).save
29
+ end
30
+
31
+ it { should_not be_nil }
32
+ its(:href) { should_not be nil }
33
+ its(:description) { should eq('I be holding') }
34
+ its(:appears_on_statement_as) { should eq('BAL*My Market.Place-13') }
35
+ its(:amount) { should == 100 }
36
+ its(:meta) {
37
+ should_not be_nil
38
+ should be_instance_of Hash
39
+ }
40
+ its(:currency) { should == 'USD' }
41
+ its(:expires_at) { should_not be_nil }
42
+
43
+ its(:debits) { should be_instance_of Balanced::Pager }
44
+ its(:debit) { should be_nil }
45
+
46
+ context '#card' do
47
+ its('card.href') { should eql(@card.href) }
48
+ end
49
+
50
+ end
51
+
52
+ describe '#capture', :vcr do
53
+ before do
54
+ @card_hold = Balanced::CardHold.new(
55
+ :href => @card.holds.href,
56
+ :amount => 100,
57
+ :currency => 'USD',
58
+ :appears_on_statement_as => 'My Market.Place-13',
59
+ :description => 'I be holding',
60
+ :meta => {
61
+ :campaign_id => SecureRandom.hex
62
+ }
63
+ ).save
64
+ end
65
+
66
+ context 'with no arguments - should just create a debit' do
67
+ subject { @card_hold.capture }
68
+ it { should be_instance_of Balanced::Debit }
69
+ its(:amount) { should eql @card_hold.amount }
70
+ its(:appears_on_statement_as) { should eql @card_hold.appears_on_statement_as }
71
+ end
72
+
73
+ it "should update the card hold's debit" do
74
+ @card_hold.debit.should be_nil
75
+ debit = @card_hold.capture
76
+ @card_hold.debit.should_not be_nil
77
+ @card_hold.debit.href.should eql(debit.href)
78
+ end
79
+
80
+ it 'should fail when captured twice' do
81
+ @card_hold.debit.should be_nil
82
+ @card_hold.capture
83
+ lambda { @card_hold.capture }.should raise_error(Balanced::Conflict)
84
+ end
85
+ end
86
+
87
+ describe '#destroy', :vcr do
88
+ before(:all) do
89
+ @hold = @card.hold(:amount => 100)
90
+ @hold_href = @hold.href
91
+ end
92
+
93
+ it 'should implicitly void the hold since it no longer exists' do
94
+ @hold.destroy
95
+ end
96
+
97
+ it 'should return a 404 when trying to access it again' do
98
+ lambda { Balanced::CardHold.find(@hold_href) }.should raise_error(Balanced::NotFound)
99
+ end
100
+
101
+ end
102
+
103
+ end
@@ -1,36 +1,110 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe Balanced::Card, '#debit', :vcr => true, :marketplace => true do
4
- it 'raises an exception with an unassociated card' do
5
- card = Balanced::Card.new
6
- expect {
7
- card.debit
8
- }.to raise_error(Balanced::UnassociatedCardError)
9
- end
10
- end
3
+ describe Balanced::Card, :vcr do
11
4
 
12
- describe Balanced::Card, '#hold', :vcr => true, :marketplace => true do
13
- it 'raises an exception with an unassociated card' do
14
- card = Balanced::Card.new
15
- expect {
16
- card.hold
17
- }.to raise_error(Balanced::UnassociatedCardError)
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
+ :number => '5105105105105100',
11
+ :expiration_month => '12',
12
+ :expiration_year => '2020',
13
+ :cvv => '123'
14
+ ).save
18
15
  end
19
- end
20
16
 
21
- describe Balanced::Card, '#debit', :vcr => true, :marketplace => true do
22
- it 'debits the card if an account is set' do
23
- # tokenize card
24
- card = Balanced::Card.new(
25
- :card_number => '4111111111111111',
26
- :expiration_year => '2016',
27
- :expiration_month => '12')
28
- card.save
17
+ describe 'card', :vcr do
18
+ it 'should be a Balanced::Card' do
19
+ @card.should be_instance_of Balanced::Card
20
+ end
21
+
22
+ describe 'attributes', :vcr do
23
+ subject { @card }
24
+ its(:href) { should match "/cards/#{@card.id}" }
25
+ its(:number) { should end_with '5100' }
26
+ its(:expiration_month) { should eql 12 }
27
+ its(:expiration_year) { should eql 2020 }
28
+ its(:cvv) { should eql 'xxx' }
29
+ its(:cvv_match) { should eql 'yes' }
30
+ its(:cvv_result) { should eql 'Match' }
31
+ end
32
+
33
+ describe 'creating a one-time debit', :vcr => {:record => :new_episodes} do
34
+ subject do
35
+ @card.debit(
36
+ :amount => 100,
37
+ :appears_on_statement_as => 'A lolipop',
38
+ :description => 'My first debit!'
39
+ )
40
+ end
41
+ it { should_not be_nil }
42
+ it { should be_instance_of Balanced::Debit }
43
+
44
+ its(:href) { should_not be_nil }
45
+ its(:amount) { should eql 100 }
46
+ its(:appears_on_statement_as) { should eql 'BAL*A lolipop' }
47
+ its(:description) { should eql 'My first debit!' }
48
+ its(:status) { should eql 'succeeded' }
49
+ end
50
+
51
+ describe 'creating a one-time hold', :vcr => true, :skip => true do
52
+ subject do
53
+ @card.hold(
54
+ :amount => 100,
55
+ :appears_on_statement_as => 'HOLD.UP',
56
+ :description => 'HeldForEver'
57
+ )
58
+ end
59
+ it { should_not be_nil }
60
+ it { should be_instance_of Balanced::CardHold }
61
+
62
+ its(:href) { should_not be_nil }
63
+ its(:amount) { should eql 100 }
64
+ its(:description) { should eql 'HeldForEver' }
65
+ its(:appears_on_statement_as) { should eql 'BAL*HOLD.UP' }
66
+ end
29
67
 
30
- # associate card to account
31
- Balanced::Account.new(:email_address => 'user@example.com', :name => 'John Doe', :card_uri => card.uri).save
68
+ describe '#debits', :vcr do
69
+ subject do
70
+ @card.debits
71
+ end
72
+ its(:href) { should eq("/cards/#{@card.id}/debits") }
73
+ it 'should be a page' do
74
+ should be_instance_of Balanced::Pager
75
+ end
76
+ end
77
+
78
+ describe '#holds', :vcr => true, :skip => true do
79
+ subject do
80
+ @card.holds
81
+ end
82
+
83
+ its(:href) { should eq("/cards/#{@card.id}/card_holds") }
84
+
85
+ it 'should be a page' do
86
+ should be_instance_of Balanced::Pager
87
+ end
88
+ end
89
+
90
+ describe '#customer', :vcr do
91
+
92
+ it 'should default to nil' do
93
+ @card.customer.should be_nil
94
+ end
95
+
96
+ context 'after associating to a customer' do
97
+ before do
98
+ @customer = Balanced::Customer.new.save
99
+ @card.associate_to_customer(@customer)
100
+ @card.reload
101
+ end
102
+ subject { @card }
103
+ its(:customer) { should_not be_nil }
104
+ end
105
+
106
+ end
32
107
 
33
- card = Balanced::Card.find(card.uri)
34
- card.debit(:amount => 10000).should be_instance_of Balanced::Debit
35
108
  end
109
+
36
110
  end
@@ -1,4 +1,4 @@
1
- require "spec_helper"
1
+ require 'spec_helper'
2
2
 
3
3
  describe Balanced::Credit, :vcr do
4
4
  before do
@@ -6,30 +6,26 @@ describe Balanced::Credit, :vcr do
6
6
  Balanced.configure api_key.secret
7
7
  @marketplace = Balanced::Marketplace.new.save
8
8
  card = Balanced::Card.new(
9
- :card_number => "5105105105105100",
10
- :expiration_month => "12",
11
- :expiration_year => "2015"
9
+ :number => '5105105105105100',
10
+ :expiration_month => '12',
11
+ :expiration_year => '2015'
12
12
  ).save
13
13
 
14
14
  # An initial balance for the marketplace
15
- @buyer = @marketplace.create_buyer(
16
- :email_address => 'buyer@example.org',
17
- :card_uri => card.uri
18
- )
19
- @buyer.debit :amount => 10000000
15
+ card.debit(:amount => 1000000)
20
16
  end
21
17
 
22
- describe "#create", :vcr do
18
+ describe '#create', :vcr do
23
19
  before do
24
20
  @credit = Balanced::Credit.new(
25
- :amount => 5000,
26
- :description => "A sweet ride",
27
- :bank_account => {
28
- :account_number => "0987654321",
29
- :bank_code => "321174851",
30
- :name => "Timmy T. McTimmerson",
31
- :type => "savings"
32
- }
21
+ :amount => 5000,
22
+ :description => 'A sweet ride',
23
+ :destination => {
24
+ :routing_number => '321174851',
25
+ :account_number => '0987654321',
26
+ :name => 'Timmy T. McTimmerson',
27
+ :type => 'checking'
28
+ }
33
29
  ).save
34
30
  end
35
31
 
@@ -38,37 +34,75 @@ describe Balanced::Credit, :vcr do
38
34
  it { should == 5000 }
39
35
  end
40
36
 
41
- describe 'account', :vcr do
42
- subject { @credit.account }
37
+ describe 'customer', :vcr do
38
+ subject { @credit.customer }
43
39
  it { should be_nil }
44
40
  end
45
41
 
46
- describe 'bank_account', :vcr do
47
- subject { @credit.bank_account }
48
- its([:account_number]) { should end_with '4321' }
49
- end
50
42
  end
51
43
 
52
- describe "#reverse", :vcr do
44
+ describe '#reverse', :vcr do
53
45
  before do
54
46
  @credit = Balanced::Credit.new(
55
- :amount => 5000,
56
- :description => "A sweet ride",
57
- :bank_account => {
58
- :account_number => "0987654321",
59
- :bank_code => "321174851",
60
- :name => "Timmy T. McTimmerson",
61
- :type => "savings"
62
- }
47
+ :amount => 5000,
48
+ :description => 'A sweet ride',
49
+ :destination => {
50
+ :routing_number => '321174851',
51
+ :account_number => '0987654321',
52
+ :name => 'Timmy T. McTimmerson',
53
+ :type => 'checking'
54
+ }
63
55
  ).save
64
- @reverse = @credit.reverse
56
+ @reversal = @credit.reverse
57
+ end
58
+
59
+ describe '#amount', :vcr do
60
+ subject { @reversal.amount }
61
+ it { should == 5000 }
62
+ end
65
63
 
64
+ describe '#type', :vcr do
65
+ subject { @reversal }
66
+ it { should be_instance_of Balanced::Reversal }
67
+ end
68
+ end
69
+
70
+ describe 'credit with underwritten customer' do
71
+ before do
72
+ @customer = Balanced::Customer.new(
73
+ :name => 'Henry Ford',
74
+ :dob_month => 7,
75
+ :dob_year => 1963,
76
+ :address => {
77
+ :postal_code => '48120'
78
+ }
79
+ ).save
80
+ @bank_account = Balanced::BankAccount.new(
81
+ :routing_number => '321174851',
82
+ :account_number => '9900000003',
83
+ :name => 'Larry Bird',
84
+ :type => 'checking'
85
+ ).save
86
+ @bank_account.associate_to_customer(@customer)
87
+ @credit = @bank_account.credit(
88
+ :amount => 5000,
89
+ :description => 'A sweet ride'
90
+ )
91
+ end
92
+
93
+ describe 'merchant_status', :vcr do
94
+ subject { @customer.merchant_status }
95
+ it { should eq 'underwritten' }
66
96
  end
67
97
 
68
98
  describe 'amount', :vcr do
69
- subject { @reverse.amount }
99
+ subject { @credit.amount }
70
100
  it { should == 5000 }
71
101
  end
72
102
 
103
+ describe 'status' do
104
+ subject { @credit.status }
105
+ it { should eq 'succeeded' }
106
+ end
73
107
  end
74
108
  end
@@ -1,313 +1,133 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Balanced::Customer, :vcr do
4
+
4
5
  before do
5
- api_key = Balanced::ApiKey.new.save
6
- Balanced.configure api_key.secret
6
+ @api_key = Balanced::ApiKey.new.save
7
+ Balanced.configure @api_key.secret
7
8
  @marketplace = Balanced::Marketplace.new.save
9
+ @customer = Balanced::Customer.new(
10
+ :name => 'Bill',
11
+ :email => 'bill@bill.com',
12
+ :business_name => 'Bill Inc.',
13
+ :ssn_last4 => '1234',
14
+ :address => {
15
+ :line1 => '1234 1st Street',
16
+ :city => 'San Francisco',
17
+ :state => 'CA'
18
+ }
19
+ ).save
8
20
  end
9
21
 
10
- describe "Customer.uri", :vcr do
11
-
12
- context "when Api Key is configured properly", :vcr do
13
- before do
14
- api_key = Balanced::ApiKey.new.save
15
- Balanced.configure api_key.secret
16
- Balanced::Customer.new
17
- end
18
-
19
- it "matches the resource's uri structure" do
20
- uri = Balanced::Customer.uri
21
- uri.should_not be_nil
22
- uri.should match CUSTOMERS_URI_REGEX
23
- end
24
- end
22
+ describe 'attributes', :vcr do
23
+ subject { @customer }
24
+ its(:href) { should match "/customers/#{@customer.id}" }
25
+ its(:name) { should eq 'Bill' }
26
+ its(:email) { should eq 'bill@bill.com' }
27
+ its(:business_name) { should eq 'Bill Inc.' }
25
28
  end
26
29
 
27
- describe "customer", :vcr do
28
- describe "#create", :vcr do
29
- before do
30
- @customer = @marketplace.create_customer(
31
- :name => "Bill",
32
- :email => "bill@bill.com",
33
- :business_name => "Bill Inc.",
34
- :ssn_last4 => "1234",
35
- :address => {
36
- :line1 => "1234 1st Street",
37
- :city => "San Francisco",
38
- :state => "CA"
39
- }
40
- ).save
41
- end
42
- it "should create a new customer" do
43
- @customer.should_not be_nil
44
- end
45
- it "should contain the correct attributes" do
46
- @customer.name.should eq("Bill")
47
- @customer.email.should eq("bill@bill.com")
48
- @customer.business_name.should eq("Bill Inc.")
49
- end
50
- end
51
-
52
- describe "#add_card using untokenized object", :vcr do
53
- before do
54
- @customer = @marketplace.create_customer
30
+ describe '#add_source', :vcr do
31
+ before do
55
32
  @card = Balanced::Card.new(
56
- :card_number => "4111111111111111",
57
- :expiration_month => "12",
58
- :expiration_year => "2015"
59
- )
60
- @customer.add_card(@card)
61
- end
62
- it "should add a card to a customer" do
63
- @customer.cards.size.should eq(1)
64
- end
33
+ :number => '4111111111111111',
34
+ :expiration_month => '12',
35
+ :expiration_year => '2015'
36
+ ).save
37
+ @card.associate_to_customer(@customer)
65
38
  end
66
39
 
67
- describe "#add_card using tokenized object", :vcr do
68
- before do
69
- @customer = @marketplace.create_customer
70
- @card = @marketplace.create_card(
71
- :card_number => "4111111111111111",
72
- :expiration_month => "12",
73
- :expiration_year => "2015"
74
- ).save
75
- @customer.add_card(@card)
76
- @customer_card_id = @customer.cards.first.id
77
- @card_id = @card.id
78
- end
79
- it "should add a card to a customer" do
80
- @customer.cards.size.should eq(1)
81
- end
82
- it "card added should be the same card" do
83
- @customer_card_id.should eq(@card_id)
84
- end
40
+ it 'assumes the card is associated', :vcr do
41
+ @customer.cards.total.should eql(1)
85
42
  end
86
43
 
87
- describe "#add_card using uri", :vcr do
88
- before do
89
- @customer = @marketplace.create_customer
90
- @card = @marketplace.create_card(
91
- :card_number => "4111111111111111",
92
- :expiration_month => "12",
93
- :expiration_year => "2015"
94
- ).save
95
- @customer.add_card(@card.uri)
96
- @customer_card_id = @customer.cards.first.id
97
- @card_id = @card.id
98
- end
99
- it "should add a card to a customer" do
100
- @customer.cards.size.should eq(1)
101
- end
102
- it "card added should be the same card" do
103
- @customer_card_id.should eq(@card_id)
104
- end
44
+ it 'should make the card a source', :vcr do
45
+ @customer.add_source(@card)
46
+ @customer.source.should be_instance_of Balanced::Card
47
+ @customer.source.href.should eql(@card.href)
105
48
  end
106
49
 
107
- describe "#delete card", :vcr do
108
- before do
109
- @card_2 = @marketplace.create_card(
110
- :card_number => "4111111111111111",
111
- :expiration_month => "12",
112
- :expiration_year => "2015"
113
- ).save
114
- @card_2.unstore
115
- end
116
- it "Should throw 404 on deleted card" do
117
- expect{
118
- Balanced::Card.find(@card_2.uri)
119
- }.to raise_error
120
- end
121
- end
50
+ end
122
51
 
123
- describe "#delete bank account", :vcr do
124
- before do
125
- @bank_account_2 = @marketplace.create_bank_account(
126
- :account_number => "0987654321",
127
- :bank_code => "321174851",
128
- :name => "Timmy T. McTimmerson",
129
- :type => "checking"
130
- )
131
- @bank_account_2.unstore
132
- end
133
- it "Should throw 404 on deleted card" do
134
- expect {
135
- Balanced::BankAccount.find(@bank_account_2.uri)
136
- }.to raise_error
137
- end
52
+ describe '#add_destination', :vcr do
53
+ before do
54
+ @bank_account = Balanced::BankAccount.new(
55
+ :account_number => '1234567980',
56
+ :routing_number => '111000025',
57
+ :name => 'Jack Q Merchant'
58
+ ).save
59
+ @bank_account.associate_to_customer(@customer)
138
60
  end
139
61
 
140
- describe "#add_bank_account using tokenized object", :vcr do
141
- before do
142
- @customer = @marketplace.create_customer
143
- @bank_account = @marketplace.create_bank_account(
144
- :account_number => "1234567980",
145
- :bank_code => "321174811",
146
- :name => "Jack Q Merchant"
147
- )
148
- @customer.add_bank_account(@bank_account)
149
- @customer_bank_account_id = @customer.bank_accounts.first.id
150
- @bank_account_id = @bank_account.id
151
- end
152
- it "should add a bank account to a customer" do
153
- @customer.bank_accounts.size.should eq(1)
154
- end
155
- it "bank account added should be the same bank account" do
156
- @customer_bank_account_id = @bank_account_id
157
- end
62
+ it 'assumes the bank account is associated', :vcr do
63
+ @customer.bank_accounts.total.should eql(1)
158
64
  end
159
65
 
160
- describe "#add_bank_account using uri", :vcr do
161
- before do
162
- @customer = @marketplace.create_customer
163
- @bank_account = @marketplace.create_bank_account(
164
- :account_number => "1234567980",
165
- :bank_code => "321174811",
166
- :name => "Jack Q Merchant"
167
- )
168
- @customer.add_bank_account(@bank_account.uri)
169
- @customer_bank_account_id = @customer.bank_accounts.first.id
170
- @bank_account_id = @bank_account.id
171
- end
172
- it "should add a bank account to a customer" do
173
- @customer.bank_accounts.size.should eq(1)
174
- end
175
- it "bank account added should be the same bank account" do
176
- @customer_bank_account_id = @bank_account_id
177
- end
66
+ it 'should make the bank account a destination', :vcr do
67
+ @customer.add_destination(@bank_account)
68
+ @customer.destination.should be_instance_of Balanced::BankAccount
69
+ @customer.destination.href.should eql(@bank_account.href)
178
70
  end
179
71
 
180
- describe "#find_by_email", :vcr => { :record => :new_episodes } do
181
- before do
182
- api_key = Balanced::ApiKey.new.save
183
- Balanced.configure api_key.secret
184
- @marketplace = Balanced::Marketplace.new.save
185
- customer = @marketplace.create_customer(
186
- :name => "Bill",
187
- :email => "bill@bill.com",
188
- :business_name => "Bill Inc.",
189
- :ssn_last4 => "1234",
190
- :address => {
191
- :line1 => "1234 1st Street",
192
- :city => "San Francisco",
193
- :state => "CA"
194
- }
195
- ).save
196
- end
72
+ end
197
73
 
198
- context "email address is in system", :vcr => { :record => :new_episodes } do
199
- it "should return customer object" do
200
- Balanced::Customer.find_by_email("bill@bill.com").should be_instance_of Balanced::Customer
201
- end
202
- end
74
+ describe '#find_by_email', :vcr do
203
75
 
204
- context "email address does not exist", :vcr => { :record => :new_episodes } do
205
- it "should return nil" do
206
- Balanced::Customer.find_by_email("foo@bar.com").should be_nil
207
- end
76
+ context 'email address is in system', :vcr do
77
+ it 'should return customer object' do
78
+ bill = Balanced::Customer.find_by_email('bill@bill.com')
79
+ bill.should be_instance_of Balanced::Customer
208
80
  end
209
81
  end
210
82
 
211
- describe "#debit" do
212
- before do
213
- @customer = @marketplace.create_customer
214
- @card = @marketplace.create_card(
215
- :card_number => "4111111111111111",
216
- :expiration_month => "12",
217
- :expiration_year => "2015"
218
- ).save
219
- @customer.add_card(@card)
220
- @customer.debit :amount => 1000
221
- end
222
- context "customer debit should be added" do
223
- subject {@customer.debits.first}
224
- its(:amount) { should eq 1000}
83
+ context 'email address does not exist', :vcr do
84
+ it 'should return nil' do
85
+ Balanced::Customer.find_by_email('foo@bar.com').should be_nil
225
86
  end
226
87
  end
88
+ end
227
89
 
228
- describe "compound credit and debit", :vcr do
229
- before do
230
- @customer = @marketplace.create_customer
231
- @bank_account = @marketplace.create_bank_account(
232
- :account_number => "1234567980",
233
- :bank_code => "321174811",
234
- :name => "Jack Q Merchant"
235
- )
236
- @card = Balanced::Card.new(
237
- :card_number => "4111111111111111",
238
- :expiration_month => "12",
239
- :expiration_year => "2015"
240
- ).save
241
- @customer.add_card(@card)
242
- @customer.add_bank_account(@bank_account)
243
- @customer.debit :amount => 1250
244
- end
245
-
246
- context "args passed by name via options hash" do
247
- subject {
248
- @customer.credit(
249
- :amount => 1250,
250
- :description => "description",
251
- :meta => {}
252
- )
253
- }
254
-
255
- its(:amount) { should == 1250 }
256
- its(:meta) { should == {} }
257
- its(:description) { should == "description" }
258
- end
90
+ describe 'update' do
91
+ before do
92
+ @customer = Balanced::Customer.new(
93
+ :name => 'Bill',
94
+ :email => 'bill@bill.com',
95
+ :business_name => 'Bill Inc.'
96
+ ).save
259
97
  end
260
98
 
261
- describe "#active_card", :vcr do
262
- before do
263
- @customer = @marketplace.create_customer
264
- @card = @marketplace.create_card(
265
- :card_number => "4111111111111111",
266
- :expiration_month => "12",
267
- :expiration_year => "2015"
268
- ).save
269
- @customer.add_card(@card)
270
- end
271
- it "should display the most recently added valid card" do
272
- @customer.active_card.should_not be_nil
273
- end
99
+ subject do
100
+ @customer
274
101
  end
275
102
 
276
- describe "#active_bank_account", :vcr do
277
- before do
278
- @customer = @marketplace.create_customer
279
- @bank_account = @marketplace.create_bank_account(
280
- :account_number => "1234567980",
281
- :bank_code => "321174811",
282
- :name => "Jack Q Merchant"
283
- )
284
- @customer.add_bank_account(@bank_account)
285
- end
286
- it "should display the most recently added valid card" do
287
- @customer.active_bank_account.should_not be_nil
288
- end
289
- end
103
+ its(:name) { should eq 'Bill' }
104
+ its(:merchant_status) { should eq 'no-match' }
290
105
 
291
- describe "find_by_email", :vcr do
292
- before do
293
- @customer = @marketplace.create_customer(
294
- :email => "balanced-ruby-issue-110@example.com"
295
- )
296
- end
106
+ it 'update name' do
107
+ @customer.name = 'William'
108
+ @customer.save
297
109
 
298
- it "should return 401 unauthorized if not authenticated" do
299
- @customer.uri.should_not be_nil
300
- key = Balanced.client.api_key
301
- Balanced.configure(nil)
302
- expect {
303
- Balanced::Customer.find(
304
- :first,
305
- :email => "balanced-ruby-issue-110@example.com")
306
- }.to raise_error Balanced::Unauthorized
307
- Balanced.configure(key)
308
- end
110
+ # Fetch the customer again
111
+ @customer.reload
112
+ @customer.name.should eq 'William'
113
+ end
309
114
 
115
+ it 'can be underwritten' do
116
+ @customer.name = 'Henry Ford'
117
+ @customer.dob_month = 7
118
+ @customer.dob_year = 1963
119
+ @customer.business_name = nil
120
+ @customer.address['postal_code'] = 48120
121
+ @customer.save
122
+
123
+ @customer.name.should eq 'Henry Ford'
124
+ @customer.dob_month.should eql 7
125
+ @customer.dob_year.should eql 1963
126
+ @customer.business_name.should be_nil
127
+ @customer.address['postal_code'].should eql '48120'
128
+ @customer.merchant_status.should eq 'underwritten'
310
129
  end
130
+
311
131
  end
312
132
 
313
133
  end