rus_bank 0.7.0 → 0.8.0
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 +4 -4
- data/VERSION +1 -1
- data/lib/rus_bank.rb +27 -25
- data/rus_bank.gemspec +2 -2
- data/test/test_rus_bank.rb +21 -17
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a79896c9ff56fec5a5fa2afa206fe2d43f11c50
|
4
|
+
data.tar.gz: f4d218426c51d95219fc3d147afb058763adefb1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 506dab7f3e70803cfa907a6eab56e145afce6eee7bebd3aff0b441fc507fa70d24d091086ead7d66b4adeffe6a89e8cc76487d5441f4c162532bd6b68ec22aea
|
7
|
+
data.tar.gz: cd555655d1883acd2529930cb44f86d21380a587cc945269c2fa76770827ee8924f2889cb69f715cff658e4775ff68b5199efd1a12fe044df6410e715a7db8d1
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.8.0
|
data/lib/rus_bank.rb
CHANGED
@@ -33,43 +33,29 @@ class RusBank
|
|
33
33
|
def SearchByRegionCodeXML(region_code)
|
34
34
|
params = { "RegCode" => region_code }
|
35
35
|
response = call(:search_by_region_code_xml, params)
|
36
|
-
|
37
|
-
nil
|
38
|
-
else
|
39
|
-
response[:credit_org][:enum_credits]
|
40
|
-
end
|
36
|
+
get_array(response, :credit_org, :enum_credits)
|
41
37
|
end
|
42
38
|
|
43
39
|
def SearchByNameXML(bank_name) # Метод возвращает nil, либо массив хэшей
|
44
40
|
params = { "NamePart" => bank_name }
|
45
41
|
response = call(:search_by_name_xml, params)
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
end
|
54
|
-
end
|
42
|
+
get_array(response, :credit_org, :enum_credits)
|
43
|
+
end
|
44
|
+
|
45
|
+
def GetOfficesXML(int_code)
|
46
|
+
params = { "IntCode" => int_code }
|
47
|
+
response = call(:get_offices_xml, params)
|
48
|
+
get_array(response, :co_offices, :offices)
|
55
49
|
end
|
56
50
|
|
57
51
|
def EnumBicXML
|
58
52
|
response = call(:enum_bic_xml)
|
59
|
-
|
60
|
-
nil
|
61
|
-
else
|
62
|
-
response[:enum_bic][:bic]
|
63
|
-
end
|
53
|
+
get_array(response, :enum_bic, :bic)
|
64
54
|
end
|
65
55
|
|
66
56
|
def RegionsEnumXML
|
67
57
|
response = call(:regions_enum_xml)
|
68
|
-
|
69
|
-
nil
|
70
|
-
else
|
71
|
-
response[:regions_enum][:rgid]
|
72
|
-
end
|
58
|
+
get_array(response, :regions_enum, :rgid)
|
73
59
|
end
|
74
60
|
|
75
61
|
def CreditInfoByIntCodeXML(internal_code)
|
@@ -78,7 +64,7 @@ class RusBank
|
|
78
64
|
if response.nil?
|
79
65
|
nil
|
80
66
|
else
|
81
|
-
response[:credit_org_info]
|
67
|
+
response[:credit_org_info]
|
82
68
|
end
|
83
69
|
end
|
84
70
|
|
@@ -90,4 +76,20 @@ class RusBank
|
|
90
76
|
response
|
91
77
|
end
|
92
78
|
end
|
79
|
+
|
80
|
+
private
|
81
|
+
|
82
|
+
def get_array(response, *params)
|
83
|
+
node = params.inject(response){|inner_node, param| inner_node[param]} # Вытягиваем вложенные ноды
|
84
|
+
if node.nil?
|
85
|
+
nil
|
86
|
+
else
|
87
|
+
if not node.instance_of?(Array) # Если найдена одна запись, возвращается единичный хэш,
|
88
|
+
[node] # если более одной, то массив хешей,
|
89
|
+
else # поэтому одну запись преобразуем к массиву из одного хэша.
|
90
|
+
node
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
93
95
|
end
|
data/rus_bank.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "rus_bank"
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.8.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["wilDAlex"]
|
12
|
-
s.date = "2013-12-
|
12
|
+
s.date = "2013-12-24"
|
13
13
|
s.description = "\u{41d}\u{430}\u{431}\u{43e}\u{440} ruby-\u{43c}\u{435}\u{442}\u{43e}\u{434}\u{43e}\u{432} \u{434}\u{43b}\u{44f} \u{440}\u{430}\u{431}\u{43e}\u{442}\u{44b} \u{441} \u{441}\u{435}\u{440}\u{432}\u{438}\u{441}\u{430}\u{43c}\u{438} \u{426}\u{411} \u{420}\u{424}"
|
14
14
|
s.email = "some@wild-x.ru"
|
15
15
|
s.extra_rdoc_files = [
|
data/test/test_rus_bank.rb
CHANGED
@@ -1,23 +1,21 @@
|
|
1
1
|
require "../test/test_helper"
|
2
2
|
|
3
3
|
class TestRusBank < Test::Unit::TestCase
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
|
5
|
+
VALID_BIC = "044585216"
|
6
|
+
INVALID_BIC = "0445852169999"
|
7
|
+
VALID_INT_CODE = "450000650"
|
8
|
+
INVALID_INT_CODE = "450000650999999"
|
9
|
+
VALID_REG_NUMBER = "316"
|
10
|
+
INVALID_REG_NUMBER = "289375237580009"
|
11
|
+
VALID_REGION = "16"
|
12
|
+
INVALID_REGION = "999"
|
13
|
+
INVALID_ORG_NAME = "djhgsjdlksl"
|
14
|
+
VALID_ORG_NAME = "ХКФ БАНК"
|
15
|
+
|
8
16
|
context "RusBank" do
|
9
17
|
setup do
|
10
18
|
@cbr = RusBank.new
|
11
|
-
VALID_BIC = "044585216"
|
12
|
-
INVALID_BIC = "0445852169999"
|
13
|
-
VALID_INT_CODE = "450000650"
|
14
|
-
INVALID_INT_CODE = "450000650999999"
|
15
|
-
VALID_REG_NUMBER = "316"
|
16
|
-
INVALID_REG_NUMBER = "289375237580009"
|
17
|
-
VALID_REGION = "16"
|
18
|
-
INVALID_REGION = "999"
|
19
|
-
INVALID_ORG_NAME = "djhgsjdlksl"
|
20
|
-
VALID_ORG_NAME = "ХКФ БАНК"
|
21
19
|
end
|
22
20
|
|
23
21
|
should "Service return implemented methods" do
|
@@ -69,10 +67,16 @@ class TestRusBank < Test::Unit::TestCase
|
|
69
67
|
assert_equal(nil, @cbr.SearchByNameXML(INVALID_ORG_NAME), "Should return nil if value not found")
|
70
68
|
end
|
71
69
|
|
70
|
+
should ":get_offices_xml returns array of elements" do
|
71
|
+
assert(@cbr.GetOfficesXML(VALID_INT_CODE).instance_of?(Array), "This should be array")
|
72
|
+
assert(@cbr.GetOfficesXML(VALID_INT_CODE).length > 2, "This should return more than 2 offices")
|
73
|
+
assert_equal(nil, @cbr.GetOfficesXML(INVALID_INT_CODE), "Should return nil if value not found")
|
74
|
+
end
|
75
|
+
|
72
76
|
should ":credit_info_by_int_code_xml return correct bank" do
|
73
|
-
assert_equal(VALID_REG_NUMBER, @cbr.CreditInfoByIntCodeXML(VALID_INT_CODE)[:reg_number])
|
74
|
-
assert_equal(VALID_ORG_NAME, @cbr.CreditInfoByIntCodeXML(VALID_INT_CODE)[:org_name])
|
75
|
-
assert_equal(VALID_BIC, @cbr.CreditInfoByIntCodeXML(VALID_INT_CODE)[:bic])
|
77
|
+
assert_equal(VALID_REG_NUMBER, @cbr.CreditInfoByIntCodeXML(VALID_INT_CODE)[:co][:reg_number])
|
78
|
+
assert_equal(VALID_ORG_NAME, @cbr.CreditInfoByIntCodeXML(VALID_INT_CODE)[:co][:org_name])
|
79
|
+
assert_equal(VALID_BIC, @cbr.CreditInfoByIntCodeXML(VALID_INT_CODE)[:co][:bic])
|
76
80
|
assert_equal(nil, @cbr.CreditInfoByIntCodeXML(INVALID_INT_CODE), "Should return nil if value not found")
|
77
81
|
end
|
78
82
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rus_bank
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- wilDAlex
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: savon
|