dji 0.7.2 → 0.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6160e5fe35970046f9d1720dcb4f5201813c5b2e
4
- data.tar.gz: fcc4ec9df200a7b34f2c26a06c99c59dd2aff780
3
+ metadata.gz: 9dc6efd18b9adfd31bd9ba9b43fa021f1e3ab0fc
4
+ data.tar.gz: 9ce0895b190909d224f92427f0ac8856155ca4e8
5
5
  SHA512:
6
- metadata.gz: 6509d5beaf6b45e7fbe1397d4f30b022c22cad4a983b9b8fc301d8dadce66b19c894bc2b97eb282dc557278cd9347f45ad4337479a1360691277f76dbae13e70
7
- data.tar.gz: 59be3eb0de717d8ec3913b1b737af47b0145cf4a9d953973866df43e068ada7472d6a1fab3ce5336e9fc8de1f683ec7dd8391fcebbf722f1c46eac9e5e2bdebd
6
+ metadata.gz: 2ebecfb6548532f2261eeb3d7916966bbbfbf19df882349458ea161b2fa493b4b6381d2c16a38171f9e7f68f323eedad5541647a6f6aea55ac8fb29b5e02fe49
7
+ data.tar.gz: 5e559b1cb3b36472ffbffa6a3d437843c5657c33435232d454ea565ec32f966b5df62cf60bade092abf5b1fa79b3daf49bdaafd32923445a1e38ef67a249611b
@@ -9,11 +9,16 @@ module DJI
9
9
 
10
10
  class << self
11
11
 
12
+ # The URL for order tracking
13
+ def tracking_url
14
+ 'http://m.dji.com/orders/tracking'
15
+ end
16
+
12
17
  # Retrieve an authenticity_token
13
18
  def authenticity_token(url, options = {})
14
19
  uri = URI(url)
15
20
  http = Net::HTTP.new uri.host, uri.port
16
- request = Net::HTTP::Get.new uri.path
21
+ request = Net::HTTP::Get.new "#{uri.path}?www=v1"
17
22
  response = http.request request
18
23
 
19
24
  if options[:debug].present?
@@ -36,13 +41,13 @@ module DJI
36
41
  auth_token = authenticity_token(tracking_url, options)
37
42
 
38
43
  url = URI.parse(tracking_url)
39
- params = { 'number' => options[:order_number], 'phone_tail' => options[:phone_tail], 'utf8' => '✓' }
44
+ params = { 'www' => 'v1', 'number' => options[:order_number], 'phone_tail' => options[:phone_tail] }
40
45
  params[auth_token[:param]] = auth_token[:token]
41
46
 
42
47
  headers = {
43
48
  'Content-Type' => 'application/x-www-form-urlencoded',
44
49
  'Cookie' => auth_token[:cookie],
45
- 'Origin' => 'http://store.dji.com',
50
+ 'Origin' => 'http://m.dji.com',
46
51
  'Referer' => tracking_url
47
52
  }
48
53
 
@@ -62,23 +67,24 @@ module DJI
62
67
  when Net::HTTPSuccess, Net::HTTPRedirection
63
68
  # OK
64
69
  page = Nokogiri::HTML(response.body)
65
- 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]')
66
-
70
+
71
+ content = page.at_xpath('//div[@id="custom-info"]/div[@class="order-tracking"]')
72
+
67
73
  if content.text.blank? || content.text.include?('Sorry, record not found.')
68
74
  puts "Order #{options[:order_number]}/#{options[:phone_tail]} not found!" if options[:output]
69
75
  else
70
76
  data = {}
71
- data[:order_number] = content.at_xpath('div[1]').text.split(' ')[-1]
72
- data[:total] = content.at_xpath('div[2]').text.split(' ')[1..-1].join(' ')
73
- data[:payment_status] = content.at_xpath('div[3]').text.split(': ')[1]
74
- data[:shipping_status] = content.at_xpath('div[4]').text.split(': ')[1]
75
- data[:shipping_company] = if content.at_xpath('div[5]/span').present?
76
- content.at_xpath('div[5]/span').text
77
+ data[:order_number] = content.at_xpath('p[1]').text.split(' ')[-1]
78
+ data[:total] = content.at_xpath('p[2]').text.split(' ')[1..-1].join(' ')
79
+ data[:payment_status] = content.at_xpath('p[3]').text.split(': ')[1]
80
+ data[:shipping_status] = content.at_xpath('p[4]').text.split(': ')[1]
81
+ data[:shipping_company] = if content.at_xpath('p[5]/span').present?
82
+ content.at_xpath('p[5]/span').text
77
83
  else
78
84
  'Tba'
79
85
  end
80
- data[:tracking_number] = if content.at_xpath('div[6]/a').present?
81
- content.at_xpath('div[6]/a').text
86
+ data[:tracking_number] = if content.at_xpath('p[6]/a').present?
87
+ content.at_xpath('p[6]/a').text
82
88
  else
83
89
  nil
84
90
  end
@@ -102,11 +108,6 @@ module DJI
102
108
  data
103
109
  end
104
110
 
105
- # The URL for order tracking
106
- def tracking_url
107
- 'http://store.dji.com/orders/tracking'
108
- end
109
-
110
111
  def print_tracking_details(data)
111
112
  now = Time.now.to_s
112
113
 
@@ -1,3 +1,3 @@
1
1
  module DJI
2
- VERSION = '0.7.2'
2
+ VERSION = '0.7.3'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dji
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Elliott
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-11 00:00:00.000000000 Z
11
+ date: 2016-11-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport