Class: ApiReference::Address
- Defined in:
- lib/api_reference/models/address.rb
Overview
Address Model.
Instance Attribute Summary collapse
-
#city ⇒ String
TODO: Write general description for this method.
-
#country ⇒ String
TODO: Write general description for this method.
-
#line1 ⇒ String
TODO: Write general description for this method.
-
#line2 ⇒ String
TODO: Write general description for this method.
-
#postal_code ⇒ String
TODO: Write general description for this method.
-
#state ⇒ 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(line1:, line2:, city:, state:, postal_code:, country:, additional_properties: nil) ⇒ Address
constructor
A new instance of Address.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#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(line1:, line2:, city:, state:, postal_code:, country:, additional_properties: nil) ⇒ Address
Returns a new instance of Address.
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/api_reference/models/address.rb', line 65 def initialize(line1:, line2:, city:, state:, postal_code:, country:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @line1 = line1 @line2 = line2 @city = city @state = state @postal_code = postal_code @country = country @additional_properties = additional_properties end |
Instance Attribute Details
#city ⇒ String
TODO: Write general description for this method
22 23 24 |
# File 'lib/api_reference/models/address.rb', line 22 def city @city end |
#country ⇒ String
TODO: Write general description for this method
34 35 36 |
# File 'lib/api_reference/models/address.rb', line 34 def country @country end |
#line1 ⇒ String
TODO: Write general description for this method
14 15 16 |
# File 'lib/api_reference/models/address.rb', line 14 def line1 @line1 end |
#line2 ⇒ String
TODO: Write general description for this method
18 19 20 |
# File 'lib/api_reference/models/address.rb', line 18 def line2 @line2 end |
#postal_code ⇒ String
TODO: Write general description for this method
30 31 32 |
# File 'lib/api_reference/models/address.rb', line 30 def postal_code @postal_code end |
#state ⇒ String
TODO: Write general description for this method
26 27 28 |
# File 'lib/api_reference/models/address.rb', line 26 def state @state end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/api_reference/models/address.rb', line 80 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. line1 = hash.key?('line1') ? hash['line1'] : nil line2 = hash.key?('line2') ? hash['line2'] : nil city = hash.key?('city') ? hash['city'] : nil state = hash.key?('state') ? hash['state'] : nil postal_code = hash.key?('postal_code') ? hash['postal_code'] : nil country = hash.key?('country') ? hash['country'] : nil # 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. Address.new(line1: line1, line2: line2, city: city, state: state, postal_code: postal_code, country: country, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
37 38 39 40 41 42 43 44 45 46 |
# File 'lib/api_reference/models/address.rb', line 37 def self.names @_hash = {} if @_hash.nil? @_hash['line1'] = 'line1' @_hash['line2'] = 'line2' @_hash['city'] = 'city' @_hash['state'] = 'state' @_hash['postal_code'] = 'postal_code' @_hash['country'] = 'country' @_hash end |
.nullables ⇒ Object
An array for nullable fields
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/api_reference/models/address.rb', line 54 def self.nullables %w[ line1 line2 city state postal_code country ] end |
.optionals ⇒ Object
An array for optional fields
49 50 51 |
# File 'lib/api_reference/models/address.rb', line 49 def self.optionals [] end |
.validate(value) ⇒ Object
Validates an instance of the object from a given value.
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 138 139 140 141 142 143 144 |
# File 'lib/api_reference/models/address.rb', line 110 def self.validate(value) if value.instance_of? self return ( APIHelper.valid_type?(value.line1, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.line2, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.city, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.state, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.postal_code, ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value.country, ->(val) { val.instance_of? String }) ) end return false unless value.instance_of? Hash ( APIHelper.valid_type?(value['line1'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['line2'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['city'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['state'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['postal_code'], ->(val) { val.instance_of? String }) and APIHelper.valid_type?(value['country'], ->(val) { val.instance_of? String }) ) end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
155 156 157 158 159 160 |
# File 'lib/api_reference/models/address.rb', line 155 def inspect class_name = self.class.name.split('::').last "<#{class_name} line1: #{@line1.inspect}, line2: #{@line2.inspect}, city: #{@city.inspect},"\ " state: #{@state.inspect}, postal_code: #{@postal_code.inspect}, country:"\ " #{@country.inspect}, additional_properties: #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
147 148 149 150 151 152 |
# File 'lib/api_reference/models/address.rb', line 147 def to_s class_name = self.class.name.split('::').last "<#{class_name} line1: #{@line1}, line2: #{@line2}, city: #{@city}, state: #{@state},"\ " postal_code: #{@postal_code}, country: #{@country}, additional_properties:"\ " #{@additional_properties}>" end |