Class: UPS::Builders::OrganisationBuilder
- Inherits:
-
BuilderBase
- Object
- BuilderBase
- UPS::Builders::OrganisationBuilder
- Includes:
- Ox
- Defined in:
- lib/ups/builders/organisation_builder.rb
Overview
The OrganisationBuilder class builds UPS XML Organization 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
-
#address ⇒ Ox::Element
Returns an XML representation of address.
-
#attention_name ⇒ Ox::Element
Returns an XML representation of AttentionName for which we use company name.
-
#company_name ⇒ Ox::Element
Returns an XML representation of company_name.
-
#email_address ⇒ Ox::Element
Returns an XML representation of the email address of the company.
-
#initialize(name, opts = {}) ⇒ OrganisationBuilder
constructor
Initializes a new AddressBuilder object.
-
#phone_number ⇒ Ox::Element
Returns an XML representation of phone_number.
-
#tax_identification_number ⇒ Ox::Element
Returns an XML representation of sender_vat_number of the company.
-
#to_xml ⇒ Ox::Element
Returns an XML representation of a UPS Organization.
-
#vendor_info ⇒ Ox::Element
Returns an XML representation of vendor info (ioss number and more) of the company.
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
#initialize(name, opts = {}) ⇒ OrganisationBuilder
Initializes a new AddressBuilder object
26 27 28 29 30 |
# File 'lib/ups/builders/organisation_builder.rb', line 26 def initialize(name, opts = {}) self.name = name self.opts = opts self.opts[:skip_ireland_state_validation] = (name == 'SoldTo') end |
Instance Attribute Details
#name ⇒ String
The Containing XML Element Name
11 12 13 |
# File 'lib/ups/builders/organisation_builder.rb', line 11 def name @name end |
#opts ⇒ Hash
The Organization and Address Parts
11 12 13 |
# File 'lib/ups/builders/organisation_builder.rb', line 11 def opts @opts end |
Instance Method Details
#address ⇒ Ox::Element
Returns an XML representation of address
72 73 74 |
# File 'lib/ups/builders/organisation_builder.rb', line 72 def address AddressBuilder.new(opts).to_xml end |
#attention_name ⇒ Ox::Element
Returns an XML representation of AttentionName for which we use company name
50 51 52 |
# File 'lib/ups/builders/organisation_builder.rb', line 50 def attention_name element_with_value('AttentionName', opts[:attention_name][0..34]) end |
#company_name ⇒ Ox::Element
Returns an XML representation of company_name
35 36 37 |
# File 'lib/ups/builders/organisation_builder.rb', line 35 def company_name element_with_value('CompanyName', opts[:company_name][0..34]) end |
#email_address ⇒ Ox::Element
Returns an XML representation of the email address of the company
64 65 66 |
# File 'lib/ups/builders/organisation_builder.rb', line 64 def email_address element_with_value('EMailAddress', opts[:email_address].to_s[0..50]) end |
#phone_number ⇒ Ox::Element
Returns an XML representation of phone_number
42 43 44 |
# File 'lib/ups/builders/organisation_builder.rb', line 42 def phone_number element_with_value('PhoneNumber', opts[:phone_number][0..14]) end |
#tax_identification_number ⇒ Ox::Element
Returns an XML representation of sender_vat_number of the company
57 58 59 |
# File 'lib/ups/builders/organisation_builder.rb', line 57 def tax_identification_number element_with_value('TaxIdentificationNumber', opts[:sender_vat_number] || '') end |
#to_xml ⇒ Ox::Element
Returns an XML representation of a UPS Organization
92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/ups/builders/organisation_builder.rb', line 92 def to_xml Element.new(name).tap do |org| org << company_name org << phone_number org << attention_name org << address org << tax_identification_number org << email_address org << vendor_info unless opts[:sender_ioss_number].to_s.empty? end end |
#vendor_info ⇒ Ox::Element
Returns an XML representation of vendor info (ioss number and more) of the company
79 80 81 82 83 84 85 86 87 |
# File 'lib/ups/builders/organisation_builder.rb', line 79 def vendor_info ioss_vendor_collect_id = '0356' Element.new('VendorInfo').tap do |vendor_info| vendor_info << element_with_value('VendorCollectIDNumber', opts[:sender_ioss_number] || '') vendor_info << element_with_value('VendorCollectIDTypeCode', ioss_vendor_collect_id) vendor_info << element_with_value('ConsigneeType', '02') end end |