justimmo_client 0.4.4 → 0.4.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6889b2849895ac84cbda9609a4d40847104acd88
4
- data.tar.gz: a90c60aef5e69d154704b24a15b13f7eef656f0c
3
+ metadata.gz: 862c14b5638385085dd28a49b7516615bad161cb
4
+ data.tar.gz: f9a71e5c7282b4e935faa15afc6f4756d7842d1d
5
5
  SHA512:
6
- metadata.gz: 7168d63aa6ff0d8c4901f0893c78b268840457d048caffb9d271c6e658f4ed030caa779dcf1299eb88cae19d9d18e4d3ad1142f02e4c652e24e14853a78fffc0
7
- data.tar.gz: 48f3d5ba3187aa261ea3ae2f72cf946ce9c616e8abbeb1c40734c2d2bacd58a7fd686e3288c5d3b0c8727206946fbff40c0c6742fe90945ae065397760c8b5a2
6
+ metadata.gz: 87d97beb7c5aff8c95bdb2e85c4726e7586e22c85665cdd9dcd9d18dd2e6a701af4180d261b88a6e180d13de80be2bb04517bdcefe7cdf57227915b708bd8f1f
7
+ data.tar.gz: d443e4e059747c07a2266ea72087fa2691d2e6c3b854e158f82c3441a664ae240fade67435444019b013a9776ed7e6018bd03d8cf2cb7c919b6fe633d683b0b9
@@ -27,6 +27,10 @@ module JustimmoClient::V1
27
27
 
28
28
  # @!group Instance Method Summary
29
29
 
30
+ def image
31
+ picture
32
+ end
33
+
30
34
  def full_name(surname_first: false, with_salutation: true)
31
35
  name = [first_name, last_name]
32
36
  name.reverse! if surname_first
@@ -10,7 +10,7 @@ module JustimmoClient::V1
10
10
  # @return [$2]
11
11
  attribute :proximity, String
12
12
  attribute :federal_state, String
13
- attribute :country, String
13
+ attribute :country, IsoCountryCodes::Code
14
14
  attribute :zip_code, Integer
15
15
  attribute :latitude, Float
16
16
  attribute :longitude, Float
@@ -30,6 +30,7 @@ module JustimmoClient::V1
30
30
  attribute :videos, Array
31
31
  attribute :images360, Array
32
32
  attribute :links, Array
33
+ attribute :construction_year, Integer
33
34
  attribute :available, DateTime
34
35
  attribute :created_at, DateTime
35
36
  attribute :updated_at, DateTime
@@ -68,6 +68,8 @@ module JustimmoClient::V1
68
68
  end
69
69
 
70
70
  def commission
71
+ return nil unless @commission
72
+
71
73
  if purcase?
72
74
  (get / 100 * @commission) * 1.20
73
75
  else
@@ -76,6 +78,7 @@ module JustimmoClient::V1
76
78
  end
77
79
 
78
80
  def rent_vat
81
+ return nil unless rent? && rent_net
79
82
  rent_net / 100 * @rent_vat
80
83
  end
81
84
 
@@ -83,8 +86,12 @@ module JustimmoClient::V1
83
86
  @purcase || @rent
84
87
  end
85
88
 
89
+ def to_f
90
+ get.to_f
91
+ end
92
+
86
93
  def to_s
87
- on_demand? ? "on demand" : "#{get} #{get.symbol}"
94
+ on_demand? ? "on demand" : get.format
88
95
  end
89
96
 
90
97
  def inspect
@@ -7,6 +7,6 @@ module JustimmoClient::V1
7
7
  # @!macro [attach] attribute
8
8
  # @return [$2]
9
9
  attribute :id, Integer
10
- attribute :name, String
10
+ attribute :name, Symbol
11
11
  end
12
12
  end
@@ -20,5 +20,23 @@ module JustimmoClient::V1
20
20
  attribute :living, Boolean
21
21
  attribute :business, Boolean
22
22
  attribute :investment, Boolean
23
+
24
+ # @!group Instance Method Summary
25
+
26
+ def to_a
27
+ tmp = []
28
+ tmp << :living if living?
29
+ tmp << :business if business?
30
+ tmp << :investment if investment?
31
+ tmp
32
+ end
33
+
34
+ def to_s
35
+ to_a.join(", ")
36
+ end
37
+
38
+ def map(&block)
39
+ to_a.map(&block)
40
+ end
23
41
  end
24
42
  end
@@ -20,6 +20,10 @@ module JustimmoClient::V1
20
20
  parse_filter: ->(_fragment, options) { options[:doc].css("user_defined_simplefield[feldname=aktualisiert_am]").text }
21
21
  end
22
22
 
23
+ nested :zustand_angaben do
24
+ property :construction_year, as: :baujahr
25
+ end
26
+
23
27
  property :geo,
24
28
  decorator: GeoLocationRepresenter,
25
29
  class: GeoLocation
@@ -5,8 +5,25 @@ module JustimmoClient::V1
5
5
  class RealtyTypeRepresenter < JustimmoRepresenter
6
6
  self.representation_wrap = :objektart
7
7
 
8
+ TRANSLATION_MAPPING = {
9
+ "Zimmer" => :room,
10
+ "Wohnung" => :apartment,
11
+ "Haus" => :house,
12
+ "Grundstück" => :property,
13
+ "Büro / Praxis" => :office,
14
+ "Einzelhandel" => :retail,
15
+ "Gastgewerbe" => :hospitality,
16
+ "Industrie / Gewerbe" => :business,
17
+ "Land und Forstwirtschaft" => :agriculture,
18
+ "Sonstige / Sonderobjekte" => :other,
19
+ "Freizeitimmobilie gewerblich" => :recreational_property_business,
20
+ "Zinshaus / Renditeobjekt" => :yield,
21
+ "Parken" => :parking
22
+ }.freeze
23
+
8
24
  property :id
9
- property :name
25
+ property :name,
26
+ parse_filter: ->(fragment, **) { TRANSLATION_MAPPING[fragment] }
10
27
 
11
28
  collection_representer class: RealtyType
12
29
  end
@@ -15,8 +15,6 @@ module JustimmoClient::V1
15
15
  price: :preis,
16
16
  zip_code: :plz,
17
17
  price_per_sqm: :preis_per_m2,
18
- type: :objektart,
19
- subtype: :subobjektart,
20
18
  tag: :tagname,
21
19
  rooms: :zimmer,
22
20
  area: :flaeche,
@@ -38,7 +36,10 @@ module JustimmoClient::V1
38
36
  location: :ort,
39
37
  all: :alle,
40
38
  rent: :miete,
41
- purcase: :kauf
39
+ purcase: :kauf,
40
+ type: :objektart,
41
+ sub_type: :subobjektart,
42
+ system_type: :realty_type
42
43
  }.freeze
43
44
 
44
45
  module_function
@@ -172,7 +173,13 @@ module JustimmoClient::V1
172
173
  f.add :price_per_sqm_min
173
174
  f.add :price_per_sqm_max
174
175
  f.add :type_id
175
- f.add :subtype_id
176
+ f.add :type do |key, *values|
177
+ values = [values].flatten.map(&:to_sym)
178
+ log.debug(values)
179
+ types = JustimmoClient::Realty.types
180
+ [:type_id, types.select { |x| values.include?(x.name) }.map(&:id)]
181
+ end
182
+ f.add :sub_type_id
176
183
  f.add :tag
177
184
  f.add :zip_code
178
185
  f.add :zip_code_min
@@ -195,7 +202,7 @@ module JustimmoClient::V1
195
202
  f.add :federal_state_id
196
203
  f.add :status_id
197
204
  f.add :project_id
198
- f.add :type
205
+ f.add :system_type
199
206
  f.add :parent_id
200
207
  f.add :rent, type: :bool
201
208
  f.add :purcase, type: :bool
@@ -100,7 +100,7 @@ module JustimmoClient
100
100
 
101
101
  coerced =
102
102
  case @options.dig(key, :type)
103
- when :bool then i_to_bool(value)
103
+ when :bool then bool_to_i(value)
104
104
  else mapping(value)
105
105
  end
106
106
 
@@ -113,8 +113,12 @@ module JustimmoClient
113
113
  { "#{api_param}#{min}": range.first, "#{api_param}#{max}": range.last }
114
114
  end
115
115
 
116
- def i_to_bool(value)
117
- value ? 1 : 0
116
+ def bool_to_i(value)
117
+ case value
118
+ when "true" then 1
119
+ when "false" then 0
120
+ else value ? 1 : 0
121
+ end
118
122
  end
119
123
  end
120
124
  end
@@ -21,6 +21,7 @@ module JustimmoClient
21
21
  # @option options [Float] :price_per_sqm_min
22
22
  # @option options [Float] :price_per_sqm_max
23
23
  # @option options [Integer] :type_id
24
+ # @option options [Symbol, String, Array<Symbol, String>] :type
24
25
  # @option options [Integer] :sub_type_id
25
26
  # @option options [Symbol, String] :tag
26
27
  # @option options [String, Integer] :zip_code
@@ -47,7 +48,7 @@ module JustimmoClient
47
48
  # @option options [Boolean] :purcase
48
49
  # @option options [Integer] :owner_id
49
50
  # @option options [Integer] :project_id
50
- # @option options [Symbol, String] :type
51
+ # @option options [String] :system_type
51
52
  # @option options [Integer] :parent_id
52
53
  # @option options [DateTime] :updated_at_min
53
54
  # @option options [DateTime] :updated_at_max
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JustimmoClient
4
- VERSION = "0.4.4"
4
+ VERSION = "0.4.5"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: justimmo_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Auernig