cxml-ruby 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.github/workflows/ruby.yml +23 -0
- data/.gitignore +14 -0
- data/.rspec +1 -0
- data/.rubocop.yml +175 -0
- data/Gemfile +2 -0
- data/LICENSE +18 -0
- data/README.md +94 -0
- data/Rakefile +6 -0
- data/cxml-ruby.gemspec +27 -0
- data/lib/cxml/accounting.rb +27 -0
- data/lib/cxml/additional_cost.rb +10 -0
- data/lib/cxml/additional_deduction.rb +12 -0
- data/lib/cxml/address.rb +16 -0
- data/lib/cxml/bill_to.rb +10 -0
- data/lib/cxml/browser_form_post.rb +13 -0
- data/lib/cxml/charge.rb +9 -0
- data/lib/cxml/classification.rb +9 -0
- data/lib/cxml/confirmation_header.rb +16 -0
- data/lib/cxml/confirmation_item.rb +14 -0
- data/lib/cxml/confirmation_request.rb +25 -0
- data/lib/cxml/confirmation_status.rb +32 -0
- data/lib/cxml/contact.rb +16 -0
- data/lib/cxml/country.rb +9 -0
- data/lib/cxml/credential.rb +49 -0
- data/lib/cxml/credential_mac.rb +26 -0
- data/lib/cxml/deducted_price.rb +9 -0
- data/lib/cxml/deduction_amount.rb +9 -0
- data/lib/cxml/description.rb +9 -0
- data/lib/cxml/discount.rb +10 -0
- data/lib/cxml/discount_percent.rb +9 -0
- data/lib/cxml/distribution.rb +11 -0
- data/lib/cxml/document.rb +71 -0
- data/lib/cxml/document_node.rb +126 -0
- data/lib/cxml/document_reference.rb +9 -0
- data/lib/cxml/due_amount.rb +9 -0
- data/lib/cxml/email.rb +10 -0
- data/lib/cxml/errors.rb +7 -0
- data/lib/cxml/extrinsic.rb +10 -0
- data/lib/cxml/from.rb +9 -0
- data/lib/cxml/gross_amount.rb +9 -0
- data/lib/cxml/header.rb +29 -0
- data/lib/cxml/id_reference.rb +13 -0
- data/lib/cxml/invoice_detail_discount.rb +13 -0
- data/lib/cxml/invoice_detail_header_indicator.rb +11 -0
- data/lib/cxml/invoice_detail_header_order.rb +24 -0
- data/lib/cxml/invoice_detail_item.rb +55 -0
- data/lib/cxml/invoice_detail_item_reference.rb +17 -0
- data/lib/cxml/invoice_detail_line_indicator.rb +14 -0
- data/lib/cxml/invoice_detail_line_shipping.rb +11 -0
- data/lib/cxml/invoice_detail_line_special_handling.rb +11 -0
- data/lib/cxml/invoice_detail_order.rb +24 -0
- data/lib/cxml/invoice_detail_order_info.rb +10 -0
- data/lib/cxml/invoice_detail_order_summary.rb +32 -0
- data/lib/cxml/invoice_detail_request.rb +40 -0
- data/lib/cxml/invoice_detail_request_header.rb +54 -0
- data/lib/cxml/invoice_detail_shipping.rb +27 -0
- data/lib/cxml/invoice_detail_summary.rb +18 -0
- data/lib/cxml/invoice_id_info.rb +10 -0
- data/lib/cxml/invoice_partner.rb +10 -0
- data/lib/cxml/item_detail.rb +27 -0
- data/lib/cxml/item_id.rb +10 -0
- data/lib/cxml/item_in.rb +14 -0
- data/lib/cxml/item_out.rb +17 -0
- data/lib/cxml/master_agreement_reference.rb +9 -0
- data/lib/cxml/message.rb +13 -0
- data/lib/cxml/modification.rb +15 -0
- data/lib/cxml/modification_detail.rb +16 -0
- data/lib/cxml/modifications.rb +23 -0
- data/lib/cxml/money.rb +35 -0
- data/lib/cxml/name.rb +9 -0
- data/lib/cxml/net_amount.rb +9 -0
- data/lib/cxml/order_reference.rb +12 -0
- data/lib/cxml/order_request.rb +33 -0
- data/lib/cxml/order_request_header.rb +66 -0
- data/lib/cxml/parser.rb +37 -0
- data/lib/cxml/payment_term.rb +28 -0
- data/lib/cxml/period.rb +10 -0
- data/lib/cxml/postal_address.rb +35 -0
- data/lib/cxml/protocol.rb +57 -0
- data/lib/cxml/punch_out_order_message.rb +33 -0
- data/lib/cxml/punch_out_order_message_header.rb +20 -0
- data/lib/cxml/punch_out_setup_request.rb +31 -0
- data/lib/cxml/punch_out_setup_response.rb +9 -0
- data/lib/cxml/request.rb +21 -0
- data/lib/cxml/response.rb +20 -0
- data/lib/cxml/segment.rb +12 -0
- data/lib/cxml/sender.rb +10 -0
- data/lib/cxml/ship_to.rb +10 -0
- data/lib/cxml/shipping.rb +10 -0
- data/lib/cxml/shipping_amount.rb +10 -0
- data/lib/cxml/special_handling_amount.rb +11 -0
- data/lib/cxml/start_page.rb +13 -0
- data/lib/cxml/state.rb +9 -0
- data/lib/cxml/status.rb +27 -0
- data/lib/cxml/subtotal_amount.rb +9 -0
- data/lib/cxml/supplier_setup.rb +13 -0
- data/lib/cxml/tax.rb +42 -0
- data/lib/cxml/tax_adjustment_amount.rb +9 -0
- data/lib/cxml/tax_amount.rb +9 -0
- data/lib/cxml/tax_detail.rb +44 -0
- data/lib/cxml/tax_location.rb +9 -0
- data/lib/cxml/taxable_amount.rb +9 -0
- data/lib/cxml/to.rb +9 -0
- data/lib/cxml/total.rb +10 -0
- data/lib/cxml/total_allowances.rb +9 -0
- data/lib/cxml/total_amount_without_tax.rb +9 -0
- data/lib/cxml/total_charges.rb +9 -0
- data/lib/cxml/unit_price.rb +9 -0
- data/lib/cxml/version.rb +5 -0
- data/lib/cxml.rb +39 -0
- data/spec/credential_spec.rb +37 -0
- data/spec/cxml_spec.rb +6 -0
- data/spec/document_spec.rb +155 -0
- data/spec/fixtures/.gitkeep +0 -0
- data/spec/fixtures/envelope.xml +31 -0
- data/spec/fixtures/envelope2.xml +36 -0
- data/spec/fixtures/invoice_backed_and_unbacked_by_pos.xml +106 -0
- data/spec/fixtures/invoice_backed_by_multiple_pos.xml +97 -0
- data/spec/fixtures/invoice_taxes_at_line.xml +82 -0
- data/spec/fixtures/invoice_taxes_at_line_multiple_taxes.xml +403 -0
- data/spec/fixtures/invoice_taxes_at_total.xml +78 -0
- data/spec/fixtures/item_in.xml +11 -0
- data/spec/fixtures/order_request.cxml +121 -0
- data/spec/fixtures/punch_out_order_message_doc.xml +32 -0
- data/spec/fixtures/punch_out_setup_request_doc.xml +32 -0
- data/spec/fixtures/punch_out_setup_request_doc_coupa.xml +42 -0
- data/spec/fixtures/punch_out_setup_request_doc_with_ship_to.xml +46 -0
- data/spec/fixtures/purchase_order_request_200.xml +132 -0
- data/spec/fixtures/request_doc.xml +79 -0
- data/spec/fixtures/response_status_200.xml +11 -0
- data/spec/fixtures/response_status_400.xml +5 -0
- data/spec/header_spec.rb +54 -0
- data/spec/invoice_detail_request_spec.rb +88 -0
- data/spec/item_detail_spec.rb +44 -0
- data/spec/item_id_spec.rb +40 -0
- data/spec/item_in_spec.rb +41 -0
- data/spec/money_spec.rb +44 -0
- data/spec/parser_spec.rb +6 -0
- data/spec/protocol_spec.rb +16 -0
- data/spec/punch_out_order_message_header_spec.rb +36 -0
- data/spec/punch_out_order_message_spec.rb +43 -0
- data/spec/punch_out_setup_request_spec.rb +60 -0
- data/spec/purchase_order_request_spec.rb +40 -0
- data/spec/request_spec.rb +36 -0
- data/spec/response_spec.rb +58 -0
- data/spec/sender_spec.rb +32 -0
- data/spec/spec_helper.rb +21 -0
- data/spec/status_spec.rb +44 -0
- data/spec/support/helpers.rb +5 -0
- metadata +317 -0
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.014/cXML.dtd">
|
|
3
|
+
<cXML payloadID="1211221788.71299@ip-10-251-122-83" timestamp="Mon May 19 18:29:48 +0000 2008" xml:lang="en-US">
|
|
4
|
+
<Header>
|
|
5
|
+
<From>
|
|
6
|
+
<Credential domain="DUNS">
|
|
7
|
+
<Identity>coupa-t</Identity>
|
|
8
|
+
</Credential>
|
|
9
|
+
</From>
|
|
10
|
+
<To>
|
|
11
|
+
<Credential domain="DUNS">
|
|
12
|
+
<Identity>coupa-t</Identity>
|
|
13
|
+
</Credential>
|
|
14
|
+
</To>
|
|
15
|
+
<Sender>
|
|
16
|
+
<Credential domain="DUNS">
|
|
17
|
+
<Identity>coupa-t</Identity>
|
|
18
|
+
<SharedSecret>test</SharedSecret>
|
|
19
|
+
</Credential>
|
|
20
|
+
<UserAgent>Coupa Procurement 1.0</UserAgent>
|
|
21
|
+
</Sender>
|
|
22
|
+
</Header>
|
|
23
|
+
<Request>
|
|
24
|
+
<PunchOutSetupRequest operation="create">
|
|
25
|
+
<BuyerCookie>c64af92dc27e68172e030d3dfd1bc944</BuyerCookie>
|
|
26
|
+
<Extrinsic name="FirstName">Jim</Extrinsic>
|
|
27
|
+
<Extrinsic name="LastName">Halpert</Extrinsic>
|
|
28
|
+
<Extrinsic name="UniqueName">jim</Extrinsic>
|
|
29
|
+
<Extrinsic name="UserEmail">noah+jim@coupa.com</Extrinsic>
|
|
30
|
+
<Extrinsic name="User">jim</Extrinsic>
|
|
31
|
+
<Extrinsic name="BusinessUnit">COUPA</Extrinsic>
|
|
32
|
+
<Contact role="endUser">
|
|
33
|
+
<Name xml:lang="en-US">jim</Name>
|
|
34
|
+
<Email>noah+jim@coupa.com</Email>
|
|
35
|
+
</Contact>
|
|
36
|
+
<BrowserFormPost>
|
|
37
|
+
<URL>https://qa.coupahost.com/punchout/checkout/4</URL>
|
|
38
|
+
</BrowserFormPost>
|
|
39
|
+
</PunchOutSetupRequest>
|
|
40
|
+
</Request>
|
|
41
|
+
</cXML>
|
|
42
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" ?>
|
|
2
|
+
<cXML payloadID="demoSCAWIG@IESAonline" xml:lang="en-UK" timestamp="2007-04-30T15:52:54+00:00">
|
|
3
|
+
<Header>
|
|
4
|
+
<From>
|
|
5
|
+
<Credential domain="DUNS">
|
|
6
|
+
<Identity>punchout@test.com</Identity>
|
|
7
|
+
</Credential>
|
|
8
|
+
</From>
|
|
9
|
+
<To>
|
|
10
|
+
<Credential domain="DUNS">
|
|
11
|
+
<Identity>punchout@test.com</Identity>
|
|
12
|
+
</Credential>
|
|
13
|
+
</To>
|
|
14
|
+
<Sender>
|
|
15
|
+
<Credential domain="IESAnetworkUserID"> <Identity>88888888</Identity> <SharedSecret>{shared secret in here}</SharedSecret> </Credential> <UserAgent>IESAonlinevers1</UserAgent>
|
|
16
|
+
</Sender>
|
|
17
|
+
</Header>
|
|
18
|
+
<Request deploymentMode="production">
|
|
19
|
+
<PunchOutSetupRequest operation="create"> <BuyerCookie>demoSCAWIGP</BuyerCookie>
|
|
20
|
+
<BrowserFormPost>
|
|
21
|
+
<URL>
|
|
22
|
+
http://return_to_supplier_url.com
|
|
23
|
+
</URL>
|
|
24
|
+
</BrowserFormPost>
|
|
25
|
+
<SupplierSetup>
|
|
26
|
+
<URL>
|
|
27
|
+
http://localhost:3000
|
|
28
|
+
</URL>
|
|
29
|
+
</SupplierSetup>
|
|
30
|
+
<ShipTo>
|
|
31
|
+
<Address isoCountryCode="US" addressID="3119">
|
|
32
|
+
<Name xml:lang="en">jmadden</Name>
|
|
33
|
+
<PostalAddress name="default">
|
|
34
|
+
<DeliverTo>j maddedn</DeliverTo>
|
|
35
|
+
<Street>333 East Hill Dr</Street>
|
|
36
|
+
<City>san leandro</City>
|
|
37
|
+
<State>ca</State>
|
|
38
|
+
<PostalCode>22222</PostalCode>
|
|
39
|
+
<Country isoCountryCode="US">United States</Country>
|
|
40
|
+
</PostalAddress>
|
|
41
|
+
<Email name="default">jmadden@coupa1.com</Email>
|
|
42
|
+
</Address>
|
|
43
|
+
</ShipTo>
|
|
44
|
+
</PunchOutSetupRequest>
|
|
45
|
+
</Request>
|
|
46
|
+
</cXML>
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE cXML SYSTEM "http://xml.cxml.org/schemas/cXML/1.2.014/cXML.dtd">
|
|
3
|
+
<cXML xml:lang="en-US" payloadID="1452186890.009162@ip-10-7-14-126" timestamp="2008-01-07T09:14:50-08:00">
|
|
4
|
+
<Header>
|
|
5
|
+
<From>
|
|
6
|
+
<Credential domain="duns">
|
|
7
|
+
<!-- Customer domain typically provided by Supplier, typically DUNS -->
|
|
8
|
+
<Identity>dell</Identity>
|
|
9
|
+
<!-- Customer id typically provided by Supplier, string -->
|
|
10
|
+
</Credential>
|
|
11
|
+
</From>
|
|
12
|
+
<To>
|
|
13
|
+
<Credential domain="Duns">
|
|
14
|
+
<!-- Supplier domain typically provided by Supplier, typically DUNS -->
|
|
15
|
+
<Identity>128293714</Identity>
|
|
16
|
+
<!-- Supplier id typically provided by Supplier, string -->
|
|
17
|
+
</Credential>
|
|
18
|
+
</To>
|
|
19
|
+
<Sender>
|
|
20
|
+
<Credential domain="duns">
|
|
21
|
+
<Identity>dell</Identity>
|
|
22
|
+
<!-- same as From -->
|
|
23
|
+
</Credential>
|
|
24
|
+
<UserAgent>Coupa Procurement 1.0</UserAgent>
|
|
25
|
+
<!-- does not change -->
|
|
26
|
+
</Sender>
|
|
27
|
+
</Header>
|
|
28
|
+
<Request deploymentMode="production">
|
|
29
|
+
<OrderRequest>
|
|
30
|
+
<OrderRequestHeader orderID="6112" orderDate="2008-01-07T09:14:50-08:00" type="new">
|
|
31
|
+
<!-- Coupa supports "new" and "update" -->
|
|
32
|
+
<Total>
|
|
33
|
+
<Money currency="USD">1505.0</Money>
|
|
34
|
+
<!-- Currency code configured in Coupa -->
|
|
35
|
+
</Total>
|
|
36
|
+
<ShipTo>
|
|
37
|
+
<Address isoCountryCode="US" addressID="3119">
|
|
38
|
+
<Name xml:lang="en">jmadden</Name>
|
|
39
|
+
<PostalAddress name="default">
|
|
40
|
+
<DeliverTo>j maddedn</DeliverTo>
|
|
41
|
+
<Street>333 East Hill Dr</Street>
|
|
42
|
+
<City>san leandro</City>
|
|
43
|
+
<State>ca</State>
|
|
44
|
+
<PostalCode>22222</PostalCode>
|
|
45
|
+
<Country isoCountryCode="US">United States</Country>
|
|
46
|
+
</PostalAddress>
|
|
47
|
+
<Email name="default">jmadden@coupa1.com</Email>
|
|
48
|
+
</Address>
|
|
49
|
+
</ShipTo>
|
|
50
|
+
<BillTo>
|
|
51
|
+
<Address isoCountryCode="US" addressID="142">
|
|
52
|
+
<Name xml:lang="en">SOB1</Name>
|
|
53
|
+
<!-- Company Name under Company Information in Coupa -->
|
|
54
|
+
<PostalAddress name="default">
|
|
55
|
+
<DeliverTo>Noah Sanity Attn: Noah Noah</DeliverTo>
|
|
56
|
+
<Street>3420 Flatiron Way</Street>
|
|
57
|
+
<City>West Index</City>
|
|
58
|
+
<State>NJ</State>
|
|
59
|
+
<PostalCode>43023</PostalCode>
|
|
60
|
+
<Country isoCountryCode="US">United States</Country>
|
|
61
|
+
</PostalAddress>
|
|
62
|
+
</Address>
|
|
63
|
+
</BillTo>
|
|
64
|
+
<Contact role="endUser">
|
|
65
|
+
<Name xml:lang="en">j maddedn</Name>
|
|
66
|
+
<Email name="default">jmadden@coupa1.com</Email>
|
|
67
|
+
</Contact>
|
|
68
|
+
<Comments xml:lang="en">header comment goes here if entered by user</Comments>
|
|
69
|
+
</OrderRequestHeader>
|
|
70
|
+
<ItemOut quantity="1" lineNumber="1">
|
|
71
|
+
<ItemID>
|
|
72
|
+
<SupplierPartID>223-4511</SupplierPartID>
|
|
73
|
+
<!-- Coupa Item Part Number -->
|
|
74
|
+
<SupplierPartAuxiliaryID>1005379527029\1</SupplierPartAuxiliaryID>
|
|
75
|
+
<!-- Auxiliary Part Number is optional, typically used by punchout suppliers -->
|
|
76
|
+
</ItemID>
|
|
77
|
+
<ItemDetail>
|
|
78
|
+
<UnitPrice>
|
|
79
|
+
<Money currency="USD">1505.0</Money>
|
|
80
|
+
<!-- Currency code configured in Coupa -->
|
|
81
|
+
</UnitPrice>
|
|
82
|
+
<Description xml:lang="en">OptiPlex 755 Energy Smart Minitower;IntelREG CoreTM 2 Quad Processor Q6600 (2.40GHz, 2X4M, 1066MHz FSB)</Description>
|
|
83
|
+
<UnitOfMeasure>EA</UnitOfMeasure>
|
|
84
|
+
<Classification domain="UNSPSC">44000000</Classification>
|
|
85
|
+
<!-- Future expansion -->
|
|
86
|
+
</ItemDetail>
|
|
87
|
+
<Distribution>
|
|
88
|
+
<Accounting name="bbbb">
|
|
89
|
+
<!-- Coupa Account name -->
|
|
90
|
+
<Segment id="bbb" description="ORG" type="Organization" />
|
|
91
|
+
<Segment id="b" description="DEPT" type="Department" />
|
|
92
|
+
<Segment id="bb" description="PROJ" type="Project" />
|
|
93
|
+
</Accounting>
|
|
94
|
+
<Charge>
|
|
95
|
+
<Money currency="USD">1505.0</Money>
|
|
96
|
+
</Charge>
|
|
97
|
+
</Distribution>
|
|
98
|
+
<Comments xml:lang="en">line item comment goes here if entered by user</Comments>
|
|
99
|
+
</ItemOut>
|
|
100
|
+
<ItemOut quantity="2" lineNumber="2">
|
|
101
|
+
<ItemID>
|
|
102
|
+
<SupplierPartID>223-4511</SupplierPartID>
|
|
103
|
+
<!-- Coupa Item Part Number -->
|
|
104
|
+
<SupplierPartAuxiliaryID>1005379527029\1</SupplierPartAuxiliaryID>
|
|
105
|
+
<!-- Auxiliary Part Number is optional, typically used by punchout suppliers -->
|
|
106
|
+
</ItemID>
|
|
107
|
+
<ItemDetail>
|
|
108
|
+
<UnitPrice>
|
|
109
|
+
<Money currency="USD">1505.0</Money>
|
|
110
|
+
<!-- Currency code configured in Coupa -->
|
|
111
|
+
</UnitPrice>
|
|
112
|
+
<Description xml:lang="en">OptiPlex 755 Energy Smart Minitower;IntelREG CoreTM 2 Quad Processor Q6600 (2.40GHz, 2X4M, 1066MHz FSB)</Description>
|
|
113
|
+
<UnitOfMeasure>EA</UnitOfMeasure>
|
|
114
|
+
<Classification domain="UNSPSC">44000000</Classification>
|
|
115
|
+
<!-- Future expansion -->
|
|
116
|
+
</ItemDetail>
|
|
117
|
+
<Distribution>
|
|
118
|
+
<Accounting name="bbbb">
|
|
119
|
+
<!-- Coupa Account name -->
|
|
120
|
+
<Segment id="bbb" description="ORG" type="Organization" />
|
|
121
|
+
<Segment id="b" description="DEPT" type="Department" />
|
|
122
|
+
<Segment id="bb" description="PROJ" type="Project" />
|
|
123
|
+
</Accounting>
|
|
124
|
+
<Charge>
|
|
125
|
+
<Money currency="USD">1505.0</Money>
|
|
126
|
+
</Charge>
|
|
127
|
+
</Distribution>
|
|
128
|
+
<Comments xml:lang="en">line item comment goes here if entered by user</Comments>
|
|
129
|
+
</ItemOut>
|
|
130
|
+
</OrderRequest>
|
|
131
|
+
</Request>
|
|
132
|
+
</cXML>
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
<?xml version="1.0"?>
|
|
2
|
+
<cXML version="1.2.011" payloadID="1346769469000.process.162998590@officedepot.com" timestamp="2012-09-04T02:37:49-05:00">
|
|
3
|
+
<Header>
|
|
4
|
+
<From>
|
|
5
|
+
<Credential domain="NetworkID">
|
|
6
|
+
<Identity>AN01000000147</Identity>
|
|
7
|
+
</Credential>
|
|
8
|
+
</From>
|
|
9
|
+
<To>
|
|
10
|
+
<Credential domain="NetworkId">
|
|
11
|
+
<Identity>customerID</Identity>
|
|
12
|
+
</Credential>
|
|
13
|
+
</To>
|
|
14
|
+
<Sender>
|
|
15
|
+
<Credential domain="NetworkID">
|
|
16
|
+
<Identity>AN01000000147</Identity>
|
|
17
|
+
<SharedSecret>welcome</SharedSecret>
|
|
18
|
+
</Credential>
|
|
19
|
+
<UserAgent>BSD 8.12</UserAgent>
|
|
20
|
+
</Sender>
|
|
21
|
+
</Header>
|
|
22
|
+
<Request deploymentMode="production">
|
|
23
|
+
<ConfirmationRequest>
|
|
24
|
+
<ConfirmationHeader confirmID="" operation="new" type="detail" noticeDate="2012-09-04T02:37:49-05:00" invoiceID="623612976001">
|
|
25
|
+
<Contact role="shipTo" addressID="0170-74629-00">
|
|
26
|
+
<Name xml:lang="en-US">HOSPITAL BUILDING</Name>
|
|
27
|
+
<PostalAddress>
|
|
28
|
+
<DeliverTo>Yvonne Smith</DeliverTo>
|
|
29
|
+
<DeliverTo>541813031</DeliverTo>
|
|
30
|
+
<Street>3601 Mile Road</Street>
|
|
31
|
+
<Street>BUILDING: 0170-74629-00</Street>
|
|
32
|
+
<City>Royal Oak</City>
|
|
33
|
+
<State>MI</State>
|
|
34
|
+
<PostalCode>48073</PostalCode>
|
|
35
|
+
<Country isoCountryCode="US">United States</Country>
|
|
36
|
+
</PostalAddress>
|
|
37
|
+
</Contact>
|
|
38
|
+
</ConfirmationHeader>
|
|
39
|
+
<OrderReference orderID="400-2591453-0">
|
|
40
|
+
<DocumentReference payloadID="20120904023747.cXMLPurchaseOrder.984556224@eprosvcs.com"/>
|
|
41
|
+
</OrderReference>
|
|
42
|
+
<ConfirmationItem quantity="20" lineNumber="1">
|
|
43
|
+
<UnitOfMeasure>RM</UnitOfMeasure>
|
|
44
|
+
<ConfirmationStatus quantity="20" type="accept" shipmentDate="2012-09-05T12:00:00-05:00" deliveryDate="2012-09-05T12:00:00-05:00">
|
|
45
|
+
<UnitOfMeasure>RM</UnitOfMeasure>
|
|
46
|
+
<UnitPrice>
|
|
47
|
+
<Money currency="USD">4.44</Money>
|
|
48
|
+
</UnitPrice>
|
|
49
|
+
<Comments></Comments>
|
|
50
|
+
<Extrinsic name="SupplierPartID">751441</Extrinsic>
|
|
51
|
+
<Extrinsic name="SupplierPartAuxilliaryID">751441</Extrinsic>
|
|
52
|
+
</ConfirmationStatus>
|
|
53
|
+
</ConfirmationItem>
|
|
54
|
+
<ConfirmationItem quantity="12" lineNumber="2">
|
|
55
|
+
<UnitOfMeasure>BX</UnitOfMeasure>
|
|
56
|
+
<ConfirmationStatus quantity="12" type="accept" shipmentDate="2012-09-05T12:00:00-05:00" deliveryDate="2012-09-05T12:00:00-05:00">
|
|
57
|
+
<UnitOfMeasure>BX</UnitOfMeasure>
|
|
58
|
+
<UnitPrice>
|
|
59
|
+
<Money currency="USD">1.52</Money>
|
|
60
|
+
</UnitPrice>
|
|
61
|
+
<Comments></Comments>
|
|
62
|
+
<Extrinsic name="SupplierPartID">429175</Extrinsic>
|
|
63
|
+
<Extrinsic name="SupplierPartAuxilliaryID">429175</Extrinsic>
|
|
64
|
+
</ConfirmationStatus>
|
|
65
|
+
</ConfirmationItem>
|
|
66
|
+
<ConfirmationItem quantity="2" lineNumber="3">
|
|
67
|
+
<UnitOfMeasure>EA</UnitOfMeasure>
|
|
68
|
+
<ConfirmationStatus quantity="2" type="accept" shipmentDate="2012-09-05T12:00:00-05:00" deliveryDate="2012-09-05T12:00:00-05:00">
|
|
69
|
+
<UnitOfMeasure>EA</UnitOfMeasure>
|
|
70
|
+
<UnitPrice>
|
|
71
|
+
<Money currency="USD">4.14</Money>
|
|
72
|
+
</UnitPrice>
|
|
73
|
+
<Comments></Comments>
|
|
74
|
+
<Extrinsic name="SupplierPartID">908194</Extrinsic>
|
|
75
|
+
</ConfirmationStatus>
|
|
76
|
+
</ConfirmationItem>
|
|
77
|
+
</ConfirmationRequest>
|
|
78
|
+
</Request>
|
|
79
|
+
</cXML>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<cXML version="1.2.011" payloadID="1346769469000.process.162998590@officedepot.com" timestamp="2012-09-04T02:37:49-05:00">
|
|
3
|
+
<Response>
|
|
4
|
+
<Status code="200" text="OK"/>
|
|
5
|
+
<PunchOutSetupResponse>
|
|
6
|
+
<StartPage>
|
|
7
|
+
<URL>http://localhost:3000/products</URL>
|
|
8
|
+
</StartPage>
|
|
9
|
+
</PunchOutSetupResponse>
|
|
10
|
+
</Response>
|
|
11
|
+
</cXML>
|
data/spec/header_spec.rb
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe CXML::Header do
|
|
6
|
+
shared_examples_for :render_defaults do
|
|
7
|
+
it 'returns xml content' do
|
|
8
|
+
output_xml.should_not be_nil
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
it 'returns xml content with with required xml nodes' do
|
|
12
|
+
header_output_data[:to].should_not be_empty
|
|
13
|
+
header_output_data[:from].should_not be_empty
|
|
14
|
+
header_output_data[:sender].should_not be_empty
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it { should respond_to :from }
|
|
19
|
+
it { should respond_to :to }
|
|
20
|
+
it { should respond_to :sender }
|
|
21
|
+
it { should respond_to :render }
|
|
22
|
+
|
|
23
|
+
let(:parser) { CXML::Parser.new }
|
|
24
|
+
let(:doc) { CXML::Document.new(data) }
|
|
25
|
+
let(:builder) { doc.render }
|
|
26
|
+
let(:header) { doc.header }
|
|
27
|
+
let(:data) { parser.parse(fixture('request_doc.xml')) }
|
|
28
|
+
|
|
29
|
+
describe '#initialize' do
|
|
30
|
+
it 'sets the mandatory attributes' do
|
|
31
|
+
header.to.should be_instance_of(CXML::To)
|
|
32
|
+
header.from.should be_instance_of(CXML::From)
|
|
33
|
+
header.sender.should be_instance_of(CXML::Sender)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe '#render' do
|
|
38
|
+
let(:output_xml) { builder.to_xml }
|
|
39
|
+
let(:output_data) { parser.parse(output_xml) }
|
|
40
|
+
let(:header_output_data) { output_data[:header] }
|
|
41
|
+
let(:from_identity) { header_output_data[:from][:credential][:identity] }
|
|
42
|
+
let(:to_identity) { header_output_data[:to][:credential][:identity] }
|
|
43
|
+
|
|
44
|
+
include_examples :render_defaults
|
|
45
|
+
|
|
46
|
+
context 'when the header is rendered as not a response' do
|
|
47
|
+
let(:data) { parser.parse(fixture('request_doc.xml')) }
|
|
48
|
+
it 'will NOT swap the to and from attributes' do
|
|
49
|
+
from_identity.should eq(header.from.credential.identity)
|
|
50
|
+
to_identity.should eq(header.to.credential.identity)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
end
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe CXML::InvoiceDetailRequest do
|
|
6
|
+
it { should respond_to :invoice_detail_request_header }
|
|
7
|
+
it { should respond_to :invoice_detail_orders }
|
|
8
|
+
it { should respond_to :invoice_detail_header_orders }
|
|
9
|
+
it { should respond_to :invoice_detail_summary }
|
|
10
|
+
|
|
11
|
+
describe '#initialize' do
|
|
12
|
+
it 'sets invoice_detail_request_header' do
|
|
13
|
+
data = CXML::Parser.new.parse(fixture('invoice_taxes_at_line.xml'))
|
|
14
|
+
doc = CXML::Document.new(data)
|
|
15
|
+
instance = doc.request.invoice_detail_request
|
|
16
|
+
instance.invoice_detail_request_header
|
|
17
|
+
.should be_an_instance_of CXML::InvoiceDetailRequestHeader
|
|
18
|
+
end
|
|
19
|
+
it 'sets invoice_detail_request_header' do
|
|
20
|
+
data = CXML::Parser.new.parse(fixture('invoice_taxes_at_total.xml'))
|
|
21
|
+
doc = CXML::Document.new(data)
|
|
22
|
+
instance = doc.request.invoice_detail_request
|
|
23
|
+
instance.invoice_detail_request_header
|
|
24
|
+
.should be_an_instance_of CXML::InvoiceDetailRequestHeader
|
|
25
|
+
end
|
|
26
|
+
it 'sets invoice_detail_request_header' do
|
|
27
|
+
data = CXML::Parser.new.parse(fixture('invoice_taxes_at_line_multiple_taxes.xml'))
|
|
28
|
+
doc = CXML::Document.new(data)
|
|
29
|
+
instance = doc.request.invoice_detail_request
|
|
30
|
+
instance.invoice_detail_request_header
|
|
31
|
+
.should be_an_instance_of CXML::InvoiceDetailRequestHeader
|
|
32
|
+
end
|
|
33
|
+
it 'sets invoice_detail_request_header' do
|
|
34
|
+
data = CXML::Parser.new.parse(fixture('invoice_backed_and_unbacked_by_pos.xml'))
|
|
35
|
+
doc = CXML::Document.new(data)
|
|
36
|
+
instance = doc.request.invoice_detail_request
|
|
37
|
+
instance.invoice_detail_request_header
|
|
38
|
+
.should be_an_instance_of CXML::InvoiceDetailRequestHeader
|
|
39
|
+
end
|
|
40
|
+
it 'sets invoice_detail_request_header' do
|
|
41
|
+
data = CXML::Parser.new.parse(fixture('invoice_backed_by_multiple_pos.xml'))
|
|
42
|
+
doc = CXML::Document.new(data)
|
|
43
|
+
instance = doc.request.invoice_detail_request
|
|
44
|
+
instance.invoice_detail_request_header
|
|
45
|
+
.should be_an_instance_of CXML::InvoiceDetailRequestHeader
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
describe '#to_xml' do
|
|
49
|
+
it 'serializes the same output' do
|
|
50
|
+
data = CXML::Parser.new.parse(fixture('invoice_taxes_at_line.xml'))
|
|
51
|
+
doc = CXML::Document.new(data)
|
|
52
|
+
CXML::Parser.new.parse(doc.render.to_xml).should eq(data)
|
|
53
|
+
end
|
|
54
|
+
it 'serializes the same output' do
|
|
55
|
+
data = CXML::Parser.new.parse(fixture('invoice_backed_and_unbacked_by_pos.xml'))
|
|
56
|
+
doc = CXML::Document.new(data)
|
|
57
|
+
CXML::Parser.new.parse(doc.render.to_xml).should eq(data)
|
|
58
|
+
end
|
|
59
|
+
it 'serializes the same output' do
|
|
60
|
+
data = CXML::Parser.new.parse(fixture('invoice_backed_by_multiple_pos.xml'))
|
|
61
|
+
doc = CXML::Document.new(data)
|
|
62
|
+
CXML::Parser.new.parse(doc.render.to_xml).should eq(data)
|
|
63
|
+
end
|
|
64
|
+
it 'serializes the same output' do
|
|
65
|
+
data = CXML::Parser.new.parse(fixture('invoice_taxes_at_line_multiple_taxes.xml'))
|
|
66
|
+
doc = CXML::Document.new(data)
|
|
67
|
+
CXML::Parser.new.parse(doc.render.to_xml).should eq(data)
|
|
68
|
+
end
|
|
69
|
+
it 'serializes the same output' do
|
|
70
|
+
fixture_xml = fixture('invoice_taxes_at_total.xml')
|
|
71
|
+
data = CXML::Parser.new.parse(fixture_xml)
|
|
72
|
+
doc = CXML::Document.new(data)
|
|
73
|
+
CXML::Parser.new.parse(doc.render.to_xml).should eq(data)
|
|
74
|
+
end
|
|
75
|
+
it 'serializes from an instance' do
|
|
76
|
+
money = CXML::Money.new(amount: '5', currency: 'USD')
|
|
77
|
+
summary = CXML::InvoiceDetailSummary.new(gross_amount: CXML::GrossAmount.new(money: money))
|
|
78
|
+
instance = described_class.new(invoice_detail_summary: summary)
|
|
79
|
+
data = CXML::Request.new(invoice_detail_request: instance)
|
|
80
|
+
doc = CXML::Document.new(request: data)
|
|
81
|
+
parsed = CXML::Parser.new.parse(doc.render.to_xml)
|
|
82
|
+
parsed[:request][:invoice_detail_request]
|
|
83
|
+
.should eq(instance.serializable_hash)
|
|
84
|
+
parsed[:request][:invoice_detail_request][:invoice_detail_summary][:gross_amount][:money]
|
|
85
|
+
.should eq({ content: '5', currency: 'USD' })
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe CXML::ItemDetail do
|
|
6
|
+
it { should respond_to :description }
|
|
7
|
+
it { should respond_to :unit_of_measure }
|
|
8
|
+
it { should respond_to :unit_price }
|
|
9
|
+
|
|
10
|
+
let(:parser) { CXML::Parser.new }
|
|
11
|
+
let(:data) { parser.parse(fixture('punch_out_order_message_doc.xml')) }
|
|
12
|
+
let(:doc) { CXML::Document.new(data) }
|
|
13
|
+
let(:punch_out_order_message) { doc.message.punch_out_order_message }
|
|
14
|
+
let(:builder) { doc.render }
|
|
15
|
+
|
|
16
|
+
describe '#initialize' do
|
|
17
|
+
let(:item_in) { CXML::ItemIn.new(build_item_in(parser)) }
|
|
18
|
+
let(:item_detail) { item_in.item_detail }
|
|
19
|
+
|
|
20
|
+
it 'sets the mandatory attributes' do
|
|
21
|
+
item_detail.unit_of_measure.should_not be_nil
|
|
22
|
+
item_detail.description.should_not be_nil
|
|
23
|
+
item_detail.unit_price.should_not be_nil
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '#render' do
|
|
28
|
+
before(:each) do
|
|
29
|
+
punch_out_order_message.add_item(build_item_in(parser))
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
let(:output_xml) { builder.to_xml }
|
|
33
|
+
let(:output_data) { parser.parse(output_xml) }
|
|
34
|
+
let(:punch_out_order_message_output_data) { output_data[:message][:punch_out_order_message] }
|
|
35
|
+
let(:item_in_output_data) { punch_out_order_message_output_data[:item_in] }
|
|
36
|
+
let(:item_detail_output_data) { item_in_output_data[:item_detail] }
|
|
37
|
+
|
|
38
|
+
it 'contains the required nodes' do
|
|
39
|
+
item_detail_output_data[:unit_of_measure].should_not be_empty
|
|
40
|
+
item_detail_output_data[:unit_price].should_not be_empty
|
|
41
|
+
item_detail_output_data[:description].should_not be_empty
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe CXML::ItemID do
|
|
6
|
+
it { should respond_to :supplier_part_id }
|
|
7
|
+
it { should respond_to :supplier_part_auxiliary_id }
|
|
8
|
+
|
|
9
|
+
let(:parser) { CXML::Parser.new }
|
|
10
|
+
let(:data) { parser.parse(fixture('punch_out_order_message_doc.xml')) }
|
|
11
|
+
let(:doc) { CXML::Document.new(data) }
|
|
12
|
+
let(:punch_out_order_message) { doc.message.punch_out_order_message }
|
|
13
|
+
let(:builder) { doc.render }
|
|
14
|
+
|
|
15
|
+
describe '#initialize' do
|
|
16
|
+
let(:item_in) { CXML::ItemIn.new(build_item_in(parser)) }
|
|
17
|
+
let(:item_id) { item_in.item_id }
|
|
18
|
+
|
|
19
|
+
it 'sets the attributes that are passed' do
|
|
20
|
+
item_id.supplier_part_id.should_not be_nil
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
describe '#render' do
|
|
25
|
+
before(:each) do
|
|
26
|
+
punch_out_order_message.add_item(build_item_in(parser))
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
let(:output_xml) { builder.to_xml }
|
|
30
|
+
let(:output_data) { parser.parse(output_xml) }
|
|
31
|
+
let(:punch_out_order_message_output_data) { output_data[:message][:punch_out_order_message] }
|
|
32
|
+
let(:item_in_output_data) { punch_out_order_message_output_data[:item_in] }
|
|
33
|
+
let(:item_id_output_data) { item_in_output_data[:item_id] }
|
|
34
|
+
|
|
35
|
+
it 'contains the required nodes' do
|
|
36
|
+
item_id_output_data[:supplier_part_id].should_not be_empty
|
|
37
|
+
item_id_output_data.should include(:supplier_part_auxiliary_id)
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe CXML::ItemIn do
|
|
6
|
+
it { should respond_to :item_id }
|
|
7
|
+
it { should respond_to :item_detail }
|
|
8
|
+
it { should respond_to :line_number }
|
|
9
|
+
it { should respond_to :quantity }
|
|
10
|
+
|
|
11
|
+
let(:parser) { CXML::Parser.new }
|
|
12
|
+
let(:data) { parser.parse(fixture('punch_out_order_message_doc.xml')) }
|
|
13
|
+
let(:doc) { CXML::Document.new(data) }
|
|
14
|
+
let(:punch_out_order_message) { doc.message.punch_out_order_message }
|
|
15
|
+
let(:builder) { doc.render }
|
|
16
|
+
|
|
17
|
+
describe '#initialize' do
|
|
18
|
+
let(:item_in) { CXML::ItemIn.new(build_item_in(parser)) }
|
|
19
|
+
|
|
20
|
+
it 'sets the mandatory attributes' do
|
|
21
|
+
item_in.quantity.should_not be_nil
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
describe '#render' do
|
|
26
|
+
before(:each) do
|
|
27
|
+
punch_out_order_message.add_item(build_item_in(parser))
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
let(:output_xml) { builder.to_xml }
|
|
31
|
+
let(:output_data) { parser.parse(output_xml) }
|
|
32
|
+
let(:punch_out_order_message_output_data) { output_data[:message][:punch_out_order_message] }
|
|
33
|
+
let(:item_in_output_data) { punch_out_order_message_output_data[:item_in] }
|
|
34
|
+
|
|
35
|
+
it 'contains the required nodes' do
|
|
36
|
+
item_in_output_data[:quantity].should_not be_empty
|
|
37
|
+
item_in_output_data[:item_id].should_not be_empty
|
|
38
|
+
item_in_output_data[:item_detail].should_not be_empty
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
data/spec/money_spec.rb
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe CXML::Money do
|
|
6
|
+
it { should respond_to :currency }
|
|
7
|
+
it { should respond_to :alternate_currency }
|
|
8
|
+
it { should respond_to :alternate_amount }
|
|
9
|
+
it { should respond_to :amount }
|
|
10
|
+
|
|
11
|
+
let(:parser) { CXML::Parser.new }
|
|
12
|
+
let(:data) { parser.parse(fixture('punch_out_order_message_doc.xml')) }
|
|
13
|
+
let(:doc) { CXML::Document.new(data) }
|
|
14
|
+
let(:punch_out_order_message) { doc.message.punch_out_order_message }
|
|
15
|
+
let(:builder) { doc.render }
|
|
16
|
+
let(:item_in) { CXML::ItemIn.new(build_item_in(parser)) }
|
|
17
|
+
let(:item_detail) { item_in.item_detail }
|
|
18
|
+
let(:money) { item_detail.unit_price.money }
|
|
19
|
+
|
|
20
|
+
describe '#initialize' do
|
|
21
|
+
it 'sets the attributes that are passed' do
|
|
22
|
+
money.currency.should_not be_nil
|
|
23
|
+
money.amount.should_not be_nil
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe '#render' do
|
|
28
|
+
before(:each) do
|
|
29
|
+
punch_out_order_message.add_item(build_item_in(parser))
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
let(:output_xml) { builder.to_xml }
|
|
33
|
+
let(:output_data) { parser.parse(output_xml) }
|
|
34
|
+
let(:punch_out_order_message_output_data) { output_data[:message][:punch_out_order_message] }
|
|
35
|
+
let(:item_in_output_data) { punch_out_order_message_output_data[:item_in] }
|
|
36
|
+
let(:item_detail_output_data) { item_in_output_data[:item_detail] }
|
|
37
|
+
let(:unit_price_output_data) { item_detail_output_data[:unit_price] }
|
|
38
|
+
let(:money_output_data) { unit_price_output_data[:money] }
|
|
39
|
+
|
|
40
|
+
it 'contains the required nodes' do
|
|
41
|
+
money_output_data[:currency].should_not be_empty
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
data/spec/parser_spec.rb
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'spec_helper'
|
|
4
|
+
|
|
5
|
+
describe CXML::Protocol do
|
|
6
|
+
it { should respond_to :version }
|
|
7
|
+
it { should respond_to :request_elements }
|
|
8
|
+
it { should respond_to :response_elements }
|
|
9
|
+
it { should respond_to :status_codes }
|
|
10
|
+
|
|
11
|
+
context '#version' do
|
|
12
|
+
it 'returns current protocol version' do
|
|
13
|
+
subject.version.should eq('1.2.011')
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|