Class: DJI::Fedex::Package

Inherits:
Object
  • Object
show all
Defined in:
lib/dji/fedex/package.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePackage

Returns a new instance of Package.



20
21
22
# File 'lib/dji/fedex/package.rb', line 20

def initialize
  @scan_events = []
end

Instance Attribute Details

#delivery_dateObject

Returns the value of attribute delivery_date.



16
17
18
# File 'lib/dji/fedex/package.rb', line 16

def delivery_date
  @delivery_date
end

#dimensionsObject

Returns the value of attribute dimensions.



17
18
19
# File 'lib/dji/fedex/package.rb', line 17

def dimensions
  @dimensions
end

#estimated_delivery_dateObject

Returns the value of attribute estimated_delivery_date.



16
17
18
# File 'lib/dji/fedex/package.rb', line 16

def estimated_delivery_date
  @estimated_delivery_date
end

#key_statusObject

Returns the value of attribute key_status.



14
15
16
# File 'lib/dji/fedex/package.rb', line 14

def key_status
  @key_status
end

#key_status_codeObject

Returns the value of attribute key_status_code.



14
15
16
# File 'lib/dji/fedex/package.rb', line 14

def key_status_code
  @key_status_code
end

#last_scan_date_timeObject

Returns the value of attribute last_scan_date_time.



14
15
16
# File 'lib/dji/fedex/package.rb', line 14

def last_scan_date_time
  @last_scan_date_time
end

#last_scan_statusObject

Returns the value of attribute last_scan_status.



14
15
16
# File 'lib/dji/fedex/package.rb', line 14

def last_scan_status
  @last_scan_status
end

#main_statusObject

Returns the value of attribute main_status.



15
16
17
# File 'lib/dji/fedex/package.rb', line 15

def main_status
  @main_status
end

#pickup_dateObject

Returns the value of attribute pickup_date.



16
17
18
# File 'lib/dji/fedex/package.rb', line 16

def pickup_date
  @pickup_date
end

#pretty_tracking_numberObject

Returns the value of attribute pretty_tracking_number.



6
7
8
# File 'lib/dji/fedex/package.rb', line 6

def pretty_tracking_number
  @pretty_tracking_number
end

#received_byObject

Returns the value of attribute received_by.



15
16
17
# File 'lib/dji/fedex/package.rb', line 15

def received_by
  @received_by
end

#recipient_addressObject

Returns the value of attribute recipient_address.



11
12
13
# File 'lib/dji/fedex/package.rb', line 11

def recipient_address
  @recipient_address
end

#recipient_address_line_2Object

Returns the value of attribute recipient_address_line_2.



11
12
13
# File 'lib/dji/fedex/package.rb', line 11

def recipient_address_line_2
  @recipient_address_line_2
end

#recipient_cityObject

Returns the value of attribute recipient_city.



11
12
13
# File 'lib/dji/fedex/package.rb', line 11

def recipient_city
  @recipient_city
end

#recipient_company_nameObject

Returns the value of attribute recipient_company_name.



11
12
13
# File 'lib/dji/fedex/package.rb', line 11

def recipient_company_name
  @recipient_company_name
end

#recipient_country_codeObject

Returns the value of attribute recipient_country_code.



11
12
13
# File 'lib/dji/fedex/package.rb', line 11

def recipient_country_code
  @recipient_country_code
end

#recipient_nameObject

Returns the value of attribute recipient_name.



11
12
13
# File 'lib/dji/fedex/package.rb', line 11

def recipient_name
  @recipient_name
end

#recipient_phone_numberObject

Returns the value of attribute recipient_phone_number.



11
12
13
# File 'lib/dji/fedex/package.rb', line 11

def recipient_phone_number
  @recipient_phone_number
end

#recipient_postal_codeObject

Returns the value of attribute recipient_postal_code.



11
12
13
# File 'lib/dji/fedex/package.rb', line 11

def recipient_postal_code
  @recipient_postal_code
end

#recipient_region_codeObject

Returns the value of attribute recipient_region_code.



11
12
13
# File 'lib/dji/fedex/package.rb', line 11

def recipient_region_code
  @recipient_region_code
end

#scan_eventsObject

Returns the value of attribute scan_events.



18
19
20
# File 'lib/dji/fedex/package.rb', line 18

def scan_events
  @scan_events
end

#ship_dateObject

Returns the value of attribute ship_date.



16
17
18
# File 'lib/dji/fedex/package.rb', line 16

def ship_date
  @ship_date
end

#shipped_byObject

Returns the value of attribute shipped_by.



8
9
10
# File 'lib/dji/fedex/package.rb', line 8

def shipped_by
  @shipped_by
end

#shipped_toObject

Returns the value of attribute shipped_to.



11
12
13
# File 'lib/dji/fedex/package.rb', line 11

def shipped_to
  @shipped_to
end

#shipper_addressObject

Returns the value of attribute shipper_address.



8
9
10
# File 'lib/dji/fedex/package.rb', line 8

def shipper_address
  @shipper_address
end

#shipper_address_line_2Object

Returns the value of attribute shipper_address_line_2.



8
9
10
# File 'lib/dji/fedex/package.rb', line 8

def shipper_address_line_2
  @shipper_address_line_2
end

#shipper_cityObject

Returns the value of attribute shipper_city.



8
9
10
# File 'lib/dji/fedex/package.rb', line 8

def shipper_city
  @shipper_city
end

#shipper_company_nameObject

Returns the value of attribute shipper_company_name.



8
9
10
# File 'lib/dji/fedex/package.rb', line 8

def shipper_company_name
  @shipper_company_name
end

#shipper_country_codeObject

Returns the value of attribute shipper_country_code.



8
9
10
# File 'lib/dji/fedex/package.rb', line 8

def shipper_country_code
  @shipper_country_code
end

#shipper_nameObject

Returns the value of attribute shipper_name.



8
9
10
# File 'lib/dji/fedex/package.rb', line 8

def shipper_name
  @shipper_name
end

#shipper_phone_numberObject

Returns the value of attribute shipper_phone_number.



8
9
10
# File 'lib/dji/fedex/package.rb', line 8

def shipper_phone_number
  @shipper_phone_number
end

#shipper_postal_codeObject

Returns the value of attribute shipper_postal_code.



8
9
10
# File 'lib/dji/fedex/package.rb', line 8

def shipper_postal_code
  @shipper_postal_code
end

#shipper_region_codeObject

Returns the value of attribute shipper_region_code.



8
9
10
# File 'lib/dji/fedex/package.rb', line 8

def shipper_region_code
  @shipper_region_code
end

#sub_statusObject

Returns the value of attribute sub_status.



15
16
17
# File 'lib/dji/fedex/package.rb', line 15

def sub_status
  @sub_status
end

#tendered_dateObject

Returns the value of attribute tendered_date.



16
17
18
# File 'lib/dji/fedex/package.rb', line 16

def tendered_date
  @tendered_date
end

#total_weightObject

Returns the value of attribute total_weight.



17
18
19
# File 'lib/dji/fedex/package.rb', line 17

def total_weight
  @total_weight
end

#tracking_carrier_codeObject

Returns the value of attribute tracking_carrier_code.



7
8
9
# File 'lib/dji/fedex/package.rb', line 7

def tracking_carrier_code
  @tracking_carrier_code
end

#tracking_carrier_descriptionObject

Returns the value of attribute tracking_carrier_description.



7
8
9
# File 'lib/dji/fedex/package.rb', line 7

def tracking_carrier_description
  @tracking_carrier_description
end

#tracking_numberObject

Returns the value of attribute tracking_number.



6
7
8
# File 'lib/dji/fedex/package.rb', line 6

def tracking_number
  @tracking_number
end

#tracking_qualifierObject

Returns the value of attribute tracking_qualifier.



7
8
9
# File 'lib/dji/fedex/package.rb', line 7

def tracking_qualifier
  @tracking_qualifier
end

Class Method Details

.new_from_response_package_item(item) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/dji/fedex/package.rb', line 36

def new_from_response_package_item(item)
  package = Package.new
  package.tracking_number = item['trackingNbr']
  package.pretty_tracking_number = item['displayTrackingNbr']
  package.tracking_qualifier = item['trackingQualifier']
  package.tracking_carrier_code = item['trackingCarrierCd']
  package.tracking_carrier_description = item['trackingCarrierDesc']

  package.shipper_company_name = item['shipperCmpnyName']
  package.shipper_name = item['shipperName']
  package.shipper_address = item['shipperAddr1']
  package.shipper_address_line_2 = item['shipperAddr2']
  package.shipper_city = item['shipperCity']
  package.shipper_region_code = item['shipperStateCD']
  package.shipper_postal_code = item['shipperZip']
  package.shipper_country_code = item['shipperCntryCD']
  package.shipper_phone_number = item['shipperPhoneNbr']
  package.shipped_by = item['shippedBy']

  package.recipient_company_name = item['recipientCmpnyName']
  package.recipient_name = item['recipientName']
  package.recipient_address = item['recipientAddr1']
  package.recipient_address_line_2 = item['recipientAddr2']
  package.recipient_city = item['recipientCity']
  package.recipient_region_code = item['recipientStateCD']
  package.recipient_postal_code = item['recipientZip']
  package.recipient_country_code = item['recipientCntryCD']
  package.recipient_phone_number = item['recipientPhoneNbr']
  package.shipped_to = item['shippedTo']

  package.key_status = item['keyStatus']
  package.key_status_code = item['keyStatusCD']
  package.last_scan_status = item['lastScanStatus']
  package.last_scan_date_time = item['lastScanDateTime']

  package.received_by = item['receivedByNm']
  package.sub_status = item['subStatus']
  package.main_status = item['mainStatus']

  package.tendered_date = Time.iso8601(item['tenderedDt']) if item['tenderedDt'].present?
  package.pickup_date = Time.iso8601(item['pickupDt']) if item['pickupDt'].present?
  package.ship_date = Time.iso8601(item['shipDt']) if item['shipDt'].present?
  package.estimated_delivery_date = Time.iso8601(item['estDeliveryDt']) if item['estDeliveryDt'].present?
  package.delivery_date = Time.iso8601(item['actDeliveryDt']) if item['actDeliveryDt'].present?

  package.dimensions = item['dimensions']
  package.total_weight = { pounds: item['totalLbsWgt'], kilograms: item['totalKgsWgt'] }

  package
end

Instance Method Details

#destinationObject



24
25
26
27
# File 'lib/dji/fedex/package.rb', line 24

def destination
  [recipient_company_name, recipient_name, recipient_address, recipient_address_line_2, recipient_city,
   recipient_region_code, recipient_country_code].reject(&:blank?).join(', ')
end

#originObject



29
30
31
32
# File 'lib/dji/fedex/package.rb', line 29

def origin
  [shipper_company_name, shipper_name, shipper_address, shipper_address_line_2, shipper_city,
   shipper_region_code, shipper_country_code].reject(&:blank?).join(', ')
end