Class: CargowiseTS::ShipmentSearch

Inherits:
Object
  • Object
show all
Defined in:
lib/cargowise-ts/shipment_search.rb

Instance Method Summary collapse

Constructor Details

#initialize(savon_client) ⇒ ShipmentSearch

Returns a new instance of ShipmentSearch.



9
10
11
# File 'lib/cargowise-ts/shipment_search.rb', line 9

def initialize(savon_client)
  @savon_client = savon_client
end

Instance Method Details

#by_masterbill_number(ref) ⇒ Object

find all shipments with a MasterBillNumber that matches ref



15
16
17
# File 'lib/cargowise-ts/shipment_search.rb', line 15

def by_masterbill_number(ref)
  by_number("MasterBillNumber", ref)
end

#by_shipment_number(ref) ⇒ Object

find all shipments with a ShipmentNumber that matches ref



21
22
23
# File 'lib/cargowise-ts/shipment_search.rb', line 21

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



57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/cargowise-ts/shipment_search.rb', line 57

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")
      }
    }
  }
  get_shipments_list(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.



31
32
33
34
35
36
# File 'lib/cargowise-ts/shipment_search.rb', line 31

def undelivered
  filter_hash = {
    "tns:Filter" => { "tns:Status" => "Undelivered" }
    }
  get_shipments_list(filter_hash)
end

#with_recent_activity(range = 14) ⇒ Object

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



41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/cargowise-ts/shipment_search.rb', line 41

def with_recent_activity(range = 14)
  filter_hash = {
    "tns:Filter" => {
      "tns:Date" => {
        "tns:DateSearchField" => "ALL",
        "tns:FromDate" => (Date.today - range).strftime("%Y-%m-%d"),
        "tns:ToDate" => (Date.today + range).strftime("%Y-%m-%d")
      }
    }
  }
  get_shipments_list(filter_hash)
end