Class: Request::Cnpj::Client
- Inherits:
-
BaseClient
- Object
- BaseClient
- Request::Cnpj::Client
- Defined in:
- lib/request/cnpj/client.rb
Overview
Client for fetching CNPJ data from the OpenCNPJ API.
Instance Attribute Summary collapse
-
#rest_client ⇒ Object
readonly
Returns the value of attribute rest_client.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
-
#find(cnpj) ⇒ Object
Method to request CNPJ to API.
-
#initialize(rest_client: RestClient::Request) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(rest_client: RestClient::Request) ⇒ Client
Returns a new instance of Client.
9 10 11 12 |
# File 'lib/request/cnpj/client.rb', line 9 def initialize(rest_client: RestClient::Request) super() @rest_client = rest_client end |
Instance Attribute Details
#rest_client ⇒ Object (readonly)
Returns the value of attribute rest_client.
7 8 9 |
# File 'lib/request/cnpj/client.rb', line 7 def rest_client @rest_client end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
7 8 9 |
# File 'lib/request/cnpj/client.rb', line 7 def url @url end |
Instance Method Details
#find(cnpj) ⇒ Object
Method to request CNPJ to API
15 16 17 |
# File 'lib/request/cnpj/client.rb', line 15 def find(cnpj) JSON.parse(get("/#{cnpj.gsub(/[^0-9]/, '')}")) end |