Class: BrNfe::Product::Response::Build::NfeInutilizacao

Inherits:
Base show all
Defined in:
lib/br_nfe/product/response/build/nfe_inutilizacao.rb

Instance Attribute Summary

Attributes inherited from Base

#operation, #savon_response

Attributes inherited from ActiveModelBase

#reference

Instance Method Summary collapse

Methods inherited from Base

#body_xml, #doc_original_xml, #header_xml, #nf_xmlns, #nfe_settings, #original_xml, #response, #response_xml, #url_xmlns_retorno, #xml_version, #xml_version_str

Methods inherited from ActiveModelBase

#assign_attributes, #default_values, #initialize

Constructor Details

This class inherits a constructor from BrNfe::ActiveModelBase

Instance Method Details

#info_xmlObject

Responsável por pegar a tag XML principal que contém os dados da homologação. Utilizado para facilitar a codificação e para não repetir o código ao buscar as informações da homologação.



24
25
26
# File 'lib/br_nfe/product/response/build/nfe_inutilizacao.rb', line 24

def info_xml
  @info_xml ||= parse_nokogiri_xml( body_xml.xpath( paths[:inf_inut], paths[:namespaces] ).to_xml )
end

#pathsObject



7
8
9
# File 'lib/br_nfe/product/response/build/nfe_inutilizacao.rb', line 7

def paths
  operation.gateway_settings[:xml_paths][:inutilizacao][:return_paths]
end

#response_classObject

Responsável por definir qual classe será instânciada para setar os valores de retorno referentes a cada operação.

Type: Class



16
17
18
# File 'lib/br_nfe/product/response/build/nfe_inutilizacao.rb', line 16

def response_class
  BrNfe::Product::Response::NfeInutilizacao
end

#specific_attributesObject

Responsável por setar os atributos específicos para cada tipo de operação. Nesse caso irá setar as informações da homologação da inutilização.

Type: Hash



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/br_nfe/product/response/build/nfe_inutilizacao.rb', line 34

def specific_attributes
  {
    environment:              info_xml.xpath( paths[:environment]).text,
    app_version:              info_xml.xpath( paths[:app_version]).text,
    processed_at:             info_xml.xpath( paths[:processed_at]).text,
    protocol:                 info_xml.xpath( paths[:protocol]).text,
    processing_status_code:   info_xml.xpath( paths[:processing_status_code]).text,
    processing_status_motive: info_xml.xpath( paths[:processing_status_motive]).text,
    uf:                       info_xml.xpath( paths[:uf]).text,
    year:                     info_xml.xpath( paths[:year]).text,
    cnpj:                     info_xml.xpath( paths[:cnpj]).text,
    nf_model:                 info_xml.xpath( paths[:nf_model]).text,
    nf_series:                info_xml.xpath( paths[:nf_series]).text,
    start_invoice_number:     info_xml.xpath( paths[:start_invoice_number]).text.to_i,
    end_invoice_number:       info_xml.xpath( paths[:end_invoice_number]).text.to_i,
  }
end