Class: ANAF::WebServices::BalanceSheet

Inherits:
Object
  • Object
show all
Defined in:
lib/anaf/web_services/balance_sheet.rb

Overview

:nodoc:

Constant Summary collapse

BASE_URL =
'https://webservicesp.anaf.ro'
PATH =
'/bilant'

Instance Method Summary collapse

Constructor Details

#initialize(cui, year) ⇒ BalanceSheet

Returns a new instance of BalanceSheet.



11
12
13
14
# File 'lib/anaf/web_services/balance_sheet.rb', line 11

def initialize(cui, year)
  @cui = cui
  @year = year
end

Instance Method Details

#callObject



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/anaf/web_services/balance_sheet.rb', line 16

def call
  response = conn.get(PATH, { cui: @cui, an: @year })

  return unless response.success?

  body = JSON.parse(response.body)

  return if body['deni'].nil? || body['deni'].strip.empty?

  body
rescue Faraday::TimeoutError, Faraday::ConnectionFailed, JSON::ParserError
  nil
end