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, #add_sold_to, #to_xml

Constructor Details

#initializeShipConfirmBuilder

Initializes a new UPS::Builders::ShipConfirmBuilder object

Since:

  • 0.1.0



16
17
18
19
20
# File 'lib/ups/builders/ship_confirm_builder.rb', line 16

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



11
12
13
# File 'lib/ups/builders/ship_confirm_builder.rb', line 11

def name
  @name
end

#optsHash

The Organization and Address Parts

Returns:

  • (Hash)

    the current value of opts



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

Parameters:

  • description (String)

    The description for goods being sent

Since:

  • 0.1.0



63
64
65
# File 'lib/ups/builders/ship_confirm_builder.rb', line 63

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

Since:

  • 0.1.0



39
40
41
42
43
# File 'lib/ups/builders/ship_confirm_builder.rb', line 39

def add_international_invoice(opts = {})
  shipment_root << Element.new('ShipmentServiceOptions').tap do |shipment_service_options|
    shipment_service_options << InternationalInvoiceBuilder.new('InternationalForms', opts).to_xml
  end
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



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

Parameters:

  • opts (Hash) (defaults to: {})

    A Hash of data to build the requested section

Options Hash (opts):

  • :code (String)

    Code

  • :value (String)

    Value

Since:

  • 0.1.0



74
75
76
# File 'lib/ups/builders/ship_confirm_builder.rb', line 74

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

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



52
53
54
55
56
# File 'lib/ups/builders/ship_confirm_builder.rb', line 52

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