dji 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e2a5d2d495eeeaadd66d708f483a1db82642463
4
- data.tar.gz: 608dd161a829331acba3ac040471fd6a18ade786
3
+ metadata.gz: c817f271d8e53a310476c6c54055b322a7f589b3
4
+ data.tar.gz: dfafb133d12fd0de90eca90b77633201a42a2c14
5
5
  SHA512:
6
- metadata.gz: 23c77b9dbcf7027cef897adeb4ae74764aaf1900f45d6c74465a2f13fcd27793a06cccc50167f39ee62dffab4c3990bc13e43028355746a24faedf02ca3b20fa
7
- data.tar.gz: 482320f82bee5ac0a77e43716133e0b6a84a3ca754b224e3b3d84d56ee8d735de02edcde66ee5b94b82ca25a332a6bab5f4211a770dfc4fa3b6ebbc1d2d58e2a
6
+ metadata.gz: f0ef0f4ef7668a45e47489fc27d1b42539d72ad7f6778b2cbe07decc42f5d5142faf600cd5dba8a30c113583ea667c1ba5e621585b1437a20cac9110373057d6
7
+ data.tar.gz: 521bf639c382ea925f1affeedc84b7c281a9fc169e22a3ffb26d4cbdab3a04bd186e93d66808c9595669d09c359b8b0264258a59183eed719cc98de8d43c0072
data/README.md CHANGED
@@ -25,9 +25,20 @@ If you are on Ubuntu Linux, you can do:
25
25
 
26
26
  ## Usage
27
27
 
28
- ### Track an order
28
+ ### Order Tracking
29
29
 
30
- $ dji track -o ORDER_NUMBER -p PHONE_TAIL
30
+ ```
31
+ $ dji track [options]
32
+
33
+ OPTIONS:
34
+
35
+ -o, --order ORDER_NUMBER # Your order number
36
+ -p, --phone PHONE_TAIL # Last 4 digits of your phone number
37
+ -r, --repeat INTERVAL # Optional: Repat every INTERVAL seconds
38
+ --publish # Optional: Publish your order details to http://dji-track.herokuapp.com/orders
39
+ ```
40
+
41
+ #### Example: Track an order
31
42
 
32
43
  Use your order number in place of ORDER_NUMBER and the last 4 digits of your phone number for PHONE_TAIL. A full example might look like this:
33
44
 
@@ -42,6 +53,8 @@ Use your order number in place of ORDER_NUMBER and the last 4 digits of your pho
42
53
  Shipping Company : Tba
43
54
  Tracking Number :
44
55
 
56
+ #### Example: Track an order, every 60 seconds
57
+
45
58
  If you want this to repeat automatically at an interval, specify the option for repeat (either -r or --repeat) with the number of seconds. Do not use this nefariously, I suggest a reasonable interval such as 60 seconds, but more useful is probably around 300 seconds (5 minutes) to 600 seconds (10 minutes).
46
59
 
47
60
  $ dji track -o 123456789012 -p 1234 -r 60
@@ -67,6 +80,34 @@ If you want this to repeat automatically at an interval, specify the option for
67
80
  Shipping Company : Tba
68
81
  Tracking Number :
69
82
 
83
+ #### Example: Track an order, every 5 minutes, and publish details for others to see
84
+
85
+ $ dji track -o 123456789012 -p 1234 -r 300 --publish
86
+
87
+ ORDER TRACKING AS OF 2016-10-27 01:12:27 -0700
88
+ ------------------------------------------------------
89
+ Order Number : 123456789012
90
+ Total : USD $1,398.00
91
+ Payment Status : Pay Confirmed
92
+ Shipping Status : Pending
93
+ Shipping Company : Tba
94
+ Tracking Number :
95
+
96
+ You have successfully published your latest order status.
97
+ See order statuses reported by others at http://dji-track.herokuapp.com/orders
98
+
99
+ ORDER TRACKING AS OF 2016-10-27 01:17:28 -0700
100
+ ------------------------------------------------------
101
+ Order Number : 123456789012
102
+ Total : USD $1,398.00
103
+ Payment Status : Pay Confirmed
104
+ Shipping Status : Pending
105
+ Shipping Company : Tba
106
+ Tracking Number :
107
+
108
+ You have successfully published your latest order status.
109
+ See order statuses reported by others at http://dji-track.herokuapp.com/orders
110
+
70
111
  ### Search FedEx and track by reference
71
112
 
72
113
  If you think your shipper is FedEx but you don't have a tracking code yet, you might be able to find your shipment by
@@ -6,6 +6,7 @@ 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 :dji_username, required: false, aliases: [:username, :u]
9
10
 
10
11
  def track
11
12
  if options[:repeat].present?
@@ -14,12 +15,12 @@ module DJI
14
15
  puts "Requesting order tracking details every #{interval} seconds. Press CONTROL-C to stop..."
15
16
 
16
17
  while true
17
- data = DJI::OrderTracking.tracking_details(options[:order_number], options[:phone_tail])
18
+ data = DJI::OrderTracking.tracking_details(order_number: options[:order_number], phone_tail: options[:phone_tail], dji_username: options[:dji_username])
18
19
  DJI::OrderTracking.publish(data) if data.present? && options[:publish].present?
19
20
  sleep(interval)
20
21
  end
21
22
  else
22
- data = DJI::OrderTracking.tracking_details(options[:order_number], options[:phone_tail])
23
+ data = DJI::OrderTracking.tracking_details(order_number: options[:order_number], phone_tail: options[:phone_tail], dji_username: options[:dji_username])
23
24
  DJI::OrderTracking.publish(data) if data.present? && options[:publish].present?
24
25
  end
25
26
  end
@@ -24,11 +24,11 @@ module DJI
24
24
  end
25
25
 
26
26
  # Get the tracking details for an order
27
- def tracking_details(order_number, phone)
27
+ def tracking_details(options = {})
28
28
  auth_token = authenticity_token(tracking_url)
29
29
 
30
30
  url = URI.parse(tracking_url)
31
- params = { 'number' => order_number, 'phone_tail' => phone, 'utf8' => '✓' }
31
+ params = { 'number' => options[:order_number], 'phone_tail' => options[:phone_tail], 'utf8' => '✓' }
32
32
  params[auth_token[:param]] = auth_token[:token]
33
33
 
34
34
  headers = {
@@ -56,6 +56,8 @@ module DJI
56
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
58
  data[:tracking_number] = content.at_xpath('div[6]/a').text
59
+
60
+ data[:dji_username] = options[:dji_username] if options[:dji_username].present?
59
61
 
60
62
  print_tracking_details(data)
61
63
  data
@@ -78,12 +80,13 @@ module DJI
78
80
  puts
79
81
  puts "ORDER TRACKING AS OF #{now}"
80
82
  puts "------------------------------------------------------"
81
- puts "Order Number : #{data[:order_number]}"
82
- puts "Total : #{data[:total]}"
83
- puts "Payment Status : #{data[:payment_status]}"
84
- puts "Shipping Status : #{data[:shipping_status]}"
85
- puts "Shipping Company : #{data[:shipping_company]}"
86
- puts "Tracking Number : #{data[:tracking_number]}"
83
+ puts "DJI Forum Username : #{data[:dji_username]}" if data[:dji_username]
84
+ puts "Order Number : #{data[:order_number]}"
85
+ puts "Total : #{data[:total]}"
86
+ puts "Payment Status : #{data[:payment_status]}"
87
+ puts "Shipping Status : #{data[:shipping_status]}"
88
+ puts "Shipping Company : #{data[:shipping_company]}"
89
+ puts "Tracking Number : #{data[:tracking_number]}"
87
90
  puts
88
91
  end
89
92
 
@@ -97,7 +100,8 @@ module DJI
97
100
  payment_total: data[:total],
98
101
  shipping_status: data[:shipping_status],
99
102
  shipping_company: data[:shipping_company],
100
- tracking_number: data[:tracking_number]
103
+ tracking_number: data[:tracking_number],
104
+ dji_username: data[:dji_username]
101
105
  }
102
106
  }
103
107
 
@@ -122,8 +126,8 @@ module DJI
122
126
  end
123
127
 
124
128
  def publish_url
125
- #'http://localhost:3000/orders'
126
- 'http://dji-track.herokuapp.com/orders'
129
+ 'http://localhost:3000/orders'
130
+ #'http://dji-track.herokuapp.com/orders'
127
131
  end
128
132
 
129
133
  end
@@ -1,3 +1,3 @@
1
1
  module DJI
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dji
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Elliott