Sha256: 23a2db6c3bb192163f717174d49966d3728884afee190569f7571c2de1664dce

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

module Recurly
  class Adjustment < Resource
    # @macro [attach] scope
    #   @scope class
    #   @return [Pager<Adjustment>] a pager that yields +$1+.
    scope :charges,  :type  => 'charge'
    scope :credits,  :type  => 'credit'

    scope :pending,  :state => 'pending'
    scope :invoiced, :state => 'invoiced'

    # @return [Account, nil]
    belongs_to :account
    # @return [Invoice, nil]
    belongs_to :invoice
    # @return [Subscription, nil]
    belongs_to :subscription

    define_attribute_methods %w(
      uuid
      state
      description
      accounting_code
      origin
      unit_amount_in_cents
      quantity
      discount_in_cents
      tax_in_cents
      total_in_cents
      currency
      tax_exempt
      tax_details
      product_code
      start_date
      end_date
      created_at
    )
    alias to_param uuid

    # @return ["charge", "credit", nil] The type of adjustment.
    attr_reader :type

    # Adjustments should be built through {Account} instances.
    #
    # @return [Adjustment] A new adjustment.
    # @example
    #   account.adjustments.new attributes
    # @see Resource#initialize
    def initialize attributes = {}
      super({ :currency => Recurly.default_currency }.merge attributes)
    end

    # Adjustments are only writeable through an {Account} instance.
    embedded! true
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
recurly-2.3.4 lib/recurly/adjustment.rb
recurly-2.3.3 lib/recurly/adjustment.rb
recurly-2.3.2 lib/recurly/adjustment.rb
recurly-2.3.1 lib/recurly/adjustment.rb
recurly-2.3.0 lib/recurly/adjustment.rb