Class: Asdawqw::Property

Inherits:
BaseModel show all
Defined in:
lib/asdawqw/models/property.rb

Overview

Property Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#to_hash, #to_json

Constructor Details

#initialize(name = nil, rooms = nil, bathrooms = nil, persons = nil, property_type = nil, currency = nil, supported_los_rates = nil, id = nil, alt_id = nil, supplier_id = nil, toilets = nil, total_beds = nil, space = nil, space_unit = nil, childs = nil, latitude = nil, longitude = nil, living_room = nil, notes = nil, attributes_with_quantity = nil, nearby_amenities = nil, bedroom_configuration = nil, check_in_time = nil, check_in_to_time = nil, check_out_time = nil, policy = nil, location = nil, tax_number = nil, tourist_license_number = nil, tourist_license_expiry_date = nil, multi_unit = nil, parent_id = nil) ⇒ Property

Returns a new instance of Property.



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/asdawqw/models/property.rb', line 190

def initialize(name = nil,
               rooms = nil,
               bathrooms = nil,
               persons = nil,
               property_type = nil,
               currency = nil,
               supported_los_rates = nil,
               id = nil,
               alt_id = nil,
               supplier_id = nil,
               toilets = nil,
               total_beds = nil,
               space = nil,
               space_unit = nil,
               childs = nil,
               latitude = nil,
               longitude = nil,
               living_room = nil,
               notes = nil,
               attributes_with_quantity = nil,
               nearby_amenities = nil,
               bedroom_configuration = nil,
               check_in_time = nil,
               check_in_to_time = nil,
               check_out_time = nil,
               policy = nil,
               location = nil,
               tax_number = nil,
               tourist_license_number = nil,
               tourist_license_expiry_date = nil,
               multi_unit = nil,
               parent_id = nil)
  @name = name
  @id = id
  @alt_id = alt_id
  @supplier_id = supplier_id
  @rooms = rooms
  @bathrooms = bathrooms
  @toilets = toilets
  @total_beds = total_beds
  @space = space
  @space_unit = space_unit
  @persons = persons
  @childs = childs
  @latitude = latitude
  @longitude = longitude
  @living_room = living_room
  @notes = notes
  @attributes_with_quantity = attributes_with_quantity
  @nearby_amenities = nearby_amenities
  @property_type = property_type
  @bedroom_configuration = bedroom_configuration
  @check_in_time = check_in_time
  @check_in_to_time = check_in_to_time
  @check_out_time = check_out_time
  @currency = currency
  @policy = policy
  @location = location
  @supported_los_rates = supported_los_rates
  @tax_number = tax_number
  @tourist_license_number = tourist_license_number
  @tourist_license_expiry_date = tourist_license_expiry_date
  @multi_unit = multi_unit
  @parent_id = parent_id
end

Instance Attribute Details

#alt_idInteger

Alternative Id of the property (ID in your PMS system). Note: this field you can not update, so this field will not be used during update.

Returns:

  • (Integer)


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

def alt_id
  @alt_id
end

#attributes_with_quantityList of AttributesWithQuantity

Use this param instead of previous if you need to set quantity more than 1 of attributes. If use both in POST request this will overwrite the previous list (under param attributes).

Returns:



82
83
84
# File 'lib/asdawqw/models/property.rb', line 82

def attributes_with_quantity
  @attributes_with_quantity
end

#bathroomsInteger

Number of bathrooms

Returns:

  • (Integer)


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

def bathrooms
  @bathrooms
end

#bedroom_configurationBedroomConfiguration

Bedroom configuration



94
95
96
# File 'lib/asdawqw/models/property.rb', line 94

def bedroom_configuration
  @bedroom_configuration
end

#check_in_timeString

Time of Check in (HH:MM:SS)

Returns:



98
99
100
# File 'lib/asdawqw/models/property.rb', line 98

def check_in_time
  @check_in_time
end

#check_in_to_timeString

Time Check in to (HH:MM:SS)

Returns:



102
103
104
# File 'lib/asdawqw/models/property.rb', line 102

def check_in_to_time
  @check_in_to_time
end

#check_out_timeString

Time of Check out (HH:MM:SS)

Returns:



106
107
108
# File 'lib/asdawqw/models/property.rb', line 106

def check_out_time
  @check_out_time
end

#childsInteger

Number of allowed children (from 7 to 12 years)

Returns:

  • (Integer)


58
59
60
# File 'lib/asdawqw/models/property.rb', line 58

def childs
  @childs
end

#currencyString

Property currency. ISO 4217 code is required.

Returns:



110
111
112
# File 'lib/asdawqw/models/property.rb', line 110

def currency
  @currency
end

#idInteger

Property ID in BookingPal

Returns:

  • (Integer)


15
16
17
# File 'lib/asdawqw/models/property.rb', line 15

def id
  @id
end

#latitudeFloat

Latitude of the property (Must set field latitude and longitude or location)

Returns:

  • (Float)


63
64
65
# File 'lib/asdawqw/models/property.rb', line 63

def latitude
  @latitude
end

#living_roomInteger

Number of Living rooms

Returns:

  • (Integer)


72
73
74
# File 'lib/asdawqw/models/property.rb', line 72

def living_room
  @living_room
end

#locationLocation

Property location (Must set field latitude and longitude or location). Some location data will not be updated, since it is not expected that property change location. Similar is with coordinates and searching location from coordinates.

Returns:



121
122
123
# File 'lib/asdawqw/models/property.rb', line 121

def location
  @location
end

#longitudeFloat

Longitude of the property (Must set field latitude and longitude or location)

Returns:

  • (Float)


68
69
70
# File 'lib/asdawqw/models/property.rb', line 68

def longitude
  @longitude
end

#multi_unitMultiUnitEnum

For regular properties (single units) you should not use this field. This field is to set if you want to create multiunit property or owner MLT,OWN. Also you can not update this field.

Returns:



144
145
146
# File 'lib/asdawqw/models/property.rb', line 144

def multi_unit
  @multi_unit
end

#nameString

Name of the property to display in the list

Returns:



11
12
13
# File 'lib/asdawqw/models/property.rb', line 11

def name
  @name
end

#nearby_amenitiesList of NearbyAmenity

List of Nearby Attributes models. Check allowed values in Appendix.

Returns:



86
87
88
# File 'lib/asdawqw/models/property.rb', line 86

def nearby_amenities
  @nearby_amenities
end

#notesNotes

Property descriptions

Returns:



76
77
78
# File 'lib/asdawqw/models/property.rb', line 76

def notes
  @notes
end

#parent_idInteger

This fields should not be used unless your property is not MLT (check field multiunit). In this case you must set owner (parent) id property to which this property will belong. Also you can not update this property.

Returns:

  • (Integer)


150
151
152
# File 'lib/asdawqw/models/property.rb', line 150

def parent_id
  @parent_id
end

#personsInteger

Maximum number of allowed adults

Returns:

  • (Integer)


54
55
56
# File 'lib/asdawqw/models/property.rb', line 54

def persons
  @persons
end

#policyPolicy

Property policy

Returns:



114
115
116
# File 'lib/asdawqw/models/property.rb', line 114

def policy
  @policy
end

#property_typePropertyTypesEnum

Property type code (Enum value)

Returns:



90
91
92
# File 'lib/asdawqw/models/property.rb', line 90

def property_type
  @property_type
end

#roomsInteger

Number of bedrooms. Number of bedrooms should be > 0. Value 0 is only allowed in case property type is Studio (PCT46 or PCT110)

Returns:

  • (Integer)


30
31
32
# File 'lib/asdawqw/models/property.rb', line 30

def rooms
  @rooms
end

#spaceFloat

Property size

Returns:

  • (Float)


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

def space
  @space
end

#space_unitSpaceUnitEnum

SQ_FT Property size unit of measurement

Returns:



50
51
52
# File 'lib/asdawqw/models/property.rb', line 50

def space_unit
  @space_unit
end

#supplier_idInteger

Id of the Property Manager (not be used for creating new property. Property will have ID of current authorized user)

Returns:

  • (Integer)


25
26
27
# File 'lib/asdawqw/models/property.rb', line 25

def supplier_id
  @supplier_id
end

#supported_los_ratesBoolean

If true - means that the property supports only LOS rates. So daily rates can not be sent and updated. Default is false.

Returns:

  • (Boolean)


126
127
128
# File 'lib/asdawqw/models/property.rb', line 126

def supported_los_rates
  @supported_los_rates
end

#tax_numberString

Tax number for product

Returns:



130
131
132
# File 'lib/asdawqw/models/property.rb', line 130

def tax_number
  @tax_number
end

#toiletsInteger

Number of toilets

Returns:

  • (Integer)


38
39
40
# File 'lib/asdawqw/models/property.rb', line 38

def toilets
  @toilets
end

#total_bedsInteger

Property’s total number of beds

Returns:

  • (Integer)


42
43
44
# File 'lib/asdawqw/models/property.rb', line 42

def total_beds
  @total_beds
end

#tourist_license_expiry_dateDate

Tourist license expiry date. Correct date format is YYYY-MM-DD.

Returns:

  • (Date)


138
139
140
# File 'lib/asdawqw/models/property.rb', line 138

def tourist_license_expiry_date
  @tourist_license_expiry_date
end

#tourist_license_numberString

Tourist license number

Returns:



134
135
136
# File 'lib/asdawqw/models/property.rb', line 134

def tourist_license_number
  @tourist_license_number
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/asdawqw/models/property.rb', line 257

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  name = hash['name']
  rooms = hash['rooms']
  bathrooms = hash['bathrooms']
  persons = hash['persons']
  property_type = hash['propertyType']
  currency = hash['currency']
  supported_los_rates = hash['supportedLosRates']
  id = hash['id']
  alt_id = hash['altId']
  supplier_id = hash['supplierId']
  toilets = hash['toilets']
  total_beds = hash['totalBeds']
  space = hash['space']
  space_unit = hash['spaceUnit']
  childs = hash['childs']
  latitude = hash['latitude']
  longitude = hash['longitude']
  living_room = hash['livingRoom']
  notes = Notes.from_hash(hash['notes']) if hash['notes']
  # Parameter is an array, so we need to iterate through it
  attributes_with_quantity = nil
  unless hash['attributesWithQuantity'].nil?
    attributes_with_quantity = []
    hash['attributesWithQuantity'].each do |structure|
      attributes_with_quantity << (AttributesWithQuantity.from_hash(structure) if structure)
    end
  end
  # Parameter is an array, so we need to iterate through it
  nearby_amenities = nil
  unless hash['nearbyAmenities'].nil?
    nearby_amenities = []
    hash['nearbyAmenities'].each do |structure|
      nearby_amenities << (NearbyAmenity.from_hash(structure) if structure)
    end
  end
  if hash['bedroomConfiguration']
    bedroom_configuration = BedroomConfiguration.from_hash(hash['bedroomConfiguration'])
  end
  check_in_time = hash['checkInTime']
  check_in_to_time = hash['checkInToTime']
  check_out_time = hash['checkOutTime']
  policy = Policy.from_hash(hash['policy']) if hash['policy']
  location = Location.from_hash(hash['location']) if hash['location']
  tax_number = hash['taxNumber']
  tourist_license_number = hash['touristLicenseNumber']
  tourist_license_expiry_date = hash['touristLicenseExpiryDate']
  multi_unit = hash['multiUnit']
  parent_id = hash['parentId']

  # Create object from extracted values.
  Property.new(name,
               rooms,
               bathrooms,
               persons,
               property_type,
               currency,
               supported_los_rates,
               id,
               alt_id,
               supplier_id,
               toilets,
               total_beds,
               space,
               space_unit,
               childs,
               latitude,
               longitude,
               living_room,
               notes,
               attributes_with_quantity,
               nearby_amenities,
               bedroom_configuration,
               check_in_time,
               check_in_to_time,
               check_out_time,
               policy,
               location,
               tax_number,
               tourist_license_number,
               tourist_license_expiry_date,
               multi_unit,
               parent_id)
end

.namesObject

A mapping from model property names to API property names.



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
183
184
185
186
187
188
# File 'lib/asdawqw/models/property.rb', line 153

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['name'] = 'name'
  @_hash['id'] = 'id'
  @_hash['alt_id'] = 'altId'
  @_hash['supplier_id'] = 'supplierId'
  @_hash['rooms'] = 'rooms'
  @_hash['bathrooms'] = 'bathrooms'
  @_hash['toilets'] = 'toilets'
  @_hash['total_beds'] = 'totalBeds'
  @_hash['space'] = 'space'
  @_hash['space_unit'] = 'spaceUnit'
  @_hash['persons'] = 'persons'
  @_hash['childs'] = 'childs'
  @_hash['latitude'] = 'latitude'
  @_hash['longitude'] = 'longitude'
  @_hash['living_room'] = 'livingRoom'
  @_hash['notes'] = 'notes'
  @_hash['attributes_with_quantity'] = 'attributesWithQuantity'
  @_hash['nearby_amenities'] = 'nearbyAmenities'
  @_hash['property_type'] = 'propertyType'
  @_hash['bedroom_configuration'] = 'bedroomConfiguration'
  @_hash['check_in_time'] = 'checkInTime'
  @_hash['check_in_to_time'] = 'checkInToTime'
  @_hash['check_out_time'] = 'checkOutTime'
  @_hash['currency'] = 'currency'
  @_hash['policy'] = 'policy'
  @_hash['location'] = 'location'
  @_hash['supported_los_rates'] = 'supportedLosRates'
  @_hash['tax_number'] = 'taxNumber'
  @_hash['tourist_license_number'] = 'touristLicenseNumber'
  @_hash['tourist_license_expiry_date'] = 'touristLicenseExpiryDate'
  @_hash['multi_unit'] = 'multiUnit'
  @_hash['parent_id'] = 'parentId'
  @_hash
end