Class: Verizon::ConditionObjectCall

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/verizon/models/condition_object_call.rb

Overview

ConditionObjectCall 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(condition_type: SKIP, comparitor: SKIP, threshold: SKIP, threshold_unit: SKIP, cycle_type: SKIP, allowance_threshold: SKIP, additional_properties: nil) ⇒ ConditionObjectCall

Returns a new instance of ConditionObjectCall.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/verizon/models/condition_object_call.rb', line 69

def initialize(condition_type: SKIP, comparitor: SKIP, threshold: SKIP,
               threshold_unit: SKIP, cycle_type: SKIP,
               allowance_threshold: SKIP, additional_properties: nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @condition_type = condition_type unless condition_type == SKIP
  @comparitor = comparitor unless comparitor == SKIP
  @threshold = threshold unless threshold == SKIP
  @threshold_unit = threshold_unit unless threshold_unit == SKIP
  @cycle_type = cycle_type unless cycle_type == SKIP
  @allowance_threshold = allowance_threshold unless allowance_threshold == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#allowance_thresholdAllowanceThreshold

The interval to monitor for the threshold. This can be Daily, Weekly or Monthly

Returns:



38
39
40
# File 'lib/verizon/models/condition_object_call.rb', line 38

def allowance_threshold
  @allowance_threshold
end

#comparitorComparitor

The boolean of the comparison. ‘gt` is Greater Than, `lt` is Less Than and `eq` is Equal To

Returns:



19
20
21
# File 'lib/verizon/models/condition_object_call.rb', line 19

def comparitor
  @comparitor
end

#condition_typeConditionType

The condition type being monitored

Returns:



14
15
16
# File 'lib/verizon/models/condition_object_call.rb', line 14

def condition_type
  @condition_type
end

#cycle_typeRulesCycleType

The interval to monitor for the threshold. This can be Daily, Weekly or Monthly

Returns:



33
34
35
# File 'lib/verizon/models/condition_object_call.rb', line 33

def cycle_type
  @cycle_type
end

#thresholdInteger

The threshold value the trigger monitors for

Returns:

  • (Integer)


23
24
25
# File 'lib/verizon/models/condition_object_call.rb', line 23

def threshold
  @threshold
end

#threshold_unitThresholdUnit

The units of the threshold. This can be KB, Kilobits, MB, Megabits, or GB, Gigabits

Returns:



28
29
30
# File 'lib/verizon/models/condition_object_call.rb', line 28

def threshold_unit
  @threshold_unit
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# File 'lib/verizon/models/condition_object_call.rb', line 85

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  condition_type = hash.key?('conditionType') ? hash['conditionType'] : SKIP
  comparitor = hash.key?('comparitor') ? hash['comparitor'] : SKIP
  threshold = hash.key?('threshold') ? hash['threshold'] : SKIP
  threshold_unit = hash.key?('thresholdUnit') ? hash['thresholdUnit'] : SKIP
  cycle_type = hash.key?('cycleType') ? hash['cycleType'] : SKIP
  allowance_threshold = AllowanceThreshold.from_hash(hash['allowanceThreshold']) if
    hash['allowanceThreshold']

  # 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.
  ConditionObjectCall.new(condition_type: condition_type,
                          comparitor: comparitor,
                          threshold: threshold,
                          threshold_unit: threshold_unit,
                          cycle_type: cycle_type,
                          allowance_threshold: allowance_threshold,
                          additional_properties: additional_properties)
end

.namesObject

A mapping from model property names to API property names.



41
42
43
44
45
46
47
48
49
50
# File 'lib/verizon/models/condition_object_call.rb', line 41

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['condition_type'] = 'conditionType'
  @_hash['comparitor'] = 'comparitor'
  @_hash['threshold'] = 'threshold'
  @_hash['threshold_unit'] = 'thresholdUnit'
  @_hash['cycle_type'] = 'cycleType'
  @_hash['allowance_threshold'] = 'allowanceThreshold'
  @_hash
end

.nullablesObject

An array for nullable fields



65
66
67
# File 'lib/verizon/models/condition_object_call.rb', line 65

def self.nullables
  []
end

.optionalsObject

An array for optional fields



53
54
55
56
57
58
59
60
61
62
# File 'lib/verizon/models/condition_object_call.rb', line 53

def self.optionals
  %w[
    condition_type
    comparitor
    threshold
    threshold_unit
    cycle_type
    allowance_threshold
  ]
end

.validate(value) ⇒ Object

Validates an instance of the object from a given value.

Parameters:



116
117
118
119
120
121
122
# File 'lib/verizon/models/condition_object_call.rb', line 116

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

  return false unless value.instance_of? Hash

  true
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



134
135
136
137
138
139
140
# File 'lib/verizon/models/condition_object_call.rb', line 134

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} condition_type: #{@condition_type.inspect}, comparitor:"\
  " #{@comparitor.inspect}, threshold: #{@threshold.inspect}, threshold_unit:"\
  " #{@threshold_unit.inspect}, cycle_type: #{@cycle_type.inspect}, allowance_threshold:"\
  " #{@allowance_threshold.inspect}, additional_properties: #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



125
126
127
128
129
130
131
# File 'lib/verizon/models/condition_object_call.rb', line 125

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} condition_type: #{@condition_type}, comparitor: #{@comparitor}, threshold:"\
  " #{@threshold}, threshold_unit: #{@threshold_unit}, cycle_type: #{@cycle_type},"\
  " allowance_threshold: #{@allowance_threshold}, additional_properties:"\
  " #{@additional_properties}>"
end