anaf-web_services 0.1.0 → 0.3.0

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
  SHA256:
3
- metadata.gz: dbb6803beb07e38bdf3d1a7870b8219543d01568b820f0d88449afaa01b334a7
4
- data.tar.gz: 9e31b78f24994b33461401024d2be5fe2c86796f72bc2b60660f4ba0c4f20712
3
+ metadata.gz: 3ece423043302125d41bc7368423ae8495b2085dbf80c995e83479fe0c26f004
4
+ data.tar.gz: 496546e3c7f3b4b75f4e2c8a1be23cdea37dbe303070093f5ed2d07c4541916c
5
5
  SHA512:
6
- metadata.gz: a53f707197b2c0b790d1fb0abcf80c30a51b72c5ff5805ba068f33d43f8f9d8fb2bd1aa329558a9f1cedb6a190a6f5fbd878b0bc5ceca1907eda4ee781427739
7
- data.tar.gz: 0e038d9928c8a6f3b554da4ec55f327cfbc995f1fe6648838b1e571721a28b8dd6dbe1dc6a4f7d1d26b5894e9ab186a358d54da604c35489d95de21eb9d3807b
6
+ metadata.gz: a4137c7b57648c8364a30be2475659b9d9aa0e116a3f2056f3ac44f88fc71c9bec6a915d8f3d7b72990acdce84145b42350367af7e30518f8b975ee4a69b060a
7
+ data.tar.gz: cae4cc8386a3f80d76f5bd6b71e648474d26d93ed15d3d4c08ad5eb6e818a94dfafa577eb4980cd2c405a648d0a79738023433560676041aece9156ab439fd7e
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- anaf-web_services (0.1.0)
4
+ anaf-web_services (0.3.0)
5
5
  faraday (>= 1.0.0, < 3.0)
6
6
 
7
7
  GEM
@@ -15,10 +15,10 @@ GEM
15
15
  crack (0.4.5)
16
16
  rexml
17
17
  diff-lcs (1.5.0)
18
- faraday (2.5.2)
18
+ faraday (2.6.0)
19
19
  faraday-net_http (>= 2.0, < 3.1)
20
20
  ruby2_keywords (>= 0.0.4)
21
- faraday-net_http (3.0.0)
21
+ faraday-net_http (3.0.1)
22
22
  ffi (1.15.5)
23
23
  formatador (1.1.0)
24
24
  guard (2.18.0)
@@ -96,6 +96,7 @@ GEM
96
96
  hashdiff (>= 0.4.0, < 2.0.0)
97
97
 
98
98
  PLATFORMS
99
+ arm64-darwin-22
99
100
  x86_64-darwin-21
100
101
  x86_64-linux
101
102
 
@@ -109,4 +110,4 @@ DEPENDENCIES
109
110
  webmock (~> 3.18, >= 3.18.1)
110
111
 
111
112
  BUNDLED WITH
112
- 2.2.32
113
+ 2.4.22
data/README.md CHANGED
@@ -40,7 +40,14 @@ The APIs operate based on this **CUI** number.
40
40
 
41
41
  This API returns some information about the companies but is mainly focused on the VAT status of the company, if it's VAT liable or not.
42
42
 
43
- For more details about the underlying API see [here](https://static.anaf.ro/static/10/Anaf/Informatii_R/doc_WS_V6.txt) the official documentation but it's only in Romanian.
43
+ For more details about the underlying API see the official documentation for the corresponding version, but it's only in Romanian.
44
+
45
+ #### API versions
46
+
47
+ | GEM | ANAF API | Docs |
48
+ |-------|----------|-------------------------------------------------------------------------------|
49
+ | 0.2.0 | V6 | https://static.anaf.ro/static/10/Anaf/Informatii_R/doc_WS_V6.txt |
50
+ | 0.3.0 | V8 | https://static.anaf.ro/static/10/Anaf/Informatii_R/Servicii_web/doc_WS_V8.txt |
44
51
 
45
52
  #### Get a company by CUI
46
53
 
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faraday'
4
+
5
+ module ANAF
6
+ module WebServices
7
+ class BalanceSheet # :nodoc:
8
+ BASE_URL = 'https://webservicesp.anaf.ro'
9
+ PATH = '/bilant'
10
+
11
+ def initialize(cui, year)
12
+ @cui = cui
13
+ @year = year
14
+ end
15
+
16
+ def call
17
+ response = conn.get(PATH, { cui: @cui, an: @year })
18
+
19
+ return unless response.success?
20
+
21
+ body = JSON.parse(response.body)
22
+
23
+ return if body['deni'].nil? || body['deni'].strip.empty?
24
+
25
+ body
26
+ rescue Faraday::TimeoutError, Faraday::ConnectionFailed, JSON::ParserError
27
+ nil
28
+ end
29
+
30
+ private
31
+
32
+ def conn
33
+ @conn ||= Faraday.new(BASE_URL, request: { timeout: 5 })
34
+ end
35
+ end
36
+ end
37
+ end
@@ -6,7 +6,7 @@ module ANAF
6
6
  module WebServices
7
7
  class VatRegistry # :nodoc:
8
8
  BASE_URL = 'https://webservicesp.anaf.ro'
9
- PATH = '/PlatitorTvaRest/api/v6/ws/tva'
9
+ PATH = '/PlatitorTvaRest/api/v8/ws/tva'
10
10
 
11
11
  attr_reader :ids
12
12
 
@@ -25,6 +25,8 @@ module ANAF
25
25
  raise InvalidRequest, body['message']
26
26
  rescue JSON::ParserError
27
27
  raise InvalidRequest, response.body
28
+ rescue Faraday::TimeoutError, Faraday::ConnectionFailed
29
+ raise TimeoutError
28
30
  end
29
31
 
30
32
  def request_body
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ANAF
4
4
  module WebServices
5
- VERSION = '0.1.0'
5
+ VERSION = '0.3.0'
6
6
  end
7
7
  end
@@ -1,9 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative 'web_services/vat_registry'
4
+ require_relative 'web_services/balance_sheet'
4
5
 
5
6
  module ANAF
6
7
  module WebServices
7
8
  class InvalidRequest < StandardError; end
9
+ class TimeoutError < StandardError; end
8
10
  end
9
11
  end
data/lib/anaf.rb CHANGED
@@ -16,5 +16,9 @@ module ANAF # :nodoc:
16
16
  rescue WebServices::InvalidRequest
17
17
  []
18
18
  end
19
+
20
+ def get_balance_sheet(cui, year)
21
+ WebServices::BalanceSheet.new(cui, year).call
22
+ end
19
23
  end
20
24
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anaf-web_services
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mariusz Siklodi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-26 00:00:00.000000000 Z
11
+ date: 2023-11-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -48,6 +48,7 @@ files:
48
48
  - anaf-web_services.gemspec
49
49
  - lib/anaf.rb
50
50
  - lib/anaf/web_services.rb
51
+ - lib/anaf/web_services/balance_sheet.rb
51
52
  - lib/anaf/web_services/vat_registry.rb
52
53
  - lib/anaf/web_services/version.rb
53
54
  homepage: https://github.com/siklodi-mariusz/anaf-web_services
@@ -71,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
71
72
  - !ruby/object:Gem::Version
72
73
  version: '0'
73
74
  requirements: []
74
- rubygems_version: 3.2.32
75
+ rubygems_version: 3.4.19
75
76
  signing_key:
76
77
  specification_version: 4
77
78
  summary: Ruby Client library for ANAF API