Class: AdvancedBilling::LineItemTransactionType

Inherits:
Object
  • Object
show all
Defined in:
lib/advanced_billing/models/line_item_transaction_type.rb

Overview

A handle for the line item transaction type

Constant Summary collapse

LINE_ITEM_TRANSACTION_TYPE =
[
  # TODO: Write general description for CHARGE
  CHARGE = 'charge'.freeze,

  # TODO: Write general description for CREDIT
  CREDIT = 'credit'.freeze,

  # TODO: Write general description for ADJUSTMENT
  ADJUSTMENT = 'adjustment'.freeze,

  # TODO: Write general description for PAYMENT
  PAYMENT = 'payment'.freeze,

  # TODO: Write general description for REFUND
  REFUND = 'refund'.freeze,

  # TODO: Write general description for INFO_TRANSACTION
  INFO_TRANSACTION = 'info_transaction'.freeze,

  # TODO: Write general description for PAYMENT_AUTHORIZATION
  PAYMENT_AUTHORIZATION = 'payment_authorization'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = CHARGE) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/advanced_billing/models/line_item_transaction_type.rb', line 38

def self.from_value(value, default_value = CHARGE)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'charge' then CHARGE
  when 'credit' then CREDIT
  when 'adjustment' then ADJUSTMENT
  when 'payment' then PAYMENT
  when 'refund' then REFUND
  when 'info_transaction' then INFO_TRANSACTION
  when 'payment_authorization' then PAYMENT_AUTHORIZATION
  else
    default_value
  end
end

.validate(value) ⇒ Object



32
33
34
35
36
# File 'lib/advanced_billing/models/line_item_transaction_type.rb', line 32

def self.validate(value)
  return false if value.nil?

  LINE_ITEM_TRANSACTION_TYPE.include?(value)
end