Class: ApiReference::BillingCycleAnchorConfiguration

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

Overview

BillingCycleAnchorConfiguration Model.

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(day:, month: SKIP, year: SKIP, additional_properties: nil) ⇒ BillingCycleAnchorConfiguration

Returns a new instance of BillingCycleAnchorConfiguration.



56
57
58
59
60
61
62
63
64
# File 'lib/api_reference/models/billing_cycle_anchor_configuration.rb', line 56

def initialize(day:, month: SKIP, year: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @day = day
  @month = month unless month == SKIP
  @year = year unless year == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#dayInteger

The day of the month on which the billing cycle is anchored. If the maximum number of days in a month is greater than this value, the last day of the month is the billing cycle day (e.g. billing_cycle_day=31 for April means the billing period begins on the 30th.

Returns:

  • (Integer)


17
18
19
# File 'lib/api_reference/models/billing_cycle_anchor_configuration.rb', line 17

def day
  @day
end

#monthInteger

The month on which the billing cycle is anchored (e.g. a quarterly price anchored in February would have cycles starting February, May, August, and November).

Returns:

  • (Integer)


23
24
25
# File 'lib/api_reference/models/billing_cycle_anchor_configuration.rb', line 23

def month
  @month
end

#yearInteger

The year on which the billing cycle is anchored (e.g. a 2 year billing cycle anchored on 2021 would have cycles starting on 2021, 2023, 2025, etc.).

Returns:

  • (Integer)


29
30
31
# File 'lib/api_reference/models/billing_cycle_anchor_configuration.rb', line 29

def year
  @year
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
84
85
86
87
# File 'lib/api_reference/models/billing_cycle_anchor_configuration.rb', line 67

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  day = hash.key?('day') ? hash['day'] : nil
  month = hash.key?('month') ? hash['month'] : SKIP
  year = hash.key?('year') ? hash['year'] : SKIP

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  BillingCycleAnchorConfiguration.new(day: day,
                                      month: month,
                                      year: year,
                                      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/api_reference/models/billing_cycle_anchor_configuration.rb', line 32

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['day'] = 'day'
  @_hash['month'] = 'month'
  @_hash['year'] = 'year'
  @_hash
end

.nullablesObject

An array for nullable fields



49
50
51
52
53
54
# File 'lib/api_reference/models/billing_cycle_anchor_configuration.rb', line 49

def self.nullables
  %w[
    month
    year
  ]
end

.optionalsObject

An array for optional fields



41
42
43
44
45
46
# File 'lib/api_reference/models/billing_cycle_anchor_configuration.rb', line 41

def self.optionals
  %w[
    month
    year
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



91
92
93
94
95
96
97
98
99
100
101
# File 'lib/api_reference/models/billing_cycle_anchor_configuration.rb', line 91

def self.validate(value)
  if value.instance_of? self
    return APIHelper.valid_type?(value.day,
                                 ->(val) { val.instance_of? Integer })
  end

  return false unless value.instance_of? Hash

  APIHelper.valid_type?(value['day'],
                        ->(val) { val.instance_of? Integer })
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



111
112
113
114
115
# File 'lib/api_reference/models/billing_cycle_anchor_configuration.rb', line 111

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} day: #{@day.inspect}, month: #{@month.inspect}, year: #{@year.inspect},"\
  " additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



104
105
106
107
108
# File 'lib/api_reference/models/billing_cycle_anchor_configuration.rb', line 104

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} day: #{@day}, month: #{@month}, year: #{@year}, additional_properties:"\
  " #{@additional_properties}>"
end