iban_calculator 0.1.0 → 0.1.1

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: 97954991695b71a07275c823e1cecff9bd92097e
4
- data.tar.gz: e484b233037768da5cc1504f5345f2f9600d686a
3
+ metadata.gz: dcc664a899ba82d49e767966619eea8ea8940e14
4
+ data.tar.gz: abd9e3ed0a5a19d11bb3059671a2390258021c86
5
5
  SHA512:
6
- metadata.gz: c962478d7712809d708fad843081d06d7a80df7d0e7f98f88b48dd203eff7ba64df054de600c6cbf1beca314deece7a6a5ad4ebe6956c267ae677270e1369a96
7
- data.tar.gz: adb62ab31cb19096726beb7a763f902a3baf355c415d95b31374ad9668b41696fd3a9b34dbe91ddb39cd841acb84af5a5ff61db94c61054efd0578c1747619ac
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
 
@@ -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
@@ -25,7 +25,7 @@ module IbanCalculator
25
25
  city: city,
26
26
  sample_url: sample_url,
27
27
  www_count: www_count,
28
- }
28
+ }.deep_stringify_keys!
29
29
  end
30
30
 
31
31
  private
@@ -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.as_json(opts),
65
- bic_candidates: bic_candidates.map { |c| c.as_json(opts) },
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
  }
@@ -1,3 +1,3 @@
1
1
  module IbanCalculator
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -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
- it 'returns an array if one item is added' do
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: 'BOFIIE2D',
61
- zip: 'zip',
62
- city: 'city',
63
- sample_url: 'sample_url',
64
- www_count: 0
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: true,
120
- errors: {},
121
- account_number: '10027952',
122
- bank: { code: '90-00-17', name: 'Bank of Ireland', country: 'IE', address: 'Dublin 2', url: '', branch: '', branch_code: '' },
123
- bic_candidates: [{ bic: 'BOFIIE2D', zip: '', city: '', sample_url: '', www_count: 0 }],
124
- checks: { length: 'passed', account_number: 'passed', bank_code: 'passed', iban_checksum: 'passed' },
125
- updated_at: Date.new(2014, 7, 6)
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: 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
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.0
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-01-27 00:00:00.000000000 Z
11
+ date: 2015-02-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport