Class: Dpd::Shipping::Parcel

Inherits:
Object
  • Object
show all
Defined in:
lib/dpd_shipping/parcel.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attributes = {}) ⇒ Parcel

Returns a new instance of Parcel.



6
7
8
9
10
11
12
13
# File 'lib/dpd_shipping/parcel.rb', line 6

def initialize(attributes = {})
  attributes.each do |key, value|
    setter = :"#{key.to_s}="
    if self.respond_to?(setter)
      self.send(setter, value)
    end
  end
end

Instance Attribute Details

#addressObject

Returns the value of attribute address.



4
5
6
# File 'lib/dpd_shipping/parcel.rb', line 4

def address
  @address
end

#contentObject

Returns the value of attribute content.



4
5
6
# File 'lib/dpd_shipping/parcel.rb', line 4

def content
  @content
end

#customerObject

Returns the value of attribute customer.



4
5
6
# File 'lib/dpd_shipping/parcel.rb', line 4

def customer
  @customer
end

#internal_referenceObject

Returns the value of attribute internal_reference.



4
5
6
# File 'lib/dpd_shipping/parcel.rb', line 4

def internal_reference
  @internal_reference
end

#referenceObject

Returns the value of attribute reference.



4
5
6
# File 'lib/dpd_shipping/parcel.rb', line 4

def reference
  @reference
end

#serviceObject

Returns the value of attribute service.



4
5
6
# File 'lib/dpd_shipping/parcel.rb', line 4

def service
  @service
end

#track_urlObject

Returns the value of attribute track_url.



4
5
6
# File 'lib/dpd_shipping/parcel.rb', line 4

def track_url
  @track_url
end

#weightObject

Returns the value of attribute weight.



4
5
6
# File 'lib/dpd_shipping/parcel.rb', line 4

def weight
  @weight
end

Instance Method Details

#append_to_xml(xml) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dpd_shipping/parcel.rb', line 15

def append_to_xml(xml)
  xml.tns(:ppvOrderData) do |xml|
    xml.tns(:PartnerOrderReference, internal_reference || " ")
    xml.tns(:Customer, customer || " ")
    xml.tns(:Reference, reference || " ")
    xml.tns(:Content, content)
    xml.tns(:Weight, weight)
    xml.tns(:ShipService, service.service_type)
    xml.tns(:CODAmount, service.cod_amount || 0)
    address.append_to_xml(xml)
    xml.tns(:TrackURL, track_url || "")
  end
end