Add Account API resource.

This commit is contained in:
Amber Feng 2012-08-16 12:25:15 -07:00
parent cf7054c430
commit 478ff80ac4
9 changed files with 52 additions and 8 deletions

View File

@ -1,7 +1,7 @@
PATH
remote: .
specs:
stripe (1.7.0)
stripe (1.7.1)
multi_json (~> 1.1)
rest-client (~> 1.4)
@ -9,10 +9,10 @@ GEM
remote: https://rubygems.org/
specs:
metaclass (0.0.1)
mime-types (1.18)
mime-types (1.19)
mocha (0.11.3)
metaclass (~> 0.0.1)
multi_json (1.3.4)
multi_json (1.3.6)
rake (0.9.2.2)
rest-client (1.6.7)
mime-types (>= 1.16)

View File

@ -1,3 +1,7 @@
=== 1.7.1 2012-08-15
* Add new Account API resource
=== 1.7.0 2012-05-17
* 3 major enhancements:

View File

@ -1 +1 @@
1.7.0
1.7.1

View File

@ -23,6 +23,8 @@ require 'stripe/util'
require 'stripe/json'
require 'stripe/stripe_object'
require 'stripe/api_resource'
require 'stripe/singleton_api_resource'
require 'stripe/account'
require 'stripe/customer'
require 'stripe/invoice'
require 'stripe/invoice_item'

4
lib/stripe/account.rb Normal file
View File

@ -0,0 +1,4 @@
module Stripe
class Account < SingletonAPIResource
end
end

View File

@ -1,11 +1,14 @@
module Stripe
class APIResource < StripeObject
def self.url
def self.class_name
self.name.split('::')[-1]
end
def self.url()
if self == APIResource
raise NotImplementedError.new('APIResource is an abstract class. You should perform actions on its subclasses (Charge, Customer, etc.)')
end
shortname = self.name.split('::')[-1]
"/#{CGI.escape(shortname.downcase)}s"
"/#{CGI.escape(class_name.downcase)}s"
end
def url

View File

@ -0,0 +1,20 @@
module Stripe
class SingletonAPIResource < APIResource
def self.url()
if self == SingletonAPIResource
raise NotImplementedError.new('SingletonAPIResource is an abstract class. You should perform actions on its subclasses (Account, etc.)')
end
"/#{CGI.escape(class_name.downcase)}"
end
def url
self.class.url
end
def self.retrieve(api_key=nil)
instance = self.new(nil, api_key)
instance.refresh
instance
end
end
end

View File

@ -1,3 +1,3 @@
module Stripe
VERSION = '1.7.0'
VERSION = '1.7.1'
end

View File

@ -263,6 +263,17 @@ class TestStripeRuby < Test::Unit::TestCase
assert c[0].card.kind_of?(Stripe::StripeObject) && c[0].card.object == 'card'
end
context "account tests" do
should "account should be retrievable" do
resp = {:email => "test+bindings@stripe.com", :charge_enabled => false, :details_submitted => false}
@mock.expects(:get).once.returns(test_response(resp))
a = Stripe::Account.retrieve
assert_equal "test+bindings@stripe.com", a.email
assert !a.charge_enabled
assert !a.details_submitted
end
end
context "charge tests" do
should "charges should be listable" do