Class: UPS::Builders::InternationalInvoiceProductBuilder
- Inherits:
-
BuilderBase
- Object
- BuilderBase
- UPS::Builders::InternationalInvoiceProductBuilder
show all
- Includes:
- Ox
- Defined in:
- lib/ups/builders/international_invoice_product_builder.rb
Overview
The InternationalProductInvoiceBuilder class builds UPS XML International invoice Produt Objects.
Instance Attribute Summary collapse
Attributes inherited from BuilderBase
#access_request, #document, #license_number, #password, #root, #shipment_root, #user_id
Instance Method Summary
collapse
Methods inherited from BuilderBase
#add_access_request, #add_insurance_charge, #add_itemized_payment_information, #add_master_carton_id, #add_master_carton_indicator, #add_package, #add_payment_information, #add_rate_information, #add_request, #add_ship_from, #add_ship_to, #add_shipment_delivery_confirmation, #add_shipment_direct_delivery_only, #add_shipper, #add_sold_to
Constructor Details
Returns a new instance of InternationalInvoiceProductBuilder.
16
17
18
19
|
# File 'lib/ups/builders/international_invoice_product_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_product_builder.rb', line 11
def name
@name
end
|
#opts ⇒ Hash
The international invoice product parts
11
12
13
|
# File 'lib/ups/builders/international_invoice_product_builder.rb', line 11
def opts
@opts
end
|
Instance Method Details
#commodity_code ⇒ Object
41
42
43
|
# File 'lib/ups/builders/international_invoice_product_builder.rb', line 41
def commodity_code
element_with_value('CommodityCode', opts[:commodity_code])
end
|
#description ⇒ Object
21
22
23
|
# File 'lib/ups/builders/international_invoice_product_builder.rb', line 21
def description
element_with_value('Description', opts[:description])
end
|
#dimensions_unit ⇒ Object
33
34
35
|
# File 'lib/ups/builders/international_invoice_product_builder.rb', line 33
def dimensions_unit
unit_of_measurement(opts[:dimensions_unit])
end
|
#number ⇒ Object
25
26
27
|
# File 'lib/ups/builders/international_invoice_product_builder.rb', line 25
def number
element_with_value('Number', opts[:number])
end
|
#origin_country_code ⇒ Object
45
46
47
|
# File 'lib/ups/builders/international_invoice_product_builder.rb', line 45
def origin_country_code
element_with_value('OriginCountryCode', opts[:origin_country_code][0..2])
end
|
#part_number ⇒ Object
37
38
39
|
# File 'lib/ups/builders/international_invoice_product_builder.rb', line 37
def part_number
element_with_value('PartNumber', opts[:part_number][0..9])
end
|
#product_unit ⇒ Object
49
50
51
52
53
54
55
|
# File 'lib/ups/builders/international_invoice_product_builder.rb', line 49
def product_unit
Element.new('Unit').tap do |unit|
unit << number
unit << value
unit << dimensions_unit
end
end
|
#to_xml ⇒ Ox::Element
Returns an XML representation of the current object
60
61
62
63
64
65
66
67
68
|
# File 'lib/ups/builders/international_invoice_product_builder.rb', line 60
def to_xml
Element.new(name).tap do |product|
product << description
product << commodity_code if opts[:commodity_code]
product << part_number if opts[:part_number]
product << origin_country_code
product << product_unit
end
end
|
#value ⇒ Object
29
30
31
|
# File 'lib/ups/builders/international_invoice_product_builder.rb', line 29
def value
element_with_value('Value', opts[:value])
end
|