mirror of
https://github.com/stripe/stripe-ruby.git
synced 2025-11-11 00:01:37 -05:00
Merge pull request #394 from shekibobo/feature/resource-url
Fix ApiResource resource URL clashing with user-defined URL properties. Fixes #393.
This commit is contained in:
commit
f612aa9057
@ -5,7 +5,7 @@ module Stripe
|
|||||||
extend Stripe::APIOperations::List
|
extend Stripe::APIOperations::List
|
||||||
include Stripe::APIOperations::Update
|
include Stripe::APIOperations::Update
|
||||||
|
|
||||||
def url
|
def resource_url
|
||||||
if self['id']
|
if self['id']
|
||||||
super
|
super
|
||||||
else
|
else
|
||||||
@ -25,7 +25,6 @@ module Stripe
|
|||||||
opts = id
|
opts = id
|
||||||
id = nil
|
id = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
super(id, opts)
|
super(id, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ module Stripe
|
|||||||
module APIOperations
|
module APIOperations
|
||||||
module Create
|
module Create
|
||||||
def create(params={}, opts={})
|
def create(params={}, opts={})
|
||||||
response, opts = request(:post, url, params, opts)
|
response, opts = request(:post, resource_url, params, opts)
|
||||||
Util.convert_to_stripe_object(response, opts)
|
Util.convert_to_stripe_object(response, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3,7 +3,7 @@ module Stripe
|
|||||||
module Delete
|
module Delete
|
||||||
def delete(params={}, opts={})
|
def delete(params={}, opts={})
|
||||||
opts = Util.normalize_opts(opts)
|
opts = Util.normalize_opts(opts)
|
||||||
response, opts = request(:delete, url, params, opts)
|
response, opts = request(:delete, resource_url, params, opts)
|
||||||
initialize_from(response, opts)
|
initialize_from(response, opts)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -5,7 +5,7 @@ module Stripe
|
|||||||
opts = Util.normalize_opts(opts)
|
opts = Util.normalize_opts(opts)
|
||||||
opts = @opts.merge(opts) if @opts
|
opts = @opts.merge(opts) if @opts
|
||||||
|
|
||||||
response, opts = request(:get, url, filters, opts)
|
response, opts = request(:get, resource_url, filters, opts)
|
||||||
obj = ListObject.construct_from(response, opts)
|
obj = ListObject.construct_from(response, opts)
|
||||||
|
|
||||||
# set filters so that we can fetch the same limit, expansions, and
|
# set filters so that we can fetch the same limit, expansions, and
|
||||||
|
|||||||
@ -14,9 +14,6 @@ module Stripe
|
|||||||
# in the list, it overrides the update URL used for the create or
|
# in the list, it overrides the update URL used for the create or
|
||||||
# update.
|
# update.
|
||||||
def save(params={})
|
def save(params={})
|
||||||
# Let the caller override the URL but avoid serializing it.
|
|
||||||
req_url = params.delete(:req_url) || save_url
|
|
||||||
|
|
||||||
# We started unintentionally (sort of) allowing attributes sent to
|
# We started unintentionally (sort of) allowing attributes sent to
|
||||||
# +save+ to override values used during the update. So as not to break
|
# +save+ to override values used during the update. So as not to break
|
||||||
# the API, this makes that official here.
|
# the API, this makes that official here.
|
||||||
@ -31,7 +28,7 @@ module Stripe
|
|||||||
# generated a uri for this object with an identifier baked in
|
# generated a uri for this object with an identifier baked in
|
||||||
values.delete(:id)
|
values.delete(:id)
|
||||||
|
|
||||||
response, opts = request(:post, req_url, values)
|
response, opts = request(:post, save_url, values)
|
||||||
initialize_from(response, opts)
|
initialize_from(response, opts)
|
||||||
|
|
||||||
self
|
self
|
||||||
@ -47,9 +44,9 @@ module Stripe
|
|||||||
# resource. Otherwise, generate a URL based on the object's identifier
|
# resource. Otherwise, generate a URL based on the object's identifier
|
||||||
# for a normal update.
|
# for a normal update.
|
||||||
if self[:id] == nil && self.class.respond_to?(:create)
|
if self[:id] == nil && self.class.respond_to?(:create)
|
||||||
self.class.url
|
self.class.resource_url
|
||||||
else
|
else
|
||||||
url
|
resource_url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -6,22 +6,22 @@ module Stripe
|
|||||||
self.name.split('::')[-1]
|
self.name.split('::')[-1]
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.url
|
def self.resource_url
|
||||||
if self == APIResource
|
if self == APIResource
|
||||||
raise NotImplementedError.new('APIResource is an abstract class. You should perform actions on its subclasses (Charge, Customer, etc.)')
|
raise NotImplementedError.new('APIResource is an abstract class. You should perform actions on its subclasses (Charge, Customer, etc.)')
|
||||||
end
|
end
|
||||||
"/v1/#{CGI.escape(class_name.downcase)}s"
|
"/v1/#{CGI.escape(class_name.downcase)}s"
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def resource_url
|
||||||
unless id = self['id']
|
unless id = self['id']
|
||||||
raise InvalidRequestError.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{id.inspect}", 'id')
|
raise InvalidRequestError.new("Could not determine which URL to request: #{self.class} instance has invalid ID: #{id.inspect}", 'id')
|
||||||
end
|
end
|
||||||
"#{self.class.url}/#{CGI.escape(id)}"
|
"#{self.class.resource_url}/#{CGI.escape(id)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def refresh
|
def refresh
|
||||||
response, opts = request(:get, url, @retrieve_params)
|
response, opts = request(:get, resource_url, @retrieve_params)
|
||||||
initialize_from(response, opts)
|
initialize_from(response, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ module Stripe
|
|||||||
class ApplicationFee < APIResource
|
class ApplicationFee < APIResource
|
||||||
extend Stripe::APIOperations::List
|
extend Stripe::APIOperations::List
|
||||||
|
|
||||||
def self.url
|
def self.resource_url
|
||||||
'/v1/application_fees'
|
'/v1/application_fees'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -3,8 +3,8 @@ module Stripe
|
|||||||
include Stripe::APIOperations::Update
|
include Stripe::APIOperations::Update
|
||||||
extend Stripe::APIOperations::List
|
extend Stripe::APIOperations::List
|
||||||
|
|
||||||
def url
|
def resource_url
|
||||||
"#{ApplicationFee.url}/#{CGI.escape(fee)}/refunds/#{CGI.escape(id)}"
|
"#{ApplicationFee.resource_url}/#{CGI.escape(fee)}/refunds/#{CGI.escape(id)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.retrieve(id, api_key=nil)
|
def self.retrieve(id, api_key=nil)
|
||||||
|
|||||||
@ -2,7 +2,7 @@ module Stripe
|
|||||||
class BalanceTransaction < APIResource
|
class BalanceTransaction < APIResource
|
||||||
extend Stripe::APIOperations::List
|
extend Stripe::APIOperations::List
|
||||||
|
|
||||||
def self.url
|
def self.resource_url
|
||||||
'/v1/balance/history'
|
'/v1/balance/history'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -5,15 +5,15 @@ module Stripe
|
|||||||
extend Stripe::APIOperations::List
|
extend Stripe::APIOperations::List
|
||||||
|
|
||||||
def verify(params={}, opts={})
|
def verify(params={}, opts={})
|
||||||
response, opts = request(:post, url + '/verify', params, opts)
|
response, opts = request(:post, resource_url + '/verify', params, opts)
|
||||||
initialize_from(response, opts)
|
initialize_from(response, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def resource_url
|
||||||
if respond_to?(:customer)
|
if respond_to?(:customer)
|
||||||
"#{Customer.url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
|
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
|
||||||
elsif respond_to?(:account)
|
elsif respond_to?(:account)
|
||||||
"#{Account.url}/#{CGI.escape(account)}/external_accounts/#{CGI.escape(id)}"
|
"#{Account.resource_url}/#{CGI.escape(account)}/external_accounts/#{CGI.escape(id)}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -5,15 +5,15 @@ module Stripe
|
|||||||
include Stripe::APIOperations::Delete
|
include Stripe::APIOperations::Delete
|
||||||
extend Stripe::APIOperations::List
|
extend Stripe::APIOperations::List
|
||||||
|
|
||||||
def self.url
|
def self.resource_url
|
||||||
"/v1/bitcoin/receivers"
|
"/v1/bitcoin/receivers"
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def resource_url
|
||||||
if respond_to?(:customer) && !self.customer.nil?
|
if respond_to?(:customer) && !self.customer.nil?
|
||||||
"#{Customer.url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
|
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
|
||||||
else
|
else
|
||||||
"#{self.class.url}/#{CGI.escape(id)}"
|
"#{self.class.resource_url}/#{CGI.escape(id)}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -2,7 +2,7 @@ module Stripe
|
|||||||
class BitcoinTransaction < APIResource
|
class BitcoinTransaction < APIResource
|
||||||
extend Stripe::APIOperations::List
|
extend Stripe::APIOperations::List
|
||||||
|
|
||||||
def self.url
|
def self.resource_url
|
||||||
"/v1/bitcoin/transactions"
|
"/v1/bitcoin/transactions"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,13 +4,13 @@ module Stripe
|
|||||||
include Stripe::APIOperations::Delete
|
include Stripe::APIOperations::Delete
|
||||||
extend Stripe::APIOperations::List
|
extend Stripe::APIOperations::List
|
||||||
|
|
||||||
def url
|
def resource_url
|
||||||
if respond_to?(:recipient)
|
if respond_to?(:recipient)
|
||||||
"#{Recipient.url}/#{CGI.escape(recipient)}/cards/#{CGI.escape(id)}"
|
"#{Recipient.resource_url}/#{CGI.escape(recipient)}/cards/#{CGI.escape(id)}"
|
||||||
elsif respond_to?(:customer)
|
elsif respond_to?(:customer)
|
||||||
"#{Customer.url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
|
"#{Customer.resource_url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
|
||||||
elsif respond_to?(:account)
|
elsif respond_to?(:account)
|
||||||
"#{Account.url}/#{CGI.escape(account)}/external_accounts/#{CGI.escape(id)}"
|
"#{Account.resource_url}/#{CGI.escape(account)}/external_accounts/#{CGI.escape(id)}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -45,7 +45,7 @@ module Stripe
|
|||||||
params = {
|
params = {
|
||||||
:fraud_details => { :user_report => 'fraudulent' }
|
:fraud_details => { :user_report => 'fraudulent' }
|
||||||
}
|
}
|
||||||
response, opts = request(:post, url, params)
|
response, opts = request(:post, resource_url, params)
|
||||||
initialize_from(response, opts)
|
initialize_from(response, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -53,28 +53,28 @@ module Stripe
|
|||||||
params = {
|
params = {
|
||||||
:fraud_details => { :user_report => 'safe' }
|
:fraud_details => { :user_report => 'safe' }
|
||||||
}
|
}
|
||||||
response, opts = request(:post, url, params)
|
response, opts = request(:post, resource_url, params)
|
||||||
initialize_from(response, opts)
|
initialize_from(response, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def capture_url
|
def capture_url
|
||||||
url + '/capture'
|
resource_url + '/capture'
|
||||||
end
|
end
|
||||||
|
|
||||||
def dispute_url
|
def dispute_url
|
||||||
url + '/dispute'
|
resource_url + '/dispute'
|
||||||
end
|
end
|
||||||
|
|
||||||
def close_dispute_url
|
def close_dispute_url
|
||||||
url + '/dispute/close'
|
resource_url + '/dispute/close'
|
||||||
end
|
end
|
||||||
|
|
||||||
# Note that this is actually the *old* refund URL and its use is no longer
|
# Note that this is actually the *old* refund URL and its use is no longer
|
||||||
# preferred.
|
# preferred.
|
||||||
def refund_url
|
def refund_url
|
||||||
url + '/refund'
|
resource_url + '/refund'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -2,7 +2,7 @@ module Stripe
|
|||||||
class CountrySpec < APIResource
|
class CountrySpec < APIResource
|
||||||
extend Stripe::APIOperations::List
|
extend Stripe::APIOperations::List
|
||||||
|
|
||||||
def self.url
|
def self.resource_url
|
||||||
'/v1/country_specs'
|
'/v1/country_specs'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -61,15 +61,15 @@ module Stripe
|
|||||||
private
|
private
|
||||||
|
|
||||||
def discount_url
|
def discount_url
|
||||||
url + '/discount'
|
resource_url + '/discount'
|
||||||
end
|
end
|
||||||
|
|
||||||
def subscription_url
|
def subscription_url
|
||||||
url + '/subscription'
|
resource_url + '/subscription'
|
||||||
end
|
end
|
||||||
|
|
||||||
def subscriptions_url
|
def subscriptions_url
|
||||||
url + '/subscriptions'
|
resource_url + '/subscriptions'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -10,7 +10,7 @@ module Stripe
|
|||||||
end
|
end
|
||||||
|
|
||||||
def close_url
|
def close_url
|
||||||
url + '/close'
|
resource_url + '/close'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3,7 +3,7 @@ module Stripe
|
|||||||
extend Stripe::APIOperations::Create
|
extend Stripe::APIOperations::Create
|
||||||
extend Stripe::APIOperations::List
|
extend Stripe::APIOperations::List
|
||||||
|
|
||||||
def self.url
|
def self.resource_url
|
||||||
"/v1/files"
|
"/v1/files"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -17,11 +17,11 @@ module Stripe
|
|||||||
private
|
private
|
||||||
|
|
||||||
def self.upcoming_url
|
def self.upcoming_url
|
||||||
url + '/upcoming'
|
resource_url + '/upcoming'
|
||||||
end
|
end
|
||||||
|
|
||||||
def pay_url
|
def pay_url
|
||||||
url + '/pay'
|
resource_url + '/pay'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -64,7 +64,7 @@ module Stripe
|
|||||||
|
|
||||||
def retrieve(id, opts={})
|
def retrieve(id, opts={})
|
||||||
id, retrieve_params = Util.normalize_id(id)
|
id, retrieve_params = Util.normalize_id(id)
|
||||||
response, opts = request(:get,"#{url}/#{CGI.escape(id)}", retrieve_params, opts)
|
response, opts = request(:get,"#{resource_url}/#{CGI.escape(id)}", retrieve_params, opts)
|
||||||
Util.convert_to_stripe_object(response, opts)
|
Util.convert_to_stripe_object(response, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -12,7 +12,7 @@ module Stripe
|
|||||||
private
|
private
|
||||||
|
|
||||||
def pay_url
|
def pay_url
|
||||||
url + "/pay"
|
resource_url + "/pay"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -4,14 +4,5 @@ module Stripe
|
|||||||
extend Stripe::APIOperations::Create
|
extend Stripe::APIOperations::Create
|
||||||
include Stripe::APIOperations::Update
|
include Stripe::APIOperations::Update
|
||||||
include Stripe::APIOperations::Delete
|
include Stripe::APIOperations::Delete
|
||||||
|
|
||||||
# Keep APIResource#url as `api_url` to avoid letting the external URL
|
|
||||||
# replace the Stripe URL.
|
|
||||||
alias_method :api_url, :url
|
|
||||||
|
|
||||||
# Override Stripe::APIOperations::Update#save to explicitly pass URL.
|
|
||||||
def save
|
|
||||||
super(:req_url => api_url)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -3,8 +3,8 @@ module Stripe
|
|||||||
include Stripe::APIOperations::Update
|
include Stripe::APIOperations::Update
|
||||||
extend Stripe::APIOperations::List
|
extend Stripe::APIOperations::List
|
||||||
|
|
||||||
def url
|
def resource_url
|
||||||
"#{Transfer.url}/#{CGI.escape(transfer)}/reversals/#{CGI.escape(id)}"
|
"#{Transfer.resource_url}/#{CGI.escape(transfer)}/reversals/#{CGI.escape(id)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.retrieve(id, opts={})
|
def self.retrieve(id, opts={})
|
||||||
|
|||||||
@ -1,14 +1,14 @@
|
|||||||
module Stripe
|
module Stripe
|
||||||
class SingletonAPIResource < APIResource
|
class SingletonAPIResource < APIResource
|
||||||
def self.url
|
def self.resource_url
|
||||||
if self == SingletonAPIResource
|
if self == SingletonAPIResource
|
||||||
raise NotImplementedError.new('SingletonAPIResource is an abstract class. You should perform actions on its subclasses (Account, etc.)')
|
raise NotImplementedError.new('SingletonAPIResource is an abstract class. You should perform actions on its subclasses (Account, etc.)')
|
||||||
end
|
end
|
||||||
"/v1/#{CGI.escape(class_name.downcase)}"
|
"/v1/#{CGI.escape(class_name.downcase)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def url
|
def resource_url
|
||||||
self.class.url
|
self.class.resource_url
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.retrieve(opts={})
|
def self.retrieve(opts={})
|
||||||
|
|||||||
@ -3,8 +3,8 @@ module Stripe
|
|||||||
include Stripe::APIOperations::Update
|
include Stripe::APIOperations::Update
|
||||||
include Stripe::APIOperations::Delete
|
include Stripe::APIOperations::Delete
|
||||||
|
|
||||||
def url
|
def resource_url
|
||||||
"#{Customer.url}/#{CGI.escape(customer)}/subscriptions/#{CGI.escape(id)}"
|
"#{Customer.resource_url}/#{CGI.escape(customer)}/subscriptions/#{CGI.escape(id)}"
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.retrieve(id, opts=nil)
|
def self.retrieve(id, opts=nil)
|
||||||
@ -19,7 +19,7 @@ module Stripe
|
|||||||
private
|
private
|
||||||
|
|
||||||
def discount_url
|
def discount_url
|
||||||
url + '/discount'
|
resource_url + '/discount'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -10,7 +10,7 @@ module Stripe
|
|||||||
end
|
end
|
||||||
|
|
||||||
def cancel_url
|
def cancel_url
|
||||||
url + '/cancel'
|
resource_url + '/cancel'
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -121,7 +121,7 @@ module Stripe
|
|||||||
:id => 'acct_1234',
|
:id => 'acct_1234',
|
||||||
:external_accounts => {
|
:external_accounts => {
|
||||||
:object => "list",
|
:object => "list",
|
||||||
:url => "/v1/accounts/acct_1234/external_accounts",
|
:resource_url => "/v1/accounts/acct_1234/external_accounts",
|
||||||
:data => [],
|
:data => [],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,7 +140,7 @@ module Stripe
|
|||||||
:id => 'acct_1234',
|
:id => 'acct_1234',
|
||||||
:external_accounts => {
|
:external_accounts => {
|
||||||
:object => "list",
|
:object => "list",
|
||||||
:url => "/v1/accounts/acct_1234/external_accounts",
|
:resource_url => "/v1/accounts/acct_1234/external_accounts",
|
||||||
:data => [{
|
:data => [{
|
||||||
:id => "ba_1234",
|
:id => "ba_1234",
|
||||||
:object => "bank_account",
|
:object => "bank_account",
|
||||||
|
|||||||
@ -7,7 +7,7 @@ module Stripe
|
|||||||
returns(make_response(country_spec_array))
|
returns(make_response(country_spec_array))
|
||||||
c = Stripe::CountrySpec.list
|
c = Stripe::CountrySpec.list
|
||||||
|
|
||||||
assert_equal('/v1/country_specs', c.url)
|
assert_equal('/v1/country_specs', c.resource_url)
|
||||||
assert_equal('list', c.object)
|
assert_equal('list', c.object)
|
||||||
assert(c.data.kind_of?(Array))
|
assert(c.data.kind_of?(Array))
|
||||||
assert_equal('US', c.data[0].id)
|
assert_equal('US', c.data[0].id)
|
||||||
@ -21,7 +21,7 @@ module Stripe
|
|||||||
returns(make_response(resp))
|
returns(make_response(resp))
|
||||||
s = Stripe::CountrySpec.retrieve('US')
|
s = Stripe::CountrySpec.retrieve('US')
|
||||||
|
|
||||||
assert_equal('/v1/country_specs/US', s.url)
|
assert_equal('/v1/country_specs/US', s.resource_url)
|
||||||
assert_equal('country_spec', s.object)
|
assert_equal('country_spec', s.object)
|
||||||
assert(s.kind_of?(Stripe::CountrySpec))
|
assert(s.kind_of?(Stripe::CountrySpec))
|
||||||
|
|
||||||
|
|||||||
@ -17,14 +17,14 @@ module Stripe
|
|||||||
assert cards[0].kind_of? Stripe::Card
|
assert cards[0].kind_of? Stripe::Card
|
||||||
end
|
end
|
||||||
|
|
||||||
should "customer cards should have the correct url" do
|
should "customer cards should have the correct resource url" do
|
||||||
c = customer
|
c = customer
|
||||||
@mock.expects(:get).once.returns(make_response(make_card(
|
@mock.expects(:get).once.returns(make_response(make_card(
|
||||||
:id => 'test_card',
|
:id => 'test_card',
|
||||||
:customer => 'test_customer'
|
:customer => 'test_customer'
|
||||||
)))
|
)))
|
||||||
card = c.sources.retrieve('card')
|
card = c.sources.retrieve('card')
|
||||||
assert_equal CUSTOMER_CARD_URL, card.url
|
assert_equal CUSTOMER_CARD_URL, card.resource_url
|
||||||
end
|
end
|
||||||
|
|
||||||
should "customer cards should be deletable" do
|
should "customer cards should be deletable" do
|
||||||
|
|||||||
@ -139,10 +139,10 @@ module Stripe
|
|||||||
@mock.expects(:get).twice.returns(make_response(make_charge_array))
|
@mock.expects(:get).twice.returns(make_response(make_charge_array))
|
||||||
c = Stripe::Charge.all
|
c = Stripe::Charge.all
|
||||||
assert c.kind_of?(Stripe::ListObject)
|
assert c.kind_of?(Stripe::ListObject)
|
||||||
assert_equal('/v1/charges', c.url)
|
assert_equal('/v1/charges', c.resource_url)
|
||||||
all = c.all
|
all = c.all
|
||||||
assert all.kind_of?(Stripe::ListObject)
|
assert all.kind_of?(Stripe::ListObject)
|
||||||
assert_equal('/v1/charges', all.url)
|
assert_equal('/v1/charges', all.resource_url)
|
||||||
assert all.data.kind_of?(Array)
|
assert all.data.kind_of?(Array)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -150,7 +150,7 @@ end
|
|||||||
|
|
||||||
# A helper class with a URL that allows us to try out pagination.
|
# A helper class with a URL that allows us to try out pagination.
|
||||||
class TestListObject < Stripe::ListObject
|
class TestListObject < Stripe::ListObject
|
||||||
def url
|
def resource_url
|
||||||
"/things"
|
"/things"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@ -17,14 +17,14 @@ module Stripe
|
|||||||
assert cards[0].kind_of? Stripe::Card
|
assert cards[0].kind_of? Stripe::Card
|
||||||
end
|
end
|
||||||
|
|
||||||
should "recipient cards should have the correct url" do
|
should "recipient cards should have the correct resource url" do
|
||||||
c = recipient
|
c = recipient
|
||||||
@mock.expects(:get).once.returns(make_response(make_card(
|
@mock.expects(:get).once.returns(make_response(make_card(
|
||||||
:id => 'test_card',
|
:id => 'test_card',
|
||||||
:recipient => 'test_recipient'
|
:recipient => 'test_recipient'
|
||||||
)))
|
)))
|
||||||
card = c.cards.retrieve('card')
|
card = c.cards.retrieve('card')
|
||||||
assert_equal RECIPIENT_CARD_URL, card.url
|
assert_equal RECIPIENT_CARD_URL, card.resource_url
|
||||||
end
|
end
|
||||||
|
|
||||||
should "recipient cards should be deletable" do
|
should "recipient cards should be deletable" do
|
||||||
|
|||||||
@ -56,7 +56,7 @@ module Stripe
|
|||||||
{
|
{
|
||||||
:data => [make_balance_transaction, make_balance_transaction, make_balance_transaction],
|
:data => [make_balance_transaction, make_balance_transaction, make_balance_transaction],
|
||||||
:object => "list",
|
:object => "list",
|
||||||
:url => "/v1/balance/history"
|
:resource_url => "/v1/balance/history"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ module Stripe
|
|||||||
{
|
{
|
||||||
:data => [make_application_fee, make_application_fee, make_application_fee],
|
:data => [make_application_fee, make_application_fee, make_application_fee],
|
||||||
:object => 'list',
|
:object => 'list',
|
||||||
:url => '/v1/application_fees'
|
:resource_url => '/v1/application_fees'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ module Stripe
|
|||||||
{
|
{
|
||||||
:data => [make_application_fee_refund, make_application_fee_refund, make_application_fee_refund],
|
:data => [make_application_fee_refund, make_application_fee_refund, make_application_fee_refund],
|
||||||
:object => 'list',
|
:object => 'list',
|
||||||
:url => '/v1/application_fees/' + fee_id + '/refunds'
|
:resource_url => '/v1/application_fees/' + fee_id + '/refunds'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -126,7 +126,7 @@ module Stripe
|
|||||||
{
|
{
|
||||||
:data => [make_customer, make_customer, make_customer],
|
:data => [make_customer, make_customer, make_customer],
|
||||||
:object => 'list',
|
:object => 'list',
|
||||||
:url => '/v1/customers'
|
:resource_url => '/v1/customers'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -160,7 +160,7 @@ module Stripe
|
|||||||
{
|
{
|
||||||
:data => [make_charge, make_charge, make_charge],
|
:data => [make_charge, make_charge, make_charge],
|
||||||
:object => 'list',
|
:object => 'list',
|
||||||
:url => '/v1/charges'
|
:resource_url => '/v1/charges'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -184,7 +184,7 @@ module Stripe
|
|||||||
{
|
{
|
||||||
:data => [make_dispute, make_dispute, make_dispute],
|
:data => [make_dispute, make_dispute, make_dispute],
|
||||||
:object => 'list',
|
:object => 'list',
|
||||||
:url => '/v1/disputes'
|
:resource_url => '/v1/disputes'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ module Stripe
|
|||||||
{
|
{
|
||||||
:data => [make_card, make_card, make_card],
|
:data => [make_card, make_card, make_card],
|
||||||
:object => 'list',
|
:object => 'list',
|
||||||
:url => '/v1/recipients/' + recipient_id + '/cards'
|
:resource_url => '/v1/recipients/' + recipient_id + '/cards'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -200,7 +200,7 @@ module Stripe
|
|||||||
{
|
{
|
||||||
:data => [make_card, make_card, make_card],
|
:data => [make_card, make_card, make_card],
|
||||||
:object => 'list',
|
:object => 'list',
|
||||||
:url => '/v1/customers/' + customer_id + '/sources'
|
:resource_url => '/v1/customers/' + customer_id + '/sources'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -235,7 +235,7 @@ module Stripe
|
|||||||
:created => 1403047735,
|
:created => 1403047735,
|
||||||
:size => 4908,
|
:size => 4908,
|
||||||
:purpose => params[:purpose] || "dispute_evidence",
|
:purpose => params[:purpose] || "dispute_evidence",
|
||||||
:url => nil,
|
:resource_url => nil,
|
||||||
:type => nil,
|
:type => nil,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -244,7 +244,7 @@ module Stripe
|
|||||||
{
|
{
|
||||||
:data => [make_file, make_file, make_file],
|
:data => [make_file, make_file, make_file],
|
||||||
:object => 'list',
|
:object => 'list',
|
||||||
:url => '/v1/files'
|
:resource_url => '/v1/files'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -287,7 +287,7 @@ module Stripe
|
|||||||
{
|
{
|
||||||
:data => [make_subscription, make_subscription, make_subscription],
|
:data => [make_subscription, make_subscription, make_subscription],
|
||||||
:object => 'list',
|
:object => 'list',
|
||||||
:url => '/v1/customers/' + customer_id + '/subscriptions'
|
:resource_url => '/v1/customers/' + customer_id + '/subscriptions'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -297,7 +297,7 @@ module Stripe
|
|||||||
{
|
{
|
||||||
:data => [make_refund(p), make_refund(p), make_refund(p)],
|
:data => [make_refund(p), make_refund(p), make_refund(p)],
|
||||||
:object => 'list',
|
:object => 'list',
|
||||||
:url => charge ? "/v1/charges/#{charge}/refunds" : '/v1/refunds'
|
:resource_url => charge ? "/v1/charges/#{charge}/refunds" : '/v1/refunds'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -305,7 +305,7 @@ module Stripe
|
|||||||
{
|
{
|
||||||
:data => [make_reversal, make_reversal, make_reversal],
|
:data => [make_reversal, make_reversal, make_reversal],
|
||||||
:object => 'list',
|
:object => 'list',
|
||||||
:url => '/v1/transfers/' + transfer_id + '/reversals'
|
:resource_url => '/v1/transfers/' + transfer_id + '/reversals'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -366,7 +366,7 @@ module Stripe
|
|||||||
{
|
{
|
||||||
:data => [make_invoice],
|
:data => [make_invoice],
|
||||||
:object => 'list',
|
:object => 'list',
|
||||||
:url => '/v1/invoices?customer=test_customer'
|
:resource_url => '/v1/invoices?customer=test_customer'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -396,7 +396,7 @@ module Stripe
|
|||||||
{
|
{
|
||||||
:data => [make_recipient, make_recipient, make_recipient],
|
:data => [make_recipient, make_recipient, make_recipient],
|
||||||
:object => 'list',
|
:object => 'list',
|
||||||
:url => '/v1/recipients'
|
:resource_url => '/v1/recipients'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -427,7 +427,7 @@ module Stripe
|
|||||||
{
|
{
|
||||||
:data => [make_transfer, make_transfer, make_transfer],
|
:data => [make_transfer, make_transfer, make_transfer],
|
||||||
:object => 'list',
|
:object => 'list',
|
||||||
:url => '/v1/transfers'
|
:resource_url => '/v1/transfers'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -466,7 +466,7 @@ module Stripe
|
|||||||
{
|
{
|
||||||
:data => [make_bitcoin_receiver, make_bitcoin_receiver, make_bitcoin_receiver],
|
:data => [make_bitcoin_receiver, make_bitcoin_receiver, make_bitcoin_receiver],
|
||||||
:object => 'list',
|
:object => 'list',
|
||||||
:url => '/v1/bitcoin/receivers'
|
:resource_url => '/v1/bitcoin/receivers'
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -485,7 +485,7 @@ module Stripe
|
|||||||
{
|
{
|
||||||
:data => [make_bitcoin_transaction, make_bitcoin_transaction, make_bitcoin_transaction],
|
:data => [make_bitcoin_transaction, make_bitcoin_transaction, make_bitcoin_transaction],
|
||||||
:object => 'list',
|
:object => 'list',
|
||||||
:url => "/v1/bitcoin/receivers/btcrcv_test_receiver/transactions"
|
:resource_url => "/v1/bitcoin/receivers/btcrcv_test_receiver/transactions"
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -567,7 +567,7 @@ module Stripe
|
|||||||
def make_product_array
|
def make_product_array
|
||||||
{
|
{
|
||||||
:object => "list",
|
:object => "list",
|
||||||
:url => "/v1/products",
|
:resource_url => "/v1/products",
|
||||||
:data => [
|
:data => [
|
||||||
make_product,
|
make_product,
|
||||||
make_product,
|
make_product,
|
||||||
@ -602,7 +602,7 @@ module Stripe
|
|||||||
def make_sku_array(product_id, params={})
|
def make_sku_array(product_id, params={})
|
||||||
{
|
{
|
||||||
:object => "list",
|
:object => "list",
|
||||||
:url => "/v1/skus",
|
:resource_url => "/v1/skus",
|
||||||
:data => [
|
:data => [
|
||||||
make_sku(:product => product_id),
|
make_sku(:product => product_id),
|
||||||
make_sku(:product => product_id),
|
make_sku(:product => product_id),
|
||||||
@ -656,7 +656,7 @@ module Stripe
|
|||||||
def make_order_array(params={})
|
def make_order_array(params={})
|
||||||
{
|
{
|
||||||
:object => "list",
|
:object => "list",
|
||||||
:url => "/v1/orders",
|
:resource_url => "/v1/orders",
|
||||||
:data => [
|
:data => [
|
||||||
make_order,
|
make_order,
|
||||||
make_order,
|
make_order,
|
||||||
@ -675,7 +675,7 @@ module Stripe
|
|||||||
def country_spec_array
|
def country_spec_array
|
||||||
{
|
{
|
||||||
:object => "list",
|
:object => "list",
|
||||||
:url => "/v1/country_specs",
|
:resource_url => "/v1/country_specs",
|
||||||
:data => [
|
:data => [
|
||||||
make_country_spec,
|
make_country_spec,
|
||||||
make_country_spec,
|
make_country_spec,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user