Module: JustimmoClient::V1::RealtyRequest Private

Extended by:
JustimmoRequest
Defined in:
lib/justimmo_client/api/v1/requests/realty_request.rb

This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.

Constant Summary collapse

TRANSLATION_MAPPING =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Mappings for the option parser

{
  limit: :Limit,
  offset: :Offset,
  lang: :culture,
  with_projects: :alleProjektObjekte,
  number: :objektnummer,
  price: :preis,
  zip_code: :plz,
  price_per_sqm: :preis_per_m2,
  tag: :tagname,
  rooms: :zimmer,
  area: :flaeche,
  living_area: :wohnflaeche,
  floor_area: :nutzflaeche,
  surface_area: :grundflaeche,
  keyword: :stichwort,
  country: :land,
  federal_state: :bundesland,
  small_undbanded: :small,
  small2_unbranded: :s220x155,
  small3_unbranded: :s312x208,
  id: :objekt_id,
  salutation: :anrede,
  title: :titel,
  first_name: :vorname,
  last_name: :nachname,
  phone: :tel,
  location: :ort,
  all: :alle,
  rent: :miete,
  purcase: :kauf,
  type: :objektart,
  sub_type: :subobjektart,
  system_type: :realty_type
}.freeze

Realty Requests collapse

Basic Data Requests collapse

Option Parsers collapse

Methods included from JustimmoRequest

get, request, with_request_error_handler

Methods included from Logging

default_logger, #logger, rails_logger

Class Method Details

.categories(all: false) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The requested XML.

Parameters:

  • all (Boolean) (defaults to: false)

    (false)

Returns:

  • (String)

    The requested XML.



96
97
98
99
100
# File 'lib/justimmo_client/api/v1/requests/realty_request.rb', line 96

def categories(all: false)
  with_error_handler do
    get("objekt/kategorien", alle: all ? 1 : 0)
  end
end

.countries(all: false) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The requested XML.

Parameters:

  • all (Boolean) (defaults to: false)

    (false)

Returns:

  • (String)

    The requested XML.



112
113
114
115
116
# File 'lib/justimmo_client/api/v1/requests/realty_request.rb', line 112

def countries(all: false)
  with_error_handler do
    get("objekt/laender", alle: all ? 1 : 0)
  end
end

.detail(id, lang: nil) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The requested XML.

Parameters:

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

Returns:

  • (String)

    The requested XML.



60
61
62
63
64
# File 'lib/justimmo_client/api/v1/requests/realty_request.rb', line 60

def detail(id, lang: nil)
  with_error_handler do
    get("objekt/detail", detail_option_parser.parse(id: id, lang: lang))
  end
end

.detail_option_parserHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Hash)


238
239
240
241
242
243
244
245
246
247
# File 'lib/justimmo_client/api/v1/requests/realty_request.rb', line 238

def detail_option_parser
  @option_parsers ||= {}
  @option_parsers[:detail] = JustimmoClient::OptionParser.new do |options|
    options.mappings = TRANSLATION_MAPPING

    options.add :all
    options.add :lang
    options.add :id
  end
end

.expose(**params) ⇒ File

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

TODO:

implement this

Returns The PDF file.

Parameters:

  • params (Hash)

Returns:

  • (File)

    The PDF file.



86
87
88
89
90
# File 'lib/justimmo_client/api/v1/requests/realty_request.rb', line 86

def expose(**params)
  with_error_handler do
    get("objekt/expose", params)
  end
end

.federal_states(country:, all: false) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The requested XML.

Parameters:

  • all (Boolean) (defaults to: false)

    (false)

  • country (Integer, String)

Returns:

  • (String)

    The requested XML.



121
122
123
124
125
# File 'lib/justimmo_client/api/v1/requests/realty_request.rb', line 121

def federal_states(country:, all: false)
  with_error_handler do
    get("objekt/bundeslaender", land: country, alle: all ? 1 : 0)
  end
end

.ids(**params) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns A JSON string containing an array of ids.

Parameters:

  • params (Hash)

Returns:

  • (String)

    A JSON string containing an array of ids.



77
78
79
80
81
# File 'lib/justimmo_client/api/v1/requests/realty_request.rb', line 77

def ids(**params)
  with_error_handler do
    get("objekt/ids", list_option_parser.parse(params))
  end
end

.inquiry(id, **params) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The requested XML.

Parameters:

  • id (Integer)
  • params (Hash)

Returns:

  • (String)

    The requested XML.



69
70
71
72
73
# File 'lib/justimmo_client/api/v1/requests/realty_request.rb', line 69

def inquiry(id, **params)
  with_error_handler do
    get("objekt/anfrage", inquiry_option_parser.parse(params.update(id: id)))
  end
end

.inquiry_option_parserHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Hash)


217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/justimmo_client/api/v1/requests/realty_request.rb', line 217

def inquiry_option_parser
  @option_parsers ||= {}
  @option_parsers[:inquiry] = JustimmoClient::OptionParser.new do |options|
    options.mappings = TRANSLATION_MAPPING
    options.range_suffix = %i[_von _bis]

    options.add :salutation_id
    options.add :title
    options.add :first_name
    options.add :last_name
    options.add :email
    options.add :phone
    options.add :message
    options.add :street
    options.add :zip_code
    options.add :location
    options.add :country
  end
end

.list(**params) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The requested XML.

Parameters:

  • params (Hash)

Returns:

  • (String)

    The requested XML.



51
52
53
54
55
# File 'lib/justimmo_client/api/v1/requests/realty_request.rb', line 51

def list(**params)
  with_error_handler do
    get("objekt/list", list_option_parser.parse(params))
  end
end

.list_option_parserHash

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Hash)


154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
# File 'lib/justimmo_client/api/v1/requests/realty_request.rb', line 154

def list_option_parser
  @option_parsers ||= {}
  @option_parsers[:list] ||= JustimmoClient::OptionParser.new do |options|
    options.mappings = TRANSLATION_MAPPING
    options.range_suffix = %i[_von _bis]

    options.add :limit
    options.add :offset
    options.add :lang
    options.add :orderby, values: %i[price zip_code number created_at updated_at published_at]
    options.add :ordertype, values: %i[asc desc]
    options.add :picturesize, values: %i[small_unbranded small2_unbranded small3_unbranded medium_unbranded big_unbranded big2_unbranded medium big big2]
    options.add :with_projects, type: :bool
    options.group :filter do |f|
      f.add :price_min
      f.add :price_max
      f.add :price_per_sqm_min
      f.add :price_per_sqm_max
      f.add :type_id
      f.add :type do |key, *values|
        values = [values].flatten.map(&:to_sym)
        log.debug(values)
        types = RealtyInterface.types
        [:type_id, types.select { |x| values.include?(x.name) }.map(&:id)]
      end
      f.add :sub_type_id
      f.add :tag
      f.add :zip_code
      f.add :zip_code_min
      f.add :zip_code_max
      f.add :rooms_min
      f.add :rooms_max
      f.add :number
      f.add :number_min
      f.add :number_max
      f.add :area_min
      f.add :area_max
      f.add :living_area_min
      f.add :living_area_max
      f.add :floor_area_min
      f.add :floor_area_max
      f.add :surface_area_min
      f.add :surface_area_max
      f.add :keyword
      f.add :country_id
      f.add :federal_state_id
      f.add :status_id
      f.add :project_id
      f.add :system_type
      f.add :parent_id
      f.add :rent, type: :bool
      f.add :purcase, type: :bool
      f.add :updated_at_min, as: :aktualisiert_am_von
      f.add :updated_at_max, as: :aktualisiert_am_bis
      f.add :location do |key, value|
        cities = RealtyInterface.zip_codes_and_cities
        [:zip_code, cities.select { |x| x.location == value }.first&.zip_code]
      end
    end
  end
end

.regions(country: nil, federal_state: nil, all: false) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The requested XML.

Parameters:

  • all (Boolean) (defaults to: false)

    (false)

  • country (Integer, String) (defaults to: nil)
  • federal_state (Integer) (defaults to: nil)

Returns:

  • (String)

    The requested XML.



131
132
133
134
135
# File 'lib/justimmo_client/api/v1/requests/realty_request.rb', line 131

def regions(country: nil, federal_state: nil, all: false)
  with_error_handler do
    get("objekt/regionen", land: country, bundesland: federal_state, alle: all ? 1 : 0)
  end
end

.types(all: false) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The requested XML.

Parameters:

  • all (Boolean) (defaults to: false)

    (false)

Returns:

  • (String)

    The requested XML.



104
105
106
107
108
# File 'lib/justimmo_client/api/v1/requests/realty_request.rb', line 104

def types(all: false)
  with_error_handler do
    get("objekt/objektarten", alle: all ? 1 : 0)
  end
end

.with_error_handlerObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



147
148
149
# File 'lib/justimmo_client/api/v1/requests/realty_request.rb', line 147

def with_error_handler
  yield
end

.zip_codes_and_cities(country: nil, federal_state: nil, all: false) ⇒ String

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns The requested XML.

Parameters:

  • all (Boolean) (defaults to: false)

    (false)

  • country (Integer, String) (defaults to: nil)
  • federal_state (Integer) (defaults to: nil)

Returns:

  • (String)

    The requested XML.



141
142
143
144
145
# File 'lib/justimmo_client/api/v1/requests/realty_request.rb', line 141

def zip_codes_and_cities(country: nil, federal_state: nil, all: false)
  with_error_handler do
    get("objekt/plzsUndOrte", land: country, bundesland: federal_state, alle: all ? 1 : 0)
  end
end