Class: ApartmentRatings::Complex

Inherits:
Hashie::Trash
  • Object
show all
Includes:
Hashie::Extensions::Coercion, Hashie::Extensions::IgnoreUndeclared, Hashie::Extensions::IndifferentAccess
Defined in:
lib/apartment_ratings/complex.rb

Class Method Summary collapse

Class Method Details

.allObject



23
24
25
26
27
28
29
30
31
# File 'lib/apartment_ratings/complex.rb', line 23

def self.all
  ApartmentRatings.post('index') do |result|
    if result['success']
      result['complexes'].map { |complex_json| new complex_json }
    else
      fail StandardError
    end
  end
end

.find(id) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/apartment_ratings/complex.rb', line 33

def self.find(id)
  ApartmentRatings.post('complex', complexId: id) do |result|
    if result['success']
      default_options = { id: id }
      new default_options.merge(result)
    else
      fail ApartmentRatings::Errors::InvalidComplexId.new(id, result['errorMessage'])
    end
  end
end