Class: ANAF::WebServices::VatRegistry
- Inherits:
-
Object
- Object
- ANAF::WebServices::VatRegistry
- Defined in:
- lib/anaf/web_services/vat_registry.rb
Overview
:nodoc:
Constant Summary collapse
- BASE_URL =
'https://webservicesp.anaf.ro'
- PATH =
'/PlatitorTvaRest/api/v8/ws/tva'
Instance Attribute Summary collapse
-
#ids ⇒ Object
readonly
Returns the value of attribute ids.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(ids) ⇒ VatRegistry
constructor
A new instance of VatRegistry.
- #request_body ⇒ Object
Constructor Details
#initialize(ids) ⇒ VatRegistry
Returns a new instance of VatRegistry.
13 14 15 |
# File 'lib/anaf/web_services/vat_registry.rb', line 13 def initialize(ids) @ids = ids end |
Instance Attribute Details
#ids ⇒ Object (readonly)
Returns the value of attribute ids.
11 12 13 |
# File 'lib/anaf/web_services/vat_registry.rb', line 11 def ids @ids end |
Instance Method Details
#call ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/anaf/web_services/vat_registry.rb', line 17 def call return [] if request_body.empty? response = conn.post(PATH, request_body) body = JSON.parse(response.body) return body['found'] if response.success? && body['cod'] == 200 raise InvalidRequest, body['message'] rescue JSON::ParserError raise InvalidRequest, response.body rescue Faraday::TimeoutError, Faraday::ConnectionFailed raise TimeoutError end |
#request_body ⇒ Object
32 33 34 |
# File 'lib/anaf/web_services/vat_registry.rb', line 32 def request_body @request_body ||= ids.map { |id| { cui: id, data: date } } end |