justimmo_client 0.6.1 → 0.6.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 28c8c5889fc30bf130af4e4f14fe53c147d7252c
4
- data.tar.gz: 269cdbff8ecd55635a8fe62efdb6f47c6b31c909
3
+ metadata.gz: 6928830a5a023c1cf09735024ca26b23fab285fc
4
+ data.tar.gz: acf43eca7ca6a680dc7b6dab59b397ab77ae4b8c
5
5
  SHA512:
6
- metadata.gz: 48aaa4888d18ee373a7b51ea8825abc7dc552b8235f9b0b729bed68a515c28455022893e56c268c8849409394db2633fd379e31de39eaebea654ec29fe30e01d
7
- data.tar.gz: 90e74ba04d557e458be70c10861ecbe15a0079a0ce72c5029d9f9e43aa9cb39693aeb2ab4f1fa6a21cc17df9462d9f95395e408adb8d4a81d845e1f6f6ca55d3
6
+ metadata.gz: 90718990f0e62c1f973a6037f34ec881d7644d7507669daa430ee6c34cc720d014ec9cf452082d467bbd2e8aa022529f349516f018f70ef8bdbf4b81d9ddecac
7
+ data.tar.gz: d2f9f2076d83e6a3372dbbe5b9d7532c2a59548f4c532f0d4df2d2ad1341cafe4697bd0466b90db6b50034b10d5dabea254298a407de276cfe86bb6ff7caddf7
@@ -36,7 +36,7 @@ module JustimmoClient::V1
36
36
  rent rent_net rent_cold rent_including_heating rent_per_sqm deposit
37
37
  ].each do |meth|
38
38
  define_method("#{meth}=") do |amount|
39
- # log.debug("Using currency #{currency.name} for #{meth}")
39
+ log.debug("Using currency #{currency&.name} for #{meth}")
40
40
  instance_variable_set("@#{meth}", Monetize.parse(amount))
41
41
  end
42
42
  end
@@ -57,9 +57,8 @@ module JustimmoClient::V1
57
57
  end
58
58
 
59
59
  def currency=(cur)
60
- return if cur.nil?
61
- @currency = Money::Currency.new(cur)
62
- Money.default_currency = @currency
60
+ @currency = Money::Currency.new(cur) unless cur.nil?
61
+ Money.default_currency = @currency || :eur
63
62
  log.debug("Set currency to #{currency.name}")
64
63
  end
65
64
 
@@ -79,7 +78,7 @@ module JustimmoClient::V1
79
78
  end
80
79
 
81
80
  def rent_vat
82
- return nil unless rent? && rent_net
81
+ return nil unless rent? && rent_net && @rent_vat
83
82
  rent_net / 100 * @rent_vat
84
83
  end
85
84
 
@@ -95,6 +94,10 @@ module JustimmoClient::V1
95
94
  on_demand? ? "on demand" : get.format
96
95
  end
97
96
 
97
+ def as_json
98
+ @attributes.to_s
99
+ end
100
+
98
101
  def inspect
99
102
  "#<#{self.class} #{self}>"
100
103
  end
@@ -1,30 +1,42 @@
1
1
  module JustimmoClient::V1
2
2
  module JSON
3
3
  class RealtyPriceRepresenter < JustimmoRepresenter
4
- property :currency
5
- property :purcase
6
- property :purcase_net
7
- property :on_demand
4
+ %i[
5
+ purcase
6
+ purcase_net
7
+ rent
8
+ rent_net
9
+ rent_cold
10
+ rent_including_heating
11
+ deposit
12
+ rent_per_sqm
13
+ operating_cost
14
+ operating_cost_net
15
+ operating_cost_per_sqm
16
+ ].each do |k|
17
+ property k,
18
+ setter: ->(represented:, fragment:, **) { represented.public_send("#{k}=", fragment) },
19
+ getter: ->(represented:, **) { represented.public_send(k)&.to_f }
20
+ end
21
+
22
+ property :currency,
23
+ setter: ->(represented:, fragment:, **) { represented.currency = fragment },
24
+ getter: ->(represented:, **) { represented.currency&.id }
8
25
 
9
- property :rent
10
- property :rent_net
11
- property :rent_vat
26
+ property :commission,
27
+ setter: ->(represented:, fragment:, **) { represented.commission = fragment },
28
+ getter: ->(represented:, **) { represented.instance_variable_get(:@commission) }
12
29
 
13
- property :deposit
14
- property :rent_cold
15
- property :rent_including_heating
16
- property :rent_per_sqm
17
- property :operating_cost_per_sqm
30
+ property :rent_vat,
31
+ setter: ->(represented:, fragment:, **) { represented.rent_vat = fragment },
32
+ getter: ->(represented:, **) { represented.instance_variable_get(:@rent_vat) }
18
33
 
19
34
  property :provision
20
35
  property :including_vat
21
- property :commission
36
+ property :on_demand
22
37
 
23
38
  property :real_estate_taxes
24
39
  property :land_registry
25
-
26
- property :operating_cost
27
- property :operating_cost_net
28
40
  property :operating_cost_vat
29
41
  end
30
42
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JustimmoClient
4
- VERSION = "0.6.1"
4
+ VERSION = "0.6.2"
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.6.1
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrick Auernig