Class: SunatInvoice::ResponseParser

Inherits:
Object
  • Object
show all
Defined in:
lib/sunat_invoice/response_parser.rb

Constant Summary collapse

STATUS_CODES =
{
  0 => 'process success',
  99 => 'in process',
  98 => 'process with errors'
}.freeze
ALLOWED_PARSERS =
%w[invoice summary status].freeze
VALID_PROCESS =
%w[0].freeze
IN_PROCESS =
%w[99].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(body, parser_type) ⇒ ResponseParser

Returns a new instance of ResponseParser.



19
20
21
22
23
24
25
# File 'lib/sunat_invoice/response_parser.rb', line 19

def initialize(body, parser_type)
  # body: SOAP body as a Hash. Typically Savon Response body.
  # parser_type: kind of parser to use.
  raise InvalidResponseParser unless ALLOWED_PARSERS.include?(parser_type)

  send("parse_#{parser_type}", body)
end

Instance Attribute Details

#cdrObject (readonly)

Returns the value of attribute cdr.



7
8
9
# File 'lib/sunat_invoice/response_parser.rb', line 7

def cdr
  @cdr
end

#document_numberObject (readonly)

Returns the value of attribute document_number.



7
8
9
# File 'lib/sunat_invoice/response_parser.rb', line 7

def document_number
  @document_number
end

#messageObject (readonly)

Returns the value of attribute message.



7
8
9
# File 'lib/sunat_invoice/response_parser.rb', line 7

def message
  @message
end

#status_codeObject (readonly)

Returns the value of attribute status_code.



7
8
9
# File 'lib/sunat_invoice/response_parser.rb', line 7

def status_code
  @status_code
end

#ticketObject (readonly)

Returns the value of attribute ticket.



7
8
9
# File 'lib/sunat_invoice/response_parser.rb', line 7

def ticket
  @ticket
end