Permalink
Browse files

Add Account API resource.

  • Loading branch information...
1 parent cf7054c commit 478ff80ac401d03077b1758fa8c1fbc0eb070bdc @amfeng amfeng committed Aug 16, 2012
Showing with 52 additions and 8 deletions.
  1. +3 −3 Gemfile.lock
  2. +4 −0 History.txt
  3. +1 −1 VERSION
  4. +2 −0 lib/stripe.rb
  5. +4 −0 lib/stripe/account.rb
  6. +6 −3 lib/stripe/api_resource.rb
  7. +20 −0 lib/stripe/singleton_api_resource.rb
  8. +1 −1 lib/stripe/version.rb
  9. +11 −0 test/test_stripe.rb
View
6 Gemfile.lock
@@ -1,18 +1,18 @@
PATH
remote: .
specs:
- stripe (1.7.0)
+ stripe (1.7.1)
multi_json (~> 1.1)
rest-client (~> 1.4)
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
4 History.txt
@@ -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
2 VERSION
@@ -1 +1 @@
-1.7.0
+1.7.1
View
2 lib/stripe.rb
@@ -23,6 +23,8 @@
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'
View
4 lib/stripe/account.rb
@@ -0,0 +1,4 @@
+module Stripe
+ class Account < SingletonAPIResource
+ end
+end
View
9 lib/stripe/api_resource.rb
@@ -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
20 lib/stripe/singleton_api_resource.rb
@@ -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
2 lib/stripe/version.rb
@@ -1,3 +1,3 @@
module Stripe
- VERSION = '1.7.0'
+ VERSION = '1.7.1'
end
View
11 test/test_stripe.rb
@@ -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

0 comments on commit 478ff80

Please sign in to comment.