Class: AdvancedBilling::CustomFieldValueChange
- Inherits:
-
BaseModel
- Object
- CoreLibrary::BaseModel
- BaseModel
- AdvancedBilling::CustomFieldValueChange
- Defined in:
- lib/advanced_billing/models/custom_field_value_change.rb
Overview
CustomFieldValueChange Model.
Instance Attribute Summary collapse
-
#event_type ⇒ String
TODO: Write general description for this method.
-
#metafield_id ⇒ Integer
TODO: Write general description for this method.
-
#metafield_name ⇒ String
TODO: Write general description for this method.
-
#new_value ⇒ String
TODO: Write general description for this method.
-
#old_value ⇒ String
TODO: Write general description for this method.
-
#resource_id ⇒ Integer
TODO: Write general description for this method.
-
#resource_type ⇒ String
TODO: Write general description for this method.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
-
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
Instance Method Summary collapse
-
#initialize(event_type:, metafield_name:, metafield_id:, old_value:, new_value:, resource_type:, resource_id:, additional_properties: {}) ⇒ CustomFieldValueChange
constructor
A new instance of CustomFieldValueChange.
Methods inherited from BaseModel
Constructor Details
#initialize(event_type:, metafield_name:, metafield_id:, old_value:, new_value:, resource_type:, resource_id:, additional_properties: {}) ⇒ CustomFieldValueChange
Returns a new instance of CustomFieldValueChange.
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/advanced_billing/models/custom_field_value_change.rb', line 66 def initialize(event_type:, metafield_name:, metafield_id:, old_value:, new_value:, resource_type:, resource_id:, additional_properties: {}) @event_type = event_type @metafield_name = @metafield_id = @old_value = old_value @new_value = new_value @resource_type = resource_type @resource_id = resource_id # Add additional model properties to the instance. additional_properties.each do |_name, _value| instance_variable_set("@#{_name}", _value) end end |
Instance Attribute Details
#event_type ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/advanced_billing/models/custom_field_value_change.rb', line 14 def event_type @event_type end |
#metafield_id ⇒ Integer
TODO: Write general description for this method
22 23 24 |
# File 'lib/advanced_billing/models/custom_field_value_change.rb', line 22 def @metafield_id end |
#metafield_name ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/advanced_billing/models/custom_field_value_change.rb', line 18 def @metafield_name end |
#new_value ⇒ String
TODO: Write general description for this method
30 31 32 |
# File 'lib/advanced_billing/models/custom_field_value_change.rb', line 30 def new_value @new_value end |
#old_value ⇒ String
TODO: Write general description for this method
26 27 28 |
# File 'lib/advanced_billing/models/custom_field_value_change.rb', line 26 def old_value @old_value end |
#resource_id ⇒ Integer
TODO: Write general description for this method
38 39 40 |
# File 'lib/advanced_billing/models/custom_field_value_change.rb', line 38 def resource_id @resource_id end |
#resource_type ⇒ String
TODO: Write general description for this method
34 35 36 |
# File 'lib/advanced_billing/models/custom_field_value_change.rb', line 34 def resource_type @resource_type end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
84 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 |
# File 'lib/advanced_billing/models/custom_field_value_change.rb', line 84 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. event_type = hash.key?('event_type') ? hash['event_type'] : nil = hash.key?('metafield_name') ? hash['metafield_name'] : nil = hash.key?('metafield_id') ? hash['metafield_id'] : nil old_value = hash.key?('old_value') ? hash['old_value'] : nil new_value = hash.key?('new_value') ? hash['new_value'] : nil resource_type = hash.key?('resource_type') ? hash['resource_type'] : nil resource_id = hash.key?('resource_id') ? hash['resource_id'] : nil # Clean out expected properties from Hash. names.each_value { |k| hash.delete(k) } # Create object from extracted values. CustomFieldValueChange.new(event_type: event_type, metafield_name: , metafield_id: , old_value: old_value, new_value: new_value, resource_type: resource_type, resource_id: resource_id, additional_properties: hash) end |
.names ⇒ Object
A mapping from model property names to API property names.
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/advanced_billing/models/custom_field_value_change.rb', line 41 def self.names @_hash = {} if @_hash.nil? @_hash['event_type'] = 'event_type' @_hash['metafield_name'] = 'metafield_name' @_hash['metafield_id'] = 'metafield_id' @_hash['old_value'] = 'old_value' @_hash['new_value'] = 'new_value' @_hash['resource_type'] = 'resource_type' @_hash['resource_id'] = 'resource_id' @_hash end |
.nullables ⇒ Object
An array for nullable fields
59 60 61 62 63 64 |
# File 'lib/advanced_billing/models/custom_field_value_change.rb', line 59 def self.nullables %w[ old_value new_value ] end |
.optionals ⇒ Object
An array for optional fields
54 55 56 |
# File 'lib/advanced_billing/models/custom_field_value_change.rb', line 54 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/advanced_billing/models/custom_field_value_change.rb', line 113 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.event_type, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value., ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value., ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value.old_value, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.new_value, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.resource_type, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.resource_id, ->(val) { val.instance_of? Integer }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['event_type'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['metafield_name'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['metafield_id'], ->(val) { val.instance_of? Integer }) and APIHelper.valid_type?(value['old_value'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['new_value'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['resource_type'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['resource_id'], ->(val) { val.instance_of? Integer }) ) end |