Class: Receitaws::Cnpj
- Inherits:
-
Object
- Object
- Receitaws::Cnpj
- Defined in:
- lib/receitaws/cnpj.rb
Instance Attribute Summary collapse
-
#abertura ⇒ Object
readonly
Returns the value of attribute abertura.
-
#atividades ⇒ Object
readonly
Returns the value of attribute atividades.
-
#bairro ⇒ Object
readonly
Returns the value of attribute bairro.
-
#cep ⇒ Object
readonly
Returns the value of attribute cep.
-
#cnaes ⇒ Object
readonly
Returns the value of attribute cnaes.
-
#cnpj ⇒ Object
readonly
Returns the value of attribute cnpj.
-
#complemento ⇒ Object
readonly
Returns the value of attribute complemento.
-
#data_situacao ⇒ Object
readonly
Returns the value of attribute data_situacao.
-
#email ⇒ Object
readonly
Returns the value of attribute email.
-
#fantasia ⇒ Object
readonly
Returns the value of attribute fantasia.
-
#logradouro ⇒ Object
readonly
Returns the value of attribute logradouro.
-
#message ⇒ Object
readonly
Returns the value of attribute message.
-
#municipio ⇒ Object
readonly
Returns the value of attribute municipio.
-
#nome ⇒ Object
readonly
Returns the value of attribute nome.
-
#numero ⇒ Object
readonly
Returns the value of attribute numero.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#telefone ⇒ Object
readonly
Returns the value of attribute telefone.
-
#uf ⇒ Object
readonly
Returns the value of attribute uf.
Instance Method Summary collapse
-
#initialize(result = nil) ⇒ Cnpj
constructor
A new instance of Cnpj.
Constructor Details
#initialize(result = nil) ⇒ Cnpj
Returns a new instance of Cnpj.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/receitaws/cnpj.rb', line 7 def initialize(result=nil) if result.nil? @status = :error @message = "Timeout" return self end if result["status"] == "ERROR" @status = :error @message = result["message"] return self end @status = :ok @nome = result["nome"] @uf = result["uf"] @telefone = result["telefone"] @email = result["email"] @fantasia = result["fantasia"] @cnpj = result["cnpj"] @bairro = result["bairro"] @logradouro = result["logradouro"] @numero = result["numero"] @cep = result["cep"] @municipio = result["municipio"] @abertura = result["abertura"] @data_situacao = result["data_situacao"] @situacao = result["situacao"] @complemento = result["complemento"] @atividades = [] result["atividade_principal"].each do |atividade| @atividades << {code: atividade["code"], text: atividade["text"]} end result["atividades_secundarias"].each do |atividade| @atividades << {code: atividade["code"], text: atividade["text"]} end @cnaes = @atividades.collect{|a| a[:code].to_s.gsub(/[^0-9A-Za-z]/, '')} return self end |
Instance Attribute Details
#abertura ⇒ Object (readonly)
Returns the value of attribute abertura.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def abertura @abertura end |
#atividades ⇒ Object (readonly)
Returns the value of attribute atividades.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def atividades @atividades end |
#bairro ⇒ Object (readonly)
Returns the value of attribute bairro.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def bairro @bairro end |
#cep ⇒ Object (readonly)
Returns the value of attribute cep.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def cep @cep end |
#cnaes ⇒ Object (readonly)
Returns the value of attribute cnaes.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def cnaes @cnaes end |
#cnpj ⇒ Object (readonly)
Returns the value of attribute cnpj.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def cnpj @cnpj end |
#complemento ⇒ Object (readonly)
Returns the value of attribute complemento.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def complemento @complemento end |
#data_situacao ⇒ Object (readonly)
Returns the value of attribute data_situacao.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def data_situacao @data_situacao end |
#email ⇒ Object (readonly)
Returns the value of attribute email.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def email @email end |
#fantasia ⇒ Object (readonly)
Returns the value of attribute fantasia.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def fantasia @fantasia end |
#logradouro ⇒ Object (readonly)
Returns the value of attribute logradouro.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def logradouro @logradouro end |
#message ⇒ Object (readonly)
Returns the value of attribute message.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def @message end |
#municipio ⇒ Object (readonly)
Returns the value of attribute municipio.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def municipio @municipio end |
#nome ⇒ Object (readonly)
Returns the value of attribute nome.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def nome @nome end |
#numero ⇒ Object (readonly)
Returns the value of attribute numero.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def numero @numero end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def status @status end |
#telefone ⇒ Object (readonly)
Returns the value of attribute telefone.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def telefone @telefone end |
#uf ⇒ Object (readonly)
Returns the value of attribute uf.
5 6 7 |
# File 'lib/receitaws/cnpj.rb', line 5 def uf @uf end |