Class: Repull::Property

Inherits:
ApiModelBase show all
Defined in:
lib/repull/models/property.rb

Overview

A vacation rental property in your Repull workspace. Backed by the core listings row — enriched per-PMS fields (bedrooms, property type, provider id, etc.) live in provider-specific detail tables and are NOT returned here. Field availability differs by endpoint: - channels is returned by the list endpoint (GET /v1/properties) only. - latitude, longitude, createdAt, and amenities are returned by the detail endpoint (GET /v1/properties/{id}) only. amenities requires ?include=amenities.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApiModelBase

_deserialize, #_to_hash, #to_body, #to_s

Constructor Details

#initialize(attributes = {}) ⇒ Property

Initializes the object

Parameters:

  • attributes (Hash) (defaults to: {})

    Model attributes in the form of hash



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
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
# File 'lib/repull/models/property.rb', line 114

def initialize(attributes = {})
  if (!attributes.is_a?(Hash))
    fail ArgumentError, "The input argument (attributes) must be a hash in `Repull::Property` 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::Property`. 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?(:'id')
    self.id = attributes[:'id']
  end

  if attributes.key?(:'name')
    self.name = attributes[:'name']
  end

  if attributes.key?(:'address')
    self.address = attributes[:'address']
  end

  if attributes.key?(:'city')
    self.city = attributes[:'city']
  end

  if attributes.key?(:'latitude')
    self.latitude = attributes[:'latitude']
  end

  if attributes.key?(:'longitude')
    self.longitude = attributes[:'longitude']
  end

  if attributes.key?(:'currency')
    self.currency = attributes[:'currency']
  end

  if attributes.key?(:'status')
    self.status = attributes[:'status']
  end

  if attributes.key?(:'lifecycle_status')
    self.lifecycle_status = attributes[:'lifecycle_status']
  end

  if attributes.key?(:'created_at')
    self.created_at = attributes[:'created_at']
  end

  if attributes.key?(:'channels')
    if (value = attributes[:'channels']).is_a?(Array)
      self.channels = value
    end
  end

  if attributes.key?(:'amenities')
    if (value = attributes[:'amenities']).is_a?(Array)
      self.amenities = value
    end
  end
end

Instance Attribute Details

#addressObject

Street address (from the listing's street field).



26
27
28
# File 'lib/repull/models/property.rb', line 26

def address
  @address
end

#amenitiesObject

Amenity rows for the property. Detail endpoint only, and only present when the caller passes ?include=amenities. Empty array ([]) when the property has no amenity rows.



52
53
54
# File 'lib/repull/models/property.rb', line 52

def amenities
  @amenities
end

#channelsObject

OTAs/channels this property is actively published on, as channel-name strings (e.g. airbnb, booking, vrbo). Empty array when the property has no active channel links. List endpoint (GET /v1/properties) only.



49
50
51
# File 'lib/repull/models/property.rb', line 49

def channels
  @channels
end

#cityObject

Returns the value of attribute city.



28
29
30
# File 'lib/repull/models/property.rb', line 28

def city
  @city
end

#created_atObject

When the property was created. Detail endpoint only.



46
47
48
# File 'lib/repull/models/property.rb', line 46

def created_at
  @created_at
end

#currencyObject

ISO 4217 currency code for this property's pricing.



37
38
39
# File 'lib/repull/models/property.rb', line 37

def currency
  @currency
end

#idObject

Internal Repull property ID. Equal to the listing id (listings.id); the same integer is used as listingId on reservations and propertyId on availability.



20
21
22
# File 'lib/repull/models/property.rb', line 20

def id
  @id
end

#latitudeObject

Detail endpoint only.



31
32
33
# File 'lib/repull/models/property.rb', line 31

def latitude
  @latitude
end

#lifecycle_statusObject

The listing's lifecycle state (e.g. live, draft, archived).



43
44
45
# File 'lib/repull/models/property.rb', line 43

def lifecycle_status
  @lifecycle_status
end

#longitudeObject

Detail endpoint only.



34
35
36
# File 'lib/repull/models/property.rb', line 34

def longitude
  @longitude
end

#nameObject

Property name



23
24
25
# File 'lib/repull/models/property.rb', line 23

def name
  @name
end

#statusObject

Derived from listings.active.



40
41
42
# File 'lib/repull/models/property.rb', line 40

def status
  @status
end

Class Method Details

.acceptable_attribute_mapObject

Returns attribute mapping this model knows about



73
74
75
# File 'lib/repull/models/property.rb', line 73

def self.acceptable_attribute_map
  attribute_map
end

.acceptable_attributesObject

Returns all the JSON keys this model knows about



78
79
80
# File 'lib/repull/models/property.rb', line 78

def self.acceptable_attributes
  acceptable_attribute_map.values
end

.attribute_mapObject

Attribute mapping from ruby-style variable name to JSON key.



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/repull/models/property.rb', line 55

def self.attribute_map
  {
    :'id' => :'id',
    :'name' => :'name',
    :'address' => :'address',
    :'city' => :'city',
    :'latitude' => :'latitude',
    :'longitude' => :'longitude',
    :'currency' => :'currency',
    :'status' => :'status',
    :'lifecycle_status' => :'lifecycleStatus',
    :'created_at' => :'createdAt',
    :'channels' => :'channels',
    :'amenities' => :'amenities'
  }
end

.build_from_hash(attributes) ⇒ Object

Builds the object from hash

Parameters:

  • attributes (Hash)

    Model attributes in the form of hash

Returns:

  • (Object)

    Returns the model itself



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
# File 'lib/repull/models/property.rb', line 230

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_nullableObject

List of attributes with nullable: true



101
102
103
104
105
106
107
108
109
110
# File 'lib/repull/models/property.rb', line 101

def self.openapi_nullable
  Set.new([
    :'address',
    :'city',
    :'latitude',
    :'longitude',
    :'currency',
    :'lifecycle_status',
  ])
end

.openapi_typesObject

Attribute type mapping.



83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/repull/models/property.rb', line 83

def self.openapi_types
  {
    :'id' => :'String',
    :'name' => :'String',
    :'address' => :'String',
    :'city' => :'String',
    :'latitude' => :'Float',
    :'longitude' => :'Float',
    :'currency' => :'String',
    :'status' => :'String',
    :'lifecycle_status' => :'String',
    :'created_at' => :'Time',
    :'channels' => :'Array<String>',
    :'amenities' => :'Array<ListingAmenity>'
  }
end

Instance Method Details

#==(o) ⇒ Object

Checks equality by comparing each attribute.

Parameters:

  • Object (Object)

    to be compared



198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/repull/models/property.rb', line 198

def ==(o)
  return true if self.equal?(o)
  self.class == o.class &&
      id == o.id &&
      name == o.name &&
      address == o.address &&
      city == o.city &&
      latitude == o.latitude &&
      longitude == o.longitude &&
      currency == o.currency &&
      status == o.status &&
      lifecycle_status == o.lifecycle_status &&
      created_at == o.created_at &&
      channels == o.channels &&
      amenities == o.amenities
end

#eql?(o) ⇒ Boolean

Parameters:

  • Object (Object)

    to be compared

Returns:

  • (Boolean)

See Also:

  • `==` method


217
218
219
# File 'lib/repull/models/property.rb', line 217

def eql?(o)
  self == o
end

#hashInteger

Calculates hash code according to all attributes.

Returns:

  • (Integer)

    Hash code



223
224
225
# File 'lib/repull/models/property.rb', line 223

def hash
  [id, name, address, city, latitude, longitude, currency, status, lifecycle_status, created_at, channels, amenities].hash
end

#list_invalid_propertiesObject

Show invalid properties with the reasons. Usually used together with valid?

Returns:

  • Array for valid properties with the reasons



183
184
185
186
187
# File 'lib/repull/models/property.rb', line 183

def list_invalid_properties
  warn '[DEPRECATED] the `list_invalid_properties` method is obsolete'
  invalid_properties = Array.new
  invalid_properties
end

#to_hashHash

Returns the object in the form of hash

Returns:

  • (Hash)

    Returns the object in the form of hash



252
253
254
255
256
257
258
259
260
261
262
263
264
# File 'lib/repull/models/property.rb', line 252

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

Returns:

  • (Boolean)

    true if the model is valid



191
192
193
194
# File 'lib/repull/models/property.rb', line 191

def valid?
  warn '[DEPRECATED] the `valid?` method is obsolete'
  true
end