Class: AdvancedBilling::CollectionMethod

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

Overview

The type of payment collection to be used in the subscription. For legacy Statements Architecture valid options are - ‘invoice`, `automatic`. For current Relationship Invoicing Architecture valid options are - `remittance`, `automatic`, `prepaid`.

Constant Summary collapse

COLLECTION_METHOD =
[
  # TODO: Write general description for AUTOMATIC
  AUTOMATIC = 'automatic'.freeze,

  # TODO: Write general description for REMITTANCE
  REMITTANCE = 'remittance'.freeze,

  # TODO: Write general description for PREPAID
  PREPAID = 'prepaid'.freeze,

  # TODO: Write general description for INVOICE
  INVOICE = 'invoice'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = AUTOMATIC) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/advanced_billing/models/collection_method.rb', line 32

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

  str = value.to_s.strip

  case str.downcase
  when 'automatic' then AUTOMATIC
  when 'remittance' then REMITTANCE
  when 'prepaid' then PREPAID
  when 'invoice' then INVOICE
  else
    default_value
  end
end

.validate(value) ⇒ Object



26
27
28
29
30
# File 'lib/advanced_billing/models/collection_method.rb', line 26

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

  COLLECTION_METHOD.include?(value)
end