Class: ApiReference::AffectedBlock
- Defined in:
- lib/api_reference/models/affected_block.rb
Overview
AffectedBlock Model.
Instance Attribute Summary collapse
-
#expiry_date ⇒ DateTime
TODO: Write general description for this method.
-
#filters ⇒ Array[PriceFilter]
TODO: Write general description for this method.
-
#id ⇒ String
TODO: Write general description for this method.
-
#per_unit_cost_basis ⇒ 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(id:, expiry_date:, per_unit_cost_basis:, filters:, additional_properties: nil) ⇒ AffectedBlock
constructor
A new instance of AffectedBlock.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_expiry_date ⇒ Object
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(id:, expiry_date:, per_unit_cost_basis:, filters:, additional_properties: nil) ⇒ AffectedBlock
Returns a new instance of AffectedBlock.
52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/api_reference/models/affected_block.rb', line 52 def initialize(id:, expiry_date:, per_unit_cost_basis:, filters:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @id = id @expiry_date = expiry_date @per_unit_cost_basis = per_unit_cost_basis @filters = filters @additional_properties = additional_properties end |
Instance Attribute Details
#expiry_date ⇒ DateTime
TODO: Write general description for this method
19 20 21 |
# File 'lib/api_reference/models/affected_block.rb', line 19 def expiry_date @expiry_date end |
#filters ⇒ Array[PriceFilter]
TODO: Write general description for this method
27 28 29 |
# File 'lib/api_reference/models/affected_block.rb', line 27 def filters @filters end |
#id ⇒ String
TODO: Write general description for this method
15 16 17 |
# File 'lib/api_reference/models/affected_block.rb', line 15 def id @id end |
#per_unit_cost_basis ⇒ String
TODO: Write general description for this method
23 24 25 |
# File 'lib/api_reference/models/affected_block.rb', line 23 def per_unit_cost_basis @per_unit_cost_basis end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/api_reference/models/affected_block.rb', line 65 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. id = hash.key?('id') ? hash['id'] : nil expiry_date = if hash.key?('expiry_date') (DateTimeHelper.from_rfc3339(hash['expiry_date']) if hash['expiry_date']) end per_unit_cost_basis = hash.key?('per_unit_cost_basis') ? hash['per_unit_cost_basis'] : nil # Parameter is an array, so we need to iterate through it filters = nil unless hash['filters'].nil? filters = [] hash['filters'].each do |structure| filters << (PriceFilter.from_hash(structure) if structure) end end filters = nil unless hash.key?('filters') # 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. AffectedBlock.new(id: id, expiry_date: expiry_date, per_unit_cost_basis: per_unit_cost_basis, filters: filters, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
30 31 32 33 34 35 36 37 |
# File 'lib/api_reference/models/affected_block.rb', line 30 def self.names @_hash = {} if @_hash.nil? @_hash['id'] = 'id' @_hash['expiry_date'] = 'expiry_date' @_hash['per_unit_cost_basis'] = 'per_unit_cost_basis' @_hash['filters'] = 'filters' @_hash end |
.nullables ⇒ Object
An array for nullable fields
45 46 47 48 49 50 |
# File 'lib/api_reference/models/affected_block.rb', line 45 def self.nullables %w[ expiry_date per_unit_cost_basis ] end |
.optionals ⇒ Object
An array for optional fields
40 41 42 |
# File 'lib/api_reference/models/affected_block.rb', line 40 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
107 108 109 110 111 112 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 |
# File 'lib/api_reference/models/affected_block.rb', line 107 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.id, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.expiry_date, ->(val) { val.instance_of? DateTime }) and APIHelper.valid_type?(value.per_unit_cost_basis, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.filters, ->(val) { PriceFilter.validate(val) }, is_model_hash: true, is_inner_model_hash: true) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['id'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['expiry_date'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['per_unit_cost_basis'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['filters'], ->(val) { PriceFilter.validate(val) }, is_model_hash: true, is_inner_model_hash: true) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
148 149 150 151 152 153 |
# File 'lib/api_reference/models/affected_block.rb', line 148 def inspect class_name = self.class.name.split('::').last "<#{class_name} id: #{@id.inspect}, expiry_date: #{@expiry_date.inspect},"\ " per_unit_cost_basis: #{@per_unit_cost_basis.inspect}, filters: #{@filters.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_custom_expiry_date ⇒ Object
101 102 103 |
# File 'lib/api_reference/models/affected_block.rb', line 101 def to_custom_expiry_date DateTimeHelper.to_rfc3339(expiry_date) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
140 141 142 143 144 145 |
# File 'lib/api_reference/models/affected_block.rb', line 140 def to_s class_name = self.class.name.split('::').last "<#{class_name} id: #{@id}, expiry_date: #{@expiry_date}, per_unit_cost_basis:"\ " #{@per_unit_cost_basis}, filters: #{@filters}, additional_properties:"\ " #{@additional_properties}>" end |