Sha256: 4df79e17a331b0008afa8f71806a667de6f94f73d9635e26b9bc90e23b4c80da

Contents?: true

Size: 815 Bytes

Versions: 1

Compression:

Stored size: 815 Bytes

Contents

module Gemgento

  # @author Gemgento LLC
  class RecurringProfile < ActiveRecord::Base

    belongs_to :user
    belongs_to :store
    has_and_belongs_to_many :orders, class_name: 'Order', join_table: 'gemgento_orders_recurring_profiles'

    validates :magento_id, uniqueness: true, presence: true

    serialize :order_info, Hash
    serialize :line_item_info, Hash
    serialize :billing_address_info, Hash
    serialize :shipping_address_info, Hash
    serialize :profile_vendor_info, Hash
    serialize :additional_info, Hash

    scope :active, -> { where(state: 'active') }
    scope :suspended, -> { where(state: 'suspended') }
    scope :canceled, -> { where(state: 'canceled') }

    def change_state(state)
      API::SOAP::Sales::RecurringProfile.update_state(self.magento_id, state)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gemgento-2.8.0 app/models/gemgento/recurring_profile.rb