ruby-vies 2.0.1 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.idea/ruby-vies.iml +18 -49
- data/Gemfile.lock +1 -1
- data/lib/ruby/vies/version.rb +1 -1
- data/lib/ruby/vies.rb +32 -8
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab9ed1bf496e498fe99493e190f49f4028ad48f9cfcacccd8b645bf86895d5fa
|
4
|
+
data.tar.gz: e70ba42691232c29181936fc770ca94434690ace2c0354024353e36c27b0cccd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f4aca22b25c5fe0661879ab1bc98d2f4ba8dc6cd0a92d427ac4cd09755263915d480abdfab16ac9429fc5f0a21d530f2aa10935f6bcc14abb6a3eb72bc70b1e2
|
7
|
+
data.tar.gz: 42c9b06c452d45e24251b085773f4b6243deed28846dfba869d2a43667d7c51e1b2280ebe5e19d7d3a52d47317be6ca95582d878b2645a2cf02718c03b7640b8
|
data/.idea/ruby-vies.iml
CHANGED
@@ -16,82 +16,51 @@
|
|
16
16
|
<orderEntry type="library" scope="PROVIDED" name="akami (v1.3.1, rbenv: 3.1.2) [gem]" level="application" />
|
17
17
|
<orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, rbenv: 3.1.2) [gem]" level="application" />
|
18
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
19
|
<orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.10, rbenv: 3.1.2) [gem]" level="application" />
|
20
|
+
<orderEntry type="library" scope="PROVIDED" name="date (v3.3.3, rbenv: 3.1.2) [gem]" level="application" />
|
21
21
|
<orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, rbenv: 3.1.2) [gem]" level="application" />
|
22
22
|
<orderEntry type="library" scope="PROVIDED" name="finest-builder (v2.0.0, rbenv: 3.1.2) [gem]" level="application" />
|
23
23
|
<orderEntry type="library" scope="PROVIDED" name="gyoku (v1.4.0, rbenv: 3.1.2) [gem]" level="application" />
|
24
24
|
<orderEntry type="library" scope="PROVIDED" name="httparty (v0.20.0, rbenv: 3.1.2) [gem]" level="application" />
|
25
25
|
<orderEntry type="library" scope="PROVIDED" name="httpi (v3.0.1, rbenv: 3.1.2) [gem]" level="application" />
|
26
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.
|
28
|
-
<orderEntry type="library" scope="PROVIDED" name="mail (v2.
|
27
|
+
<orderEntry type="library" scope="PROVIDED" name="json (v2.6.3, rbenv: 3.1.2) [gem]" level="application" />
|
28
|
+
<orderEntry type="library" scope="PROVIDED" name="mail (v2.8.0, rbenv: 3.1.2) [gem]" level="application" />
|
29
29
|
<orderEntry type="library" scope="PROVIDED" name="mime-types (v3.4.1, rbenv: 3.1.2) [gem]" level="application" />
|
30
30
|
<orderEntry type="library" scope="PROVIDED" name="mime-types-data (v3.2022.0105, rbenv: 3.1.2) [gem]" level="application" />
|
31
31
|
<orderEntry type="library" scope="PROVIDED" name="mini_mime (v1.1.2, rbenv: 3.1.2) [gem]" level="application" />
|
32
32
|
<orderEntry type="library" scope="PROVIDED" name="minitest (v5.16.3, rbenv: 3.1.2) [gem]" level="application" />
|
33
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="
|
34
|
+
<orderEntry type="library" scope="PROVIDED" name="net-imap (v0.3.4, rbenv: 3.1.2) [gem]" level="application" />
|
35
|
+
<orderEntry type="library" scope="PROVIDED" name="net-pop (v0.1.2, rbenv: 3.1.2) [gem]" level="application" />
|
36
|
+
<orderEntry type="library" scope="PROVIDED" name="net-protocol (v0.2.1, rbenv: 3.1.2) [gem]" level="application" />
|
37
|
+
<orderEntry type="library" scope="PROVIDED" name="net-smtp (v0.3.3, rbenv: 3.1.2) [gem]" level="application" />
|
38
|
+
<orderEntry type="library" scope="PROVIDED" name="nokogiri (v1.13.10, rbenv: 3.1.2) [gem]" level="application" />
|
35
39
|
<orderEntry type="library" scope="PROVIDED" name="nori (v2.6.0, rbenv: 3.1.2) [gem]" level="application" />
|
36
40
|
<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.
|
38
|
-
<orderEntry type="library" scope="PROVIDED" name="public_suffix (v5.0.
|
39
|
-
<orderEntry type="library" scope="PROVIDED" name="racc (v1.6.
|
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="parser (v3.1.3.0, rbenv: 3.1.2) [gem]" level="application" />
|
42
|
+
<orderEntry type="library" scope="PROVIDED" name="public_suffix (v5.0.1, rbenv: 3.1.2) [gem]" level="application" />
|
43
|
+
<orderEntry type="library" scope="PROVIDED" name="racc (v1.6.2, rbenv: 3.1.2) [gem]" level="application" />
|
41
44
|
<orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, rbenv: 3.1.2) [gem]" level="application" />
|
42
45
|
<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.
|
46
|
+
<orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.6.1, rbenv: 3.1.2) [gem]" level="application" />
|
44
47
|
<orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, rbenv: 3.1.2) [gem]" level="application" />
|
45
48
|
<orderEntry type="library" scope="PROVIDED" name="rspec (v3.12.0, rbenv: 3.1.2) [gem]" level="application" />
|
46
49
|
<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.
|
48
|
-
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.12.
|
50
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.12.1, rbenv: 3.1.2) [gem]" level="application" />
|
51
|
+
<orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.12.1, rbenv: 3.1.2) [gem]" level="application" />
|
49
52
|
<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.
|
51
|
-
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.23.0, rbenv: 3.1.2) [gem]" level="application" />
|
53
|
+
<orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.24.0, rbenv: 3.1.2) [gem]" level="application" />
|
52
54
|
<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.
|
55
|
+
<orderEntry type="library" scope="PROVIDED" name="savon (v2.14.0, rbenv: 3.1.2) [gem]" level="application" />
|
56
|
+
<orderEntry type="library" scope="PROVIDED" name="timeout (v0.3.1, rbenv: 3.1.2) [gem]" level="application" />
|
54
57
|
<orderEntry type="library" scope="PROVIDED" name="tzinfo (v2.0.5, rbenv: 3.1.2) [gem]" level="application" />
|
55
58
|
<orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.3.0, rbenv: 3.1.2) [gem]" level="application" />
|
56
59
|
<orderEntry type="library" scope="PROVIDED" name="wasabi (v3.8.0, rbenv: 3.1.2) [gem]" level="application" />
|
57
60
|
</component>
|
58
61
|
<component name="RakeTasksCache">
|
59
62
|
<option name="myRootTask">
|
60
|
-
<RakeTaskImpl id="rake"
|
61
|
-
<subtasks>
|
62
|
-
<RakeTaskImpl description="Build ruby-vies-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
|
63
|
-
<RakeTaskImpl id="build">
|
64
|
-
<subtasks>
|
65
|
-
<RakeTaskImpl description="Generate SHA512 checksum if ruby-vies-0.1.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
|
66
|
-
</subtasks>
|
67
|
-
</RakeTaskImpl>
|
68
|
-
<RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
|
69
|
-
<RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
|
70
|
-
<RakeTaskImpl description="Build and install ruby-vies-0.1.0.gem into system gems" fullCommand="install" id="install" />
|
71
|
-
<RakeTaskImpl id="install">
|
72
|
-
<subtasks>
|
73
|
-
<RakeTaskImpl description="Build and install ruby-vies-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
|
74
|
-
</subtasks>
|
75
|
-
</RakeTaskImpl>
|
76
|
-
<RakeTaskImpl description="Create tag v0.1.0 and build and push ruby-vies-0.1.0.gem to TODO: Set to 'https://mygemserver.com'" fullCommand="release[remote]" id="release[remote]" />
|
77
|
-
<RakeTaskImpl description="Run RuboCop" fullCommand="rubocop" id="rubocop" />
|
78
|
-
<RakeTaskImpl id="rubocop">
|
79
|
-
<subtasks>
|
80
|
-
<RakeTaskImpl description="Auto-correct RuboCop offenses" fullCommand="rubocop:auto_correct" id="auto_correct" />
|
81
|
-
</subtasks>
|
82
|
-
</RakeTaskImpl>
|
83
|
-
<RakeTaskImpl description="Run RSpec code examples" fullCommand="spec" id="spec" />
|
84
|
-
<RakeTaskImpl description="" fullCommand="default" id="default" />
|
85
|
-
<RakeTaskImpl description="" fullCommand="release" id="release" />
|
86
|
-
<RakeTaskImpl id="release">
|
87
|
-
<subtasks>
|
88
|
-
<RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
|
89
|
-
<RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
|
90
|
-
<RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
|
91
|
-
</subtasks>
|
92
|
-
</RakeTaskImpl>
|
93
|
-
</subtasks>
|
94
|
-
</RakeTaskImpl>
|
63
|
+
<RakeTaskImpl id="rake" />
|
95
64
|
</option>
|
96
65
|
</component>
|
97
66
|
</module>
|
data/Gemfile.lock
CHANGED
data/lib/ruby/vies/version.rb
CHANGED
data/lib/ruby/vies.rb
CHANGED
@@ -14,9 +14,12 @@ module Ruby
|
|
14
14
|
class Error < StandardError; end
|
15
15
|
|
16
16
|
mattr_accessor :endpoints, default: {
|
17
|
-
siren: "https://api.
|
17
|
+
siren: "https://api.insee.fr/entreprises/sirene/siren/%<siren>s",
|
18
|
+
siren_token: "https://api.insee.fr/token?grant_type=client_credentials&client_id=%<id>s&client_secret=%<secret>s&validity_period=%<period>s",
|
18
19
|
vat: "https://ec.europa.eu/taxation_customs/vies/services/checkVatService.wsdl"
|
19
20
|
}
|
21
|
+
mattr_accessor :customer_key, default: ENV["SIREN_CUSTOMER_KEY"]
|
22
|
+
mattr_accessor :customer_secret, default: ENV["SIREN_CUSTOMER_SECRET"]
|
20
23
|
|
21
24
|
# Setup data from initializer
|
22
25
|
def self.setup
|
@@ -63,20 +66,41 @@ module Ruby
|
|
63
66
|
|
64
67
|
def check_siren(args)
|
65
68
|
url = Ruby::Vies.endpoints[:siren] % { siren: args.fetch(:vat_number) }
|
66
|
-
if (
|
67
|
-
|
69
|
+
if (
|
70
|
+
resp = JSON.parse(
|
71
|
+
self.class.method(:get).call(
|
72
|
+
url,
|
73
|
+
headers: {
|
74
|
+
authorization: "Bearer #{siren_token}",
|
75
|
+
'Content-Type': 'application/json'
|
76
|
+
}
|
77
|
+
).body
|
78
|
+
)
|
79
|
+
).dig("header", "statut") != 200
|
80
|
+
{ error: resp["header"]["message"], valid: false }
|
68
81
|
else
|
69
82
|
{
|
70
83
|
valid: true,
|
71
84
|
name: resp.dig("uniteLegale", "periodesUniteLegale")&.first&.dig("denominationUniteLegale"),
|
72
|
-
address:
|
73
|
-
siren: resp.dig("
|
74
|
-
siret:
|
75
|
-
nic: resp.dig("
|
76
|
-
created: resp.dig("
|
85
|
+
address: "",
|
86
|
+
siren: resp.dig("uniteLegale", "siren"),
|
87
|
+
siret: "",
|
88
|
+
nic: resp.dig("uniteLegale", "periodesUniteLegale")&.first&.dig("nicSiegeUniteLegale"),
|
89
|
+
created: resp.dig("uniteLegale", "periodesUniteLegale")&.first&.dig("dateDebut"),
|
77
90
|
}
|
78
91
|
end
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
79
95
|
|
96
|
+
def siren_token
|
97
|
+
url = Ruby::Vies.endpoints[:siren_token] % {
|
98
|
+
id: Ruby::Vies.customer_key,
|
99
|
+
secret: Ruby::Vies.customer_secret,
|
100
|
+
period: 604800
|
101
|
+
}
|
102
|
+
resp = self.class.method(:post).call(url)
|
103
|
+
JSON.parse(resp.body)["access_token"]
|
80
104
|
end
|
81
105
|
end
|
82
106
|
end
|
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:
|
4
|
+
version: 3.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:
|
11
|
+
date: 2023-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: finest-builder
|