Class: Shipping::Organization

Inherits:
Object
  • Object
show all
Defined in:
lib/ups_shipping/organization.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Organization

Returns a new instance of Organization.



7
8
9
10
11
12
13
14
# File 'lib/ups_shipping/organization.rb', line 7

def initialize(options={})
  @name = options[:name]
  @phone = options[:phone]
  @address = options[:address]
  if options[:shipper_number]
    @shipper_number = options[:shipper_number]
  end
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



5
6
7
# File 'lib/ups_shipping/organization.rb', line 5

def address
  @address
end

#emailObject

Returns the value of attribute email.



5
6
7
# File 'lib/ups_shipping/organization.rb', line 5

def email
  @email
end

#nameObject

Returns the value of attribute name.



5
6
7
# File 'lib/ups_shipping/organization.rb', line 5

def name
  @name
end

#phoneObject

Returns the value of attribute phone.



5
6
7
# File 'lib/ups_shipping/organization.rb', line 5

def phone
  @phone
end

#shipper_numberObject

Returns the value of attribute shipper_number.



5
6
7
# File 'lib/ups_shipping/organization.rb', line 5

def shipper_number
  @shipper_number
end

Instance Method Details

#build(xml, rootname) ⇒ Object



16
17
18
19
20
21
22
23
24
25
# File 'lib/ups_shipping/organization.rb', line 16

def build(xml, rootname)
  xml.send(rootname) {
    xml.CompanyName @name
    xml.PhoneNumber @phone
    if @shipper_number
      xml.ShipperNumber @shipper_number
    end
    @address.build(xml)
  }
end

#to_xml(rootname) ⇒ Object



27
28
29
30
31
32
# File 'lib/ups_shipping/organization.rb', line 27

def to_xml(rootname)
  builder = Nokogiri::XML::Builder.new do |xml|
    build(xml, rootname)
  end
  builder.to_xml
end