Merge pull request #48 from stripe/sp-version

Add API version setting.
This commit is contained in:
spakanati 2013-01-15 12:59:54 -08:00
commit fb29711a4f
4 changed files with 19 additions and 2 deletions

View File

@ -1,3 +1,6 @@
=== 1.7.9 2013-01-15
* Add support for setting a Stripe API version override.
=== 1.7.8 2012-11-21
* Relax the version constraint on multi_json (github issue #44)

View File

@ -1 +1 @@
1.7.8
1.7.9

View File

@ -49,6 +49,7 @@ module Stripe
@@api_key = nil
@@api_base = 'https://api.stripe.com'
@@verify_ssl_certs = true
@@api_version = nil
def self.api_url(url='')
@@api_base + url
@ -78,6 +79,14 @@ module Stripe
@@verify_ssl_certs
end
def self.api_version=(version)
@@api_version = version
end
def self.api_version
@@api_version
end
def self.request(method, url, api_key, params={}, headers={})
api_key ||= @@api_key
raise AuthenticationError.new('No API key provided. (HINT: set your API key using "Stripe.api_key = <API-KEY>". You can generate API keys from the Stripe web interface. See https://stripe.com/api for details, or email support@stripe.com if you have any questions.)') unless api_key
@ -139,6 +148,11 @@ module Stripe
:authorization => "Bearer #{api_key}",
:content_type => 'application/x-www-form-urlencoded'
}.merge(headers)
if self.api_version
headers[:stripe_version] = self.api_version
end
opts = {
:method => method,
:url => url,

View File

@ -1,3 +1,3 @@
module Stripe
VERSION = '1.7.8'
VERSION = '1.7.9'
end