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>
93 94 95 96 97 98 |
# File 'lib/justimmo_client/realty.rb', line 93 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>
111 112 113 114 115 116 |
# File 'lib/justimmo_client/realty.rb', line 111 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.
68 69 70 71 72 73 74 |
# File 'lib/justimmo_client/realty.rb', line 68 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.
78 79 80 |
# File 'lib/justimmo_client/realty.rb', line 78 def details( = {}) ids().map { |id| detail(id) } end |
.federal_states(options = {}) ⇒ Array<Object>
121 122 123 124 125 126 |
# File 'lib/justimmo_client/realty.rb', line 121 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.
84 85 86 87 88 89 |
# File 'lib/justimmo_client/realty.rb', line 84 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.
57 58 59 60 61 62 63 |
# File 'lib/justimmo_client/realty.rb', line 57 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>
132 133 134 135 136 137 |
# File 'lib/justimmo_client/realty.rb', line 132 def regions( = {}) xml_response = request(:realty).regions() representer(:region).for_collection.new([]).from_xml(xml_response) rescue JustimmoClient::RetrievalFailed [] end |
.types(options = {}) ⇒ Array<Object>
102 103 104 105 106 107 |
# File 'lib/justimmo_client/realty.rb', line 102 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>
143 144 145 146 147 148 |
# File 'lib/justimmo_client/realty.rb', line 143 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 |