d9177f32
Isaac Lewis
create sor model;...
|
1
2
|
# frozen_string_literal: true
|
b0dddc7f
Isaac Lewis
change from sorqb...
|
3
|
require 'syspro/business_objects/parsers/sorqry_parser'
|
d9177f32
Isaac Lewis
create sor model;...
|
4
5
6
7
|
require 'erb'
module Syspro
module BusinessObjects
|
b0dddc7f
Isaac Lewis
change from sorqb...
|
8
|
class SorQry < ApiResource
|
d9177f32
Isaac Lewis
create sor model;...
|
9
10
11
|
include Syspro::ApiOperations::Query
include Syspro::BusinessObjects::Parsers
|
b0dddc7f
Isaac Lewis
change from sorqb...
|
12
13
14
|
attr_accessor :sales_order, :invoice, :stocked_lines, :non_stocked_lines, :freight_lines,
:misc_lines, :comment_lines, :completed_lines, :serials, :lots, :bins,
:attached_items, :custom_forms, :detail_line_custom_forms, :values, :line_ship_date
|
d9177f32
Isaac Lewis
create sor model;...
|
15
16
17
|
def call(user_id)
xml_in = template.result(binding)
|
b0dddc7f
Isaac Lewis
change from sorqb...
|
18
|
business_object = 'SORQRY'
|
d9177f32
Isaac Lewis
create sor model;...
|
19
|
params = { 'UserId' => user_id, 'BusinessObject' => business_object, 'XmlIn' => xml_in }
|
b0dddc7f
Isaac Lewis
change from sorqb...
|
20
21
|
resp = SorQry.query(params)
|
d9177f32
Isaac Lewis
create sor model;...
|
22
23
24
25
|
parse_response(resp)
end
def template
|
b0dddc7f
Isaac Lewis
change from sorqb...
|
26
|
ERB.new File.read(File.expand_path('schemas/sorqry.xml.erb', File.dirname(__FILE__))), nil, '%'
|
d9177f32
Isaac Lewis
create sor model;...
|
27
28
29
30
|
end
def parse_response(resp)
handle_errors(resp)
|
b0dddc7f
Isaac Lewis
change from sorqb...
|
31
|
parser = SorQryParser.new(resp[0].data)
|
d9177f32
Isaac Lewis
create sor model;...
|
32
33
34
35
36
37
38
39
40
41
|
parser.parse
end
def handle_errors(resp)
body = resp[0].http_body
raise SysproError, body if body =~ /^(ERROR)/
end
end
end
end
|