vat_number_validator 0.0.2 → 0.0.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ac5ba631470949a68bfc215a6b8149f282765cb4
4
- data.tar.gz: 2a7d092beae8ba9623f9cff4913964b80b11dde7
3
+ metadata.gz: 9328a1ef6c901e4c3b819fcf6cfdeb638c8f6f1a
4
+ data.tar.gz: 7d858bf4fe1a85ed3a76ed0340c55a62fbd1a126
5
5
  SHA512:
6
- metadata.gz: 75fe4dabea299b25dc66e8361ce7f8ee1e1ed15da870e031fbf8e6bd4f2d72b61a5c2452c180c8514791d7e9e5334a7be2a483f9ad15a8d6c9c28e2ebebf9c91
7
- data.tar.gz: d030675e6a8cd82f9977f11e8031bccf079201ea28e3320013287517a650c2a4bb116a8f17eb7a9f446632fdbae7fa4bf05d6ab98a83947234056120b442e908
6
+ metadata.gz: b1324c8560f663ecca55c7e26a3e8f18be90c629006fb26a72d48c5cc452a886c8b021cbbde2e2929cb1465505f1150164f9ccff947aff2b160395aa7bdb985c
7
+ data.tar.gz: a2707a829eeee18aed335c3207b6a3c35e75ec5f19494d175b4b6f1931dd91e3d62107e1f9c724ce8288ef2b21c75c9f3bcaad7fc5c597272175f831b1c3e41e
@@ -4,6 +4,6 @@ class VatNumberValidator
4
4
  class Configuration
5
5
  include Confiture::Configuration
6
6
 
7
- confiture_allowed_keys(:access_key)
7
+ confiture_allowed_keys(:access_key, :use_https)
8
8
  end
9
9
  end
@@ -1,7 +1,8 @@
1
1
  class VatNumberValidator
2
2
  class APIError < StandardError
3
3
  def initialize(result)
4
- message = case result['code']
4
+ code = result['error']['code']
5
+ message = case code
5
6
  when 101
6
7
  'invalid/missing access_key'
7
8
  when 104
@@ -11,7 +12,7 @@ class VatNumberValidator
11
12
  when 102
12
13
  'inactive user'
13
14
  else
14
- "vatlayer API error code #{result['code']}"
15
+ "vatlayer API error code #{code}"
15
16
  end
16
17
  super(message)
17
18
  end
@@ -6,7 +6,7 @@ class VatNumberValidator < ActiveModel::EachValidator
6
6
 
7
7
  include HTTParty
8
8
 
9
- base_uri 'http://apilayer.net/api'
9
+ base_uri 'https://apilayer.net/api'
10
10
 
11
11
  def validate_each(record, attribute, value)
12
12
  unless valid?(value)
@@ -18,7 +18,7 @@ class VatNumberValidator < ActiveModel::EachValidator
18
18
 
19
19
  def valid?(value)
20
20
  result = self.class.get('/validate', http_options(value))
21
- raise(VatlayerError.new(result)) if result['success'] == false
21
+ raise(APIError.new(result)) if result['success'] == false
22
22
  result['valid']
23
23
  end
24
24
 
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'vat_number_validator'
3
- s.version = '0.0.2'
3
+ s.version = '0.0.3'
4
4
  s.authors = 'Marek Lipka'
5
5
  s.summary = 'Vat number validator'
6
6
  s.description = 'Vat number validator for Rails 3+ using vatlayer.com API'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vat_number_validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Lipka