Class: PropertySolutions::Properties
- Inherits:
-
ApiConsumer
- Object
- ApiConsumer
- PropertySolutions::Properties
- Defined in:
- app/models/property_solutions/properties.rb
Constant Summary collapse
- @@field_order =
'id'
- @@base =
'properties'
Class Method Summary collapse
-
.all ⇒ Object
Return all the properties.
-
.find(property_id) ⇒ Object
Find a property given a property ID.
-
.properties(property_ids = nil) ⇒ Object
Return all the properties.
-
.reorder(field) ⇒ Object
Reorder the properties that will be returned based on the given field.
Methods inherited from ApiConsumer
Class Method Details
.all ⇒ Object
Return all the properties
25 26 27 |
# File 'app/models/property_solutions/properties.rb', line 25 def self.all return self.properties end |
.find(property_id) ⇒ Object
Find a property given a property ID
9 10 11 12 13 14 15 16 |
# File 'app/models/property_solutions/properties.rb', line 9 def self.find(property_id) resp = self.request('getProperties', { 'propertyIds' => [property_id] }) return nil if !resp || resp['PhysicalProperty'].nil? || resp['PhysicalProperty']['Property'].nil? prop = Property.new(resp['PhysicalProperty']['Property'][0]) return prop end |
.properties(property_ids = nil) ⇒ Object
Return all the properties
30 31 32 33 34 35 36 37 38 39 40 |
# File 'app/models/property_solutions/properties.rb', line 30 def self.properties(property_ids = nil) resp = self.request('getProperties', { 'propertyIds' => property_ids }) return [] if !resp || resp['PhysicalProperty'].nil? || resp['PhysicalProperty']['Property'].nil? props = resp['PhysicalProperty']['Property'].collect { |p| Property.new(p) } props.sort! { |x,y| x.send(@@field_order.to_sym) <=> y.send(@@field_order.to_sym) } return props end |
.reorder(field) ⇒ Object
Reorder the properties that will be returned based on the given field
19 20 21 22 |
# File 'app/models/property_solutions/properties.rb', line 19 def self.reorder(field) @@field_order = field return self end |