Class: AdvancedBilling::ReactivationCharge

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

Overview

You may choose how to handle the reactivation charge for that subscription: 1) ‘prorated` A prorated charge for the product price will be attempted for to complete the period 2) `immediate` A full-price charge for the product price will be attempted immediately 3) `delayed` A full-price charge for the product price will be attempted at the next renewal

Constant Summary collapse

REACTIVATION_CHARGE =
[
  # TODO: Write general description for PRORATED
  PRORATED = 'prorated'.freeze,

  # TODO: Write general description for IMMEDIATE
  IMMEDIATE = 'immediate'.freeze,

  # TODO: Write general description for DELAYED
  DELAYED = 'delayed'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = PRORATED) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/advanced_billing/models/reactivation_charge.rb', line 30

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

  str = value.to_s.strip

  case str.downcase
  when 'prorated' then PRORATED
  when 'immediate' then IMMEDIATE
  when 'delayed' then DELAYED
  else
    default_value
  end
end

.validate(value) ⇒ Object



24
25
26
27
28
# File 'lib/advanced_billing/models/reactivation_charge.rb', line 24

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

  REACTIVATION_CHARGE.include?(value)
end