Class: Justimmo::API::Realty Private

Inherits:
Resource show all
Defined in:
lib/justimmo/api/v1/realty.rb

Overview

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

Represents a complete realty resource.

Direct Known Subclasses

Realty

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

class_name, from_json, mapper, query, #to_h, #to_json

Constructor Details

#initialize(options = {}) ⇒ Realty

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 new instance of Realty.


30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/justimmo/api/v1/realty.rb', line 30

def initialize(options = {})
  @attributes = %i[
    id external_id
    title description
    openimmo_obid language
    teaser proximity
    first_image second_image
    created_at updated_at
  ] + SECTIONS

  SECTIONS.each { |x| options[x] = build_section(x, options) }
  MERGE.each { |x| merge_section(x, options) }

  super(options)
end

Class Method Details

.detail(params = {}) ⇒ Realty

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 Realty object.


114
115
116
# File 'lib/justimmo/api/v1/realty.rb', line 114

def detail(params = {})
  from_xml(query.detail(params))
end

.expose(params = {}) ⇒ Object

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.


118
119
120
# File 'lib/justimmo/api/v1/realty.rb', line 118

def expose(params = {})
  query.expose(params)
end

.from_xml(xml) ⇒ Object

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.


97
98
99
100
101
102
103
104
# File 'lib/justimmo/api/v1/realty.rb', line 97

def from_xml(xml)
  parsed = Justimmo::Parser.parse(xml, mapper)
  parsed = parsed.fetch(:justimmo, {}).fetch(:realty, {})
  case parsed
  when Array then parsed.map { |x| new(x) }
  when Hash  then new(parsed)
  end
end

.ids(params = {}) ⇒ Object

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.


126
127
128
# File 'lib/justimmo/api/v1/realty.rb', line 126

def ids(params = {})
  query.ids(params)
end

.inquiry(params = {}) ⇒ Object

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.


122
123
124
# File 'lib/justimmo/api/v1/realty.rb', line 122

def inquiry(params = {})
  query.inquiry(params)
end

.list(params = {}) ⇒ Array<Realty>

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 Array of Realty objects or empty Array.


108
109
110
# File 'lib/justimmo/api/v1/realty.rb', line 108

def list(params = {})
  from_xml(query.list(params))
end

Instance Method Details

#descriptionObject

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.


58
59
60
# File 'lib/justimmo/api/v1/realty.rb', line 58

def description
  @attributes[:free_text].description
end

#inspectObject

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.


50
51
52
# File 'lib/justimmo/api/v1/realty.rb', line 50

def inspect
  "<Realty: #{self}>"
end

#property_numberObject

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.


54
55
56
# File 'lib/justimmo/api/v1/realty.rb', line 54

def property_number
  external_id
end

#titleObject

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.


62
63
64
# File 'lib/justimmo/api/v1/realty.rb', line 62

def title
  @attributes[:free_text].title
end

#to_sObject

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.


46
47
48
# File 'lib/justimmo/api/v1/realty.rb', line 46

def to_s
  @attributes[:id].to_s
end