ruby-vies 1.0.0 → 2.0.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
  SHA256:
3
- metadata.gz: 4fe8b2a93c2c783566cb7d3ee6e4bc58a16a7877d759b643be76e3bbc2f15ee2
4
- data.tar.gz: '086f4b6df19cbc30a9b00a24e3be1ec27cdfbfa75523935fad83ad06e0768225'
3
+ metadata.gz: 8acb99fb51bb2f419f66efe09820d25c024a1b825c6c6b51aaf00fd1fc2555d7
4
+ data.tar.gz: 63b872131431a1073a677719fa39c8ba8f009ff2d9cfbc6799c86447e573c850
5
5
  SHA512:
6
- metadata.gz: f171e968e9be0915d0019a68680e716843c0dbba99ffa5f7952221a5c8d5655497f870121c5e51ebc63f7b93186f5181f6eb05e19215b7ec4bdd02c889d020ee
7
- data.tar.gz: e742258235a260d6ed0d9d263f8cb89c76aaeb4aebf427500cb9cdb579e3e4c3eb375798612a99a66f57dd98da75e007f82eb5a75b231757247834db33b34496
6
+ metadata.gz: c973b7561ea0208482b8beaf5e9fd1758ba13ea7187f8fc11f5c5aadebd38f7408bc59a0c0bb06cb3705353ad04de86a71397520177f9ded86e2eeb88692e10e
7
+ data.tar.gz: bf08224fd1c457e272bfd8a5c3c942d537c2b3957183779c4e846ad1270f425bb65ae7c10098ef0f59ebb5f5b2528ea9c96587a07a73eab587f1ca23ed37906c
data/.idea/ruby-vies.iml CHANGED
@@ -9,50 +9,51 @@
9
9
  <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
10
  <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
11
  </content>
12
- <orderEntry type="jdk" jdkName="rbenv: 3.1.0" jdkType="RUBY_SDK" />
12
+ <orderEntry type="jdk" jdkName="rbenv: 3.1.2" jdkType="RUBY_SDK" />
13
13
  <orderEntry type="sourceFolder" forTests="false" />
14
- <orderEntry type="library" scope="PROVIDED" name="activesupport (v6.1.4.3, rbenv: 2.7.4) [gem]" level="application" />
15
- <orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.0, rbenv: 2.7.4) [gem]" level="application" />
16
- <orderEntry type="library" scope="PROVIDED" name="akami (v1.3.1, rbenv: 2.7.4) [gem]" level="application" />
17
- <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, rbenv: 2.7.4) [gem]" level="application" />
18
- <orderEntry type="library" scope="PROVIDED" name="builder (v3.2.4, rbenv: 2.7.4) [gem]" level="application" />
19
- <orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.24, rbenv: 2.7.4) [gem]" level="application" />
20
- <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.9, rbenv: 2.7.4) [gem]" level="application" />
21
- <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.4.4, rbenv: 2.7.4) [gem]" level="application" />
22
- <orderEntry type="library" scope="PROVIDED" name="finest-builder (v1.1.1, rbenv: 2.7.4) [gem]" level="application" />
23
- <orderEntry type="library" scope="PROVIDED" name="gyoku (v1.3.1, rbenv: 2.7.4) [gem]" level="application" />
24
- <orderEntry type="library" scope="PROVIDED" name="httparty (v0.20.0, rbenv: 2.7.4) [gem]" level="application" />
25
- <orderEntry type="library" scope="PROVIDED" name="httpi (v2.5.0, rbenv: 2.7.4) [gem]" level="application" />
26
- <orderEntry type="library" scope="PROVIDED" name="i18n (v1.8.11, rbenv: 2.7.4) [gem]" level="application" />
27
- <orderEntry type="library" scope="PROVIDED" name="mime-types (v3.4.1, rbenv: 2.7.4) [gem]" level="application" />
28
- <orderEntry type="library" scope="PROVIDED" name="mime-types-data (v3.2021.1115, rbenv: 2.7.4) [gem]" level="application" />
29
- <orderEntry type="library" scope="PROVIDED" name="minitest (v5.15.0, rbenv: 2.7.4) [gem]" level="application" />
30
- <orderEntry type="library" scope="PROVIDED" name="multi_xml (v0.6.0, rbenv: 2.7.4) [gem]" level="application" />
31
- <orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.12.5, rbenv: 2.7.4) [gem]" level="application" />
32
- <orderEntry type="library" scope="PROVIDED" name="nori (v2.6.0, rbenv: 2.7.4) [gem]" level="application" />
33
- <orderEntry type="library" scope="PROVIDED" name="parallel (v1.21.0, rbenv: 2.7.4) [gem]" level="application" />
34
- <orderEntry type="library" scope="PROVIDED" name="parser (v3.0.3.2, rbenv: 2.7.4) [gem]" level="application" />
35
- <orderEntry type="library" scope="PROVIDED" name="public_suffix (v4.0.6, rbenv: 2.7.4) [gem]" level="application" />
36
- <orderEntry type="library" scope="PROVIDED" name="racc (v1.6.0, rbenv: 2.7.4) [gem]" level="application" />
37
- <orderEntry type="library" scope="PROVIDED" name="rack (v2.2.3, rbenv: 2.7.4) [gem]" level="application" />
38
- <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.0.0, rbenv: 2.7.4) [gem]" level="application" />
39
- <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, rbenv: 2.7.4) [gem]" level="application" />
40
- <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.2.0, rbenv: 2.7.4) [gem]" level="application" />
41
- <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, rbenv: 2.7.4) [gem]" level="application" />
42
- <orderEntry type="library" scope="PROVIDED" name="rspec (v3.10.0, rbenv: 2.7.4) [gem]" level="application" />
43
- <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.10.1, rbenv: 2.7.4) [gem]" level="application" />
44
- <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.10.1, rbenv: 2.7.4) [gem]" level="application" />
45
- <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.10.2, rbenv: 2.7.4) [gem]" level="application" />
46
- <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.10.3, rbenv: 2.7.4) [gem]" level="application" />
47
- <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.23.0, rbenv: 2.7.4) [gem]" level="application" />
48
- <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.15.0, rbenv: 2.7.4) [gem]" level="application" />
49
- <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, rbenv: 2.7.4) [gem]" level="application" />
50
- <orderEntry type="library" scope="PROVIDED" name="savon (v2.12.1, rbenv: 2.7.4) [gem]" level="application" />
51
- <orderEntry type="library" scope="PROVIDED" name="socksify (v1.7.1, rbenv: 2.7.4) [gem]" level="application" />
52
- <orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.4, rbenv: 2.7.4) [gem]" level="application" />
53
- <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.1.0, rbenv: 2.7.4) [gem]" level="application" />
54
- <orderEntry type="library" scope="PROVIDED" name="wasabi (v3.6.1, rbenv: 2.7.4) [gem]" level="application" />
55
- <orderEntry type="library" scope="PROVIDED" name="zeitwerk (v2.5.1, rbenv: 2.7.4) [gem]" level="application" />
14
+ <orderEntry type="library" scope="PROVIDED" name="activesupport (v7.0.4, rbenv: 3.1.2) [gem]" level="application" />
15
+ <orderEntry type="library" scope="PROVIDED" name="addressable (v2.8.1, rbenv: 3.1.2) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="akami (v1.3.1, rbenv: 3.1.2) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, rbenv: 3.1.2) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="builder (v3.2.4, rbenv: 3.1.2) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.2.24, rbenv: 3.1.2) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.10, rbenv: 3.1.2) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, rbenv: 3.1.2) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="finest-builder (v2.0.0, rbenv: 3.1.2) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="gyoku (v1.4.0, rbenv: 3.1.2) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="httparty (v0.20.0, rbenv: 3.1.2) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="httpi (v3.0.1, rbenv: 3.1.2) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="i18n (v1.12.0, rbenv: 3.1.2) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="json (v2.6.2, rbenv: 3.1.2) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="mail (v2.7.1, rbenv: 3.1.2) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="mime-types (v3.4.1, rbenv: 3.1.2) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="mime-types-data (v3.2022.0105, rbenv: 3.1.2) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="mini_mime (v1.1.2, rbenv: 3.1.2) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="minitest (v5.16.3, rbenv: 3.1.2) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="multi_xml (v0.6.0, rbenv: 3.1.2) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.13.9, rbenv: 3.1.2) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="nori (v2.6.0, rbenv: 3.1.2) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="parallel (v1.22.1, rbenv: 3.1.2) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="parser (v3.1.2.1, rbenv: 3.1.2) [gem]" level="application" />
38
+ <orderEntry type="library" scope="PROVIDED" name="public_suffix (v5.0.0, rbenv: 3.1.2) [gem]" level="application" />
39
+ <orderEntry type="library" scope="PROVIDED" name="racc (v1.6.0, rbenv: 3.1.2) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="rack (v3.0.0, rbenv: 3.1.2) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, rbenv: 3.1.2) [gem]" level="application" />
42
+ <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, rbenv: 3.1.2) [gem]" level="application" />
43
+ <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.6.0, rbenv: 3.1.2) [gem]" level="application" />
44
+ <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, rbenv: 3.1.2) [gem]" level="application" />
45
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.12.0, rbenv: 3.1.2) [gem]" level="application" />
46
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.12.0, rbenv: 3.1.2) [gem]" level="application" />
47
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.12.0, rbenv: 3.1.2) [gem]" level="application" />
48
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.12.0, rbenv: 3.1.2) [gem]" level="application" />
49
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.12.0, rbenv: 3.1.2) [gem]" level="application" />
50
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.39.0, rbenv: 3.1.2) [gem]" level="application" />
51
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.23.0, rbenv: 3.1.2) [gem]" level="application" />
52
+ <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, rbenv: 3.1.2) [gem]" level="application" />
53
+ <orderEntry type="library" scope="PROVIDED" name="savon (v2.13.1, rbenv: 3.1.2) [gem]" level="application" />
54
+ <orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.5, rbenv: 3.1.2) [gem]" level="application" />
55
+ <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.3.0, rbenv: 3.1.2) [gem]" level="application" />
56
+ <orderEntry type="library" scope="PROVIDED" name="wasabi (v3.8.0, rbenv: 3.1.2) [gem]" level="application" />
56
57
  </component>
57
58
  <component name="RakeTasksCache">
58
59
  <option name="myRootTask">
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.1.0
1
+ 3.1.2
data/.travis.yml CHANGED
@@ -2,5 +2,5 @@
2
2
  language: ruby
3
3
  cache: bundler
4
4
  rvm:
5
- - 2.7.4
5
+ - 3.2.1
6
6
  before_install: gem install bundler -v 2.2.24
data/Gemfile.lock CHANGED
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- ruby-vies (1.0.0)
4
+ ruby-vies (2.0.1)
5
5
  activesupport (~> 7.0)
6
- finest-builder (~> 1.0)
6
+ finest-builder (~> 2.0)
7
7
  httparty (~> 0.18)
8
8
  rake (~> 13.0)
9
9
  rspec (~> 3.0)
@@ -13,89 +13,108 @@ PATH
13
13
  GEM
14
14
  remote: https://rubygems.org/
15
15
  specs:
16
- activesupport (7.0.1)
16
+ activesupport (7.0.4)
17
17
  concurrent-ruby (~> 1.0, >= 1.0.2)
18
18
  i18n (>= 1.6, < 2)
19
19
  minitest (>= 5.1)
20
20
  tzinfo (~> 2.0)
21
- addressable (2.8.0)
22
- public_suffix (>= 2.0.2, < 5.0)
21
+ addressable (2.8.1)
22
+ public_suffix (>= 2.0.2, < 6.0)
23
23
  akami (1.3.1)
24
24
  gyoku (>= 0.4.0)
25
25
  nokogiri
26
26
  ast (2.4.2)
27
27
  builder (3.2.4)
28
- concurrent-ruby (1.1.9)
28
+ concurrent-ruby (1.1.10)
29
+ date (3.3.3)
29
30
  diff-lcs (1.5.0)
30
- finest-builder (1.1.1)
31
- gyoku (1.3.1)
31
+ finest-builder (2.0.0)
32
+ gyoku (1.4.0)
32
33
  builder (>= 2.1.2)
34
+ rexml (~> 3.0)
33
35
  httparty (0.20.0)
34
36
  mime-types (~> 3.0)
35
37
  multi_xml (>= 0.5.2)
36
- httpi (2.5.0)
38
+ httpi (3.0.1)
37
39
  rack
38
- socksify
39
- i18n (1.8.11)
40
+ i18n (1.12.0)
40
41
  concurrent-ruby (~> 1.0)
42
+ json (2.6.3)
43
+ mail (2.8.0)
44
+ mini_mime (>= 0.1.1)
45
+ net-imap
46
+ net-pop
47
+ net-smtp
41
48
  mime-types (3.4.1)
42
49
  mime-types-data (~> 3.2015)
43
50
  mime-types-data (3.2022.0105)
44
- minitest (5.15.0)
51
+ mini_mime (1.1.2)
52
+ minitest (5.16.3)
45
53
  multi_xml (0.6.0)
46
- nokogiri (1.13.0-x86_64-linux)
54
+ net-imap (0.3.4)
55
+ date
56
+ net-protocol
57
+ net-pop (0.1.2)
58
+ net-protocol
59
+ net-protocol (0.2.1)
60
+ timeout
61
+ net-smtp (0.3.3)
62
+ net-protocol
63
+ nokogiri (1.13.10-x86_64-linux)
47
64
  racc (~> 1.4)
48
65
  nori (2.6.0)
49
- parallel (1.21.0)
50
- parser (3.1.0.0)
66
+ parallel (1.22.1)
67
+ parser (3.1.3.0)
51
68
  ast (~> 2.4.1)
52
- public_suffix (4.0.6)
53
- racc (1.6.0)
54
- rack (2.2.3)
55
- rainbow (3.0.0)
69
+ public_suffix (5.0.1)
70
+ racc (1.6.2)
71
+ rack (3.0.2)
72
+ rainbow (3.1.1)
56
73
  rake (13.0.6)
57
- regexp_parser (2.2.0)
74
+ regexp_parser (2.6.1)
58
75
  rexml (3.2.5)
59
- rspec (3.10.0)
60
- rspec-core (~> 3.10.0)
61
- rspec-expectations (~> 3.10.0)
62
- rspec-mocks (~> 3.10.0)
63
- rspec-core (3.10.1)
64
- rspec-support (~> 3.10.0)
65
- rspec-expectations (3.10.1)
76
+ rspec (3.12.0)
77
+ rspec-core (~> 3.12.0)
78
+ rspec-expectations (~> 3.12.0)
79
+ rspec-mocks (~> 3.12.0)
80
+ rspec-core (3.12.0)
81
+ rspec-support (~> 3.12.0)
82
+ rspec-expectations (3.12.1)
66
83
  diff-lcs (>= 1.2.0, < 2.0)
67
- rspec-support (~> 3.10.0)
68
- rspec-mocks (3.10.2)
84
+ rspec-support (~> 3.12.0)
85
+ rspec-mocks (3.12.1)
69
86
  diff-lcs (>= 1.2.0, < 2.0)
70
- rspec-support (~> 3.10.0)
71
- rspec-support (3.10.3)
72
- rubocop (1.24.1)
87
+ rspec-support (~> 3.12.0)
88
+ rspec-support (3.12.0)
89
+ rubocop (1.41.1)
90
+ json (~> 2.3)
73
91
  parallel (~> 1.10)
74
- parser (>= 3.0.0.0)
92
+ parser (>= 3.1.2.1)
75
93
  rainbow (>= 2.2.2, < 4.0)
76
94
  regexp_parser (>= 1.8, < 3.0)
77
- rexml
78
- rubocop-ast (>= 1.15.1, < 2.0)
95
+ rexml (>= 3.2.5, < 4.0)
96
+ rubocop-ast (>= 1.23.0, < 2.0)
79
97
  ruby-progressbar (~> 1.7)
80
98
  unicode-display_width (>= 1.4.0, < 3.0)
81
- rubocop-ast (1.15.1)
82
- parser (>= 3.0.1.1)
99
+ rubocop-ast (1.24.0)
100
+ parser (>= 3.1.1.0)
83
101
  ruby-progressbar (1.11.0)
84
- savon (2.12.1)
102
+ savon (2.14.0)
85
103
  akami (~> 1.2)
86
104
  builder (>= 2.1.2)
87
105
  gyoku (~> 1.2)
88
- httpi (~> 2.3)
106
+ httpi (>= 2.4.5)
107
+ mail (~> 2.5)
89
108
  nokogiri (>= 1.8.1)
90
109
  nori (~> 2.4)
91
110
  wasabi (~> 3.4)
92
- socksify (1.7.1)
93
- tzinfo (2.0.4)
111
+ timeout (0.3.1)
112
+ tzinfo (2.0.5)
94
113
  concurrent-ruby (~> 1.0)
95
- unicode-display_width (2.1.0)
96
- wasabi (3.6.1)
114
+ unicode-display_width (2.3.0)
115
+ wasabi (3.8.0)
97
116
  addressable
98
- httpi (~> 2.0)
117
+ httpi (~> 3.0)
99
118
  nokogiri (>= 1.4.2)
100
119
 
101
120
  PLATFORMS
@@ -108,4 +127,4 @@ DEPENDENCIES
108
127
  ruby-vies!
109
128
 
110
129
  BUNDLED WITH
111
- 2.3.3
130
+ 2.2.24
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ruby
4
4
  module Vies
5
- VERSION = "1.0.0"
5
+ VERSION = "2.0.1"
6
6
  end
7
7
  end
data/lib/ruby/vies.rb CHANGED
@@ -4,7 +4,8 @@ require_relative "vies/version"
4
4
  require "savon"
5
5
  require "httparty"
6
6
  require "finest/builder"
7
- require 'active_support/isolated_execution_state'
7
+ require "active_support/isolated_execution_state"
8
+ require "active_support/core_ext/hash/indifferent_access"
8
9
  require "active_support/core_ext/module"
9
10
  require "active_support/core_ext/object"
10
11
 
@@ -12,6 +13,16 @@ module Ruby
12
13
  module Vies
13
14
  class Error < StandardError; end
14
15
 
16
+ mattr_accessor :endpoints, default: {
17
+ siren: "https://api.avis-situation-sirene.insee.fr/identification/siren/%<siren>s",
18
+ vat: "https://ec.europa.eu/taxation_customs/vies/services/checkVatService.wsdl"
19
+ }
20
+
21
+ # Setup data from initializer
22
+ def self.setup
23
+ yield(self)
24
+ end
25
+
15
26
  class Client
16
27
  include Savon
17
28
  include HTTParty
@@ -19,30 +30,30 @@ module Ruby
19
30
 
20
31
  mattr_reader :id_numbers, default: { FR: "((12 + 3 * ( %d.divmod(97)[1])).divmod(97)[1])" }
21
32
 
22
- def initialize(args = {})
23
- super args
33
+ def initialize(args = nil)
34
+ super args || {}
24
35
  end
25
36
 
26
- def check_vat_details(args = {})
27
- args[:country_code].upcase == "FR" ? check_siren(args) : check_vat(args)
28
- rescue => e
37
+ def check_vat_details(args)
38
+ (args[:country_code].upcase == "FR" ? check_siren(args) : check_vat(args)).with_indifferent_access
39
+ rescue StandardError => e
29
40
  { error: e&.message, valid: false }
30
41
  end
31
42
 
32
43
  protected
33
44
 
34
- def generate_id(vat = {})
45
+ def generate_id(vat)
35
46
  id_numbers[vat[:country_code].to_sym] &&
36
47
  "%02<digit>d%<vat>d" % {
37
48
  digit: eval(id_numbers[vat[:country_code].to_sym] % vat[:vat_number]),
38
49
  vat: vat[:vat_number]
39
50
  } || vat[:vat_number]
40
- rescue
51
+ rescue StandardError
41
52
  vat[:vat_number]
42
53
  end
43
54
 
44
- def check_vat(args = {})
45
- Savon::Client.new(wsdl: "https://ec.europa.eu/taxation_customs/vies/checkVatService.wsdl")
55
+ def check_vat(args)
56
+ Savon::Client.new(wsdl: Ruby::Vies.endpoints[:vat])
46
57
  .call(
47
58
  :check_vat,
48
59
  message: args.merge({ vat_number: generate_id(args) }).as_json.transform_keys! { |i| i.camelize(:lower) },
@@ -50,8 +61,8 @@ module Ruby
50
61
  ).body[:check_vat_response].as_json(except: :@xmlns)
51
62
  end
52
63
 
53
- def check_siren(args = {})
54
- url = "https://api.avis-situation-sirene.insee.fr/identification/siren/#{args.fetch(:vat_number)}"
64
+ def check_siren(args)
65
+ url = Ruby::Vies.endpoints[:siren] % { siren: args.fetch(:vat_number) }
55
66
  if (resp = JSON.parse(self.class.method(:get).call(url).body))["code"]
56
67
  { error: resp["message"], valid: false }
57
68
  else
data/ruby-vies.gemspec CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
12
12
  spec.description = "Vies is a EU service that checks EU VAT business number validation and sends back its information."
13
13
  spec.homepage = "https://github.com/eddygarcas/ruby-vies"
14
14
  spec.license = "MIT"
15
- spec.required_ruby_version = Gem::Requirement.new(">= 3.1.0")
15
+ spec.required_ruby_version = Gem::Requirement.new(">= 3.1.2")
16
16
 
17
17
  spec.metadata["allowed_push_host"] = "https://rubygems.org/"
18
18
 
@@ -31,7 +31,7 @@ Gem::Specification.new do |spec|
31
31
 
32
32
  # Uncomment to register a new dependency of your gem
33
33
  # spec.add_dependency "example-gem", "~> 1.0"
34
- spec.add_dependency "finest-builder", "~> 1.0"
34
+ spec.add_dependency "finest-builder", "~> 2.0"
35
35
  spec.add_dependency "httparty", "~> 0.18"
36
36
  spec.add_dependency "rake", "~> 13.0"
37
37
  spec.add_dependency "rspec", "~> 3.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-vies
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduard Garcia Castelló
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-01-07 00:00:00.000000000 Z
11
+ date: 2022-12-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: finest-builder
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '1.0'
19
+ version: '2.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '1.0'
26
+ version: '2.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: httparty
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -154,14 +154,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
154
154
  requirements:
155
155
  - - ">="
156
156
  - !ruby/object:Gem::Version
157
- version: 3.1.0
157
+ version: 3.1.2
158
158
  required_rubygems_version: !ruby/object:Gem::Requirement
159
159
  requirements:
160
160
  - - ">="
161
161
  - !ruby/object:Gem::Version
162
162
  version: '0'
163
163
  requirements: []
164
- rubygems_version: 3.3.3
164
+ rubygems_version: 3.3.7
165
165
  signing_key:
166
166
  specification_version: 4
167
167
  summary: Ruby EU VIES VAT and SIREN number validation