alfa_insurance 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/alfa_insurance.gemspec +1 -1
- data/lib/alfa_insurance/base_client.rb +5 -2
- data/lib/alfa_insurance/find_response.rb +1 -5
- data/lib/alfa_insurance/response.rb +12 -2
- data/lib/alfa_insurance/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 42e9ed6c30beda70cd6590f58f2703bfc2ecb741d7d5bb3f6f94d2b8bb72169c
|
4
|
+
data.tar.gz: '084c653092c927f042a53e69315f1ec96ab46529baa083fe6e1ec76e7db4a1a5'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aa37ec72faaab78d249a3303af3beae0ea6b9479fb26948b4f285472d2e3cb1b90c788e3932d414f18170439cfa98f42d24b525ad487d0bc9c8943ad5e568071
|
7
|
+
data.tar.gz: f3a150e2aaec16235a4eb956c8e99073ef72f7951a6097736b9cb8fd90106f28c0387e68a1bf0f0823e9dcfeb35b06e5601a787d056d407a1143f5765fba0ebc
|
data/alfa_insurance.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency "nokogiri", "~> 1"
|
25
25
|
spec.add_dependency "money", "~> 6.7"
|
26
26
|
|
27
|
-
spec.add_development_dependency "bundler"
|
27
|
+
spec.add_development_dependency "bundler"
|
28
28
|
spec.add_development_dependency "rake", "~> 10.0"
|
29
29
|
spec.add_development_dependency "minitest", "~> 5.0"
|
30
30
|
spec.add_development_dependency "vcr"
|
@@ -2,19 +2,21 @@ module AlfaInsurance
|
|
2
2
|
class BaseClient
|
3
3
|
SANDBOX_WSDL = 'https://uat-tes.alfastrah.ru/travel-ext-services/TravelExtService?wsdl'.freeze
|
4
4
|
|
5
|
-
attr_accessor :log, :log_level, :operator, :product_code, :wsdl, :timeout
|
5
|
+
attr_accessor :log, :log_level, :logger, :operator, :product_code, :wsdl, :timeout
|
6
6
|
|
7
|
-
def initialize(debug: false, wsdl: SANDBOX_WSDL, operator:, product_code:, timeout: 5)
|
7
|
+
def initialize(debug: false, wsdl: SANDBOX_WSDL, operator:, product_code:, timeout: 5, logger: nil)
|
8
8
|
if debug
|
9
9
|
@log_level = :debug
|
10
10
|
@log = true
|
11
11
|
else
|
12
12
|
@log = false
|
13
13
|
end
|
14
|
+
|
14
15
|
@wsdl = wsdl
|
15
16
|
@operator = operator
|
16
17
|
@product_code = product_code
|
17
18
|
@timeout = timeout
|
19
|
+
@logger = logger
|
18
20
|
end
|
19
21
|
|
20
22
|
def get_available_products
|
@@ -79,6 +81,7 @@ module AlfaInsurance
|
|
79
81
|
wsdl: wsdl,
|
80
82
|
log_level: log_level,
|
81
83
|
log: log,
|
84
|
+
logger: logger,
|
82
85
|
pretty_print_xml: log,
|
83
86
|
open_timeout: timeout,
|
84
87
|
read_timeout: timeout
|
@@ -26,15 +26,11 @@ module AlfaInsurance
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def risk_values
|
29
|
-
@risk_values ||= risk_values_from(policy
|
29
|
+
@risk_values ||= risk_values_from(policy)
|
30
30
|
end
|
31
31
|
|
32
32
|
private
|
33
33
|
|
34
|
-
def risk_currency
|
35
|
-
policy.dig(:risk_currency, :@value)
|
36
|
-
end
|
37
|
-
|
38
34
|
def policy
|
39
35
|
@policy ||= body[:policy_information] || {}
|
40
36
|
end
|
@@ -22,19 +22,29 @@ module AlfaInsurance
|
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
def risk_values_from(data, currency:)
|
25
|
+
def risk_values_from(data, currency: nil)
|
26
26
|
raw_values = data[:risk_value]
|
27
27
|
raw_values = [raw_values] unless raw_values.is_a?(Array)
|
28
28
|
|
29
29
|
raw_values.each_with_object({}) do |item, result|
|
30
30
|
risk_type = item[:@risk_type]
|
31
31
|
risk_value = item[:@value]
|
32
|
-
|
32
|
+
value_currency = currency || risk_currency(risk_type)
|
33
|
+
result[risk_type] = to_money(risk_value, value_currency)
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
36
37
|
def to_money(amount, currency)
|
37
38
|
Money.from_amount(amount.to_f, currency)
|
38
39
|
end
|
40
|
+
|
41
|
+
def risk_currency(risk_type)
|
42
|
+
risk_currency_data = policy.dig(:risk_currency)
|
43
|
+
if risk_currency_data.is_a?(Array)
|
44
|
+
risk_currency_data.find { |currency_hash| currency_hash[:@risk_type] == risk_type }[:@value]
|
45
|
+
else
|
46
|
+
risk_currency_data[:@value]
|
47
|
+
end
|
48
|
+
end
|
39
49
|
end
|
40
50
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: alfa_insurance
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexander Sviridov
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: savon
|
@@ -56,16 +56,16 @@ dependencies:
|
|
56
56
|
name: bundler
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '
|
61
|
+
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '
|
68
|
+
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|