justimmo_client 0.6.5 → 0.6.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4af966499684afea9e28c2dacb01816d618c4fe3
|
4
|
+
data.tar.gz: 77b692e3404c61651985609698a80ab77867fa17
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 43f05f744a4496eb025f13e65f1993052c3c7e8e5cebc9fe7dfbaa6ec5497ec6e4bd34a0dca35aeb7dd73d357ce5c518e641998467968128c55966e9c211e21c
|
7
|
+
data.tar.gz: '0385a7d9afde08ada26e6f1aa8576765fecd46f19b903eef3e0ab09f2a84bcca15c2b15a170e685b391c4ca08430ca30c7a8d175f9c146380882fabdacaa6bcd'
|
@@ -16,24 +16,44 @@ module JustimmoClient::V1
|
|
16
16
|
# @!group Instance Method Summary
|
17
17
|
|
18
18
|
def initialize(**options)
|
19
|
-
@country = find_country(options[:name])
|
20
|
-
return unless @country
|
21
|
-
options.update(name: @country.name, alpha2: @country.alpha2, alpha3: @country.alpha3)
|
22
19
|
super(options)
|
20
|
+
find_country(options[:name])
|
21
|
+
find_country(options[:alpha3])
|
22
|
+
find_country(options[:alpha2])
|
23
|
+
@name = @country&.name
|
24
|
+
@alpha3 = @country&.alpha3
|
25
|
+
@alpha2 = @country&.alpha2
|
23
26
|
end
|
24
27
|
|
25
28
|
def alpha2=(code)
|
26
|
-
|
29
|
+
find_country(code)
|
30
|
+
@alpha2 ||= @country&.alpha2
|
27
31
|
end
|
28
32
|
|
29
33
|
def alpha3=(code)
|
30
|
-
|
34
|
+
find_country(code)
|
35
|
+
@alpha3 ||= @country&.alpha3
|
36
|
+
end
|
37
|
+
|
38
|
+
def name=(country_name)
|
39
|
+
find_country(country_name)
|
40
|
+
@name ||= @country&.name
|
31
41
|
end
|
32
42
|
|
33
43
|
def to_s
|
34
44
|
name
|
35
45
|
end
|
36
46
|
|
47
|
+
def to_h
|
48
|
+
attributes
|
49
|
+
end
|
50
|
+
|
51
|
+
def to_json(options = nil)
|
52
|
+
to_h.to_json(options)
|
53
|
+
end
|
54
|
+
|
55
|
+
alias as_json to_json
|
56
|
+
|
37
57
|
def inspect
|
38
58
|
"#<#{self.class} #{self}>"
|
39
59
|
end
|
@@ -41,11 +61,14 @@ module JustimmoClient::V1
|
|
41
61
|
private
|
42
62
|
|
43
63
|
def find_country(name_or_code)
|
44
|
-
if name_or_code.
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
64
|
+
return if name_or_code.nil?
|
65
|
+
|
66
|
+
@country ||=
|
67
|
+
if name_or_code.size <= 3
|
68
|
+
IsoCountryCodes.find(name_or_code)
|
69
|
+
else
|
70
|
+
IsoCountryCodes.search_by_name(name_or_code).first
|
71
|
+
end
|
49
72
|
rescue IsoCountryCodes::UnknownCodeError
|
50
73
|
nil
|
51
74
|
end
|
@@ -20,8 +20,12 @@ module JustimmoClient::V1
|
|
20
20
|
|
21
21
|
# @!group Instance Method Summary
|
22
22
|
|
23
|
-
def country=(
|
24
|
-
@country = Country.new(
|
23
|
+
def country=(code)
|
24
|
+
@country = Country.new(alpha3: code)
|
25
|
+
end
|
26
|
+
|
27
|
+
def country
|
28
|
+
@country&.alpha3
|
25
29
|
end
|
26
30
|
|
27
31
|
def floor=(flr)
|