Blame view

lib/syspro/business_objects/invsws.rb 1.4 KB
762ae45f   chadzink   Added InvSws Busi...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
  # frozen_string_literal: true
  
  require 'syspro/business_objects/parsers/invsws_parser'
  require 'erb'
  
  module Syspro
    module BusinessObjects
      class InvSws < ApiResource
        include Syspro::ApiOperations::Setup
        include Syspro::BusinessObjects::Parsers
  
        attr_accessor :validate_only,
                      :apply_product_class_default,
                      :ignore_warnings,
                      :apply_if_entire_document_valid,
                      :item
  
        def add(user_id)
          xml_parameters = params_template.result(binding)
          xml_in = template.result(binding)
          business_object = 'INVSWS'
          params = { 'UserId' => user_id,
b1c0def6   Samuel J Clopton   rubocop violation...
23
24
25
                     'BusinessObject' => business_object,
                     'XmlParameters' => xml_parameters,
                     'XmlIn' => xml_in }
762ae45f   chadzink   Added InvSws Busi...
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
          resp = InvSws.add(params)
  
          parse_response(resp)
        end
  
        def template
          ERB.new File.read(File.expand_path('schemas/invsws_doc.xml.erb', File.dirname(__FILE__))), nil, '%'
        end
  
        def params_template
          ERB.new File.read(File.expand_path('schemas/invsws.xml.erb', File.dirname(__FILE__))), nil, '%'
        end
  
        def parse_response(resp)
          handle_errors(resp)
          parser = InvSwsParser.new(resp[0].data)
          parser.parse
        end
  
b1c0def6   Samuel J Clopton   rubocop violation...
45
        def render_xml(inner_text, dflt_value = '')
762ae45f   chadzink   Added InvSws Busi...
46
47
48
49
50
          inner_text ? inner_text.to_s : dflt_value
        end
      end
    end
  end