Class: AdvancedBilling::GroupBilling

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

Overview

Optional attributes related to billing date and accrual. Note: Only applicable for new subscriptions.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(accrue: false, align_date: false, prorate: false, additional_properties: {}) ⇒ GroupBilling

Returns a new instance of GroupBilling.



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/advanced_billing/models/group_billing.rb', line 54

def initialize(accrue: false, align_date: false, prorate: false,
               additional_properties: {})
  # Add additional model properties to the instance.
  additional_properties.each do |_name, _value|
    instance_variable_set("@#{_name}", _value)
  end

  @accrue = accrue unless accrue == SKIP
  @align_date = align_date unless align_date == SKIP
  @prorate = prorate unless prorate == SKIP
end

Instance Attribute Details

#accrueTrueClass | FalseClass

A flag indicating whether or not to accrue charges on the new subscription.

Returns:

  • (TrueClass | FalseClass)


16
17
18
# File 'lib/advanced_billing/models/group_billing.rb', line 16

def accrue
  @accrue
end

#align_dateTrueClass | FalseClass

A flag indicating whether or not to align the billing date of the new subscription with the billing date of the primary subscription of the hierarchy’s default subscription group. Required to be true if prorate is also true.

Returns:

  • (TrueClass | FalseClass)


23
24
25
# File 'lib/advanced_billing/models/group_billing.rb', line 23

def align_date
  @align_date
end

#prorateTrueClass | FalseClass

A flag indicating whether or not to prorate billing of the new subscription for the current period. A value of true is ignored unless align_date is also true.

Returns:

  • (TrueClass | FalseClass)


29
30
31
# File 'lib/advanced_billing/models/group_billing.rb', line 29

def prorate
  @prorate
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/advanced_billing/models/group_billing.rb', line 67

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  accrue = hash['accrue'] ||= false
  align_date = hash['align_date'] ||= false
  prorate = hash['prorate'] ||= false

  # Clean out expected properties from Hash.
  additional_properties = hash.reject { |k, _| names.value?(k) }

  # Create object from extracted values.
  GroupBilling.new(accrue: accrue,
                   align_date: align_date,
                   prorate: prorate,
                   additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



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

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['accrue'] = 'accrue'
  @_hash['align_date'] = 'align_date'
  @_hash['prorate'] = 'prorate'
  @_hash
end

.nullablesObject

An array for nullable fields



50
51
52
# File 'lib/advanced_billing/models/group_billing.rb', line 50

def self.nullables
  []
end

.optionalsObject

An array for optional fields



41
42
43
44
45
46
47
# File 'lib/advanced_billing/models/group_billing.rb', line 41

def self.optionals
  %w[
    accrue
    align_date
    prorate
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:

  • The (GroupBilling | Hash)

    value against the validation is performed.



87
88
89
90
91
92
93
# File 'lib/advanced_billing/models/group_billing.rb', line 87

def self.validate(value)
  return true if value.instance_of? self

  return false unless value.instance_of? Hash

  true
end