Class: ApiReference::CreditBlockSource

Inherits:
Object
  • Object
show all
Defined in:
lib/api_reference/models/credit_block_source.rb

Overview

How this credit block was created: allocation (a subscription's recurring credit allocation), top_up (an automatic balance-threshold top-up), or manual (a manual credit ledger increment, including credits voided or expired off another block).

Constant Summary collapse

CREDIT_BLOCK_SOURCE =
[
  # TODO: Write general description for ALLOCATION
  ALLOCATION = 'allocation'.freeze,

  # TODO: Write general description for TOP_UP
  TOP_UP = 'top_up'.freeze,

  # TODO: Write general description for MANUAL
  MANUAL = 'manual'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = ALLOCATION) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/api_reference/models/credit_block_source.rb', line 29

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

  str = value.to_s.strip

  case str.downcase
  when 'allocation' then ALLOCATION
  when 'top_up' then TOP_UP
  when 'manual' then MANUAL
  else
    default_value
  end
end

.validate(value) ⇒ Object



23
24
25
26
27
# File 'lib/api_reference/models/credit_block_source.rb', line 23

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

  true
end