Brandur 42ea34b969 Pagination
Usage on a top-level collection:

```
Stripe::Customer.list.auto_paging_each do |customer|
  puts customer
end
```

Usage on a subcollection:

``` ruby
customer.invoices.auto_paging_each do |invoice|
  puts invoice
end
```

We've also renamed `#all` to `#list` to prevent confusion ("all" implies
that all resources are being returned, and in Stripe's paginated API
this was not the case). An alias has been provided for backward API
compatibility.

Fixes #167.

Replaces #211 and #248.
2015-10-05 12:15:09 -07:00

22 lines
735 B
Ruby

module Stripe
class Card < APIResource
include Stripe::APIOperations::Update
include Stripe::APIOperations::Delete
extend Stripe::APIOperations::List
def url
if respond_to?(:recipient)
"#{Recipient.url}/#{CGI.escape(recipient)}/cards/#{CGI.escape(id)}"
elsif respond_to?(:customer)
"#{Customer.url}/#{CGI.escape(customer)}/sources/#{CGI.escape(id)}"
elsif respond_to?(:account)
"#{Account.url}/#{CGI.escape(account)}/external_accounts/#{CGI.escape(id)}"
end
end
def self.retrieve(id, opts=nil)
raise NotImplementedError.new("Cards cannot be retrieved without a customer ID. Retrieve a card using customer.sources.retrieve('card_id')")
end
end
end