Class: Cargowise::ShipmentSearch
- Inherits:
-
AbstractSearch
- Object
- AbstractSearch
- Cargowise::ShipmentSearch
- Defined in:
- lib/cargowise/shipment_search.rb
Instance Method Summary collapse
-
#by_masterbill_number(ref) ⇒ Object
find all shipments with a MasterBillNumber that matches ref.
-
#by_shipment_number(ref) ⇒ Object
find all shipments with a ShipmentNumber that matches ref.
-
#recently_shipped ⇒ Object
find all shipments that had were shipped in the past 14 days or will ship in the next 14 days.
-
#undelivered ⇒ Object
find all shipments that haven’t been delivered yet.
-
#with_recent_activity ⇒ Object
find all shipments that had some activity in the past fourteen days.
Methods inherited from AbstractSearch
Constructor Details
This class inherits a constructor from Cargowise::AbstractSearch
Instance Method Details
#by_masterbill_number(ref) ⇒ Object
find all shipments with a MasterBillNumber that matches ref
9 10 11 |
# File 'lib/cargowise/shipment_search.rb', line 9 def by_masterbill_number(ref) by_number("MasterBillNumber", ref) end |
#by_shipment_number(ref) ⇒ Object
find all shipments with a ShipmentNumber that matches ref
15 16 17 |
# File 'lib/cargowise/shipment_search.rb', line 15 def by_shipment_number(ref) by_number("ShipmentNumber", ref) end |
#recently_shipped ⇒ Object
find all shipments that had were shipped in the past 14 days or will ship in the next 14 days
53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/cargowise/shipment_search.rb', line 53 def recently_shipped filter_hash = { "tns:Filter" => { "tns:Date" => { "tns:DateSearchField" => "ETD", "tns:FromDate" => (Date.today - 14).strftime("%Y-%m-%d"), "tns:ToDate" => (Date.today + 14).strftime("%Y-%m-%d") } } } ShipmentsClient.endpoint(endpoint_hash) # probably not threadsafe. oops. ShipmentsClient.get_shipments_list(ep.code, ep.user, ep.password, filter_hash) end |
#undelivered ⇒ Object
find all shipments that haven’t been delivered yet.
This times out on some systems, possibly because the logistics company isn’t correctly marking shipments as delivered, so the result is too large to transfer in a timely manner.
25 26 27 28 29 30 31 |
# File 'lib/cargowise/shipment_search.rb', line 25 def undelivered filter_hash = { "tns:Filter" => { "tns:Status" => "Undelivered" } } ShipmentsClient.endpoint(endpoint_hash) # probably not threadsafe. oops. ShipmentsClient.get_shipments_list(ep.code, ep.user, ep.password, filter_hash) end |
#with_recent_activity ⇒ Object
find all shipments that had some activity in the past fourteen days. This could include leaving port, being delivered or passing a milestone.
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/cargowise/shipment_search.rb', line 36 def with_recent_activity filter_hash = { "tns:Filter" => { "tns:Date" => { "tns:DateSearchField" => "ALL", "tns:FromDate" => (Date.today - 14).strftime("%Y-%m-%d"), "tns:ToDate" => (Date.today + 14).strftime("%Y-%m-%d") } } } ShipmentsClient.endpoint(endpoint_hash) # probably not threadsafe. oops. ShipmentsClient.get_shipments_list(ep.code, ep.user, ep.password, filter_hash) end |