iban_calculator 0.1.0 → 0.1.1
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/CHANGELOG.md +9 -0
- data/lib/iban_calculator.rb +1 -1
- data/lib/iban_calculator/bic_candidate.rb +1 -1
- data/lib/iban_calculator/iban_validator_response.rb +6 -3
- data/lib/iban_calculator/invalid_data.rb +1 -0
- data/lib/iban_calculator/version.rb +1 -1
- data/spec/bic_candidate_spec.rb +6 -6
- data/spec/iban_validator_response_spec.rb +16 -14
- 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: dcc664a899ba82d49e767966619eea8ea8940e14
|
4
|
+
data.tar.gz: abd9e3ed0a5a19d11bb3059671a2390258021c86
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e026ee6df2aaf18a0f7b0303e9bdf913c2c2d4104939dda87e239f3a787d0a8fe1000c00d1d09731d0e09bd05d52f7ae0b650a71fba76d29ca6409c19a7aa073
|
7
|
+
data.tar.gz: 50ade0dd48e46ceede0b8e83e45de038547b45c2e611cc6cd2d72832131b774400ac38e9a019b3fce673f7a1dc2c12531e310b7217dcdd592be200957c131404
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
0.1.1
|
2
|
+
-----
|
3
|
+
|
4
|
+
* added missing failure code for iban checksum
|
5
|
+
* fixed error condition, so not every request is concidered an error ;)
|
6
|
+
* `#as_json` will have stringified keys
|
7
|
+
* `#valdiate_iban` and `#calculate_iban` should respond with mostly the same format
|
8
|
+
* rescue from `ArgumentError` happening when the date is present but not valid
|
9
|
+
|
1
10
|
0.1.0
|
2
11
|
-----
|
3
12
|
|
data/lib/iban_calculator.rb
CHANGED
@@ -36,7 +36,7 @@ module IbanCalculator
|
|
36
36
|
client = Savon.client(wsdl: config.url, logger: config.logger)
|
37
37
|
client.call(method, message: options).tap do |response|
|
38
38
|
status = response.body[:"#{method}_response"][:return][:result]
|
39
|
-
fail(ServiceError, status) unless response.body[:"#{method}_response"][:return_code]
|
39
|
+
fail(ServiceError, status) unless response.body[:"#{method}_response"][:return][:return_code]
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
@@ -50,6 +50,8 @@ module IbanCalculator
|
|
50
50
|
|
51
51
|
def updated_at
|
52
52
|
@data_created_at ||= Date.parse(raw_response[:data_age]) if string_or_default(raw_response[:data_age], nil)
|
53
|
+
rescue ArgumentError
|
54
|
+
nil
|
53
55
|
end
|
54
56
|
|
55
57
|
def errors
|
@@ -61,11 +63,12 @@ module IbanCalculator
|
|
61
63
|
valid: valid?,
|
62
64
|
errors: errors,
|
63
65
|
account_number: account_number,
|
64
|
-
bank: bank.
|
65
|
-
|
66
|
+
bank: bank.name,
|
67
|
+
bank_code: bank.code,
|
68
|
+
bics: bic_candidates.map { |c| c.as_json(opts) },
|
66
69
|
updated_at: updated_at,
|
67
70
|
checks: checks,
|
68
|
-
}
|
71
|
+
}.deep_stringify_keys!
|
69
72
|
end
|
70
73
|
|
71
74
|
private
|
@@ -5,6 +5,7 @@ module IbanCalculator
|
|
5
5
|
256 => [:bank_code, [:not_found]],
|
6
6
|
512 => [:account_number, [:invalid_length]],
|
7
7
|
1024 => [:bank_code, [:invalid_length]],
|
8
|
+
2048 => [:iban, [:checksum_failed]],
|
8
9
|
4096 => [:base, [:data_missing]],
|
9
10
|
8192 => [:country, [:not_supported]],
|
10
11
|
}
|
data/spec/bic_candidate_spec.rb
CHANGED
@@ -3,7 +3,7 @@ RSpec.describe IbanCalculator::BicCandidate do
|
|
3
3
|
subject { described_class.new(single_candidate[:item]) }
|
4
4
|
|
5
5
|
describe '.build_list' do
|
6
|
-
|
6
|
+
it 'returns an array if one item is added' do
|
7
7
|
expect(described_class.build_list(single_candidate).size).to eq(1)
|
8
8
|
end
|
9
9
|
|
@@ -57,11 +57,11 @@ RSpec.describe IbanCalculator::BicCandidate do
|
|
57
57
|
|
58
58
|
it 'returns all attributes' do
|
59
59
|
expect(subject.as_json).to eq({
|
60
|
-
bic
|
61
|
-
zip
|
62
|
-
city
|
63
|
-
sample_url
|
64
|
-
www_count
|
60
|
+
"bic" => 'BOFIIE2D',
|
61
|
+
"zip" => 'zip',
|
62
|
+
"city" => 'city',
|
63
|
+
"sample_url" => 'sample_url',
|
64
|
+
"www_count" => 0
|
65
65
|
})
|
66
66
|
end
|
67
67
|
end
|
@@ -116,25 +116,27 @@ RSpec.describe IbanCalculator::IbanValidatorResponse do
|
|
116
116
|
describe '#as_json' do
|
117
117
|
it 'returns an hash with all attributes' do
|
118
118
|
expect(valid.as_json).to eq({
|
119
|
-
valid
|
120
|
-
errors
|
121
|
-
account_number
|
122
|
-
bank
|
123
|
-
|
124
|
-
|
125
|
-
|
119
|
+
"valid" => true,
|
120
|
+
"errors" => {},
|
121
|
+
"account_number" => '10027952',
|
122
|
+
"bank" => "Bank of Ireland",
|
123
|
+
"bank_code" => '90-00-17',
|
124
|
+
"bics" => [{ "bic" => 'BOFIIE2D', "zip" => '', "city" => '', "sample_url" => '', "www_count" => 0 }],
|
125
|
+
"checks" => { "length" => 'passed', "account_number" => 'passed', "bank_code" => 'passed', "iban_checksum" => 'passed' },
|
126
|
+
"updated_at" => Date.new(2014, 7, 6)
|
126
127
|
})
|
127
128
|
end
|
128
129
|
|
129
130
|
it 'also returns errors for invalid response' do
|
130
131
|
expect(invalid.as_json).to eq({
|
131
|
-
valid
|
132
|
-
errors
|
133
|
-
account_number
|
134
|
-
bank
|
135
|
-
|
136
|
-
|
137
|
-
|
132
|
+
"valid" => false,
|
133
|
+
"errors" => { "account_number" => [:invalid_length]},
|
134
|
+
"account_number" => nil,
|
135
|
+
"bank" => '',
|
136
|
+
"bank_code" => '',
|
137
|
+
"bics" => [],
|
138
|
+
"checks" => { "length" => 'failed', "account_number" => 'not_checked', "bank_code" => 'not_checked', "iban_checksum" => 'not_checked' },
|
139
|
+
"updated_at" => nil
|
138
140
|
})
|
139
141
|
end
|
140
142
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: iban_calculator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Maximilian Schulz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-02-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|