Class: UPS::Builders::ShipConfirmBuilder

Inherits:
BuilderBase show all
Includes:
Ox
Defined in:
lib/ups/builders/ship_confirm_builder.rb

Overview

The ShipConfirmBuilder class builds UPS XML ShipConfirm Objects.

Author:

  • Paul Trippett

Since:

  • 0.1.0

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_package, #add_payment_information, #add_rate_information, #add_request, #add_ship_from, #add_ship_to, #add_shipper, #to_xml

Constructor Details

#initializeShipConfirmBuilder

Initializes a new UPS::Builders::ShipConfirmBuilder object

Since:

  • 0.1.0


18
19
20
21
22
# File 'lib/ups/builders/ship_confirm_builder.rb', line 18

def initialize
  super 'ShipmentConfirmRequest'

  add_request 'ShipConfirm', 'validate'
end

Instance Attribute Details

#nameString

The Containing XML Element Name

Returns:

  • (String)

    the current value of name


13
14
15
# File 'lib/ups/builders/ship_confirm_builder.rb', line 13

def name
  @name
end

#optsHash

The Organization and Address Parts

Returns:

  • (Hash)

    the current value of opts


13
14
15
# File 'lib/ups/builders/ship_confirm_builder.rb', line 13

def opts
  @opts
end

Instance Method Details

#add_description(description) ⇒ void

This method returns an undefined value.

Adds Description to XML document being built

Parameters:

  • description (String)

    The description for goods being sent

Since:

  • 0.1.0


55
56
57
# File 'lib/ups/builders/ship_confirm_builder.rb', line 55

def add_description(description)
  shipment_root << element_with_value('Description', description)
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

Since:

  • 0.1.0


28
29
30
31
32
33
34
35
# File 'lib/ups/builders/ship_confirm_builder.rb', line 28

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_service(service_code, service_description = '') ⇒ void

This method returns an undefined value.

Adds a Service section to the XML document being built

Parameters:

  • service_code (String)

    The Service code for the choosen Shipping method

  • service_description (optional, String) (defaults to: '')

    A description for the choosen Shipping Method

Since:

  • 0.1.0


44
45
46
47
48
# File 'lib/ups/builders/ship_confirm_builder.rb', line 44

def add_service(service_code, service_description = '')
  shipment_root << code_description('Service',
                                    service_code,
                                    service_description)
end