combrw.rb
1.09 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# frozen_string_literal: true
require 'syspro/business_objects/parsers/combrw_parser'
require 'erb'
module Syspro
module BusinessObjects
class ComBrw < ApiResource
include Syspro::ApiOperations::Query
include Syspro::BusinessObjects::Parsers
attr_accessor :browse_name, :start_at_key, :start_condition, :return_rows,
:filters, :table_name, :title, :columns
attr_writer :filters
def call(user_id, raw = false)
xml_in = template.result(binding)
params = { 'UserId' => user_id, 'XmlIn' => xml_in }
resp = ComBrw.browse(params)
if raw
resp
else
parse_response(resp)
end
end
def template
ERB.new(
File.read(
File.expand_path('schemas/combrw.xml.erb', File.dirname(__FILE__))
),
nil,
'%'
)
end
def parse_response(resp)
handle_errors(resp)
parser = ComBrwParser.new(resp[0].data)
parser.parse
end
def filters
@filters || []
end
end
end
end