Module: JustimmoClient::Realty

Extended by:
Utils
Defined in:
lib/justimmo_client/realty.rb

Overview

Public realty query interface

Class Method Summary collapse

Methods included from Utils

api, autoload_dir, model, representer, request, versioned_api

Class Method Details

.categories(options = {}) ⇒ Array<Object>

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :all (Boolean) — default: false

Returns:

  • (Array<Object>)


93
94
95
96
97
98
# File 'lib/justimmo_client/realty.rb', line 93

def categories(options = {})
  xml_response = request(:realty).categories(options)
  representer(:realty_category).for_collection.new([]).from_xml(xml_response)
rescue JustimmoClient::RetrievalFailed
  []
end

.countries(options = {}) ⇒ Array<Object>

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :all (Boolean) — default: false

Returns:

  • (Array<Object>)


111
112
113
114
115
116
# File 'lib/justimmo_client/realty.rb', line 111

def countries(options = {})
  xml_response = request(:realty).countries(options)
  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.

Parameters:

  • id (Integer)
  • lang (Symbol, String) (defaults to: nil)

Returns:

  • (Object, nil)

    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.

Returns:

  • (Array<Object>)

    An array of detailed realty objects, or an empty array on error.

See Also:



78
79
80
# File 'lib/justimmo_client/realty.rb', line 78

def details(options = {})
  ids(options).map { |id| detail(id) }
end

.federal_states(options = {}) ⇒ Array<Object>

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :all (Boolean) — default: false
  • :country (Integer) — default: nil

Returns:

  • (Array<Object>)


121
122
123
124
125
126
# File 'lib/justimmo_client/realty.rb', line 121

def federal_states(options = {})
  xml_response = request(:realty).federal_states(options)
  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.

Returns:

  • (Array<Integer>)

    An array of realty ids, empty array if no results.

See Also:



84
85
86
87
88
89
# File 'lib/justimmo_client/realty.rb', line 84

def ids(options = {})
  json_response = request(:realty).ids(options)
  ::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.

Examples:

Filter by zip code and limit to three results.

JustimmoClient::Realty.list(zip_code: 6800, limit: 3)

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :limit (Integer) — default: 10
  • :offset (Integer) — default: 0
  • :lang (Symbol, String) — default: :de
  • :orderby (Symbol, String)
  • :ordertype (Symbol, String) — default: :asc
  • :picturesize (Symbol, String) — default: :small
  • :with_projects (Boolean) — default: false
  • :price_min (Float)
  • :price_max (Float)
  • :price_per_sqm_min (Float)
  • :price_per_sqm_max (Float)
  • :type_id (Integer)
  • :sub_type_id (Integer)
  • :tag (Symbol, String)
  • :zip_code (String, Integer)
  • :zip_code_min (String, Integer)
  • :zip_code_max (String, Integer)
  • :rooms_min (Integer)
  • :rooms_max (Integer)
  • :number (Integer)
  • :number_min (Integer)
  • :number_max (Integer)
  • :area_min (Float)
  • :area_max (Float)
  • :living_area_min (Float)
  • :living_area_max (Float)
  • :floor_area_min (Float)
  • :floor_area_max (Float)
  • :surface_area_min (Float)
  • :surface_area_max (Float)
  • :keyword (Symbol, String)
  • :country_id (Integer)
  • :federal_state_id (Integer)
  • :status_id (Integer)
  • :rent (Boolean)
  • :purcase (Boolean)
  • :owner_id (Integer)
  • :project_id (Integer)
  • :type (Symbol, String)
  • :parent_id (Integer)
  • :updated_at_min (DateTime)
  • :updated_at_max (DateTime)

Returns:

  • (Array<Object>)

    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(options = {})
  xml_response = request(:realty).list(options)
  model = Struct.new(:realties).new
  representer(:realty_list).new(model).from_xml(xml_response).realties
rescue JustimmoClient::RetrievalFailed
  []
end

.regions(options = {}) ⇒ Array<Object>

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :all (Boolean) — default: false
  • :country (Integer) — default: nil
  • :federal_state (Integer) — default: nil

Returns:

  • (Array<Object>)


132
133
134
135
136
137
# File 'lib/justimmo_client/realty.rb', line 132

def regions(options = {})
  xml_response = request(:realty).regions(options)
  representer(:region).for_collection.new([]).from_xml(xml_response)
rescue JustimmoClient::RetrievalFailed
  []
end

.types(options = {}) ⇒ Array<Object>

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :all (Boolean) — default: false

Returns:

  • (Array<Object>)


102
103
104
105
106
107
# File 'lib/justimmo_client/realty.rb', line 102

def types(options = {})
  xml_response = request(:realty).types(options)
  representer(:realty_type).for_collection.new([]).from_xml(xml_response)
rescue JustimmoClient::RetrievalFailed
  []
end

.zip_codes_and_cities(options = {}) ⇒ Array<Object>

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :all (Boolean) — default: false
  • :country (Integer) — default: nil
  • :federal_state (Integer) — default: nil

Returns:

  • (Array<Object>)


143
144
145
146
147
148
# File 'lib/justimmo_client/realty.rb', line 143

def zip_codes_and_cities(options = {})
  xml_response = request(:realty).zip_codes_and_cities(options)
  representer(:city).for_collection.new([]).from_xml(xml_response)
rescue JustimmoClient::RetrievalFailed
  []
end