Class: FmTimbradoCfdi::FmRespuesta

Inherits:
Object
  • Object
show all
Defined in:
lib/fm_adapter/fm_respuesta.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(response) ⇒ FmRespuesta

Returns a new instance of FmRespuesta.



9
10
11
12
13
14
15
16
17
# File 'lib/fm_adapter/fm_respuesta.rb', line 9

def initialize(response)
  @errors = []
  if response.is_a? String
    @raw = response
    procesar_respuesta(response)
  else
    parse_savon(response)
  end
end

Instance Attribute Details

#cbbObject (readonly)

Returns the value of attribute cbb.



7
8
9
# File 'lib/fm_adapter/fm_respuesta.rb', line 7

def cbb
  @cbb
end

#errorsObject (readonly)

Returns the value of attribute errors.



7
8
9
# File 'lib/fm_adapter/fm_respuesta.rb', line 7

def errors
  @errors
end

#no_csd_emisorObject (readonly)

Returns the value of attribute no_csd_emisor.



7
8
9
# File 'lib/fm_adapter/fm_respuesta.rb', line 7

def no_csd_emisor
  @no_csd_emisor
end

#pdfObject (readonly)

Returns the value of attribute pdf.



7
8
9
# File 'lib/fm_adapter/fm_respuesta.rb', line 7

def pdf
  @pdf
end

#rawObject (readonly)

Returns the value of attribute raw.



7
8
9
# File 'lib/fm_adapter/fm_respuesta.rb', line 7

def raw
  @raw
end

#timbreObject (readonly)

Returns the value of attribute timbre.



7
8
9
# File 'lib/fm_adapter/fm_respuesta.rb', line 7

def timbre
  @timbre
end

#xmlObject (readonly)

Returns the value of attribute xml.



7
8
9
# File 'lib/fm_adapter/fm_respuesta.rb', line 7

def xml
  @xml
end

Instance Method Details

#cbb?Boolean Also known as: cbb_present?

Returns:

  • (Boolean)


39
40
41
# File 'lib/fm_adapter/fm_respuesta.rb', line 39

def cbb?
  !!@cbb
end

#no_csd_emisor?Boolean Also known as: no_csd_emisor_present?

Returns:

  • (Boolean)


51
52
53
# File 'lib/fm_adapter/fm_respuesta.rb', line 51

def no_csd_emisor?
  !!@no_csd_emisor
end

#parse_savon(savon_response) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fm_adapter/fm_respuesta.rb', line 19

def parse_savon(savon_response)
  if savon_response.success?
    @raw = savon_response.to_xml
    procesar_respuesta(savon_response.to_xml)
  else
    @errors << savon_response.soap_fault.to_s if savon_response.soap_fault?
    @doc = @xml = @no_csd_emisor = @timbre = @pdf = @cbb = nil
  end
rescue Exception => e
  @errors << "No se ha podido realizar el parseo de la respuesta. #{e.message}"
end

#pdf?Boolean Also known as: pdf_present?

Returns:

  • (Boolean)


43
44
45
# File 'lib/fm_adapter/fm_respuesta.rb', line 43

def pdf?
  !!@pdf
end

#timbre?Boolean Also known as: timbre_present?

Returns:

  • (Boolean)


47
48
49
# File 'lib/fm_adapter/fm_respuesta.rb', line 47

def timbre?
  !!@timbre
end

#valid?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/fm_adapter/fm_respuesta.rb', line 31

def valid?
  @errors.empty?
end

#xml?Boolean Also known as: xml_present?

Returns:

  • (Boolean)


35
36
37
# File 'lib/fm_adapter/fm_respuesta.rb', line 35

def xml?
  !!@xml
end