cxml-ruby 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CXML
|
4
|
+
class InvoiceDetailRequestHeader < DocumentNode
|
5
|
+
accessible_attributes %i[
|
6
|
+
invoice_date
|
7
|
+
invoice_id
|
8
|
+
invoice_origin
|
9
|
+
is_information_only
|
10
|
+
operation
|
11
|
+
purpose
|
12
|
+
]
|
13
|
+
accessible_nodes %i[
|
14
|
+
comments
|
15
|
+
document_reference
|
16
|
+
extrinsics
|
17
|
+
invoice_detail_header_indicator
|
18
|
+
invoice_detail_line_indicator
|
19
|
+
invoice_detail_shipping
|
20
|
+
invoice_id_info
|
21
|
+
invoice_partners
|
22
|
+
payment_term
|
23
|
+
period
|
24
|
+
]
|
25
|
+
|
26
|
+
def initialize_invoice_partner(value)
|
27
|
+
value = [value] unless value.is_a?(Array)
|
28
|
+
@invoice_partners = value.map do |item|
|
29
|
+
InvoicePartner.new(item)
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize_invoice_partners(value)
|
34
|
+
value = [value] unless value.is_a?(Array)
|
35
|
+
@invoice_partners = value.map do |item|
|
36
|
+
InvoicePartner.new(item)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def initialize_extrinsic(value)
|
41
|
+
value = [value] unless value.is_a?(Array)
|
42
|
+
@extrinsics = value.map do |item|
|
43
|
+
Extrinsic.new(item)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def initialize_extrinsics(value)
|
48
|
+
value = [value] unless value.is_a?(Array)
|
49
|
+
@extrinsics = value.map do |item|
|
50
|
+
Extrinsic.new(item)
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CXML
|
4
|
+
class InvoiceDetailShipping < DocumentNode
|
5
|
+
accessible_attributes %i[
|
6
|
+
shipping_date
|
7
|
+
]
|
8
|
+
accessible_nodes %i[
|
9
|
+
contacts
|
10
|
+
document_reference
|
11
|
+
]
|
12
|
+
|
13
|
+
def initialize_contact(value)
|
14
|
+
value = [value] unless value.is_a?(Array)
|
15
|
+
@contacts = value.map do |item|
|
16
|
+
Contact.new(item)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize_contacts(value)
|
21
|
+
value = [value] unless value.is_a?(Array)
|
22
|
+
@contacts = value.map do |item|
|
23
|
+
Contact.new(item)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CXML
|
4
|
+
class InvoiceDetailSummary < DocumentNode
|
5
|
+
accessible_nodes %i[
|
6
|
+
gross_amount
|
7
|
+
invoice_detail_discount
|
8
|
+
net_amount
|
9
|
+
shipping_amount
|
10
|
+
special_handling_amount
|
11
|
+
subtotal_amount
|
12
|
+
tax
|
13
|
+
total_allowances
|
14
|
+
total_amount_without_tax
|
15
|
+
total_charges
|
16
|
+
]
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CXML
|
4
|
+
class ItemDetail < DocumentNode
|
5
|
+
accessible_nodes %i[
|
6
|
+
description
|
7
|
+
unit_of_measure
|
8
|
+
unit_price
|
9
|
+
classification
|
10
|
+
extrinsics
|
11
|
+
]
|
12
|
+
|
13
|
+
def initialize_extrinsic(value)
|
14
|
+
value = [value] unless value.is_a?(Array)
|
15
|
+
@extrinsics = value.map do |item|
|
16
|
+
Extrinsic.new(item)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize_extrinsics(value)
|
21
|
+
value = [value] unless value.is_a?(Array)
|
22
|
+
@extrinsics = value.map do |item|
|
23
|
+
Extrinsic.new(item)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/cxml/item_id.rb
ADDED
data/lib/cxml/item_in.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CXML
|
4
|
+
# items in purchase order message
|
5
|
+
class ItemOut < DocumentNode
|
6
|
+
accessible_attributes %i[
|
7
|
+
quantity
|
8
|
+
line_number
|
9
|
+
]
|
10
|
+
accessible_nodes %i[
|
11
|
+
item_id
|
12
|
+
item_detail
|
13
|
+
distribution
|
14
|
+
comments
|
15
|
+
]
|
16
|
+
end
|
17
|
+
end
|
data/lib/cxml/message.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CXML
|
4
|
+
class Modifications < DocumentNode
|
5
|
+
accessible_nodes %i[
|
6
|
+
modifications
|
7
|
+
]
|
8
|
+
|
9
|
+
def initialize_modification(value)
|
10
|
+
value = [value] unless value.is_a?(Array)
|
11
|
+
@modifications = value.map do |item|
|
12
|
+
Modification.new(item)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def initialize_modifications(value)
|
17
|
+
value = [value] unless value.is_a?(Array)
|
18
|
+
@modifications = value.map do |item|
|
19
|
+
Modification.new(item)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/cxml/money.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The Money element has three possible attributes: currency, alternateAmount,
|
4
|
+
# alternateCurrency. The attributes currency and alternateCurrecy must be a three-letter ISO
|
5
|
+
# 4217 currency code. The content of the Money element and of the aternateAmount
|
6
|
+
# attribute should be a numeric value. For example:
|
7
|
+
# <Money currency="USD">12.34</Money>
|
8
|
+
# The optional alternateCurrency and alternateAmount attributes are used together to specify
|
9
|
+
# an amount in an alternate currency. These can be used to support dual-currency
|
10
|
+
# requirements such as the euro. For example:
|
11
|
+
# <Money currency="USD" alternateCurrency=”EUR” alternateAmount=”14.28”>12.34
|
12
|
+
# </Money>
|
13
|
+
# Note: You can optionally use commas as thousands separators. Do not use
|
14
|
+
# commas as decimal separators.
|
15
|
+
#
|
16
|
+
# Page: 59
|
17
|
+
# <Money currency="GBP">5.35</Money>
|
18
|
+
|
19
|
+
module CXML
|
20
|
+
class Money < DocumentNode
|
21
|
+
accessible_attributes %i[
|
22
|
+
alternate_amount
|
23
|
+
alternate_currency
|
24
|
+
currency
|
25
|
+
]
|
26
|
+
|
27
|
+
def amount
|
28
|
+
content
|
29
|
+
end
|
30
|
+
|
31
|
+
def amount=(value)
|
32
|
+
self.content = value
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
data/lib/cxml/name.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CXML
|
4
|
+
# body of purchase order request
|
5
|
+
class OrderRequest < DocumentNode
|
6
|
+
accessible_nodes %i[
|
7
|
+
order_request_header
|
8
|
+
items_out
|
9
|
+
]
|
10
|
+
|
11
|
+
def initialize_item_out(value)
|
12
|
+
value = [value] unless value.is_a?(Array)
|
13
|
+
@items_out = value.map do |item|
|
14
|
+
CXML::ItemOut.new(item)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize_items_out(value)
|
19
|
+
value = [value] unless value.is_a?(Array)
|
20
|
+
@items_out = value.map do |item|
|
21
|
+
CXML::ItemOut.new(item)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_item(item_in_data)
|
26
|
+
items_out << CXML::ItemOut.new(item_in_data)
|
27
|
+
end
|
28
|
+
|
29
|
+
def items_out
|
30
|
+
@items_out ||= []
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CXML
|
4
|
+
# body header of purchase order request
|
5
|
+
class OrderRequestHeader < DocumentNode
|
6
|
+
accessible_attributes %i[
|
7
|
+
agreement_id
|
8
|
+
agreement_payload_id
|
9
|
+
effective_date
|
10
|
+
expiration_date
|
11
|
+
is_internal_version
|
12
|
+
order_date
|
13
|
+
order_id
|
14
|
+
order_type
|
15
|
+
order_version
|
16
|
+
parent_agreement_id
|
17
|
+
parent_agreement_payload_id
|
18
|
+
pick_up_date
|
19
|
+
release_required
|
20
|
+
requested_delivery_date
|
21
|
+
requisition_id
|
22
|
+
ship_complete
|
23
|
+
type
|
24
|
+
]
|
25
|
+
accessible_nodes %i[
|
26
|
+
bill_to
|
27
|
+
comments
|
28
|
+
contact
|
29
|
+
control_keys
|
30
|
+
delivery_period
|
31
|
+
document_reference
|
32
|
+
extrinsics
|
33
|
+
followup
|
34
|
+
id_reference
|
35
|
+
legal_identity
|
36
|
+
order_request_header_industry
|
37
|
+
organizational_unit
|
38
|
+
payment
|
39
|
+
payment_term
|
40
|
+
ship_to
|
41
|
+
shipping
|
42
|
+
supplier_order_info
|
43
|
+
tax
|
44
|
+
terms_of_delivery
|
45
|
+
total
|
46
|
+
]
|
47
|
+
|
48
|
+
def type
|
49
|
+
@type || 'new'
|
50
|
+
end
|
51
|
+
|
52
|
+
def initialize_extrinsic(value)
|
53
|
+
value = [value] unless value.is_a?(Array)
|
54
|
+
@extrinsics = value.map do |item|
|
55
|
+
Extrinsic.new(item)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def initialize_extrinsics(value)
|
60
|
+
value = [value] unless value.is_a?(Array)
|
61
|
+
@extrinsics = value.map do |item|
|
62
|
+
Extrinsic.new(item)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
data/lib/cxml/parser.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require('nokogiri')
|
4
|
+
require('xmlsimple')
|
5
|
+
|
6
|
+
module CXML
|
7
|
+
class Parser
|
8
|
+
def parse(data)
|
9
|
+
hash = XmlSimple.xml_in(data, { 'ForceArray' => false })
|
10
|
+
hash.transform_keys!(&method(:underscore_key))
|
11
|
+
hash.transform_values!(&method(:underscore_hash_values))
|
12
|
+
hash
|
13
|
+
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def underscore_hash_values(value)
|
18
|
+
return value.map(&method(:underscore_hash_values)) if value.is_a?(Array)
|
19
|
+
return value unless value.is_a?(Hash)
|
20
|
+
|
21
|
+
value.transform_keys!(&method(:underscore_key))
|
22
|
+
value.transform_values!(&method(:underscore_hash_values))
|
23
|
+
value
|
24
|
+
end
|
25
|
+
|
26
|
+
def underscore_key(key)
|
27
|
+
return key.to_s.to_sym unless /[A-Z-]|:/.match?(key)
|
28
|
+
|
29
|
+
word = key.to_s.gsub(':', '_')
|
30
|
+
word.gsub!(/([A-Z\d]+)([A-Z][a-z])/, '\1_\2')
|
31
|
+
word.gsub!(/([a-z\d])([A-Z])/, '\1_\2')
|
32
|
+
word.tr!('-', '_')
|
33
|
+
word.downcase!
|
34
|
+
word.to_sym
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CXML
|
4
|
+
class PaymentTerm < DocumentNode
|
5
|
+
accessible_attributes %i[
|
6
|
+
pay_in_number_of_days
|
7
|
+
]
|
8
|
+
accessible_nodes %i[
|
9
|
+
discount
|
10
|
+
extrinsics
|
11
|
+
net_due_days
|
12
|
+
]
|
13
|
+
|
14
|
+
def initialize_extrinsic(value)
|
15
|
+
value = [value] unless value.is_a?(Array)
|
16
|
+
@extrinsics = value.map do |item|
|
17
|
+
Extrinsic.new(item)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize_extrinsics(value)
|
22
|
+
value = [value] unless value.is_a?(Array)
|
23
|
+
@extrinsics = value.map do |item|
|
24
|
+
Extrinsic.new(item)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/lib/cxml/period.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CXML
|
4
|
+
# postal address, typically in a purchase order message
|
5
|
+
class PostalAddress < DocumentNode
|
6
|
+
accessible_attributes %i[
|
7
|
+
name
|
8
|
+
]
|
9
|
+
accessible_nodes %i[
|
10
|
+
deliver_to
|
11
|
+
state
|
12
|
+
street
|
13
|
+
municipality
|
14
|
+
city
|
15
|
+
postal_code
|
16
|
+
country
|
17
|
+
]
|
18
|
+
|
19
|
+
def initialize_deliver_to(value)
|
20
|
+
@deliver_to = if value.is_a?(Array)
|
21
|
+
value
|
22
|
+
else
|
23
|
+
[value]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def initialize_street(value)
|
28
|
+
@street = if value.is_a?(Array)
|
29
|
+
value
|
30
|
+
else
|
31
|
+
[value]
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CXML
|
4
|
+
module Protocol
|
5
|
+
VERSION = '1.2.011'
|
6
|
+
|
7
|
+
REQUEST_ELEMENTS = %w[
|
8
|
+
OrderRequest
|
9
|
+
ProfileRequest
|
10
|
+
PunchOutSetupRequest
|
11
|
+
StatusUpdateRequest
|
12
|
+
GetPendingRequest
|
13
|
+
ConfirmationRequest
|
14
|
+
ShipNoticeRequest
|
15
|
+
ProviderSetupRequest
|
16
|
+
PaymentRemittanceRequest
|
17
|
+
].freeze
|
18
|
+
|
19
|
+
RESPONSE_ELEMENTS = %w[
|
20
|
+
ProfileResponse
|
21
|
+
PunchOutSetupResponse
|
22
|
+
GetPendingResponse
|
23
|
+
].freeze
|
24
|
+
|
25
|
+
STATUS_CODES = [
|
26
|
+
200, 201, 204, 280, 281,
|
27
|
+
400, 401, 402, 403, 406, 409, 412, 417, 450, 475, 476, 477,
|
28
|
+
500, 550, 551, 560,
|
29
|
+
].freeze
|
30
|
+
|
31
|
+
class << self
|
32
|
+
# Get current protocol version
|
33
|
+
# @return [String]
|
34
|
+
def version
|
35
|
+
VERSION
|
36
|
+
end
|
37
|
+
|
38
|
+
# Get available request elements
|
39
|
+
# @return [Array<String>]
|
40
|
+
def request_elements
|
41
|
+
REQUEST_ELEMENTS
|
42
|
+
end
|
43
|
+
|
44
|
+
# Get available response elements
|
45
|
+
# @return [Array<String>]
|
46
|
+
def response_elements
|
47
|
+
RESPONSE_ELEMENTS
|
48
|
+
end
|
49
|
+
|
50
|
+
# Get available status codes
|
51
|
+
# @return [Array<Fixnum>]
|
52
|
+
def status_codes
|
53
|
+
STATUS_CODES
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CXML
|
4
|
+
class PunchOutOrderMessage < DocumentNode
|
5
|
+
accessible_nodes %i[
|
6
|
+
buyer_cookie
|
7
|
+
punch_out_order_message_header
|
8
|
+
items_in
|
9
|
+
]
|
10
|
+
|
11
|
+
def initialize_item_in(value)
|
12
|
+
value = [value] unless value.is_a?(Array)
|
13
|
+
@items_in = value.map do |item|
|
14
|
+
CXML::ItemIn.new(item)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize_items_in(value)
|
19
|
+
value = [value] unless value.is_a?(Array)
|
20
|
+
@items_in = value.map do |item|
|
21
|
+
CXML::ItemIn.new(item)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def add_item(item_in_data)
|
26
|
+
items_in << CXML::ItemIn.new(item_in_data)
|
27
|
+
end
|
28
|
+
|
29
|
+
def items_in
|
30
|
+
@items_in ||= []
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module CXML
|
4
|
+
# punchout order message header
|
5
|
+
class PunchOutOrderMessageHeader < DocumentNode
|
6
|
+
accessible_attributes %i[
|
7
|
+
operation_allowed
|
8
|
+
]
|
9
|
+
accessible_nodes %i[
|
10
|
+
total
|
11
|
+
shipping
|
12
|
+
tax
|
13
|
+
ship_to
|
14
|
+
]
|
15
|
+
|
16
|
+
def operation_allowed
|
17
|
+
@operation_allowed || 'create'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|