Class: FnsClient
- Inherits:
-
Object
- Object
- FnsClient
- Defined in:
- lib/fns_client.rb
Instance Method Summary collapse
- #call ⇒ Object
- #generate_token ⇒ Object
- #handle_info(token) ⇒ Object
-
#initialize(query) ⇒ FnsClient
constructor
A new instance of FnsClient.
Constructor Details
#initialize(query) ⇒ FnsClient
Returns a new instance of FnsClient.
6 7 8 9 |
# File 'lib/fns_client.rb', line 6 def initialize(query) @query = query @uri = URI('https://egrul.nalog.ru') end |
Instance Method Details
#call ⇒ Object
11 12 13 14 15 |
# File 'lib/fns_client.rb', line 11 def call handle_info(generate_token) rescue => e "Error: #{e}" end |
#generate_token ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/fns_client.rb', line 17 def generate_token response = Net::HTTP.post_form(@uri, query: @query) result = JSON.parse(response.body) result['t'] end |
#handle_info(token) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/fns_client.rb', line 25 def handle_info(token) response = Net::HTTP.get_response(@uri + '/search-result/' + token) result = JSON.parse(response.body) result end |