Class: AdvancedBilling::CancellationMethod

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

Overview

The process used to cancel the subscription, if the subscription has been canceled. It is nil if the subscription’s state is not canceled.

Constant Summary collapse

CANCELLATION_METHOD =
[
  # TODO: Write general description for MERCHANT_UI
  MERCHANT_UI = 'merchant_ui'.freeze,

  # TODO: Write general description for MERCHANT_API
  MERCHANT_API = 'merchant_api'.freeze,

  # TODO: Write general description for DUNNING
  DUNNING = 'dunning'.freeze,

  # TODO: Write general description for BILLING_PORTAL
  BILLING_PORTAL = 'billing_portal'.freeze,

  # TODO: Write general description for UNKNOWN
  UNKNOWN = 'unknown'.freeze,

  # TODO: Write general description for IMPORTED
  IMPORTED = 'imported'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = MERCHANT_UI) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/advanced_billing/models/cancellation_method.rb', line 36

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

  str = value.to_s.strip

  case str.downcase
  when 'merchant_ui' then MERCHANT_UI
  when 'merchant_api' then MERCHANT_API
  when 'dunning' then DUNNING
  when 'billing_portal' then BILLING_PORTAL
  when 'unknown' then UNKNOWN
  when 'imported' then IMPORTED
  else
    default_value
  end
end

.validate(value) ⇒ Object



30
31
32
33
34
# File 'lib/advanced_billing/models/cancellation_method.rb', line 30

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

  CANCELLATION_METHOD.include?(value)
end