dji 0.5.0 → 0.5.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: 89bee1947fd5fb1fd18d6ff55bc7df1a3ab40221
4
- data.tar.gz: a764b6f12a17fea87e8cab0f55ec3bbf8479d3a5
3
+ metadata.gz: c82fd8c61b70c5a7b5980b388726aae3b8ac92dc
4
+ data.tar.gz: 40a0a18edb195b887ee85bf3d4abbdd913c28380
5
5
  SHA512:
6
- metadata.gz: 9b7ebbf6aa341c2c271609ec34bb547f144a3b1a192e9fd6f0e768974f2bccd7c3891a3d0277e2870c211300760e237907dd21465cda69d8edeecd3b68bd90ed
7
- data.tar.gz: c573eda472a8b359c21321685eb57a2fe4e5c2d35875de4047d079af28c5cb2336d2c8d02dbd91e20bd8438bc28ddf36b8001f48e77757b23870917b3886cc25
6
+ metadata.gz: eaad2ed22058032b63f701dafcde2255e220ce4d61e3a74c4fc46bb5f89f1605f1c058884cf6c08fbb5b815b2ef2381d5cb7cdb3576c8ebfbfa8b7ea02300d84
7
+ data.tar.gz: 5e524a3f7028e8b004ee127b3b623406f1f8858e3e0dddb6a2ddfc6a554a48437223c7ceff50ffa14256d05804ab7ccb96ff812628ea20e497fe2a13266eb86b
@@ -64,22 +64,27 @@ module DJI
64
64
  page = Nokogiri::HTML(response.body)
65
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
66
 
67
- data = {}
68
- data[:order_number] = content.at_xpath('div[1]').text.split(' ')[-1]
69
- data[:total] = content.at_xpath('div[2]').text.split(' ')[1..-1].join(' ')
70
- data[:payment_status] = content.at_xpath('div[3]').text.split(': ')[1]
71
- data[:shipping_status] = content.at_xpath('div[4]').text.split(': ')[1]
72
- data[:shipping_company] = content.at_xpath('div[5]/span').text
73
- data[:tracking_number] = content.at_xpath('div[6]/a').text
74
-
75
- data[:debug] = options[:debug] if options[:debug].present?
76
- data[:dji_username] = options[:dji_username] if options[:dji_username].present?
77
- data[:email_address] = options[:email_address] if options[:email_address].present?
78
- data[:phone_tail] = options[:phone_tail]
79
- data[:order_time] = options[:order_time] if options[:order_time].present?
80
- data[:shipping_country] = options[:country] if options[:country].present?
81
-
82
- print_tracking_details(data)
67
+ if content.text.blank? || content.text.include?('Sorry, record not found.')
68
+ puts "Order #{options[:order_number]}/#{options[:phone_tail]} not found!"
69
+ else
70
+ 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] = content.at_xpath('div[5]/span').text
76
+ data[:tracking_number] = content.at_xpath('div[6]/a').text
77
+
78
+ data[:debug] = options[:debug] if options[:debug].present?
79
+ data[:dji_username] = options[:dji_username] if options[:dji_username].present?
80
+ data[:email_address] = options[:email_address] if options[:email_address].present?
81
+ data[:phone_tail] = options[:phone_tail] if options[:phone_tail].present?
82
+ data[:order_time] = options[:order_time] if options[:order_time].present?
83
+ data[:shipping_country] = options[:country] if options[:country].present?
84
+
85
+ print_tracking_details(data)
86
+ end
87
+
83
88
  data
84
89
  else
85
90
  puts "There was an error: #{response.message}"
data/lib/dji/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module DJI
2
- VERSION = '0.5.0'
2
+ VERSION = '0.5.1'
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.5.0
4
+ version: 0.5.1
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-10-30 00:00:00.000000000 Z
11
+ date: 2016-10-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport