Sha256: b334d8f64fcc7822afa3b736c35b3059a317aa8e960b200345d06e7a7f258940

Contents?: true

Size: 822 Bytes

Versions: 48

Compression:

Stored size: 822 Bytes

Contents

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

48 entries across 48 versions & 1 rubygems

Version Path
shopify_api-4.3.2 lib/shopify_api/resources/recurring_application_charge.rb
shopify_api-4.3.1 lib/shopify_api/resources/recurring_application_charge.rb
shopify_api-4.3.0 lib/shopify_api/resources/recurring_application_charge.rb
shopify_api-4.2.2 lib/shopify_api/resources/recurring_application_charge.rb
shopify_api-4.2.1 lib/shopify_api/resources/recurring_application_charge.rb
shopify_api-4.2.0 lib/shopify_api/resources/recurring_application_charge.rb
shopify_api-4.1.1 lib/shopify_api/resources/recurring_application_charge.rb
shopify_api-4.1.0 lib/shopify_api/resources/recurring_application_charge.rb