Sha256: dabb604395747fd493f4967dd23f49efe70e20b54c561f1f1ffdfa9626be60a0

Contents?: true

Size: 1.15 KB

Versions: 5

Compression:

Stored size: 1.15 KB

Contents

module Stripe
  class Account < APIResource
    include Stripe::APIOperations::Create
    include Stripe::APIOperations::List
    include Stripe::APIOperations::Update

    def url
      if self['id']
        super
      else
        "/v1/account"
      end
    end

    # @override To make id optional
    def self.retrieve(id=nil, opts={})
      # Account used to be a singleton, where this method's signature was `(opts={})`.
      # For the sake of not breaking folks who pass in an OAuth key in opts, let's lurkily
      # string match for it.
      if opts == {} && id.is_a?(String) && id.start_with?('sk_')
        # `super` properly assumes a String opts is the apiKey and normalizes as expected.
        opts = id
        id = nil
      end
      super(id, opts)
    end

    def deauthorize(client_id, opts={})
      opts = {:api_base => Stripe.connect_base}.merge(Util.normalize_opts(opts))
      response, opts = request(:post, '/oauth/deauthorize', { 'client_id' => client_id, 'stripe_user_id' => self.id }, opts)
      opts.delete(:api_base) # the api_base here is a one-off, don't persist it
      Util.convert_to_stripe_object(response, opts)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
stripe-1.20.3 lib/stripe/account.rb
stripe-1.20.2 lib/stripe/account.rb
stripe-1.20.1 lib/stripe/account.rb
stripe-1.20.0 lib/stripe/account.rb
stripe-1.19.0 lib/stripe/account.rb