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.
-
#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.
Methods inherited from BuilderBase
#add_access_request, #add_insurance_charge, #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, #customer_supplied_packaging
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
65 66 67 |
# File 'lib/ups/builders/organisation_builder.rb', line 65 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 |
#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
72 73 74 75 76 77 78 79 80 |
# File 'lib/ups/builders/organisation_builder.rb', line 72 def to_xml Element.new(name).tap do |org| org << company_name org << phone_number org << attention_name org << address org << tax_identification_number end end |