cxml-ruby 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ruby.yml +23 -0
  3. data/.gitignore +14 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +175 -0
  6. data/Gemfile +2 -0
  7. data/LICENSE +18 -0
  8. data/README.md +94 -0
  9. data/Rakefile +6 -0
  10. data/cxml-ruby.gemspec +27 -0
  11. data/lib/cxml/accounting.rb +27 -0
  12. data/lib/cxml/additional_cost.rb +10 -0
  13. data/lib/cxml/additional_deduction.rb +12 -0
  14. data/lib/cxml/address.rb +16 -0
  15. data/lib/cxml/bill_to.rb +10 -0
  16. data/lib/cxml/browser_form_post.rb +13 -0
  17. data/lib/cxml/charge.rb +9 -0
  18. data/lib/cxml/classification.rb +9 -0
  19. data/lib/cxml/confirmation_header.rb +16 -0
  20. data/lib/cxml/confirmation_item.rb +14 -0
  21. data/lib/cxml/confirmation_request.rb +25 -0
  22. data/lib/cxml/confirmation_status.rb +32 -0
  23. data/lib/cxml/contact.rb +16 -0
  24. data/lib/cxml/country.rb +9 -0
  25. data/lib/cxml/credential.rb +49 -0
  26. data/lib/cxml/credential_mac.rb +26 -0
  27. data/lib/cxml/deducted_price.rb +9 -0
  28. data/lib/cxml/deduction_amount.rb +9 -0
  29. data/lib/cxml/description.rb +9 -0
  30. data/lib/cxml/discount.rb +10 -0
  31. data/lib/cxml/discount_percent.rb +9 -0
  32. data/lib/cxml/distribution.rb +11 -0
  33. data/lib/cxml/document.rb +71 -0
  34. data/lib/cxml/document_node.rb +126 -0
  35. data/lib/cxml/document_reference.rb +9 -0
  36. data/lib/cxml/due_amount.rb +9 -0
  37. data/lib/cxml/email.rb +10 -0
  38. data/lib/cxml/errors.rb +7 -0
  39. data/lib/cxml/extrinsic.rb +10 -0
  40. data/lib/cxml/from.rb +9 -0
  41. data/lib/cxml/gross_amount.rb +9 -0
  42. data/lib/cxml/header.rb +29 -0
  43. data/lib/cxml/id_reference.rb +13 -0
  44. data/lib/cxml/invoice_detail_discount.rb +13 -0
  45. data/lib/cxml/invoice_detail_header_indicator.rb +11 -0
  46. data/lib/cxml/invoice_detail_header_order.rb +24 -0
  47. data/lib/cxml/invoice_detail_item.rb +55 -0
  48. data/lib/cxml/invoice_detail_item_reference.rb +17 -0
  49. data/lib/cxml/invoice_detail_line_indicator.rb +14 -0
  50. data/lib/cxml/invoice_detail_line_shipping.rb +11 -0
  51. data/lib/cxml/invoice_detail_line_special_handling.rb +11 -0
  52. data/lib/cxml/invoice_detail_order.rb +24 -0
  53. data/lib/cxml/invoice_detail_order_info.rb +10 -0
  54. data/lib/cxml/invoice_detail_order_summary.rb +32 -0
  55. data/lib/cxml/invoice_detail_request.rb +40 -0
  56. data/lib/cxml/invoice_detail_request_header.rb +54 -0
  57. data/lib/cxml/invoice_detail_shipping.rb +27 -0
  58. data/lib/cxml/invoice_detail_summary.rb +18 -0
  59. data/lib/cxml/invoice_id_info.rb +10 -0
  60. data/lib/cxml/invoice_partner.rb +10 -0
  61. data/lib/cxml/item_detail.rb +27 -0
  62. data/lib/cxml/item_id.rb +10 -0
  63. data/lib/cxml/item_in.rb +14 -0
  64. data/lib/cxml/item_out.rb +17 -0
  65. data/lib/cxml/master_agreement_reference.rb +9 -0
  66. data/lib/cxml/message.rb +13 -0
  67. data/lib/cxml/modification.rb +15 -0
  68. data/lib/cxml/modification_detail.rb +16 -0
  69. data/lib/cxml/modifications.rb +23 -0
  70. data/lib/cxml/money.rb +35 -0
  71. data/lib/cxml/name.rb +9 -0
  72. data/lib/cxml/net_amount.rb +9 -0
  73. data/lib/cxml/order_reference.rb +12 -0
  74. data/lib/cxml/order_request.rb +33 -0
  75. data/lib/cxml/order_request_header.rb +66 -0
  76. data/lib/cxml/parser.rb +37 -0
  77. data/lib/cxml/payment_term.rb +28 -0
  78. data/lib/cxml/period.rb +10 -0
  79. data/lib/cxml/postal_address.rb +35 -0
  80. data/lib/cxml/protocol.rb +57 -0
  81. data/lib/cxml/punch_out_order_message.rb +33 -0
  82. data/lib/cxml/punch_out_order_message_header.rb +20 -0
  83. data/lib/cxml/punch_out_setup_request.rb +31 -0
  84. data/lib/cxml/punch_out_setup_response.rb +9 -0
  85. data/lib/cxml/request.rb +21 -0
  86. data/lib/cxml/response.rb +20 -0
  87. data/lib/cxml/segment.rb +12 -0
  88. data/lib/cxml/sender.rb +10 -0
  89. data/lib/cxml/ship_to.rb +10 -0
  90. data/lib/cxml/shipping.rb +10 -0
  91. data/lib/cxml/shipping_amount.rb +10 -0
  92. data/lib/cxml/special_handling_amount.rb +11 -0
  93. data/lib/cxml/start_page.rb +13 -0
  94. data/lib/cxml/state.rb +9 -0
  95. data/lib/cxml/status.rb +27 -0
  96. data/lib/cxml/subtotal_amount.rb +9 -0
  97. data/lib/cxml/supplier_setup.rb +13 -0
  98. data/lib/cxml/tax.rb +42 -0
  99. data/lib/cxml/tax_adjustment_amount.rb +9 -0
  100. data/lib/cxml/tax_amount.rb +9 -0
  101. data/lib/cxml/tax_detail.rb +44 -0
  102. data/lib/cxml/tax_location.rb +9 -0
  103. data/lib/cxml/taxable_amount.rb +9 -0
  104. data/lib/cxml/to.rb +9 -0
  105. data/lib/cxml/total.rb +10 -0
  106. data/lib/cxml/total_allowances.rb +9 -0
  107. data/lib/cxml/total_amount_without_tax.rb +9 -0
  108. data/lib/cxml/total_charges.rb +9 -0
  109. data/lib/cxml/unit_price.rb +9 -0
  110. data/lib/cxml/version.rb +5 -0
  111. data/lib/cxml.rb +39 -0
  112. data/spec/credential_spec.rb +37 -0
  113. data/spec/cxml_spec.rb +6 -0
  114. data/spec/document_spec.rb +155 -0
  115. data/spec/fixtures/.gitkeep +0 -0
  116. data/spec/fixtures/envelope.xml +31 -0
  117. data/spec/fixtures/envelope2.xml +36 -0
  118. data/spec/fixtures/invoice_backed_and_unbacked_by_pos.xml +106 -0
  119. data/spec/fixtures/invoice_backed_by_multiple_pos.xml +97 -0
  120. data/spec/fixtures/invoice_taxes_at_line.xml +82 -0
  121. data/spec/fixtures/invoice_taxes_at_line_multiple_taxes.xml +403 -0
  122. data/spec/fixtures/invoice_taxes_at_total.xml +78 -0
  123. data/spec/fixtures/item_in.xml +11 -0
  124. data/spec/fixtures/order_request.cxml +121 -0
  125. data/spec/fixtures/punch_out_order_message_doc.xml +32 -0
  126. data/spec/fixtures/punch_out_setup_request_doc.xml +32 -0
  127. data/spec/fixtures/punch_out_setup_request_doc_coupa.xml +42 -0
  128. data/spec/fixtures/punch_out_setup_request_doc_with_ship_to.xml +46 -0
  129. data/spec/fixtures/purchase_order_request_200.xml +132 -0
  130. data/spec/fixtures/request_doc.xml +79 -0
  131. data/spec/fixtures/response_status_200.xml +11 -0
  132. data/spec/fixtures/response_status_400.xml +5 -0
  133. data/spec/header_spec.rb +54 -0
  134. data/spec/invoice_detail_request_spec.rb +88 -0
  135. data/spec/item_detail_spec.rb +44 -0
  136. data/spec/item_id_spec.rb +40 -0
  137. data/spec/item_in_spec.rb +41 -0
  138. data/spec/money_spec.rb +44 -0
  139. data/spec/parser_spec.rb +6 -0
  140. data/spec/protocol_spec.rb +16 -0
  141. data/spec/punch_out_order_message_header_spec.rb +36 -0
  142. data/spec/punch_out_order_message_spec.rb +43 -0
  143. data/spec/punch_out_setup_request_spec.rb +60 -0
  144. data/spec/purchase_order_request_spec.rb +40 -0
  145. data/spec/request_spec.rb +36 -0
  146. data/spec/response_spec.rb +58 -0
  147. data/spec/sender_spec.rb +32 -0
  148. data/spec/spec_helper.rb +21 -0
  149. data/spec/status_spec.rb +44 -0
  150. data/spec/support/helpers.rb +5 -0
  151. metadata +317 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 98317a7d62fb43104dbd038070b78b22981025d0c328a26641a30fa87510e64d
4
+ data.tar.gz: 39e13fc128347f928599c4420e78dfeda06c5387cf30973181d97f42b50f12ab
5
+ SHA512:
6
+ metadata.gz: e9d4be0021787dae95673c237463832c46673ab42c74dc0a25eaa7a06fd9a5494720351fe693e24a6389bbceab58c295d1ff5c5eb483b25aa84b11b7c35541b2
7
+ data.tar.gz: def87ff8ce650f3a2d81237a69e3a0e4fa859df5599cae58ab17327bf62a42ff03a3da25b64b87ac716ecf0534a4168790086b246f0e635b6f46150b8c9dcd4e
@@ -0,0 +1,23 @@
1
+ name: Ruby Specs
2
+
3
+ on: [push, pull_request]
4
+
5
+ jobs:
6
+ build:
7
+
8
+ runs-on: ubuntu-latest
9
+
10
+ steps:
11
+ - uses: actions/checkout@v2
12
+ - name: Set up Ruby 2.6
13
+ uses: actions/setup-ruby@v1
14
+ with:
15
+ ruby-version: 2.6.x
16
+ - name: Test with Rake
17
+ run: |
18
+ gem install bundler
19
+ bundle install --jobs 4 --retry 3
20
+ bundle exec rake
21
+ - name: Check with Rubocop
22
+ run: |
23
+ bundle exec rubocop
data/.gitignore ADDED
@@ -0,0 +1,14 @@
1
+ *.gem
2
+ *.rbc
3
+ *.swp
4
+ *.tmproj
5
+ *~
6
+ .DS_Store
7
+ .\#*
8
+ .bundle
9
+ .config
10
+ .yardoc
11
+ Gemfile.lock
12
+ spec/reports
13
+ tmp
14
+ tmtags
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --color
data/.rubocop.yml ADDED
@@ -0,0 +1,175 @@
1
+ AllCops:
2
+ Exclude:
3
+ - Gemfile
4
+ - vendor/**/*
5
+
6
+ # # Disable checking for block length
7
+ Metrics/BlockLength:
8
+ Enabled: false
9
+
10
+ # # The guiding principle of classes is SRP, SRP can't be accurately measured by LoC
11
+ Metrics/ClassLength:
12
+ Max: 1500
13
+
14
+ Metrics/ModuleLength:
15
+ Max: 1500
16
+
17
+ # # Commonly used screens these days easily fit more than 80 characters.
18
+ Layout/LineLength:
19
+ Max: 120
20
+ IgnoredPatterns: ['\A#', 'def .*# rubocop:disable']
21
+
22
+ # Raise the upper branch condition size, default max: 15
23
+ Metrics/AbcSize:
24
+ Max: 20
25
+
26
+ # # Too short methods lead to extraction of single-use methods, which can make
27
+ # # the code easier to read (by naming things), but can also clutter the class
28
+ Metrics/MethodLength:
29
+ Max: 30
30
+
31
+ # # Single quotes being faster is hardly measurable and only affects parse time.
32
+ # # Enforcing double quotes reduces the times where you need to change them
33
+ # # when introducing an interpolation. Use single quotes only if their semantics
34
+ # # are needed.
35
+ Style/StringLiterals:
36
+ EnforcedStyle: single_quotes
37
+
38
+ # # We do not need to support Ruby 1.9, so this is good to use.
39
+ Style/SymbolArray:
40
+ Enabled: true
41
+
42
+ Style/TrailingCommaInHashLiteral:
43
+ EnforcedStyleForMultiline: consistent_comma
44
+
45
+ Style/TrailingCommaInArrayLiteral:
46
+ EnforcedStyleForMultiline: consistent_comma
47
+
48
+ Style/AsciiComments:
49
+ Enabled: false
50
+
51
+ Style/Documentation:
52
+ Enabled: false
53
+
54
+ Style/ClassAndModuleChildren:
55
+ Enabled: false
56
+
57
+ Style/HashEachMethods:
58
+ Enabled: true
59
+
60
+ Style/HashTransformKeys:
61
+ Enabled: true
62
+
63
+ Style/HashTransformValues:
64
+ Enabled: true
65
+
66
+ Lint/RaiseException:
67
+ Enabled: true
68
+
69
+ Lint/StructNewOverride:
70
+ Enabled: true
71
+
72
+ # # Mixing the styles looks just silly.
73
+ # Style/HashSyntax:
74
+ # EnforcedStyle: ruby19_no_mixed_keys
75
+
76
+ # # has_key? and has_value? are far more readable than key? and value?
77
+ # Style/PreferredHashMethods:
78
+ # Enabled: false
79
+
80
+ # Style/CollectionMethods:
81
+ # Enabled: true
82
+
83
+ # # Either allow this style or don't. Marking it as safe with parenthesis
84
+ # # is silly. Let's try to live without them for now.
85
+ # Style/ParenthesesAroundCondition:
86
+ # AllowSafeAssignment: false
87
+ # Lint/AssignmentInCondition:
88
+ # AllowSafeAssignment: false
89
+
90
+ # # A specialized exception class will take one or more arguments and construct the message from it.
91
+ # # So both variants make sense.
92
+ # Style/RaiseArgs:
93
+ # Enabled: false
94
+
95
+ # # Fail is an alias of raise. Avoid aliases, it's more cognitive load for no gain.
96
+ # # The argument that fail should be used to abort the program is wrong too,
97
+ # # there's Kernel#abort for that.
98
+ # Style/SignalException:
99
+ # EnforcedStyle: only_raise
100
+
101
+ # # do / end blocks should be used for side effects,
102
+ # # methods that run a block for side effects and have
103
+ # # a useful return value are rare, assign the return
104
+ # # value to a local variable for those cases.
105
+ # Style/MethodCalledOnDoEndBlock:
106
+ # Enabled: true
107
+
108
+ # # Enforcing the names of variables? To single letter ones? Just no.
109
+ # Style/SingleLineBlockParams:
110
+ # Enabled: false
111
+
112
+ # # This is just silly. Calling the argument `other` in all cases makes no sense.
113
+ # Style/OpMethod:
114
+ # Enabled: false
115
+
116
+ # # Style preference
117
+ Style/MethodDefParentheses:
118
+ Enabled: true
119
+ Exclude:
120
+ - spec/**/*
121
+ Style/MethodCallWithArgsParentheses:
122
+ Enabled: true
123
+ Exclude:
124
+ - spec/**/*
125
+
126
+ # Style/WhileUntilModifier:
127
+ # Enabled: false
128
+
129
+ # Style/IfUnlessModifier:
130
+ # Enabled: false
131
+
132
+ # # Suppressing exceptions can be perfectly fine, and be it to avoid to
133
+ # # explicitly type nil into the rescue since that's what you want to return,
134
+ # # or suppressing LoadError for optional dependencies
135
+ # Lint/HandleExceptions:
136
+ # Enabled: false
137
+
138
+ # # Shadowing outer local variables with block parameters is often useful
139
+ # # to not reinvent a new name for the same thing, it highlights the relation
140
+ # # between the outer variable and the parameter. The cases where it's actually
141
+ # # confusing are rare, and usually bad for other reasons already, for example
142
+ # # because the method is too long.
143
+ # Lint/ShadowingOuterLocalVariable:
144
+ # Enabled: false
145
+
146
+ # # There are valid cases, for example debugging Cucumber steps,
147
+ # # also they'll fail CI anyway
148
+ # Lint/Debugger:
149
+ # Enabled: false
150
+
151
+ # # No space makes the method definition shorter and differentiates
152
+ # # from a regular assignment.
153
+ # Layout/SpaceAroundEqualsInParameterDefault:
154
+ # EnforcedStyle: no_space
155
+
156
+ # # Most readable form.
157
+ # Layout/AlignHash:
158
+ # EnforcedHashRocketStyle: table
159
+ # EnforcedColonStyle: table
160
+
161
+ # # Indenting the chained dots beneath each other is not supported by this cop,
162
+ # # see https://github.com/bbatsov/rubocop/issues/1633
163
+ # Layout/MultilineOperationIndentation:
164
+ # Enabled: false
165
+
166
+ # Layout/SpaceInsideBlockBraces:
167
+ # # The space here provides no real gain in readability while consuming
168
+ # # horizontal space that could be used for a better parameter name.
169
+ # # Also {| differentiates better from a hash than { | does.
170
+ # SpaceBeforeBlockParameters: true
171
+
172
+ # # No trailing space differentiates better from the block:
173
+ # # foo} means hash, foo } means block.
174
+ # Layout/SpaceInsideHashLiteralBraces:
175
+ # EnforcedStyle: no_space
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source "https://rubygems.org"
2
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) OfficeLuv <development@officeluv.com>
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE
data/README.md ADDED
@@ -0,0 +1,94 @@
1
+ # cXML-Ruby
2
+
3
+ ![Ruby Specs](https://github.com/officeluv/cxml/workflows/Ruby%20Specs/badge.svg)
4
+
5
+ Ruby implementation of the cXML protocol.
6
+
7
+ Currently supports these top-level documents in v1.2.037:
8
+
9
+ - Request
10
+ - InvoiceDetailRequest
11
+ - OrderRequest
12
+ - PunchOutSetupRequest
13
+ - ConfirmationRequest
14
+ - Response
15
+ - Status
16
+ - PunchOutSetupResponse
17
+ - Message
18
+ - PunchOutOrderMessage
19
+ - Pull requests welcome to support more!
20
+
21
+ ## Usage
22
+
23
+ ```rb
24
+ some_xml = '....'
25
+ doc = CXML::Document.new.from_xml(some_xml)
26
+ # raises CXML::UnknownAttributeError if unknown fields are present
27
+
28
+ doc.response.status.code
29
+ # => 200
30
+ doc.response.status.success?
31
+ # => true
32
+
33
+ # initialize docs with a hash
34
+ CXML::Document.new(response: { status: { code: '200' } }).render.to_xml
35
+ # => '<?xml.....'
36
+
37
+ # initialize docs with instances
38
+ status = CXML::Status.new(code: '200')
39
+ response = CXML::Response.new(status: status)
40
+ CXML::Document.new(response: response).render.to_xml
41
+ # => '<?xml.....'
42
+
43
+ # Set a different version
44
+ CXML::Document.new(version: '1.1.0', response: { status: { code: '200' } }).render.to_xml
45
+ # => '<?xml.....'
46
+ ```
47
+
48
+ ## Installation
49
+
50
+ Add this line to the application's Gemfile:
51
+
52
+ ```ruby
53
+ gem 'cxml-ruby'
54
+ ```
55
+
56
+ And then execute:
57
+
58
+ $ bundle
59
+
60
+ Or install it yourself as:
61
+
62
+ $ gem install cxml-ruby
63
+
64
+ ## Configuration
65
+
66
+ ```rb
67
+ CXML.configure do |config|
68
+ # Set this to false to log intead of raise exception on unknown elements
69
+ # defaults to true, raises CXML::UnknownAttributeError
70
+ config.raise_unknown_elements = true
71
+
72
+ # Optionally set a custom logger, used for parsing error logging
73
+ # defaults to Logger.new(STDOUT, level: :warn)
74
+ config.logger = Logger.new(STDOUT, level: :warn)
75
+ end
76
+ ```
77
+
78
+ ## Running Tests
79
+
80
+ Install dependencies:
81
+
82
+ ```sh
83
+ bundle install
84
+ ```
85
+
86
+ Run suite:
87
+
88
+ ```sh
89
+ rspec
90
+ ```
91
+
92
+ ## Documentation
93
+
94
+ Procotol specifications could be found here [http://xml.cxml.org/current/cXMLUsersGuide.pdf](http://xml.cxml.org/current/cXMLUsersGuide.pdf)
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ # frozen_string_literal: true
2
+
3
+ require('rspec/core/rake_task')
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+ task(default: :spec)
data/cxml-ruby.gemspec ADDED
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require(File.expand_path('lib/cxml/version', __dir__))
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = 'cxml-ruby'
7
+ s.version = CXML::VERSION
8
+ s.license = 'MIT'
9
+ s.summary = 'Parse/generate documents with the cXML protocol'
10
+ s.description = 'Ruby library to parse/generate documents with the cXML protocol'
11
+ s.homepage = 'https://github.com/officeluv/cxml'
12
+ s.authors = ['Josh Beckman', 'Eleni Chappen']
13
+ s.email = ['josh@officeluv.com', 'eleni@officeluv.com']
14
+
15
+ s.add_development_dependency('pry', '~> 0.12')
16
+ s.add_development_dependency('rake', '~> 13.0')
17
+ s.add_development_dependency('rspec', '~> 3.9')
18
+ s.add_development_dependency('rubocop', '~> 0.81')
19
+
20
+ s.add_dependency('nokogiri', '~> 1.10')
21
+ s.add_dependency('xml-simple', '~> 1.1')
22
+
23
+ s.files = `git ls-files`.split("\n")
24
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
25
+ s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
26
+ s.require_paths = ['lib']
27
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ # accounting details in item outs
5
+ class Accounting < DocumentNode
6
+ accessible_attributes %i[
7
+ name
8
+ ]
9
+ accessible_nodes %i[
10
+ segments
11
+ ]
12
+
13
+ def initialize_segments(value)
14
+ value = [value] unless value.is_a?(Array)
15
+ @segments = value.map do |item|
16
+ CXML::Segment.new(item)
17
+ end
18
+ end
19
+
20
+ def initialize_segment(value)
21
+ value = [value] unless value.is_a?(Array)
22
+ @segments = value.map do |item|
23
+ CXML::Segment.new(item)
24
+ end
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class AdditionalCost < DocumentNode
5
+ accessible_nodes %i[
6
+ money
7
+ percentage
8
+ ]
9
+ end
10
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class AdditionalDeduction < DocumentNode
5
+ accessible_nodes %i[
6
+ money
7
+ deduction_amount
8
+ deduction_percent
9
+ deducted_price
10
+ ]
11
+ end
12
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ # address, typically in a purchase order message
5
+ class Address < DocumentNode
6
+ accessible_attributes %i[
7
+ address_id
8
+ iso_country_code
9
+ ]
10
+ accessible_nodes %i[
11
+ email
12
+ name
13
+ postal_address
14
+ ]
15
+ end
16
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ # shipping details object within punchout setup request
5
+ class BillTo < DocumentNode
6
+ accessible_nodes %i[
7
+ address
8
+ ]
9
+ end
10
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class BrowserFormPost < DocumentNode
5
+ accessible_nodes %i[
6
+ url
7
+ ]
8
+
9
+ def render_nodes(node)
10
+ node.URL(url)
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class Charge < DocumentNode
5
+ accessible_nodes %i[
6
+ money
7
+ ]
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class Classification < DocumentNode
5
+ accessible_attributes %i[
6
+ domain
7
+ ]
8
+ end
9
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class ConfirmationHeader < DocumentNode
5
+ accessible_attributes %i[
6
+ confirm_id
7
+ operation
8
+ type
9
+ notice_date
10
+ invoice_id
11
+ ]
12
+ accessible_nodes %i[
13
+ contact
14
+ ]
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class ConfirmationItem < DocumentNode
5
+ accessible_attributes %i[
6
+ quantity
7
+ line_number
8
+ ]
9
+ accessible_nodes %i[
10
+ confirmation_status
11
+ unit_of_measure
12
+ ]
13
+ end
14
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class ConfirmationRequest < DocumentNode
5
+ accessible_nodes %i[
6
+ confirmation_header
7
+ order_reference
8
+ confirmation_items
9
+ ]
10
+
11
+ def initialize_confirmation_item(value)
12
+ value = [value] unless value.is_a?(Array)
13
+ @confirmation_items = value.map do |item|
14
+ CXML::ConfirmationItem.new(item)
15
+ end
16
+ end
17
+
18
+ def initialize_confirmation_items(value)
19
+ value = [value] unless value.is_a?(Array)
20
+ @confirmation_items = value.map do |item|
21
+ CXML::ConfirmationItem.new(item)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,32 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class ConfirmationStatus < DocumentNode
5
+ accessible_attributes %i[
6
+ quantity
7
+ type
8
+ shipment_date
9
+ delivery_date
10
+ ]
11
+ accessible_nodes %i[
12
+ comments
13
+ unit_of_measure
14
+ unit_price
15
+ extrinsics
16
+ ]
17
+
18
+ def initialize_extrinsic(value)
19
+ value = [value] unless value.is_a?(Array)
20
+ @extrinsics = value.map do |item|
21
+ Extrinsic.new(item)
22
+ end
23
+ end
24
+
25
+ def initialize_extrinsics(value)
26
+ value = [value] unless value.is_a?(Array)
27
+ @extrinsics = value.map do |item|
28
+ Extrinsic.new(item)
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ # contact object within punchout setup request
5
+ class Contact < DocumentNode
6
+ accessible_attributes %i[
7
+ role
8
+ address_id
9
+ ]
10
+ accessible_nodes %i[
11
+ email
12
+ name
13
+ postal_address
14
+ ]
15
+ end
16
+ end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CXML
4
+ class Country < DocumentNode
5
+ accessible_attributes %i[
6
+ iso_country_code
7
+ ]
8
+ end
9
+ end
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ # This element contains identification and authentication values.
4
+ # Credential contains an Identity element and optionally a SharedSecret or a CredentialMac
5
+ # element. The Identity element states who the Credential represents, while the optional
6
+ # authentication elements verify the identity of the party
7
+ #
8
+ # Credential has the following attributes:
9
+ #
10
+ # *domain*
11
+ # Specifies the type of credential. This attribute allows
12
+ # documents to contain multiple types of credentials for multiple
13
+ # authentication domains.
14
+ # For messages sent on the Ariba Supplier Network, for
15
+ # instance, the domain can be AribaNetworkUserId to indicate an
16
+ # email address, DUNS for a D-U-N-S number, or NetworkId for a
17
+ # preassigned ID.
18
+ #
19
+ # *type* - optional
20
+ # Requests to or from a marketplace identify both the
21
+ # marketplace and the member company in From or To Credential
22
+ # elements. In this case, the credential for the marketplace uses
23
+ # the type attribute, which is set to the value “marketplace”
24
+ #
25
+ # *SharedSecred*
26
+ # The SharedSecret element is used when the Sender has a password that the requester recognizes.
27
+ #
28
+ # *CredentialMac*
29
+ # The CredentialMac element is used for the Message Authentication Code (MAC)
30
+ # authentication method. This authentication method is used in situations where the
31
+ # sender must prove to the receiver that it has been authenticated by shared secret by a
32
+ # trusted third party. For example, a direct PunchOut request can travel directly from a
33
+ # buyer to a supplier without going through a network commerce hub, because it
34
+ # contains a MAC (generated by the network commerce hub) that allows the supplier to
35
+ # authenticate it.
36
+
37
+ module CXML
38
+ class Credential < DocumentNode
39
+ accessible_attributes %i[
40
+ domain
41
+ type
42
+ ]
43
+ accessible_nodes %i[
44
+ shared_secret
45
+ identity
46
+ credential_mac
47
+ ]
48
+ end
49
+ end