stripe 1.8.5 → 1.8.6

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,3 +1,7 @@
1
+ === 1.8.6 2013-08-13
2
+
3
+ * Add Balance and BalanceTransaction API resources
4
+
1
5
  === 1.8.5 2013-08-12
2
6
 
3
7
  * Add support for unsetting attributes by setting to nil.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.8.5
1
+ 1.8.6
data/lib/stripe.rb CHANGED
@@ -23,6 +23,8 @@ require 'stripe/api_resource'
23
23
  require 'stripe/singleton_api_resource'
24
24
  require 'stripe/list_object'
25
25
  require 'stripe/account'
26
+ require 'stripe/balance'
27
+ require 'stripe/balance_transaction'
26
28
  require 'stripe/customer'
27
29
  require 'stripe/invoice'
28
30
  require 'stripe/invoice_item'
@@ -0,0 +1,4 @@
1
+ module Stripe
2
+ class Balance < SingletonAPIResource
3
+ end
4
+ end
@@ -0,0 +1,9 @@
1
+ module Stripe
2
+ class BalanceTransaction < APIResource
3
+ include Stripe::APIOperations::List
4
+
5
+ def self.url
6
+ '/v1/balance/history'
7
+ end
8
+ end
9
+ end
data/lib/stripe/util.rb CHANGED
@@ -17,6 +17,8 @@ module Stripe
17
17
 
18
18
  def self.object_classes
19
19
  @object_classes ||= {
20
+ 'balance' => Balance,
21
+ 'balance_transaction' => BalanceTransaction,
20
22
  'charge' => Charge,
21
23
  'customer' => Customer,
22
24
  'invoiceitem' => InvoiceItem,
@@ -1,3 +1,3 @@
1
1
  module Stripe
2
- VERSION = '1.8.5'
2
+ VERSION = '1.8.6'
3
3
  end
data/test/test_helper.rb CHANGED
@@ -34,6 +34,42 @@ def test_response(body, code=200)
34
34
  m
35
35
  end
36
36
 
37
+ def test_balance(params={})
38
+ {
39
+ :pending => [
40
+ {:amount => 12345, :currency => "usd"}
41
+ ],
42
+ :available => [
43
+ {:amount => 6789, :currency => "usd"}
44
+ ],
45
+ :livemode => false,
46
+ :object => "balance"
47
+ }.merge(params)
48
+ end
49
+
50
+ def test_balance_transaction(params={})
51
+ {
52
+ :amount => 100,
53
+ :net => 41,
54
+ :currency => "usd",
55
+ :type => "charge",
56
+ :created => 1371945005,
57
+ :available_on => 1372549805,
58
+ :status => "pending",
59
+ :description => "A test balance transaction",
60
+ :fee => 59,
61
+ :object => "balance_transaction"
62
+ }.merge(params)
63
+ end
64
+
65
+ def test_balance_transaction_array
66
+ {
67
+ :data => [test_balance_transaction, test_balance_transaction, test_balance_transaction],
68
+ :object => "list",
69
+ :url => "/v1/balance/history"
70
+ }
71
+ end
72
+
37
73
  def test_customer(params={})
38
74
  {
39
75
  :subscription_history => [],
data/test/test_stripe.rb CHANGED
@@ -351,6 +351,26 @@ class TestStripeRuby < Test::Unit::TestCase
351
351
  end
352
352
  end
353
353
 
354
+ context "balance tests" do
355
+ should "balance should be retrievable" do
356
+ @mock.expects(:get).once.returns(test_response(test_balance))
357
+ b = Stripe::Balance.retrieve
358
+ assert_equal 12345, b.pending.first.amount
359
+ assert_equal 6789, b.available.first.amount
360
+ end
361
+ end
362
+
363
+ context "balance transaction tests" do
364
+ should "balance transactions should be listable" do
365
+ @mock.expects(:get).once.returns(test_response(test_balance_transaction_array))
366
+ bt = Stripe::BalanceTransaction.all
367
+ assert bt.data.kind_of?(Array)
368
+ bt.each do |balance_transaction|
369
+ assert balance_transaction.kind_of?(Stripe::BalanceTransaction)
370
+ end
371
+ end
372
+ end
373
+
354
374
  context "list tests" do
355
375
  should "be able to retrieve full lists given a listobject" do
356
376
  @mock.expects(:get).twice.returns(test_response(test_charge_array))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.5
4
+ version: 1.8.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2013-08-12 00:00:00.000000000 Z
13
+ date: 2013-08-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rest-client
@@ -145,6 +145,8 @@ files:
145
145
  - lib/stripe/api_operations/list.rb
146
146
  - lib/stripe/api_operations/update.rb
147
147
  - lib/stripe/api_resource.rb
148
+ - lib/stripe/balance.rb
149
+ - lib/stripe/balance_transaction.rb
148
150
  - lib/stripe/card.rb
149
151
  - lib/stripe/charge.rb
150
152
  - lib/stripe/coupon.rb