Class: FmTimbradoCfdi::FmRespuesta

Inherits:
Object
  • Object
show all
Defined in:
lib/fm_timbrado_cfdi/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_timbrado_cfdi/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.



8
9
10
# File 'lib/fm_timbrado_cfdi/fm_respuesta.rb', line 8

def cbb
  @cbb
end

#errorsObject (readonly)

Returns the value of attribute errors.



8
9
10
# File 'lib/fm_timbrado_cfdi/fm_respuesta.rb', line 8

def errors
  @errors
end

#no_csd_emisorObject (readonly)

Returns the value of attribute no_csd_emisor.



8
9
10
# File 'lib/fm_timbrado_cfdi/fm_respuesta.rb', line 8

def no_csd_emisor
  @no_csd_emisor
end

#pdfObject (readonly)

Returns the value of attribute pdf.



8
9
10
# File 'lib/fm_timbrado_cfdi/fm_respuesta.rb', line 8

def pdf
  @pdf
end

#rawObject (readonly)

Returns the value of attribute raw.



8
9
10
# File 'lib/fm_timbrado_cfdi/fm_respuesta.rb', line 8

def raw
  @raw
end

#timbreObject (readonly)

Returns the value of attribute timbre.



8
9
10
# File 'lib/fm_timbrado_cfdi/fm_respuesta.rb', line 8

def timbre
  @timbre
end

#xmlObject (readonly)

Returns the value of attribute xml.



8
9
10
# File 'lib/fm_timbrado_cfdi/fm_respuesta.rb', line 8

def xml
  @xml
end

Instance Method Details

#cbb?Boolean Also known as: cbb_present?

Returns:

  • (Boolean)


42
43
44
# File 'lib/fm_timbrado_cfdi/fm_respuesta.rb', line 42

def cbb?
  !!@cbb
end

#no_csd_emisor?Boolean Also known as: no_csd_emisor_present?

Returns:

  • (Boolean)


57
58
59
# File 'lib/fm_timbrado_cfdi/fm_respuesta.rb', line 57

def no_csd_emisor?
  !!@no_csd_emisor
end

#parse_savon(savon_response) ⇒ Object



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

def parse_savon (savon_response)
  begin
    if savon_response.success? then
      @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
end

#pdf?Boolean Also known as: pdf_present?

Returns:

  • (Boolean)


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

def pdf?
  !!@pdf
end

#timbre?Boolean Also known as: timbre_present?

Returns:

  • (Boolean)


52
53
54
# File 'lib/fm_timbrado_cfdi/fm_respuesta.rb', line 52

def timbre?
  !!@timbre
end

#valid?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/fm_timbrado_cfdi/fm_respuesta.rb', line 33

def valid?
  @errors.empty?
end

#xml?Boolean Also known as: xml_present?

Returns:

  • (Boolean)


37
38
39
# File 'lib/fm_timbrado_cfdi/fm_respuesta.rb', line 37

def xml?
  !!@xml
end