Commit 8d1385a3d1a6c1188baf0ba4618b9d4edbb2ed8a
Committed by
GitHub
1 parent
3947376e
Update combrw query to be more useable (#22)
* Update combrw query to be more useable
Showing
6 changed files
with
191 additions
and
45 deletions
Show diff stats
lib/syspro/business_objects/combrw.rb
@@ -9,13 +9,16 @@ module Syspro | @@ -9,13 +9,16 @@ module Syspro | ||
9 | include Syspro::ApiOperations::Query | 9 | include Syspro::ApiOperations::Query |
10 | include Syspro::BusinessObjects::Parsers | 10 | include Syspro::BusinessObjects::Parsers |
11 | 11 | ||
12 | - attr_accessor :browse_name, :start_at_key, :start_condition, :return_rows, :filters, | ||
13 | - :table_name, :title, :columns | 12 | + attr_accessor :browse_name, :start_at_key, :start_condition, :return_rows, |
13 | + :filters, :table_name, :title, :columns | ||
14 | + | ||
15 | + attr_writer :filters | ||
14 | 16 | ||
15 | def call(user_id, raw = false) | 17 | def call(user_id, raw = false) |
16 | xml_in = template.result(binding) | 18 | xml_in = template.result(binding) |
17 | params = { 'UserId' => user_id, 'XmlIn' => xml_in } | 19 | params = { 'UserId' => user_id, 'XmlIn' => xml_in } |
18 | resp = ComBrw.browse(params) | 20 | resp = ComBrw.browse(params) |
21 | + | ||
19 | if raw | 22 | if raw |
20 | resp | 23 | resp |
21 | else | 24 | else |
@@ -38,6 +41,10 @@ module Syspro | @@ -38,6 +41,10 @@ module Syspro | ||
38 | parser = ComBrwParser.new(resp[0].data) | 41 | parser = ComBrwParser.new(resp[0].data) |
39 | parser.parse | 42 | parser.parse |
40 | end | 43 | end |
44 | + | ||
45 | + def filters | ||
46 | + @filters || [] | ||
47 | + end | ||
41 | end | 48 | end |
42 | end | 49 | end |
43 | end | 50 | end |
lib/syspro/business_objects/parsers/combrw_parser.rb
@@ -4,6 +4,8 @@ module Syspro | @@ -4,6 +4,8 @@ module Syspro | ||
4 | module BusinessObjects | 4 | module BusinessObjects |
5 | module Parsers | 5 | module Parsers |
6 | class ComBrwParser | 6 | class ComBrwParser |
7 | + BrowseObject = Struct.new(:headers, :rows, :next_key, :prev_key, :fwd, :back, :key) | ||
8 | + | ||
7 | attr_reader :doc | 9 | attr_reader :doc |
8 | 10 | ||
9 | def initialize(doc) | 11 | def initialize(doc) |
@@ -11,44 +13,32 @@ module Syspro | @@ -11,44 +13,32 @@ module Syspro | ||
11 | end | 13 | end |
12 | 14 | ||
13 | def parse | 15 | def parse |
14 | - next_prev_key = doc.first_element_child.xpath('NextPrevKey') | ||
15 | - next_prev_key_obj = next_prev_key.children.map do |el| | ||
16 | - next if el.name == 'text' | ||
17 | - { | ||
18 | - name: el.name, | ||
19 | - text: el.text | ||
20 | - } | ||
21 | - end.compact | ||
22 | - | ||
23 | - header_details = doc.first_element_child.xpath('HeaderDetails') | ||
24 | - header_details_obj = header_details.children.map do |el| | ||
25 | - next if el.name == 'text' | ||
26 | - { | ||
27 | - name: el.name, | ||
28 | - text: el.text | ||
29 | - } | ||
30 | - end.compact | 16 | + prev_key = doc.xpath('//NextPrevKey/PrevKey').text |
17 | + next_key = doc.xpath('//NextPrevKey/NextKey').text | ||
18 | + fwd = doc.xpath('//NextPrevKey/Fwd').text.casecmp('true').zero? | ||
19 | + back = doc.xpath('//NextPrevKey/Back').text.casecmp('true').zero? | ||
20 | + headers = doc.xpath('//HeaderDetails/Header').map { |h| h.text } | ||
21 | + key = doc.xpath('//HeaderDetails/Key').text | ||
31 | 22 | ||
32 | - rows = doc.first_element_child.xpath('Row') | ||
33 | - rows_obj = rows.flat_map do |el| | ||
34 | - el.elements.map do |inner| | ||
35 | - { | ||
36 | - name: inner.name, | ||
37 | - value: inner.xpath('Value').text, | ||
38 | - data_type: inner.xpath('DataType').text | ||
39 | - } | 23 | + rows = doc.xpath('//Row').map do |row| |
24 | + columns = row.children.select { |n| n.node_type == Nokogiri::XML::Reader::TYPE_ELEMENT } | ||
25 | + columns.each_with_object({}) do |column, hash| | ||
26 | + hash[column.name] = column.children | ||
27 | + .find { |child| child.name == 'Value' } | ||
28 | + .text | ||
40 | end | 29 | end |
41 | - end.compact | 30 | + end |
42 | 31 | ||
43 | BrowseObject.new( | 32 | BrowseObject.new( |
44 | - doc.first_element_child.xpath('Title').text, | ||
45 | - rows_obj, | ||
46 | - next_prev_key_obj, | ||
47 | - header_details_obj | 33 | + headers, |
34 | + rows, | ||
35 | + next_key, | ||
36 | + prev_key, | ||
37 | + fwd, | ||
38 | + back, | ||
39 | + key | ||
48 | ) | 40 | ) |
49 | end | 41 | end |
50 | - | ||
51 | - BrowseObject = Struct.new(:title, :rows, :next_prev_key, :header_details) | ||
52 | end | 42 | end |
53 | end | 43 | end |
54 | end | 44 | end |
lib/syspro/business_objects/schemas/combrw.xml.erb
@@ -4,11 +4,11 @@ | @@ -4,11 +4,11 @@ | ||
4 | <StartAtKey><%= @start_at_key %></StartAtKey> | 4 | <StartAtKey><%= @start_at_key %></StartAtKey> |
5 | <StartCondition><%= @start_condition %></StartCondition> | 5 | <StartCondition><%= @start_condition %></StartCondition> |
6 | <ReturnRows><%= @return_rows %></ReturnRows> | 6 | <ReturnRows><%= @return_rows %></ReturnRows> |
7 | - <% for @filter in @filters %> | 7 | + <% for filter in filters %> |
8 | <Filter> | 8 | <Filter> |
9 | - <ColumnFilterName><%= @filter[:name] %></ColumnFilterName> | ||
10 | - <ColumnFilterValue><%= @filter[:value] %></ColumnFilterValue> | ||
11 | - </Filter> | 9 | + <ColumnFilterName><%= filter[:name] %></ColumnFilterName> |
10 | + <ColumnFilterValue><%= filter[:value] %></ColumnFilterValue> | ||
11 | + </Filter> | ||
12 | <% end %> | 12 | <% end %> |
13 | </Browse> | 13 | </Browse> |
14 | 14 |
1 | +--- | ||
2 | +http_interactions: | ||
3 | +- request: | ||
4 | + method: get | ||
5 | + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/logon?CompanyId=<syspro_company>&CompanyPassword=&Operator=<syspro_username>&OperatorPassword=<syspro_password> | ||
6 | + body: | ||
7 | + encoding: US-ASCII | ||
8 | + string: '' | ||
9 | + headers: | ||
10 | + User-Agent: | ||
11 | + - Syspro/7 RubyBindings/1.0.0.alpha.2 | ||
12 | + Content-Type: | ||
13 | + - application/x-www-form-urlencoded | ||
14 | + Accept-Encoding: | ||
15 | + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 | ||
16 | + Accept: | ||
17 | + - "*/*" | ||
18 | + response: | ||
19 | + status: | ||
20 | + code: 200 | ||
21 | + message: OK | ||
22 | + headers: | ||
23 | + Content-Type: | ||
24 | + - application/octet-stream | ||
25 | + Server: | ||
26 | + - Microsoft-HTTPAPI/2.0 | ||
27 | + Date: | ||
28 | + - Thu, 30 May 2019 23:45:30 GMT | ||
29 | + Content-<syspro_company>ength: | ||
30 | + - '36' | ||
31 | + body: | ||
32 | + encoding: UTF-8 | ||
33 | + string: '919BB8178D221E4F92299528B68B597000 ' | ||
34 | + http_version: | ||
35 | + recorded_at: Thu, 30 May 2019 23:45:29 GMT | ||
36 | +- request: | ||
37 | + method: get | ||
38 | + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/Query/Browse?UserId=919BB8178D221E4F92299528B68B597000%20%20&XmlIn=%3C?xml%20version=%221.0%22%20encoding=%22Windows-1252%22?%3E%0A%3CBrowse%20xmlns:xsd=%22http://www.w3.org/2001/XM<syspro_company>Schema-instance%22%20xsd:noNamespaceSchema<syspro_company>ocation=%22COMBRW.XSD%22%3E%0A%20%20%3CBrowseName%3E<syspro_company>abbeeInvWhControl%3C/BrowseName%3E%0A%20%20%3CStartAtKey%3E%3C/StartAtKey%3E%0A%20%20%3CStartCondition%3E%3C/StartCondition%3E%0A%20%20%3CReturnRows%3E30%3C/ReturnRows%3E%0A%20%20%0A%3C/Browse%3E%0A%0A | ||
39 | + body: | ||
40 | + encoding: US-ASCII | ||
41 | + string: '' | ||
42 | + headers: | ||
43 | + User-Agent: | ||
44 | + - Syspro/7 RubyBindings/1.0.0.alpha.2 | ||
45 | + Content-Type: | ||
46 | + - application/x-www-form-urlencoded | ||
47 | + Accept-Encoding: | ||
48 | + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 | ||
49 | + Accept: | ||
50 | + - "*/*" | ||
51 | + response: | ||
52 | + status: | ||
53 | + code: 200 | ||
54 | + message: OK | ||
55 | + headers: | ||
56 | + Content-Type: | ||
57 | + - application/octet-stream | ||
58 | + Server: | ||
59 | + - Microsoft-HTTPAPI/2.0 | ||
60 | + Date: | ||
61 | + - Thu, 30 May 2019 23:45:57 GMT | ||
62 | + Content-<syspro_company>ength: | ||
63 | + - '7988' | ||
64 | + body: | ||
65 | + encoding: UTF-8 | ||
66 | + string: "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<InvWhControl <syspro_company>anguage='05' | ||
67 | + <syspro_company>anguage2='EN' CssStyle='' DecFormat='1' DateFormat='01' Role='01' | ||
68 | + Version='7.0.038' OperatorPrimaryRole=' '>\n<Title>Warehouses</Title>\n<Row>\n<Warehouse>\n<Value>BJ</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>BRONSON | ||
69 | + & JACOBS</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>CB</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>CO<syspro_company>GATE | ||
70 | + @ BE<syspro_company>GIUM</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>CG</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>CO<syspro_company>GATE | ||
71 | + @ harrah</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>DR</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>HARRAH-<syspro_company>ABBEEMINT | ||
72 | + OWNED</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>EX</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>ESSEX | ||
73 | + <syspro_company>ABS</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>F9</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>FIRMENICH | ||
74 | + HE<syspro_company>D INVENTORY</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>FI</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>FIRMENICH</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>GV</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>GIVAUDAN</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>H0</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>HARRAH-GROWER | ||
75 | + OWNED</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>H1</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>HARRAH-<syspro_company>ABBEEMINT | ||
76 | + OWNED</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>H8</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>HARRAH-CUSTOMER | ||
77 | + OWNED</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>H9</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>HARRAH-CUSTOMER | ||
78 | + SET ASIDE</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>HD</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>HRF(D)</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>HQ</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>MAIN-11793 | ||
79 | + FORT ROAD</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>HR</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>HAARMANN | ||
80 | + & RIEMER</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>I9</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>IFF | ||
81 | + HE<syspro_company>D INVENTORY</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>IF</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>IFF</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>J9</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>JC | ||
82 | + BUCK HE<syspro_company>D INVENTORY</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>JC</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>JCBUCK | ||
83 | + <syspro_company>TD HE<syspro_company>D INVENTORY</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>K9</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>KAR<syspro_company> | ||
84 | + RAPP HE<syspro_company>D INVENTORY</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>M0</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>MADRAS-GROWER | ||
85 | + OWNED</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>M1</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>MADRAS-<syspro_company>ABBEEMINT | ||
86 | + OWNED</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>MD</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>MADRAS | ||
87 | + OREGON</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>MS</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>MATAS</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>MW</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>PORTAGE | ||
88 | + WISCONSIN</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>N0</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>NAMPA-GROWER | ||
89 | + OWNED</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>N1</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>NAMPA-<syspro_company>ABBEEMINT | ||
90 | + OWNED</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>NV</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>NOVI<syspro_company><syspro_company>E</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>P0</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>PORTAGE-GROWER | ||
91 | + OWNED</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>P1</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>PORTAGE-<syspro_company>ABBEEMINT | ||
92 | + OWNED</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>P8</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>PORTAGE-CUSTOMER | ||
93 | + OWNED</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>P9</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>PORTAGE-CUSTOMER | ||
94 | + SETASIDE</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>PG</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>PROCTER&GAMB<syspro_company>E</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>PO</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>PO<syspro_company>AROME</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>QI</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>QUEST | ||
95 | + INTRNTN<syspro_company></Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>RE</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>REYNAUD@St. | ||
96 | + Didier</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>T9</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value><syspro_company>MT | ||
97 | + OWNED INV AT PDI</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>T<syspro_company></Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>TI<syspro_company><syspro_company>OTS | ||
98 | + WAREHOUSE</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>U8</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>U<syspro_company><syspro_company> | ||
99 | + OWNED @ PDI</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<Row>\n<Warehouse>\n<Value>WY</Value>\n<DataType>AlphaNumeric</DataType>\n</Warehouse>\n<Description>\n<Value>WRIG<syspro_company>EY</Value>\n<DataType>AlphaNumeric</DataType>\n</Description>\n</Row>\n<NextPrevKey>\n<PrevKey>BJ</PrevKey>\n<NextKey>WY</NextKey>\n<Fwd>False</Fwd>\n<Back>False</Back>\n</NextPrevKey>\n<HeaderDetails>\n<Header>Warehouse</Header>\n<Header>Description | ||
100 | + \ .</Header>\n<Key>Warehouse</Key>\n<KeyDescription>Warehouse | ||
101 | + code</KeyDescription>\n<Table>InvWhControl</Table>\n</HeaderDetails>\n</InvWhControl>\n " | ||
102 | + http_version: | ||
103 | + recorded_at: Thu, 30 May 2019 23:45:56 GMT | ||
104 | +recorded_with: VCR 4.0.0 |
test/cassettes/test_portor.yml
@@ -25,17 +25,17 @@ http_interactions: | @@ -25,17 +25,17 @@ http_interactions: | ||
25 | Server: | 25 | Server: |
26 | - Microsoft-HTTPAPI/2.0 | 26 | - Microsoft-HTTPAPI/2.0 |
27 | Date: | 27 | Date: |
28 | - - Thu, 23 May 2019 16:43:21 GMT | 28 | + - Wed, 19 Jun 2019 21:18:47 GMT |
29 | Content-<syspro_company>ength: | 29 | Content-<syspro_company>ength: |
30 | - '36' | 30 | - '36' |
31 | body: | 31 | body: |
32 | encoding: UTF-8 | 32 | encoding: UTF-8 |
33 | - string: '6D8139C868FDD74487FB2B80F8CC4EBD00 ' | 33 | + string: '2088C39D9FF2C34281100962D8D28EC100 ' |
34 | http_version: | 34 | http_version: |
35 | - recorded_at: Thu, 23 May 2019 16:43:18 GMT | 35 | + recorded_at: Wed, 19 Jun 2019 21:18:45 GMT |
36 | - request: | 36 | - request: |
37 | method: get | 37 | method: get |
38 | - uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/Transaction/Post?BusinessObject=PORTOR&UserId=6D8139C868FDD74487FB2B80F8CC4EBD00%20%20&XmlIn=%3C?xml%20version=%221.0%22%20encoding=%22Windows-1252%22?%3E%0A%3CPostPurchaseOrderReceipts%20xmlns:xsd=%22http://www.w3.org/2001/XM<syspro_company>Schema-instance%22%20xsd:noNamespaceSchema<syspro_company>ocation=%22portordoc.xsd%22%3E%0A%20%20%0A%20%20%3CItem%3E%0A%20%20%20%20%3CReceiptIntoInspection%3E%0A%20%20%20%20%20%20%3CPurchaseOrder%3EZ01308%3C/PurchaseOrder%3E%0A%20%20%20%20%20%20%3CWarehouse%3EP0%3C/Warehouse%3E%0A%20%20%20%20%20%20%3CStockCode%3E8801%3C/StockCode%3E%0A%20%20%20%20%20%20%3CQuantity%3E0.01%3C/Quantity%3E%0A%20%20%20%20%20%20%3CCountedQuantityComplete%3EY%3C/CountedQuantityComplete%3E%0A%20%20%20%20%20%20%3CDeliveryNote%3EDE<syspro_company>IVER%20NOTE%20HERE-W<syspro_company>%3C/DeliveryNote%3E%0A%20%20%20%20%20%20%3CCertificate%3E8/45-3%3C/Certificate%3E%0A%20%20%20%20%20%20%3CNarration%3E%3C/Narration%3E%0A%20%20%20%20%20%20%3C<syspro_company>ot%3E7097505%3C/<syspro_company>ot%3E%0A%20%20%20%20%20%20%3CGRNNumber%3E%3C/GRNNumber%3E%0A%20%20%20%20%20%20%3CConcession%3E%3C/Concession%3E%0A%20%20%20%20%20%20%3CCostBasis%3E%3C/CostBasis%3E%0A%20%20%20%20%20%20%3CNotation%3E%3C/Notation%3E%0A%20%20%20%20%20%20%3CReference%3E%3C/Reference%3E%0A%20%20%20%20%20%20%3CGRNSource%3E%3C/GRNSource%3E%0A%20%20%20%20%20%20%0A%20%20%20%20%3C/ReceiptIntoInspection%3E%0A%20%20%3C/Item%3E%0A%20%20%20%20%20%20%0A%3C/PostPurchaseOrderReceipts%3E&XmlParameters=%3C?xml%20version=%221.0%22%20encoding=%22Windows-1252%22?%3E%0A%3CPostPurchaseOrderReceipts%20xmlns:xsd=%22http://www.w3.org/2001/XM<syspro_company>Schema-instance%22%20xsd:noNamespaceSchema<syspro_company>ocation=%22portor.xsd%22%3E%0A%20%20%3CParameters%3E%0A%20%20%20%20%3CTransactionDate%3E2019-05-23%3C/TransactionDate%3E%0A%20%20%20%20%3CIgnoreWarnings%3EN%3C/IgnoreWarnings%3E%0A%20%20%20%20%3CNonStockedWhToUse%3E%3C/NonStockedWhToUse%3E%0A%20%20%20%20%3CGRNMatchingAction%3EA%3C/GRNMatchingAction%3E%0A%20%20%20%20%3CAllowBlankSupplier%3EN%3C/AllowBlankSupplier%3E%0A%20%20%20%20%3CApplyIfEntireDocumentValid%3EN%3C/ApplyIfEntireDocumentValid%3E%0A%20%20%20%20%3CValidateOnly%3EN%3C/ValidateOnly%3E%0A%20%20%20%20%3CManualSerialTransfersAllowed%3EN%3C/ManualSerialTransfersAllowed%3E%0A%20%20%20%20%3CIgnoreAnalysis%3EN%3C/IgnoreAnalysis%3E%0A%20%20%3C/Parameters%3E%0A%3C/PostPurchaseOrderReceipts%3E | 38 | + uri: http://syspro.wildlandlabs.com:90/SYSPROWCFService/Rest/Transaction/Post?BusinessObject=PORTOR&UserId=2088C39D9FF2C34281100962D8D28EC100%20%20&XmlIn=%3C?xml%20version=%221.0%22%20encoding=%22Windows-1252%22?%3E%0A%3CPostPurchaseOrderReceipts%20xmlns:xsd=%22http://www.w3.org/2001/XM<syspro_company>Schema-instance%22%20xsd:noNamespaceSchema<syspro_company>ocation=%22portordoc.xsd%22%3E%0A%20%20%0A%20%20%3CItem%3E%0A%20%20%20%20%3CReceiptIntoInspection%3E%0A%20%20%20%20%20%20%3CPurchaseOrder%3EZ01308%3C/PurchaseOrder%3E%0A%20%20%20%20%20%20%3CWarehouse%3EP0%3C/Warehouse%3E%0A%20%20%20%20%20%20%3CStockCode%3E8801%3C/StockCode%3E%0A%20%20%20%20%20%20%3CQuantity%3E0.01%3C/Quantity%3E%0A%20%20%20%20%20%20%3CCountedQuantityComplete%3EY%3C/CountedQuantityComplete%3E%0A%20%20%20%20%20%20%3CDeliveryNote%3EDE<syspro_company>IVER%20NOTE%20HERE-W<syspro_company>%3C/DeliveryNote%3E%0A%20%20%20%20%20%20%3CCertificate%3E8/45-3%3C/Certificate%3E%0A%20%20%20%20%20%20%3CNarration%3E%3C/Narration%3E%0A%20%20%20%20%20%20%3C<syspro_company>ot%3E7097505%3C/<syspro_company>ot%3E%0A%20%20%20%20%20%20%3CGRNNumber%3E%3C/GRNNumber%3E%0A%20%20%20%20%20%20%3CConcession%3E%3C/Concession%3E%0A%20%20%20%20%20%20%3CCostBasis%3E%3C/CostBasis%3E%0A%20%20%20%20%20%20%3CNotation%3E%3C/Notation%3E%0A%20%20%20%20%20%20%3CReference%3E%3C/Reference%3E%0A%20%20%20%20%20%20%3CGRNSource%3E%3C/GRNSource%3E%0A%20%20%20%20%20%20%0A%20%20%20%20%3C/ReceiptIntoInspection%3E%0A%20%20%3C/Item%3E%0A%20%20%20%20%20%20%0A%3C/PostPurchaseOrderReceipts%3E&XmlParameters=%3C?xml%20version=%221.0%22%20encoding=%22Windows-1252%22?%3E%0A%3CPostPurchaseOrderReceipts%20xmlns:xsd=%22http://www.w3.org/2001/XM<syspro_company>Schema-instance%22%20xsd:noNamespaceSchema<syspro_company>ocation=%22portor.xsd%22%3E%0A%20%20%3CParameters%3E%0A%20%20%20%20%3CTransactionDate%3E2019-06-19%3C/TransactionDate%3E%0A%20%20%20%20%3CIgnoreWarnings%3EN%3C/IgnoreWarnings%3E%0A%20%20%20%20%3CNonStockedWhToUse%3E%3C/NonStockedWhToUse%3E%0A%20%20%20%20%3CGRNMatchingAction%3EA%3C/GRNMatchingAction%3E%0A%20%20%20%20%3CAllowBlankSupplier%3EN%3C/AllowBlankSupplier%3E%0A%20%20%20%20%3CApplyIfEntireDocumentValid%3EN%3C/ApplyIfEntireDocumentValid%3E%0A%20%20%20%20%3CValidateOnly%3EN%3C/ValidateOnly%3E%0A%20%20%20%20%3CManualSerialTransfersAllowed%3EN%3C/ManualSerialTransfersAllowed%3E%0A%20%20%20%20%3CIgnoreAnalysis%3EN%3C/IgnoreAnalysis%3E%0A%20%20%3C/Parameters%3E%0A%3C/PostPurchaseOrderReceipts%3E |
39 | body: | 39 | body: |
40 | encoding: US-ASCII | 40 | encoding: US-ASCII |
41 | string: '' | 41 | string: '' |
@@ -58,14 +58,14 @@ http_interactions: | @@ -58,14 +58,14 @@ http_interactions: | ||
58 | Server: | 58 | Server: |
59 | - Microsoft-HTTPAPI/2.0 | 59 | - Microsoft-HTTPAPI/2.0 |
60 | Date: | 60 | Date: |
61 | - - Thu, 23 May 2019 16:43:23 GMT | 61 | + - Wed, 19 Jun 2019 21:18:47 GMT |
62 | Content-<syspro_company>ength: | 62 | Content-<syspro_company>ength: |
63 | - '397' | 63 | - '397' |
64 | body: | 64 | body: |
65 | encoding: UTF-8 | 65 | encoding: UTF-8 |
66 | string: "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<postpurchaseorderreceipts | 66 | string: "<?xml version=\"1.0\" encoding=\"Windows-1252\"?>\n<postpurchaseorderreceipts |
67 | <syspro_company>anguage='05' <syspro_company>anguage2='EN' CssStyle='' DecFormat='1' | 67 | <syspro_company>anguage='05' <syspro_company>anguage2='EN' CssStyle='' DecFormat='1' |
68 | - DateFormat='01' Role='01' Version='7.0.111' OperatorPrimaryRole=' '>\n<Item>\n<Key>\n<PurchaseOrder>Z01308</PurchaseOrder>\n<<syspro_company>ine>0002</<syspro_company>ine>\n<Grn>P00013152</Grn>\n<<syspro_company>otNumber>7097505</<syspro_company>otNumber>\n</Key>\n<ItemNumber>000001</ItemNumber>\n</Item>\n</postpurchaseorderreceipts>\n " | 68 | + DateFormat='01' Role='01' Version='7.0.111' OperatorPrimaryRole=' '>\n<Item>\n<Key>\n<PurchaseOrder>Z01308</PurchaseOrder>\n<<syspro_company>ine>0002</<syspro_company>ine>\n<Grn>P00013151</Grn>\n<<syspro_company>otNumber>7097505</<syspro_company>otNumber>\n</Key>\n<ItemNumber>000001</ItemNumber>\n</Item>\n</postpurchaseorderreceipts>\n " |
69 | http_version: | 69 | http_version: |
70 | - recorded_at: Thu, 23 May 2019 16:43:20 GMT | 70 | + recorded_at: Wed, 19 Jun 2019 21:18:46 GMT |
71 | recorded_with: VCR 4.0.0 | 71 | recorded_with: VCR 4.0.0 |
1 | +# frozen_string_literal: true | ||
2 | + | ||
3 | +require 'test_helper' | ||
4 | + | ||
5 | +class ComBrwTest < Minitest::Test | ||
6 | + extend Minitest::Spec::DSL | ||
7 | + before do | ||
8 | + VCR.insert_cassette name | ||
9 | + end | ||
10 | + after { VCR.eject_cassette } | ||
11 | + | ||
12 | + let(:username) { ENV['SYSPRO_USERNAME'] } | ||
13 | + let(:password) { ENV['SYSPRO_PASSWORD'] } | ||
14 | + let(:company) { ENV['SYSPRO_COMPANY'] } | ||
15 | + let(:company_password) { '' } | ||
16 | + let(:user_id) do | ||
17 | + Syspro::Logon.logon(username, password, company, company_password) | ||
18 | + end | ||
19 | + | ||
20 | + def test_inv_wh_ctrl_qry | ||
21 | + com_browse = Syspro::BusinessObjects::ComBrw.new | ||
22 | + | ||
23 | + com_browse.return_rows = 30 | ||
24 | + com_browse.browse_name = 'LabbeeInvWhControl' | ||
25 | + query = com_browse.call(user_id.guid) | ||
26 | + | ||
27 | + assert_kind_of Syspro::BusinessObjects::Parsers::ComBrwParser::BrowseObject, query | ||
28 | + assert query.headers, 'has headers' | ||
29 | + assert_equal 2, query.headers.count, 'has headers' | ||
30 | + assert query.prev_key, 'has a previous key' | ||
31 | + assert query.next_key, 'has a next key' | ||
32 | + assert query.key, 'has a key' | ||
33 | + assert_includes [true, false], query.fwd | ||
34 | + assert_includes [true, false], query.back | ||
35 | + query.rows.each do |row| | ||
36 | + assert_kind_of( | ||
37 | + Hash, | ||
38 | + row | ||
39 | + ) | ||
40 | + | ||
41 | + assert row.key?('Warehouse'), 'row should contain a warehouse' | ||
42 | + assert row.key?('Description'), 'row should contain a description' | ||
43 | + end | ||
44 | + end | ||
45 | +end |