Sha256: 80c13da875fbae9168f5989a620b64233945f930ac9fcabd20605d081cc9b407
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
module Stripe class ListObject < StripeObject include Enumerable include Stripe::APIOperations::Request def [](k) case k when String, Symbol super else raise ArgumentError.new("You tried to access the #{k.inspect} index, but ListObject types only support String keys. (HINT: List calls return an object with a 'data' (which is the data array). You likely want to call #data[#{k.inspect}])") end end def each(&blk) self.data.each(&blk) end # Returns true if the page object contains no elements. def empty? self.data.empty? end def retrieve(id, opts={}) id, retrieve_params = Util.normalize_id(id) response, opts = request(:get,"#{url}/#{CGI.escape(id)}", retrieve_params, opts) Util.convert_to_stripe_object(response, opts) end def create(params={}, opts={}) response, opts = request(:post, url, params, opts) Util.convert_to_stripe_object(response, opts) end def all(params={}, opts={}) response, opts = request(:get, url, params, opts) Util.convert_to_stripe_object(response, opts) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
stripe-1.28.1 | lib/stripe/list_object.rb |
stripe-1.28.0 | lib/stripe/list_object.rb |