dji 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dji/commands/track/track_command.rb +10 -2
- data/lib/dji/order_tracking.rb +11 -8
- data/lib/dji/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18de7fa01d13c5d98f38ab7cad4097ee955e5243
|
4
|
+
data.tar.gz: 3c72542e8ec311a68b3f5225e8b2ea5168be3c5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a0f94f39006cdcf59222e21714c3928372766315968779bdbdcdfe4c0c7f1791b67e8096c097d1a1930ce8fa131db6a29b9e67df50b5678d14180d6f939a13d
|
7
|
+
data.tar.gz: 69c8a2fcfa9801599e17ff4c24af95a794bb43ca01e7f9b4b3e32f148ffa7d86608d114233588ef6ec300c9f45d400327c81784d5dbec883c41e7737899e78eb
|
@@ -6,21 +6,29 @@ module DJI
|
|
6
6
|
option :phone_tail, required: true, aliases: :p
|
7
7
|
option :repeat, aliases: :r
|
8
8
|
option :publish, required: false, default: false
|
9
|
+
option :country, required: false, aliases: :c
|
9
10
|
option :dji_username, required: false, aliases: [:username, :u]
|
10
11
|
|
11
12
|
def track
|
13
|
+
provided_options = {
|
14
|
+
order_number: options[:order_number],
|
15
|
+
phone_tail: options[:phone_tail],
|
16
|
+
country: options[:country],
|
17
|
+
dji_username: options[:dji_username]
|
18
|
+
}
|
19
|
+
|
12
20
|
if options[:repeat].present?
|
13
21
|
interval = options[:repeat].to_i.presence || 300
|
14
22
|
puts
|
15
23
|
puts "Requesting order tracking details every #{interval} seconds. Press CONTROL-C to stop..."
|
16
24
|
|
17
25
|
while true
|
18
|
-
data = DJI::OrderTracking.tracking_details(
|
26
|
+
data = DJI::OrderTracking.tracking_details(provided_options)
|
19
27
|
DJI::OrderTracking.publish(data) if data.present? && options[:publish].present?
|
20
28
|
sleep(interval)
|
21
29
|
end
|
22
30
|
else
|
23
|
-
data = DJI::OrderTracking.tracking_details(
|
31
|
+
data = DJI::OrderTracking.tracking_details(provided_options)
|
24
32
|
DJI::OrderTracking.publish(data) if data.present? && options[:publish].present?
|
25
33
|
end
|
26
34
|
end
|
data/lib/dji/order_tracking.rb
CHANGED
@@ -48,15 +48,16 @@ module DJI
|
|
48
48
|
# OK
|
49
49
|
page = Nokogiri::HTML(res.body)
|
50
50
|
content = page.at_xpath('//div[@id="main"]/div[@class="container"]/div[@class="row"]/div[@class="col-xs-9"]/div[@class="col-xs-10 well"][2]')
|
51
|
-
|
52
|
-
data
|
53
|
-
data[:order_number]
|
54
|
-
data[:total]
|
55
|
-
data[:payment_status]
|
56
|
-
data[:shipping_status]
|
51
|
+
|
52
|
+
data = {}
|
53
|
+
data[:order_number] = content.at_xpath('div[1]').text.split(' ')[-1]
|
54
|
+
data[:total] = content.at_xpath('div[2]').text.split(' ')[1..-1].join(' ')
|
55
|
+
data[:payment_status] = content.at_xpath('div[3]').text.split(': ')[1]
|
56
|
+
data[:shipping_status] = content.at_xpath('div[4]').text.split(': ')[1]
|
57
57
|
data[:shipping_company] = content.at_xpath('div[5]/span').text
|
58
|
-
data[:tracking_number]
|
58
|
+
data[:tracking_number] = content.at_xpath('div[6]/a').text
|
59
59
|
|
60
|
+
data[:country] = options[:country] if option[:country].present?
|
60
61
|
data[:dji_username] = options[:dji_username] if options[:dji_username].present?
|
61
62
|
|
62
63
|
print_tracking_details(data)
|
@@ -84,6 +85,7 @@ module DJI
|
|
84
85
|
puts "Order Number : #{data[:order_number]}"
|
85
86
|
puts "Total : #{data[:total]}"
|
86
87
|
puts "Payment Status : #{data[:payment_status]}"
|
88
|
+
puts "Country : #{data[:shipping_country]}" if data[:country]
|
87
89
|
puts "Shipping Status : #{data[:shipping_status]}"
|
88
90
|
puts "Shipping Company : #{data[:shipping_company]}"
|
89
91
|
puts "Tracking Number : #{data[:tracking_number]}"
|
@@ -99,10 +101,11 @@ module DJI
|
|
99
101
|
order_id: data[:order_number],
|
100
102
|
payment_status: data[:payment_status],
|
101
103
|
payment_total: data[:total],
|
104
|
+
shipping_country: data[:shipping_country],
|
102
105
|
shipping_status: data[:shipping_status],
|
103
106
|
shipping_company: data[:shipping_company],
|
104
107
|
tracking_number: data[:tracking_number],
|
105
|
-
dji_username: data[:dji_username]
|
108
|
+
dji_username: data[:dji_username],
|
106
109
|
}
|
107
110
|
}
|
108
111
|
|
data/lib/dji/version.rb
CHANGED