class Nfe::Operations::ConsultEmitter

Public Class Methods

new(certificate, private_key, environment, uf, kind_of_document, document_number, use_schema: true) click to toggle source
Calls superclass method Nfe::Operations::Base::new
# File lib/nfe/operations/consult_emitter.rb, line 7
def initialize(certificate, private_key, environment, uf, kind_of_document,
  document_number, use_schema: true)
  super(certificate, private_key, use_schema: use_schema)

  @uf = uf
  @environment = environment
  @kind_of_document = kind_of_document
  @document_number = document_number
end

Protected Instance Methods

before_execute() click to toggle source
# File lib/nfe/operations/consult_emitter.rb, line 18
def before_execute
  @object = object_to_send
end
handle_result(xml) click to toggle source
# File lib/nfe/operations/consult_emitter.rb, line 22
def handle_result(xml)
  @result = Services::Regress::RetConsCad.new xml
end
schema_name() click to toggle source
# File lib/nfe/operations/consult_emitter.rb, line 30
def schema_name
  ws_info.schema
end
ws_info() click to toggle source
# File lib/nfe/operations/consult_emitter.rb, line 34
def ws_info
  Webservices::Wsinfo::ConsultEmitter.new(@environment, @uf)
end
xpath() click to toggle source
# File lib/nfe/operations/consult_emitter.rb, line 26
def xpath
  "//ns:retConsCad"
end

Private Instance Methods

object_to_send() click to toggle source
# File lib/nfe/operations/consult_emitter.rb, line 39
def object_to_send
  consCad = Services::Dispatch::ConsCad.new
  consCad.versao = ws_info.version
  consCad.tpAmb = @environment
  consCad.uf = @uf
  set_document consCad
  consCad
end
set_document(object) click to toggle source
# File lib/nfe/operations/consult_emitter.rb, line 48
def set_document(object)
  case @kind_of_document
  when :ie
   object.ie = @document_number

  when :cnpj
    object.cnpj = @document_number

  else
    object.cpf = @document_number
  end
end