dji 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dji/fedex.rb +65 -11
- data/lib/dji/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d68f0ce20f2c80fa4383c208f6edfc614a3b97a9
|
4
|
+
data.tar.gz: f46f7d001d7a0f46891e477b72dc557bde47c82a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0813f17416a2ed6ddf5acc835a14c7fc76a42e58a77aca849a7d003da9d57e1473d83017d699ec01e72d292064891899d99c08e50e9c717d6fced0bd767d523b
|
7
|
+
data.tar.gz: 95b3fdc513d4b86ab863f62acf3c91e7465ad4d061ecaa12d05e639b7823c0ff9a8154d05f0f994d788678503b7aa6f04177dc676c1b99347f042158071a6eb5
|
data/lib/dji/fedex.rb
CHANGED
@@ -11,6 +11,70 @@ module DJI
|
|
11
11
|
|
12
12
|
class << self
|
13
13
|
|
14
|
+
def track(tracking_number)
|
15
|
+
uri = URI.parse(tracking_url_json)
|
16
|
+
|
17
|
+
params = {
|
18
|
+
'action' => 'trackpackages',
|
19
|
+
'locale' => 'en_US',
|
20
|
+
'version' => 1,
|
21
|
+
'format' => 'json'
|
22
|
+
}
|
23
|
+
params['data'] = {
|
24
|
+
'TrackPackagesRequest' => {
|
25
|
+
'appType' => 'WTRK',
|
26
|
+
'appDeviceType' => 'DESKTOP',
|
27
|
+
'uniqueKey' => '',
|
28
|
+
'processingParameters' => {},
|
29
|
+
'trackingInfoList' => [
|
30
|
+
{
|
31
|
+
'trackNumberInfo' => {
|
32
|
+
'trackingNumber' => tracking_number,
|
33
|
+
'trackingQualifier' => '',
|
34
|
+
'trackingCarrier' => ''
|
35
|
+
}
|
36
|
+
}
|
37
|
+
]
|
38
|
+
}
|
39
|
+
}.to_json
|
40
|
+
|
41
|
+
headers = {
|
42
|
+
'Content-Type' => 'application/x-www-form-urlencoded',
|
43
|
+
'Origin' => 'https://www.fedex.com/',
|
44
|
+
'Referer' => "#{tracking_url}?tracknumbers=#{tracking_number}",
|
45
|
+
'Accept' => '*/*',
|
46
|
+
'X-Requested-With' => 'XMLHttpRequest'
|
47
|
+
}
|
48
|
+
|
49
|
+
http = Net::HTTP.new uri.host, uri.port
|
50
|
+
http.use_ssl = true
|
51
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
52
|
+
request = Net::HTTP::Post.new uri.path, headers
|
53
|
+
request.set_form_data params
|
54
|
+
res = http.request(request)
|
55
|
+
|
56
|
+
case res
|
57
|
+
when Net::HTTPSuccess, Net::HTTPRedirection
|
58
|
+
# OK
|
59
|
+
# puts res.body
|
60
|
+
response = JSON.parse(res.body)['TrackPackagesResponse']
|
61
|
+
tpr = DJI::Fedex::TrackPackagesResponse.new_from_response(response)
|
62
|
+
|
63
|
+
data = { tracking_number: tracking_number }
|
64
|
+
if tpr.present?
|
65
|
+
data[:track_packages_response] = tpr
|
66
|
+
print_track_packages_response(data)
|
67
|
+
else
|
68
|
+
puts response
|
69
|
+
puts "Nothing parsed!"
|
70
|
+
end
|
71
|
+
else
|
72
|
+
puts res.inspect
|
73
|
+
res.error!
|
74
|
+
end
|
75
|
+
|
76
|
+
end
|
77
|
+
|
14
78
|
# Get the tracking details for an order
|
15
79
|
def tracking_details(country, postal_code)
|
16
80
|
uri = URI.parse(tracking_url)
|
@@ -121,17 +185,7 @@ module DJI
|
|
121
185
|
puts response
|
122
186
|
puts "Nothing parsed!"
|
123
187
|
end
|
124
|
-
|
125
|
-
# 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]')
|
126
|
-
# # puts content
|
127
|
-
# data = {}
|
128
|
-
# data[:order_number] = content.at_xpath('div[1]').text.split(' ')[-1]
|
129
|
-
# data[:total] = content.at_xpath('div[2]').text.split(' ')[1..-1].join(' ')
|
130
|
-
# data[:payment_status] = content.at_xpath('div[3]').text.split(': ')[1]
|
131
|
-
# data[:shipping_status] = content.at_xpath('div[4]').text.split(': ')[1]
|
132
|
-
# data[:shipping_company] = content.at_xpath('div[5]/span').text
|
133
|
-
# data[:tracking_number] = content.at_xpath('div[6]/a').text
|
134
|
-
|
188
|
+
|
135
189
|
# print_tracking_details(data)
|
136
190
|
else
|
137
191
|
puts res.inspect
|
data/lib/dji/version.rb
CHANGED
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.
|
4
|
+
version: 0.7.0
|
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
|
+
date: 2016-11-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|