Class: UPS::Builders::ShipConfirmBuilder
- Inherits:
-
BuilderBase
- Object
- BuilderBase
- UPS::Builders::ShipConfirmBuilder
- Includes:
- Ox
- Defined in:
- lib/ups/builders/ship_confirm_builder.rb
Overview
The ShipConfirmBuilder class builds UPS XML ShipConfirm Objects.
Instance Attribute Summary collapse
-
#name ⇒ String
The Containing XML Element Name.
-
#opts ⇒ Hash
The Organization and Address Parts.
Attributes inherited from BuilderBase
#access_request, #document, #license_number, #password, #root, #shipment_root, #user_id
Instance Method Summary collapse
-
#add_description(description) ⇒ void
Adds Description to XML document being built.
-
#add_international_invoice(opts = {}) ⇒ void
Adds a InternationalForms section to the XML document being built according to user inputs.
- #add_invoice_line_total(value, currency_code) ⇒ Object
-
#add_label_specification(format, size) ⇒ void
Adds a LabelSpecification section to the XML document being built according to user inputs.
-
#add_reference_number(opts = {}) ⇒ void
Adds ReferenceNumber to the XML document being built.
-
#add_service(service_code, service_description = '') ⇒ void
Adds a Service section to the XML document being built.
-
#initialize ⇒ ShipConfirmBuilder
constructor
Initializes a new ShipConfirmBuilder object.
- #update_and_validate_for_worldwide_economy! ⇒ Object
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, #to_xml
Constructor Details
#initialize ⇒ ShipConfirmBuilder
Initializes a new UPS::Builders::ShipConfirmBuilder object
16 17 18 19 20 |
# File 'lib/ups/builders/ship_confirm_builder.rb', line 16 def initialize super 'ShipmentConfirmRequest' add_request 'ShipConfirm', 'validate', sub_version: '1807' end |
Instance Attribute Details
#name ⇒ String
The Containing XML Element Name
11 12 13 |
# File 'lib/ups/builders/ship_confirm_builder.rb', line 11 def name @name end |
#opts ⇒ Hash
The Organization and Address Parts
11 12 13 |
# File 'lib/ups/builders/ship_confirm_builder.rb', line 11 def opts @opts end |
Instance Method Details
#add_description(description) ⇒ void
This method returns an undefined value.
Adds Description to XML document being built
66 67 68 |
# File 'lib/ups/builders/ship_confirm_builder.rb', line 66 def add_description(description) shipment_root << element_with_value('Description', description) end |
#add_international_invoice(opts = {}) ⇒ void
This method returns an undefined value.
Adds a InternationalForms section to the XML document being built according to user inputs
39 40 41 42 |
# File 'lib/ups/builders/ship_confirm_builder.rb', line 39 def add_international_invoice(opts = {}) << InternationalInvoiceBuilder.new('InternationalForms', opts).to_xml end |
#add_invoice_line_total(value, currency_code) ⇒ Object
57 58 59 |
# File 'lib/ups/builders/ship_confirm_builder.rb', line 57 def add_invoice_line_total(value, currency_code) shipment_root << invoice_line_total(value, currency_code) end |
#add_label_specification(format, size) ⇒ void
This method returns an undefined value.
Adds a LabelSpecification section to the XML document being built according to user inputs
26 27 28 29 30 31 32 33 |
# File 'lib/ups/builders/ship_confirm_builder.rb', line 26 def add_label_specification(format, size) root << Element.new('LabelSpecification').tap do |label_spec| label_spec << label_print_method(format) label_spec << label_image_format(format) label_spec << label_stock_size(size) label_spec << http_user_agent if gif?(format) end end |
#add_reference_number(opts = {}) ⇒ void
This method returns an undefined value.
Adds ReferenceNumber to the XML document being built
77 78 79 |
# File 'lib/ups/builders/ship_confirm_builder.rb', line 77 def add_reference_number(opts = {}) shipment_root << reference_number(opts[:code], opts[:value]) end |
#add_service(service_code, service_description = '') ⇒ void
This method returns an undefined value.
Adds a Service section to the XML document being built
51 52 53 54 55 |
# File 'lib/ups/builders/ship_confirm_builder.rb', line 51 def add_service(service_code, service_description = '') shipment_root << code_description('Service', service_code, service_description) end |
#update_and_validate_for_worldwide_economy! ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/ups/builders/ship_confirm_builder.rb', line 81 def update_and_validate_for_worldwide_economy! shipment_charge << element_with_value('Type', '01') packages = document.locate('ShipmentConfirmRequest/Shipment/Package') bill_shipper_account_number = document.locate( 'ShipmentConfirmRequest/Shipment/ItemizedPaymentInformation/ShipmentCharge/BillShipper/AccountNumber/*' ).first unless packages.count == 1 raise InvalidAttributeError, 'Worldwide Economy shipment must be single-piece' end unless packages.first.locate('PackagingType/Code/*').first == '02' raise InvalidAttributeError, 'Worldwide Economy shipment must use Customer Supplied Package' end unless bill_shipper_account_number.to_s.length > 0 raise InvalidAttributeError, 'Worldwide Economy shipment must have "Bill Shipper" Itemized Payment Information' end end |