vat_number_validator 0.0.3 → 0.0.4

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: 9328a1ef6c901e4c3b819fcf6cfdeb638c8f6f1a
4
- data.tar.gz: 7d858bf4fe1a85ed3a76ed0340c55a62fbd1a126
3
+ metadata.gz: 21f71a631e6dc07ab612c1e57c685697872108dc
4
+ data.tar.gz: 1f198faa7e5c9dbe9650ba6113cbd33be55028d8
5
5
  SHA512:
6
- metadata.gz: b1324c8560f663ecca55c7e26a3e8f18be90c629006fb26a72d48c5cc452a886c8b021cbbde2e2929cb1465505f1150164f9ccff947aff2b160395aa7bdb985c
7
- data.tar.gz: a2707a829eeee18aed335c3207b6a3c35e75ec5f19494d175b4b6f1931dd91e3d62107e1f9c724ce8288ef2b21c75c9f3bcaad7fc5c597272175f831b1c3e41e
6
+ metadata.gz: d9fc346a317af51e949308e7678ab57d430f6b936db078dbc2d94475a1979423128f112aea069ccdae336d20bb3fb84cc6036ed1d081e5e851704c30c5554b51
7
+ data.tar.gz: e83fdb4fb0ccbb4f416d7fc4ed50c7293be2b59b22a9286a0a2c35e8ce2057b1ffa83529ad2edee2250bc4d8b7ec80104792fa19cac1bb50081e48bcc146a451
@@ -4,10 +4,6 @@ class VatNumberValidator < ActiveModel::EachValidator
4
4
  require 'vat_number_validator/configuration'
5
5
  require 'vat_number_validator/errors'
6
6
 
7
- include HTTParty
8
-
9
- base_uri 'https://apilayer.net/api'
10
-
11
7
  def validate_each(record, attribute, value)
12
8
  unless valid?(value)
13
9
  record.errors.add(attribute, :incorrect_vat_number_format)
@@ -16,8 +12,14 @@ class VatNumberValidator < ActiveModel::EachValidator
16
12
 
17
13
  private
18
14
 
15
+ def base_uri
16
+ use_https = Configuration.use_https
17
+ protocol = use_https ? 'https' : 'http'
18
+ "#{protocol}://apilayer.net/api"
19
+ end
20
+
19
21
  def valid?(value)
20
- result = self.class.get('/validate', http_options(value))
22
+ result = HTTParty.get(base_uri + '/validate', http_options(value))
21
23
  raise(APIError.new(result)) if result['success'] == false
22
24
  result['valid']
23
25
  end
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'vat_number_validator'
3
- s.version = '0.0.3'
3
+ s.version = '0.0.4'
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marek Lipka