Module: JustimmoClient::Realty
- Extended by:
- Utils
- Defined in:
- lib/justimmo_client/realty.rb
Overview
Public realty query interface
Class Method Summary collapse
- .categories(options = {}) ⇒ Array<Object>
- .countries(options = {}) ⇒ Array<Object>
-
.detail(id, lang: nil) ⇒ Object?
A detailed realty object, or nil if it could not be found.
-
.details(options = {}) ⇒ Array<Object>
An array of detailed realty objects, or an empty array on error.
- .federal_states(options = {}) ⇒ Array<Object>
-
.ids(options = {}) ⇒ Array<Integer>
An array of realty ids, empty array if no results.
-
.list(options = {}) ⇒ Array<Object>
An array of basic realty objects, or an empty array on error.
- .regions(options = {}) ⇒ Array<Object>
- .types(options = {}) ⇒ Array<Object>
- .zip_codes_and_cities(options = {}) ⇒ Array<Object>
Methods included from Utils
api, autoload_dir, model, representer, request, versioned_api
Class Method Details
.categories(options = {}) ⇒ Array<Object>
94 95 96 97 98 99 |
# File 'lib/justimmo_client/realty.rb', line 94 def categories( = {}) xml_response = request(:realty).categories() representer(:realty_category).for_collection.new([]).from_xml(xml_response) rescue JustimmoClient::RetrievalFailed [] end |
.countries(options = {}) ⇒ Array<Object>
112 113 114 115 116 117 |
# File 'lib/justimmo_client/realty.rb', line 112 def countries( = {}) xml_response = request(:realty).countries() representer(:country).for_collection.new([]).from_xml(xml_response) rescue JustimmoClient::RetrievalFailed [] end |
.detail(id, lang: nil) ⇒ Object?
Returns A detailed realty object, or nil if it could not be found.
69 70 71 72 73 74 75 |
# File 'lib/justimmo_client/realty.rb', line 69 def detail(id, lang: nil) xml_response = request(:realty).detail(id, lang: lang) model = Struct.new(:realty).new representer(:realty_detail).new(model).from_xml(xml_response).realty rescue JustimmoClient::RetrievalFailed nil end |
.details(options = {}) ⇒ Array<Object>
Returns An array of detailed realty objects, or an empty array on error.
79 80 81 |
# File 'lib/justimmo_client/realty.rb', line 79 def details( = {}) ids().map { |id| detail(id) } end |
.federal_states(options = {}) ⇒ Array<Object>
122 123 124 125 126 127 |
# File 'lib/justimmo_client/realty.rb', line 122 def federal_states( = {}) xml_response = request(:realty).federal_states() representer(:federal_state).for_collection.new([]).from_xml(xml_response) rescue JustimmoClient::RetrievalFailed [] end |
.ids(options = {}) ⇒ Array<Integer>
Returns An array of realty ids, empty array if no results.
85 86 87 88 89 90 |
# File 'lib/justimmo_client/realty.rb', line 85 def ids( = {}) json_response = request(:realty).ids() ::JSON.parse(json_response).map(&:to_i) rescue JustimmoClient::RetrievalFailed [] end |
.list(options = {}) ⇒ Array<Object>
Returns An array of basic realty objects, or an empty array on error.
58 59 60 61 62 63 64 |
# File 'lib/justimmo_client/realty.rb', line 58 def list( = {}) xml_response = request(:realty).list() model = Struct.new(:realties).new representer(:realty_list).new(model).from_xml(xml_response).realties rescue JustimmoClient::RetrievalFailed [] end |
.regions(options = {}) ⇒ Array<Object>
133 134 135 136 137 138 |
# File 'lib/justimmo_client/realty.rb', line 133 def regions( = {}) xml_response = request(:realty).regions() representer(:region).for_collection.new([]).from_xml(xml_response) rescue JustimmoClient::RetrievalFailed [] end |
.types(options = {}) ⇒ Array<Object>
103 104 105 106 107 108 |
# File 'lib/justimmo_client/realty.rb', line 103 def types( = {}) xml_response = request(:realty).types() representer(:realty_type).for_collection.new([]).from_xml(xml_response) rescue JustimmoClient::RetrievalFailed [] end |
.zip_codes_and_cities(options = {}) ⇒ Array<Object>
144 145 146 147 148 149 |
# File 'lib/justimmo_client/realty.rb', line 144 def zip_codes_and_cities( = {}) xml_response = request(:realty).zip_codes_and_cities() representer(:city).for_collection.new([]).from_xml(xml_response) rescue JustimmoClient::RetrievalFailed [] end |