Blame view

lib/syspro/business_objects/comsfm.rb 1.16 KB
d9a9cb5d   chadzink   Add portoi and co...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
  # frozen_string_literal: true
  
  require 'syspro/business_objects/parsers/comsfm_parser'
  require 'erb'
  
  module Syspro
    module BusinessObjects
      class ComsFm < ApiResource
        include Syspro::ApiOperations::Setup
        include Syspro::BusinessObjects::Parsers
  
        attr_accessor :validate_only,
                      :items
  
762ae45f   chadzink   Added InvSws Busi...
15
        def add(user_id)
d9a9cb5d   chadzink   Add portoi and co...
16
17
18
19
          xml_parameters = params_template.result(binding)
          xml_in = template.result(binding)
          business_object = 'COMSFM'
          params = { 'UserId' => user_id,
b1c0def6   Samuel J Clopton   rubocop violation...
20
21
22
                     'BusinessObject' => business_object,
                     'XmlParameters' => xml_parameters,
                     'XmlIn' => xml_in }
d9a9cb5d   chadzink   Add portoi and co...
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
          resp = ComsFm.add(params)
  
          parse_response(resp)
        end
  
        def template
          ERB.new File.read(File.expand_path('schemas/comsfm_doc.xml.erb', File.dirname(__FILE__))), nil, '%'
        end
  
        def params_template
          ERB.new File.read(File.expand_path('schemas/comsfm.xml.erb', File.dirname(__FILE__))), nil, '%'
        end
  
        def parse_response(resp)
          handle_errors(resp)
          parser = ComsFmParser.new(resp[0].data)
          parser.parse
        end
      end
    end
b1c0def6   Samuel J Clopton   rubocop violation...
43
  end