Class: BrNfe::Servico::Betha::BuildResponse

Inherits:
ActiveModelBase show all
Defined in:
lib/br_nfe/servico/betha/build_response.rb

Direct Known Subclasses

V1::BuildResponse, V2::BuildResponse

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from ActiveModelBase

#assign_attributes, #default_values

Constructor Details

#initialize(attributes = {}) ⇒ BuildResponse

Returns a new instance of BuildResponse.



7
8
9
10
# File 'lib/br_nfe/servico/betha/build_response.rb', line 7

def initialize(attributes = {})
	@error_messages = []
	super(attributes)
end

Instance Attribute Details

#nfe_methodObject

Returns the value of attribute nfe_method.



5
6
7
# File 'lib/br_nfe/servico/betha/build_response.rb', line 5

def nfe_method
  @nfe_method
end

Instance Method Details

#error_messagesObject



27
28
29
30
31
32
33
34
35
# File 'lib/br_nfe/servico/betha/build_response.rb', line 27

def error_messages						
	return @error_messages unless @error_messages.blank?

	get_messages!(messages[:lista_nfse][:listamensagem_alerta_retorno]) if messages[:lista_nfse]						
	get_messages!(messages[:lista_mensagem_retorno])						
	get_messages!(messages[:lista_mensagem_retorno_lote])

	@error_messages
end

#responseObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/br_nfe/servico/betha/build_response.rb', line 16

def response
	@response ||= BrNfe::Servico::Response::Default.new do |resp|
		resp.success          = success?
		resp.error_messages   = error_messages
		resp.notas_fiscais    = get_notas_fiscais
		resp.protocolo        = messages[:protocolo]
		resp.data_recebimento = messages[:data_recebimento]
		resp.numero_lote      = messages[:numero_lote]
	end
end

#success?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/br_nfe/servico/betha/build_response.rb', line 12

def success?
	error_messages.blank?
end