cargowise 0.7.1 → 0.7.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cargowise/consol.rb +1 -1
- data/lib/cargowise/shipment.rb +16 -0
- data/lib/cargowise/shipment_search.rb +21 -10
- metadata +4 -4
data/lib/cargowise/consol.rb
CHANGED
@@ -15,7 +15,7 @@ module Cargowise
|
|
15
15
|
def initialize(node)
|
16
16
|
@node = node
|
17
17
|
|
18
|
-
@
|
18
|
+
@master_bill = text_value("./MasterBill")
|
19
19
|
@console_mode = text_value("./ConsolMode")
|
20
20
|
@transport_mode = text_value("./TransportMode")
|
21
21
|
@vessel_name = text_value("./VesselName")
|
data/lib/cargowise/shipment.rb
CHANGED
@@ -85,5 +85,21 @@ module Cargowise
|
|
85
85
|
@orders ||= Cargowise::Order.via(via).by_shipment_number(self.number)
|
86
86
|
end
|
87
87
|
|
88
|
+
# lookup related Cargowise::Shipment objects. These are usually "child" shipments
|
89
|
+
# grouped under a parent. Think a consolidated pallet (the parent) with cartons from
|
90
|
+
# multiple suppliers (the children).
|
91
|
+
#
|
92
|
+
# 'via' is a symbol indicating which API endpoint to lookup.
|
93
|
+
#
|
94
|
+
def related_shipments(via)
|
95
|
+
@related ||= @consols.map { |consol|
|
96
|
+
consol.master_bill
|
97
|
+
}.compact.map { |master_bill|
|
98
|
+
Cargowise::Shipment.via(via).by_masterbill_number(master_bill)
|
99
|
+
}.flatten.select { |shipment|
|
100
|
+
shipment.number != self.number
|
101
|
+
}.compact
|
102
|
+
end
|
103
|
+
|
88
104
|
end
|
89
105
|
end
|
@@ -4,19 +4,16 @@ module Cargowise
|
|
4
4
|
|
5
5
|
class ShipmentSearch < AbstractSearch
|
6
6
|
|
7
|
+
# find all shipments with a MasterBillNumber that matches ref
|
8
|
+
#
|
9
|
+
def by_masterbill_number(ref)
|
10
|
+
by_number("MasterBillNumber", ref)
|
11
|
+
end
|
12
|
+
|
7
13
|
# find all shipments with a ShipmentNumber that matches ref
|
8
14
|
#
|
9
15
|
def by_shipment_number(ref)
|
10
|
-
|
11
|
-
"tns:Filter" => {
|
12
|
-
"tns:Number" => {
|
13
|
-
"tns:NumberSearchField" => "ShipmentNumber",
|
14
|
-
"tns:NumberValue" => ref
|
15
|
-
}
|
16
|
-
}
|
17
|
-
}
|
18
|
-
ShipmentsClient.endpoint(endpoint_hash) # probably not threadsafe. oops.
|
19
|
-
ShipmentsClient.get_shipments_list(ep.code, ep.user, ep.password, filter_hash)
|
16
|
+
by_number("ShipmentNumber", ref)
|
20
17
|
end
|
21
18
|
|
22
19
|
# find all shipments that haven't been delivered yet.
|
@@ -67,6 +64,20 @@ module Cargowise
|
|
67
64
|
ShipmentsClient.get_shipments_list(ep.code, ep.user, ep.password, filter_hash)
|
68
65
|
end
|
69
66
|
|
67
|
+
private
|
68
|
+
|
69
|
+
def by_number(field, ref)
|
70
|
+
filter_hash = {
|
71
|
+
"tns:Filter" => {
|
72
|
+
"tns:Number" => {
|
73
|
+
"tns:NumberSearchField" => field,
|
74
|
+
"tns:NumberValue" => ref
|
75
|
+
}
|
76
|
+
}
|
77
|
+
}
|
78
|
+
ShipmentsClient.endpoint(endpoint_hash) # probably not threadsafe. oops.
|
79
|
+
ShipmentsClient.get_shipments_list(ep.code, ep.user, ep.password, filter_hash)
|
80
|
+
end
|
70
81
|
|
71
82
|
end
|
72
83
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cargowise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 2
|
10
|
+
version: 0.7.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- James Healy
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-09-
|
18
|
+
date: 2010-09-07 00:00:00 +10:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|