iban_calculator 0.0.3 → 0.1.0

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: 179e94a9310e590bdbe6b16fb6f3fa6e49535c5d
4
- data.tar.gz: 5b727e33c86f8a30b724ea6435b47d0258731497
3
+ metadata.gz: 97954991695b71a07275c823e1cecff9bd92097e
4
+ data.tar.gz: e484b233037768da5cc1504f5345f2f9600d686a
5
5
  SHA512:
6
- metadata.gz: 33bcc32cc39d265627e8bac2d04abc4f29f2ec6d14e7dd062e55e77f2999f3184fa16da203e7a4fc101ca5f6df9eedfb61f90d126fd34380ff8db2180deb4c1e
7
- data.tar.gz: 9ff76bf3659848efd836707db1e5bc391c9fe12c41f5482f29a0dbc3c2c09f2519bb3211db41432ddb1943778f740e66fa247387f76310dd6697c6e47b78fc11
6
+ metadata.gz: c962478d7712809d708fad843081d06d7a80df7d0e7f98f88b48dd203eff7ba64df054de600c6cbf1beca314deece7a6a5ad4ebe6956c267ae677270e1369a96
7
+ data.tar.gz: adb62ab31cb19096726beb7a763f902a3baf355c415d95b31374ad9668b41696fd3a9b34dbe91ddb39cd841acb84af5a5ff61db94c61054efd0578c1747619ac
@@ -1,3 +1,8 @@
1
+ 0.1.0
2
+ -----
3
+
4
+ * Allow invalid IBANs to bubble though and not to fail spectacular
5
+
1
6
  0.0.3
2
7
  -----
3
8
 
@@ -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 status == 'passed'
39
+ fail(ServiceError, status) unless response.body[:"#{method}_response"][:return_code]
40
40
  end
41
41
  end
42
42
  end
@@ -39,7 +39,7 @@ module IbanCalculator
39
39
  end
40
40
 
41
41
  def account_number
42
- @account_number ||= raw_response[:account_number]
42
+ @account_number ||= string_or_default(raw_response[:account_number], nil)
43
43
  end
44
44
 
45
45
  def checks
@@ -49,7 +49,7 @@ module IbanCalculator
49
49
  end
50
50
 
51
51
  def updated_at
52
- @data_created_at ||= Date.parse(raw_response[:data_age])
52
+ @data_created_at ||= Date.parse(raw_response[:data_age]) if string_or_default(raw_response[:data_age], nil)
53
53
  end
54
54
 
55
55
  def errors
@@ -58,6 +58,8 @@ module IbanCalculator
58
58
 
59
59
  def as_json(opts = {})
60
60
  {
61
+ valid: valid?,
62
+ errors: errors,
61
63
  account_number: account_number,
62
64
  bank: bank.as_json(opts),
63
65
  bic_candidates: bic_candidates.map { |c| c.as_json(opts) },
@@ -1,3 +1,3 @@
1
1
  module IbanCalculator
2
- VERSION = "0.0.3"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -93,6 +93,10 @@ RSpec.describe IbanCalculator::IbanValidatorResponse do
93
93
  it 'returns a proper date object' do
94
94
  expect(valid.updated_at).to eq(Date.new(2014, 07, 06))
95
95
  end
96
+
97
+ it 'is nil for invalid response' do
98
+ expect(invalid.updated_at).to eq(nil)
99
+ end
96
100
  end
97
101
 
98
102
  describe '#errors' do
@@ -112,6 +116,8 @@ RSpec.describe IbanCalculator::IbanValidatorResponse do
112
116
  describe '#as_json' do
113
117
  it 'returns an hash with all attributes' do
114
118
  expect(valid.as_json).to eq({
119
+ valid: true,
120
+ errors: {},
115
121
  account_number: '10027952',
116
122
  bank: { code: '90-00-17', name: 'Bank of Ireland', country: 'IE', address: 'Dublin 2', url: '', branch: '', branch_code: '' },
117
123
  bic_candidates: [{ bic: 'BOFIIE2D', zip: '', city: '', sample_url: '', www_count: 0 }],
@@ -119,6 +125,18 @@ RSpec.describe IbanCalculator::IbanValidatorResponse do
119
125
  updated_at: Date.new(2014, 7, 6)
120
126
  })
121
127
  end
128
+
129
+ it 'also returns errors for invalid response' do
130
+ expect(invalid.as_json).to eq({
131
+ valid: false,
132
+ errors: {:account_number=>[:invalid_length]},
133
+ account_number: nil,
134
+ bank: { code: '', name: '', country: 'IE', address: '', url: '', branch: '', branch_code: '' },
135
+ bic_candidates: [],
136
+ checks: { length: 'failed', account_number: 'not_checked', bank_code: 'not_checked', iban_checksum: 'not_checked' },
137
+ updated_at: nil
138
+ })
139
+ end
122
140
  end
123
141
 
124
142
  def valid_response
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.0.3
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maximilian Schulz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-23 00:00:00.000000000 Z
11
+ date: 2015-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  version: '0'
129
129
  requirements: []
130
130
  rubyforge_project:
131
- rubygems_version: 2.2.2
131
+ rubygems_version: 2.4.3
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: Calculate IBAN and BIC for countries of Single European Payments Area (SEPA).
@@ -139,4 +139,3 @@ test_files:
139
139
  - spec/iban_validator_response_spec.rb
140
140
  - spec/invalid_data_spec.rb
141
141
  - spec/spec_helper.rb
142
- has_rdoc: