Class: Repull::ListingComp
- Inherits:
-
ApiModelBase
- Object
- ApiModelBase
- Repull::ListingComp
- Defined in:
- lib/repull/models/listing_comp.rb
Overview
A single competitor listing in a comp set, sorted closest-first. Includes per-day rate/availability for the requested calendar window.
Instance Attribute Summary collapse
-
#bedrooms ⇒ Object
Returns the value of attribute bedrooms.
-
#comp_id ⇒ Object
Returns the value of attribute comp_id.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#current_nightly_rate ⇒ Object
Latest snapshot ADR — fallback to render when the calendar window is empty.
-
#distance_km ⇒ Object
Haversine distance from the source listing in km, rounded to 3 decimals.
-
#external_url ⇒ Object
Link to the listing on its source platform when one is available.
-
#lat ⇒ Object
Returns the value of attribute lat.
-
#listing_name ⇒ Object
Returns the value of attribute listing_name.
-
#lng ⇒ Object
Returns the value of attribute lng.
-
#max_guests ⇒ Object
Returns the value of attribute max_guests.
-
#nightly ⇒ Object
Per-day rate + availability for the requested window.
-
#platform ⇒ Object
Returns the value of attribute platform.
-
#ratings ⇒ Object
Returns the value of attribute ratings.
Class Method Summary collapse
-
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about.
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ ListingComp
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Methods inherited from ApiModelBase
_deserialize, #_to_hash, #to_body, #to_s
Constructor Details
#initialize(attributes = {}) ⇒ ListingComp
Initializes the object
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 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 |
# File 'lib/repull/models/listing_comp.rb', line 115 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `Repull::ListingComp` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key acceptable_attribute_map = self.class.acceptable_attribute_map attributes = attributes.each_with_object({}) { |(k, v), h| if (!acceptable_attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Repull::ListingComp`. Please check the name to make sure it's valid. List of attributes: " + acceptable_attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'comp_id') self.comp_id = attributes[:'comp_id'] end if attributes.key?(:'listing_name') self.listing_name = attributes[:'listing_name'] end if attributes.key?(:'distance_km') self.distance_km = attributes[:'distance_km'] end if attributes.key?(:'bedrooms') self.bedrooms = attributes[:'bedrooms'] end if attributes.key?(:'max_guests') self.max_guests = attributes[:'max_guests'] end if attributes.key?(:'ratings') self. = attributes[:'ratings'] end if attributes.key?(:'currency') self.currency = attributes[:'currency'] end if attributes.key?(:'current_nightly_rate') self.current_nightly_rate = attributes[:'current_nightly_rate'] end if attributes.key?(:'nightly') if (value = attributes[:'nightly']).is_a?(Array) self.nightly = value end end if attributes.key?(:'lat') self.lat = attributes[:'lat'] end if attributes.key?(:'lng') self.lng = attributes[:'lng'] end if attributes.key?(:'platform') self.platform = attributes[:'platform'] end if attributes.key?(:'external_url') self.external_url = attributes[:'external_url'] end end |
Instance Attribute Details
#bedrooms ⇒ Object
Returns the value of attribute bedrooms.
26 27 28 |
# File 'lib/repull/models/listing_comp.rb', line 26 def bedrooms @bedrooms end |
#comp_id ⇒ Object
Returns the value of attribute comp_id.
19 20 21 |
# File 'lib/repull/models/listing_comp.rb', line 19 def comp_id @comp_id end |
#currency ⇒ Object
Returns the value of attribute currency.
32 33 34 |
# File 'lib/repull/models/listing_comp.rb', line 32 def currency @currency end |
#current_nightly_rate ⇒ Object
Latest snapshot ADR — fallback to render when the calendar window is empty.
35 36 37 |
# File 'lib/repull/models/listing_comp.rb', line 35 def current_nightly_rate @current_nightly_rate end |
#distance_km ⇒ Object
Haversine distance from the source listing in km, rounded to 3 decimals.
24 25 26 |
# File 'lib/repull/models/listing_comp.rb', line 24 def distance_km @distance_km end |
#external_url ⇒ Object
Link to the listing on its source platform when one is available.
47 48 49 |
# File 'lib/repull/models/listing_comp.rb', line 47 def external_url @external_url end |
#lat ⇒ Object
Returns the value of attribute lat.
40 41 42 |
# File 'lib/repull/models/listing_comp.rb', line 40 def lat @lat end |
#listing_name ⇒ Object
Returns the value of attribute listing_name.
21 22 23 |
# File 'lib/repull/models/listing_comp.rb', line 21 def listing_name @listing_name end |
#lng ⇒ Object
Returns the value of attribute lng.
42 43 44 |
# File 'lib/repull/models/listing_comp.rb', line 42 def lng @lng end |
#max_guests ⇒ Object
Returns the value of attribute max_guests.
28 29 30 |
# File 'lib/repull/models/listing_comp.rb', line 28 def max_guests @max_guests end |
#nightly ⇒ Object
Per-day rate + availability for the requested window. May be empty if Atlas hasn’t snapshotted the comp recently.
38 39 40 |
# File 'lib/repull/models/listing_comp.rb', line 38 def nightly @nightly end |
#platform ⇒ Object
Returns the value of attribute platform.
44 45 46 |
# File 'lib/repull/models/listing_comp.rb', line 44 def platform @platform end |
#ratings ⇒ Object
Returns the value of attribute ratings.
30 31 32 |
# File 'lib/repull/models/listing_comp.rb', line 30 def @ratings end |
Class Method Details
.acceptable_attribute_map ⇒ Object
Returns attribute mapping this model knows about
69 70 71 |
# File 'lib/repull/models/listing_comp.rb', line 69 def self.acceptable_attribute_map attribute_map end |
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
74 75 76 |
# File 'lib/repull/models/listing_comp.rb', line 74 def self.acceptable_attributes acceptable_attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/repull/models/listing_comp.rb', line 50 def self.attribute_map { :'comp_id' => :'compId', :'listing_name' => :'listingName', :'distance_km' => :'distanceKm', :'bedrooms' => :'bedrooms', :'max_guests' => :'maxGuests', :'ratings' => :'ratings', :'currency' => :'currency', :'current_nightly_rate' => :'currentNightlyRate', :'nightly' => :'nightly', :'lat' => :'lat', :'lng' => :'lng', :'platform' => :'platform', :'external_url' => :'externalUrl' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 |
# File 'lib/repull/models/listing_comp.rb', line 234 def self.build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) transformed_hash = {} openapi_types.each_pair do |key, type| if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = nil elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[attribute_map[key]].is_a?(Array) transformed_hash["#{key}"] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) } end elsif !attributes[attribute_map[key]].nil? transformed_hash["#{key}"] = _deserialize(type, attributes[attribute_map[key]]) end end new(transformed_hash) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/repull/models/listing_comp.rb', line 98 def self.openapi_nullable Set.new([ :'listing_name', :'distance_km', :'bedrooms', :'max_guests', :'currency', :'current_nightly_rate', :'lat', :'lng', :'platform', :'external_url' ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/repull/models/listing_comp.rb', line 79 def self.openapi_types { :'comp_id' => :'String', :'listing_name' => :'String', :'distance_km' => :'Float', :'bedrooms' => :'Integer', :'max_guests' => :'Integer', :'ratings' => :'ListingCompRatings', :'currency' => :'String', :'current_nightly_rate' => :'Float', :'nightly' => :'Array<ListingCompNightly>', :'lat' => :'Float', :'lng' => :'Float', :'platform' => :'String', :'external_url' => :'String' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 |
# File 'lib/repull/models/listing_comp.rb', line 201 def ==(o) return true if self.equal?(o) self.class == o.class && comp_id == o.comp_id && listing_name == o.listing_name && distance_km == o.distance_km && bedrooms == o.bedrooms && max_guests == o.max_guests && == o. && currency == o.currency && current_nightly_rate == o.current_nightly_rate && nightly == o.nightly && lat == o.lat && lng == o.lng && platform == o.platform && external_url == o.external_url end |
#eql?(o) ⇒ Boolean
221 222 223 |
# File 'lib/repull/models/listing_comp.rb', line 221 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
227 228 229 |
# File 'lib/repull/models/listing_comp.rb', line 227 def hash [comp_id, listing_name, distance_km, bedrooms, max_guests, , currency, current_nightly_rate, nightly, lat, lng, platform, external_url].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
186 187 188 189 190 |
# File 'lib/repull/models/listing_comp.rb', line 186 def list_invalid_properties warn '[DEPRECATED] the `list_invalid_properties` method is obsolete' invalid_properties = Array.new invalid_properties end |
#to_hash ⇒ Hash
Returns the object in the form of hash
256 257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/repull/models/listing_comp.rb', line 256 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
194 195 196 197 |
# File 'lib/repull/models/listing_comp.rb', line 194 def valid? warn '[DEPRECATED] the `valid?` method is obsolete' true end |