Class: Dina::Shipment

Inherits:
Object
  • Object
show all
Defined in:
lib/dina/components/shipment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeShipment

Returns a new instance of Shipment.



14
15
16
# File 'lib/dina/components/shipment.rb', line 14

def initialize
  @address = {}
end

Instance Attribute Details

#addressObject

with properties receiverName, companyName, addressLine1, addressLine2, city, provinceState, zipCode, country



12
13
14
# File 'lib/dina/components/shipment.rb', line 12

def address
  @address
end

#contentRemarksObject

Returns the value of attribute contentRemarks.



3
4
5
# File 'lib/dina/components/shipment.rb', line 3

def contentRemarks
  @contentRemarks
end

#currencyObject

Returns the value of attribute currency.



5
6
7
# File 'lib/dina/components/shipment.rb', line 5

def currency
  @currency
end

#itemCountObject

Returns the value of attribute itemCount.



6
7
8
# File 'lib/dina/components/shipment.rb', line 6

def itemCount
  @itemCount
end

#packingMethodObject

Returns the value of attribute packingMethod.



9
10
11
# File 'lib/dina/components/shipment.rb', line 9

def packingMethod
  @packingMethod
end

#shipmentRemarksObject

Returns the value of attribute shipmentRemarks.



11
12
13
# File 'lib/dina/components/shipment.rb', line 11

def shipmentRemarks
  @shipmentRemarks
end

#shippedOnObject

Returns the value of attribute shippedOn.



7
8
9
# File 'lib/dina/components/shipment.rb', line 7

def shippedOn
  @shippedOn
end

#statusObject

Returns the value of attribute status.



8
9
10
# File 'lib/dina/components/shipment.rb', line 8

def status
  @status
end

#trackingNumberObject

Returns the value of attribute trackingNumber.



10
11
12
# File 'lib/dina/components/shipment.rb', line 10

def trackingNumber
  @trackingNumber
end

#valueObject

Returns the value of attribute value.



4
5
6
# File 'lib/dina/components/shipment.rb', line 4

def value
  @value
end

Instance Method Details

#add_address(address:) ⇒ Object



18
19
20
21
22
23
# File 'lib/dina/components/shipment.rb', line 18

def add_address(address:)
  if !address.instance_of?(Address)
    raise PropertyValueInvalid, "Address must be of type Address."
  end
  @address.merge!(address.to_hash)
end

#to_hashObject



25
26
27
28
29
# File 'lib/dina/components/shipment.rb', line 25

def to_hash
  hash = {}
  instance_variables.each { |var| hash[var.to_s.delete('@')] = instance_variable_get(var) }
  hash.deep_symbolize_keys
end