Sha256: cd1850ff34ce725f7c5e329ea0b7c7b94757f5f00fc327b8ff2fb5e907b708c4

Contents?: true

Size: 993 Bytes

Versions: 8

Compression:

Stored size: 993 Bytes

Contents

# frozen_string_literal: true

module Stripe
  class Subscription < APIResource
    extend Stripe::APIOperations::List
    extend Stripe::APIOperations::Create
    include Stripe::APIOperations::Save
    include Stripe::APIOperations::Delete

    OBJECT_NAME = "subscription".freeze

    save_nested_resource :source

    def delete_discount
      _, opts = request(:delete, discount_url)
      initialize_from({ discount: nil }, opts, true)
    end

    def self.update(id, params = {}, opts = {})
      params[:items] = Util.array_to_hash(params[:items]) if params[:items]
      super(id, params, opts)
    end

    def self.create(params = {}, opts = {})
      params[:items] = Util.array_to_hash(params[:items]) if params[:items]
      super(params, opts)
    end

    def serialize_params(options = {})
      @values[:items] = Util.array_to_hash(@values[:items]) if @values[:items]
      super
    end

    private

    def discount_url
      resource_url + "/discount"
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
stripe-3.21.0 lib/stripe/subscription.rb
stripe-3.20.0 lib/stripe/subscription.rb
stripe-3.19.0 lib/stripe/subscription.rb
stripe-3.18.0 lib/stripe/subscription.rb
stripe-3.17.2 lib/stripe/subscription.rb
stripe-3.17.1 lib/stripe/subscription.rb
stripe-3.17.0 lib/stripe/subscription.rb
stripe-3.15.0 lib/stripe/subscription.rb