Class: Cargowise::ShipmentSearch

Inherits:
AbstractSearch show all
Defined in:
lib/cargowise/shipment_search.rb

Instance Method Summary collapse

Methods inherited from AbstractSearch

#initialize

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_shippedObject

find all shipments that had were shipped in the past 14 days or will ship in the next 14 days



51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/cargowise/shipment_search.rb', line 51

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.new.get_shipments_list(ep.uri, ep.code, ep.user, ep.password, filter_hash)
end

#undeliveredObject

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
# File 'lib/cargowise/shipment_search.rb', line 25

def undelivered
  filter_hash = {
    "tns:Filter" => { "tns:Status" => "Undelivered" }
    }
  ShipmentsClient.new.get_shipments_list(ep.uri, ep.code, ep.user, ep.password, filter_hash)
end

#with_recent_activityObject

find all shipments that had some activity in the past fourteen days. This could include leaving port, being delivered or passing a milestone.



35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/cargowise/shipment_search.rb', line 35

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.new.get_shipments_list(ep.uri, ep.code, ep.user, ep.password, filter_hash)
end