Class: UPS::Builders::InternationalInvoiceBuilder
- Inherits:
-
BuilderBase
- Object
- BuilderBase
- UPS::Builders::InternationalInvoiceBuilder
- Includes:
- Ox
- Defined in:
- lib/ups/builders/international_invoice_builder.rb
Overview
The InternationalInvoiceBuilder class builds UPS XML International invoice Objects.
Instance Attribute Summary collapse
-
#name ⇒ String
The Containing XML Element Name.
-
#opts ⇒ Hash
The international invoice parts.
Attributes inherited from BuilderBase
#access_request, #document, #license_number, #password, #root, #shipment_root, #user_id
Instance Method Summary collapse
- #currency_code ⇒ Object
- #form_type ⇒ Object
-
#initialize(name, opts = {}) ⇒ InternationalInvoiceBuilder
constructor
A new instance of InternationalInvoiceBuilder.
- #invoice_date ⇒ Object
- #invoice_number ⇒ Object
- #product_container(opts = {}) ⇒ Object
- #product_details ⇒ Object
- #reason_for_export ⇒ Object
-
#to_xml ⇒ Ox::Element
Returns an XML representation of the current object.
Methods inherited from BuilderBase
#add_access_request, #add_package, #add_payment_information, #add_rate_information, #add_request, #add_ship_from, #add_ship_to, #add_shipper, #add_sold_to
Constructor Details
#initialize(name, opts = {}) ⇒ InternationalInvoiceBuilder
Returns a new instance of InternationalInvoiceBuilder.
16 17 18 19 |
# File 'lib/ups/builders/international_invoice_builder.rb', line 16 def initialize(name, opts = {}) self.name = name self.opts = opts end |
Instance Attribute Details
#name ⇒ String
The Containing XML Element Name
11 12 13 |
# File 'lib/ups/builders/international_invoice_builder.rb', line 11 def name @name end |
#opts ⇒ Hash
The international invoice parts
11 12 13 |
# File 'lib/ups/builders/international_invoice_builder.rb', line 11 def opts @opts end |
Instance Method Details
#currency_code ⇒ Object
37 38 39 |
# File 'lib/ups/builders/international_invoice_builder.rb', line 37 def currency_code element_with_value('CurrencyCode', opts[:currency_code]) end |
#form_type ⇒ Object
21 22 23 |
# File 'lib/ups/builders/international_invoice_builder.rb', line 21 def form_type element_with_value('FormType', '01') end |
#invoice_date ⇒ Object
29 30 31 |
# File 'lib/ups/builders/international_invoice_builder.rb', line 29 def invoice_date element_with_value('InvoiceDate', opts[:invoice_date]) end |
#invoice_number ⇒ Object
25 26 27 |
# File 'lib/ups/builders/international_invoice_builder.rb', line 25 def invoice_number element_with_value('InvoiceNumber', opts[:invoice_number]) if opts[:invoice_number] end |
#product_container(opts = {}) ⇒ Object
47 48 49 |
# File 'lib/ups/builders/international_invoice_builder.rb', line 47 def product_container(opts = {}) InternationalInvoiceProductBuilder.new('Product', opts).to_xml end |
#product_details ⇒ Object
41 42 43 44 45 |
# File 'lib/ups/builders/international_invoice_builder.rb', line 41 def product_details opts[:products].map do |product_opts| product_container(product_opts) end end |
#reason_for_export ⇒ Object
33 34 35 |
# File 'lib/ups/builders/international_invoice_builder.rb', line 33 def reason_for_export element_with_value('ReasonForExport', opts[:reason_for_export]) end |
#to_xml ⇒ Ox::Element
Returns an XML representation of the current object
54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/ups/builders/international_invoice_builder.rb', line 54 def to_xml Element.new(name).tap do |international_form| international_form << form_type international_form << invoice_number international_form << invoice_date international_form << reason_for_export international_form << currency_code product_details.each do |product_detail| international_form << product_detail end end end |