Blame view

lib/syspro/business_objects/parsers/portii_parser.rb 649 Bytes
6a873e0f   chadzink   Implement PorTii ...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
  # frozen_string_literal: true
  
  module Syspro
    module BusinessObjects
      module Parsers
        class PorTiiParser
          attr_reader :doc
  
          def initialize(doc)
            @doc = doc
          end
  
          def parse
            {
              error_numbers: doc.xpath("//ErrorNumber").map{|e| e.text},
              grn_numbers: doc.xpath("//Item/Key/GRNNumber").map{|e| e.text},
              items_processed: doc.xpath("//StatusOfItems/ItemsProcessed").first.text,
              items_invalid: doc.xpath("//StatusOfItems/ItemsInvalid").first.text
            }
          end
  
          PorToiObject = Struct.new(:key, :receipts)
        end
      end
    end
  end