Sha256: 687682b036c8657f02a1fd94918c68227740c1a374489c7a43232ddb6b29215f

Contents?: true

Size: 1.35 KB

Versions: 18

Compression:

Stored size: 1.35 KB

Contents

# frozen_string_literal: true

module IronBank
  module Resources
    # A Zuora account is used for billing purposes: it holds many subscriptions,
    # has many contacts (but only one bill to and one sold to contact), can have
    # a default payment method, hence auto-pay can be activated for this account
    # or not, is billed invoices and can pay them using an electronic payment
    # method (usually a credit card, but PayPal is also accepted by Zuora).
    #
    class Account < Resource
      with_schema

      # Contacts
      with_one :bill_to, resource_name: "Contact"
      with_one :sold_to, resource_name: "Contact"
      with_many :contacts

      # Subscriptions
      with_many :subscriptions
      with_many :active_subscriptions,
                resource_name: "Subscription",
                conditions:    { status: "Active" }

      # Invoices
      with_many :invoices

      # Payment Methods
      with_one :default_payment_method, resource_name: "PaymentMethod"
      with_many :payment_methods

      # Payments
      with_many :payments

      # Usages
      with_many :usages

      # Parent
      with_one :parent, resource_name: "Account"

      # Communication Profile
      with_one :communication_profile

      def ultimate_parent
        root if parent
      end

      def root
        parent ? parent.root : self
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
iron_bank-5.4.1 lib/iron_bank/resources/account.rb
iron_bank-5.4.0 lib/iron_bank/resources/account.rb
iron_bank-5.3.2 lib/iron_bank/resources/account.rb
iron_bank-5.3.0 lib/iron_bank/resources/account.rb
iron_bank-5.2.6 lib/iron_bank/resources/account.rb
iron_bank-5.2.4 lib/iron_bank/resources/account.rb
iron_bank-5.2.3 lib/iron_bank/resources/account.rb
iron_bank-5.2.0 lib/iron_bank/resources/account.rb
iron_bank-5.1.1 lib/iron_bank/resources/account.rb
iron_bank-5.1.0 lib/iron_bank/resources/account.rb
iron_bank-4.4.3 lib/iron_bank/resources/account.rb
iron_bank-5.0.1 lib/iron_bank/resources/account.rb
iron_bank-5.0.0 lib/iron_bank/resources/account.rb
iron_bank-4.4.1 lib/iron_bank/resources/account.rb
iron_bank-4.4.0 lib/iron_bank/resources/account.rb
iron_bank-4.3.1 lib/iron_bank/resources/account.rb
iron_bank-4.3.0 lib/iron_bank/resources/account.rb
iron_bank-4.2.0 lib/iron_bank/resources/account.rb