Sha256: ce5921b20a0d6b9cb44a7ff0b78b64ae555a81aae975f4a8ef6e87691ffb2df0

Contents?: true

Size: 867 Bytes

Versions: 8

Compression:

Stored size: 867 Bytes

Contents

# frozen_string_literal: true
module ShopifyAPI
  class RecurringApplicationCharge < Base
    undef_method :test

    class << self
      def current
        (all || []).find { |c| c.status == 'active' }
      end

      [:pending, :cancelled, :accepted, :declined].each do |status|
        define_method(status) { (all || []).select { |c| c.status == status.to_s } }
      end
    end

    def usage_charges
      UsageCharge.find(:all, params: { recurring_application_charge_id: id })
    end

    def cancel
      load_attributes_from_response(self.destroy)
    end

    def activate
      load_attributes_from_response(post(:activate))
    end

    def customize(customize_recurring_app_charge_params = {})
      load_attributes_from_response(
        put(:customize, recurring_application_charge: customize_recurring_app_charge_params)
      )
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
ruby_shopify_api-1.2.0 lib/ruby_shopify_api/resources/recurring_application_charge.rb
ruby_shopify_api-1.1.0 lib/shopify_api/resources/recurring_application_charge.rb
ruby_shopify_api-1.0.0 lib/shopify_api/resources/recurring_application_charge.rb
shopify_api-9.5.1 lib/shopify_api/resources/recurring_application_charge.rb
shopify_api-9.5 lib/shopify_api/resources/recurring_application_charge.rb
shopify_api-9.4.1 lib/shopify_api/resources/recurring_application_charge.rb
shopify_api-9.4.0 lib/shopify_api/resources/recurring_application_charge.rb
shopify_api-9.3.0 lib/shopify_api/resources/recurring_application_charge.rb