mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-11-22 00:05:58 -05:00
Added BalanceTransaction list resource.
Added Balance singleton resource.
This commit is contained in:
parent
56d8b910f7
commit
0851f2a7fd
@ -23,6 +23,8 @@ require 'stripe/api_resource'
|
||||
require 'stripe/singleton_api_resource'
|
||||
require 'stripe/list_object'
|
||||
require 'stripe/account'
|
||||
require 'stripe/balance'
|
||||
require 'stripe/balance_transaction'
|
||||
require 'stripe/customer'
|
||||
require 'stripe/invoice'
|
||||
require 'stripe/invoice_item'
|
||||
|
||||
4
lib/stripe/balance.rb
Normal file
4
lib/stripe/balance.rb
Normal file
@ -0,0 +1,4 @@
|
||||
module Stripe
|
||||
class Balance < SingletonAPIResource
|
||||
end
|
||||
end
|
||||
9
lib/stripe/balance_transaction.rb
Normal file
9
lib/stripe/balance_transaction.rb
Normal file
@ -0,0 +1,9 @@
|
||||
module Stripe
|
||||
class BalanceTransaction < APIResource
|
||||
include Stripe::APIOperations::List
|
||||
|
||||
def self.url
|
||||
'/v1/balance/history'
|
||||
end
|
||||
end
|
||||
end
|
||||
@ -17,6 +17,8 @@ module Stripe
|
||||
|
||||
def self.object_classes
|
||||
@object_classes ||= {
|
||||
'balance' => Balance,
|
||||
'balance_transaction' => BalanceTransaction,
|
||||
'charge' => Charge,
|
||||
'customer' => Customer,
|
||||
'invoiceitem' => InvoiceItem,
|
||||
|
||||
@ -34,6 +34,42 @@ def test_response(body, code=200)
|
||||
m
|
||||
end
|
||||
|
||||
def test_balance(params={})
|
||||
{
|
||||
:pending => [
|
||||
{:amount => 12345, :currency => "usd"}
|
||||
],
|
||||
:available => [
|
||||
{:amount => 6789, :currency => "usd"}
|
||||
],
|
||||
:livemode => false,
|
||||
:object => "balance"
|
||||
}.merge(params)
|
||||
end
|
||||
|
||||
def test_balance_transaction(params={})
|
||||
{
|
||||
:amount => 100,
|
||||
:net => 41,
|
||||
:currency => "usd",
|
||||
:type => "charge",
|
||||
:created => 1371945005,
|
||||
:available_on => 1372549805,
|
||||
:status => "pending",
|
||||
:description => "A test balance transaction",
|
||||
:fee => 59,
|
||||
:object => "balance_transaction"
|
||||
}.merge(params)
|
||||
end
|
||||
|
||||
def test_balance_transaction_array
|
||||
{
|
||||
:data => [test_balance_transaction, test_balance_transaction, test_balance_transaction],
|
||||
:object => "list",
|
||||
:url => "/v1/balance/history"
|
||||
}
|
||||
end
|
||||
|
||||
def test_customer(params={})
|
||||
{
|
||||
:subscription_history => [],
|
||||
|
||||
@ -351,6 +351,26 @@ class TestStripeRuby < Test::Unit::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
context "balance tests" do
|
||||
should "balance should be retrievable" do
|
||||
@mock.expects(:get).once.returns(test_response(test_balance))
|
||||
b = Stripe::Balance.retrieve
|
||||
assert_equal 12345, b.pending.first.amount
|
||||
assert_equal 6789, b.available.first.amount
|
||||
end
|
||||
end
|
||||
|
||||
context "balance transaction tests" do
|
||||
should "balance transactions should be listable" do
|
||||
@mock.expects(:get).once.returns(test_response(test_balance_transaction_array))
|
||||
bt = Stripe::BalanceTransaction.all
|
||||
assert bt.data.kind_of?(Array)
|
||||
bt.each do |balance_transaction|
|
||||
assert balance_transaction.kind_of?(Stripe::BalanceTransaction)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
context "list tests" do
|
||||
should "be able to retrieve full lists given a listobject" do
|
||||
@mock.expects(:get).twice.returns(test_response(test_charge_array))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user