Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add the ability to send options with retrieve requests. #50

Merged
merged 2 commits into from

2 participants

@boucher

No description provided.

lib/stripe.rb
@@ -10,39 +10,39 @@
require 'multi_json'
# Version
-require 'stripe/version'
+require './lib/stripe/version'
@ebroder Owner
ebroder added a note

Are you sure this exact incant actually works with the gem installed (and on both 1.8 and 1.9 for that matter)? My recollection was that requires were always relative to paths on the load list, and that an installed gem has the lib directory (not the root of the gem) in its load path.

Also seems a bit unfortunate to include this in an otherwise unrelated commit

@boucher
boucher added a note
@ebroder Owner
ebroder added a note

It's true that running irb or pry out of the root of the repo on its own won't work, but rake test works out of box, and bundler will add the right directory to your load path for shells (just do bundle exec irb or pry -rbundler/setup)

@boucher
boucher added a note
@ebroder Owner
ebroder added a note

Can you be a bit more specific? This works for me on both 1.8 and 1.9:

evan@caron:~/stripe/stripe-ruby (master)$ bundle exec irb
irb(main):001:0> require 'stripe'
=> true
@boucher
boucher added a note
@ebroder Owner
ebroder added a note

How are you concluding that? My load path suggests that it should be using the local code not the system gem, and loading it seems to confirm:

evan@caron:~/stripe/stripe-ruby (master)$ bundle exec irb
irb(main):001:0> $:
=> ["/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/test-unit-2.5.0/lib", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/shoulda-3.3.2/lib", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/shoulda-matchers-1.4.1/lib", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/shoulda-context-1.0.1/lib", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/rest-client-1.6.7/lib", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/mocha-0.13.0/lib", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/mime-types-1.19/lib", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/metaclass-0.0.1/lib", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/activesupport-3.2.8/lib", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/multi_json-1.3.7/lib", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/i18n-0.6.1/lib", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/rake-10.0.2/lib", "/home/evan/stripe/stripe-ruby/lib", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/gems/1.9.1/gems/bundler-1.2.3/lib", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/site_ruby/1.9.1", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/site_ruby/1.9.1/x86_64-linux", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/site_ruby", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/vendor_ruby/1.9.1", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/vendor_ruby/1.9.1/x86_64-linux", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/vendor_ruby", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/1.9.1", "/home/evan/.rbenv/versions/1.9.3-p374/lib/ruby/1.9.1/x86_64-linux"]
irb(main):002:0> require 'stripe'
=> true
irb(main):003:0> Stripe::Customer.method(:all).source_location
=> ["/home/evan/stripe/stripe-ruby/lib/stripe/api_operations/list.rb", 5]
@boucher
boucher added a note
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@boucher boucher merged commit 1b9f776 into from
@amfeng amfeng deleted the branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 1, 2013
  1. @boucher
Commits on Feb 4, 2013
  1. @boucher
This page is out of date. Refresh to see the latest.
View
5 History.txt
@@ -1,3 +1,8 @@
+=== 1.7.10 2013-02-01
+* Add support for passing options when retrieving Stripe objects
+ e.g., Stripe::Charge.retrieve({id:"foo", expand:["customer"]})
+ Stripe::Charge("foo") is still supported as well
+
=== 1.7.9 2013-01-15
* Add support for setting a Stripe API version override.
View
2  VERSION
@@ -1 +1 @@
-1.7.9
+1.7.10
View
2  lib/stripe/api_resource.rb
@@ -19,7 +19,7 @@ def url
end
def refresh
- response, api_key = Stripe.request(:get, url, @api_key)
+ response, api_key = Stripe.request(:get, url, @api_key, @retrieve_options)
refresh_from(response, api_key)
self
end
View
9 lib/stripe/stripe_object.rb
@@ -11,6 +11,15 @@ class StripeObject
end
def initialize(id=nil, api_key=nil)
+ # parameter overloading!
+ if id.kind_of?(Hash)
+ @retrieve_options = id.dup
+ @retrieve_options.delete(:id)
+ id = id[:id]
+ else
+ @retrieve_options = {}
+ end
+
@api_key = api_key
@values = {}
# This really belongs in APIResource, but not putting it there allows us
View
2  lib/stripe/version.rb
@@ -1,3 +1,3 @@
module Stripe
- VERSION = '1.7.9'
+ VERSION = '1.7.10'
end
Something went wrong with that request. Please try again.