Sha256: 4ebdef51dbf1325b56ff5ebbbce3da827d2d2c121bbde82be90a2c2ea780c4d0

Contents?: true

Size: 1.75 KB

Versions: 1

Compression:

Stored size: 1.75 KB

Contents

# coding: utf-8
module Timbradocfdi
  class Generator

    ##
    # Parse result for registro emisor
    def parse_result_registro_emisor(result)
      object        = result.to_hash
      result_object = object[:registra_emisor_response][:registra_emisor_result][:any_type]

      {
        code: result_object[1],
        message: (result_object[2].to_s).encode("utf-8")
      }
    end
    
    ##
    # Parse result for timbraCFDI
    def parse_result_timbraCFDI(result)
      object = result.to_hash
      result_object = object[:timbra_cfdi_response][:timbra_cfdi_result][:any_type]

      if result_object[1].to_i === 0 
        return_object = {
          code: 0,
          xml: result_object[3],
          qr: result_object[4],
          details: result_object[5]
        }
      else
        return_object = {
          code: result_object[1],
          message: result_object[2]
        }
      end

      return_object
    end

    ##
    # Parse result for obtieneCFDI
    def parse_result_obtieneCFDI(result)
      object = result.to_hash
      result_object = object[:obtiene_cfdi_response][:obtiene_cfdi_result][:any_type]

      if result_object[1].to_i === 0 
        return_object = {
          code: 0,
          xml: result_object[3],
          qr: result_object[4],
          details: result_object[5]
        }
      else
        return_object = {
          code: result_object[1],
          message: result_object[2]
        }
      end
    end

    ##
    # Parse result for cancelaCFDI
    def parse_result_cancelaCFDI(result)
      object = result.to_hash 
      result_object = object[:cancela_cfdi_response][:cancela_cfdi_result][:any_type]

      {
        code: result_object[1],
        message: (result_object[2].to_s).encode("utf-8")
      }
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
timbradocfdi-0.0.2 lib/timbradocfdi/results.rb