Class: BrNfe::Servico::Betha::V1::Gateway

Inherits:
Base show all
Defined in:
lib/br_nfe/servico/betha/v1/gateway.rb

Instance Attribute Summary

Attributes inherited from BrNfe::Servico::Base

#lote_rps, #numero_lote_rps, #operacao

Attributes inherited from Base

#certificado_password, #certificado_path, #certificado_value, #env

Instance Method Summary collapse

Methods inherited from BrNfe::Servico::Base

#initialize

Methods inherited from Base

#certificado, #certificado=, #certificado_obrigatorio?, #client_wsdl, #env_namespace, #method_wsdl, #original_response, #response, #wsdl, #wsdl_encoding, #xml_builder

Methods included from Helper::HaveEmitente

#emitente, #emitente=

Methods inherited from ActiveModelBase

#assign_attributes, #default_values, #initialize

Constructor Details

This class inherits a constructor from BrNfe::Servico::Base

Instance Method Details

#content_xmlObject



36
37
38
# File 'lib/br_nfe/servico/betha/v1/gateway.rb', line 36

def content_xml
	canonicalize(xml_builder).gsub('<Temp>','').gsub('</Temp>','')
end

#namespace_identifierObject



10
11
12
# File 'lib/br_nfe/servico/betha/v1/gateway.rb', line 10

def namespace_identifier
	:ns1	
end

#namespacesObject



6
7
8
# File 'lib/br_nfe/servico/betha/v1/gateway.rb', line 6

def namespaces
	{"xmlns:ns1" => "http://www.betha.com.br/e-nota-contribuinte-ws"}
end

#requestObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/br_nfe/servico/betha/v1/gateway.rb', line 18

def request
	set_response( 
		client_wsdl.call("#{method_wsdl}_envio".to_sym, 
			message:    "#{content_xml}",
			attributes: {'xmlns:ns1' => 'http://www.betha.com.br/e-nota-contribuinte-ws'} 
		) 
	)
rescue Savon::SOAPFault => error
	return @response = BrNfe::Servico::Response::Default.new(success: false, error_messages: [error.message])
end

#set_response(resp) ⇒ Object



29
30
31
32
33
34
# File 'lib/br_nfe/servico/betha/v1/gateway.rb', line 29

def set_response(resp)
	method_response = (method_wsdl.to_s + "_envio_response").to_sym
	@builder =  BrNfe::Servico::Betha::V1::BuildResponse.new(hash: resp.hash[:envelope][:body][method_response], nfe_method: method_wsdl)
	@original_response = @builder.messages
	@response          = @builder.response
end

#versionObject



14
15
16
# File 'lib/br_nfe/servico/betha/v1/gateway.rb', line 14

def version
	:v1
end