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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a45fe6db55a056b60b82fb1a8eb395ae82bb9841
4
- data.tar.gz: a885ab19d9994b807ea7cf6bfa5db8fa286a8b79
3
+ metadata.gz: 18de7fa01d13c5d98f38ab7cad4097ee955e5243
4
+ data.tar.gz: 3c72542e8ec311a68b3f5225e8b2ea5168be3c5b
5
5
  SHA512:
6
- metadata.gz: b7f2fab5ad4d46d504874b042102eceb0c5a2502e7d9631be1146e1ae774869444fe242707bf5a3d8e496c1f23aa38b9d6dd5e0ccef17b7d37bf8374eb403998
7
- data.tar.gz: 726745c89e6e990476be0dd75c71709ab022d81567a20dac65d2257bb3cb779e94e6d4d0412e1942baf510850c21c4d05348ebf1f081243fb735c1f5e5f3e46e
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(order_number: options[:order_number], phone_tail: options[:phone_tail], dji_username: options[:dji_username])
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(order_number: options[:order_number], phone_tail: options[:phone_tail], dji_username: options[:dji_username])
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
@@ -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
- # puts content
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]
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] = content.at_xpath('div[6]/a').text
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
 
@@ -1,3 +1,3 @@
1
1
  module DJI
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.4'
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.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Elliott