Sha256: a2ce90944a50f572a6128e2dee93dc186e10ded445947b9a42df6d4c6929c4e3

Contents?: true

Size: 1.05 KB

Versions: 23

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

require 'br_invoices_pdf/cfe/parser/access_key'
require 'br_invoices_pdf/cfe/parser/company_attributes'
require 'br_invoices_pdf/cfe/parser/cpf'
require 'br_invoices_pdf/cfe/parser/cnpj'
require 'br_invoices_pdf/cfe/parser/document_number'
require 'br_invoices_pdf/cfe/parser/fisco_obs'
require 'br_invoices_pdf/cfe/parser/payment'
require 'br_invoices_pdf/cfe/parser/payments'
require 'br_invoices_pdf/cfe/parser/products_data'
require 'br_invoices_pdf/cfe/parser/sat'

module BrInvoicesPdf
  module Cfe
    module Parser
      module_function

      PARSERS = {
        sat_params: Sat,
        document_number: DocumentNumber,
        totals: Payment,
        payments: Payments,
        products: ProductsData,
        company_attributes: CompanyAttributes,
        fisco_obs: FiscoObs,
        access_key: AccessKey,
        cpf: Cpf,
        cnpj: Cnpj
      }.freeze

      def parse(xml)
        PARSERS.reduce({}) do |response, (param, parser)|
          { **response, param => parser.execute(xml) }
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
br_invoices_pdf-0.2.8 lib/br_invoices_pdf/cfe/parser.rb
br_invoices_pdf-0.2.7 lib/br_invoices_pdf/cfe/parser.rb
br_invoices_pdf-0.2.6.alpha.19 lib/br_invoices_pdf/cfe/parser.rb