mge_wholesale 3.0.0 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/README.md +14 -0
- data/lib/mge_wholesale.rb +1 -0
- data/lib/mge_wholesale/base.rb +2 -2
- data/lib/mge_wholesale/tracking.rb +40 -0
- data/lib/mge_wholesale/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: fbebb0dfe087167de9ec8ce78571e8bfe128ab31
|
4
|
+
data.tar.gz: b073aef3d68b8b17af1e29de66bae087157fefbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5aca7dfed8100237dfd50d616f59efa7e2dcd2c4f5de5f6fe86823f78182d15d510c9e20ad4fdc25836f089d8f61006024c19ff0be7fdfbfd0b8b149ec7478f6
|
7
|
+
data.tar.gz: b8f437d4d4163c9d5cb2eeed64ff097ed5ef38ecf812a1f141dd616cc85039e2460743f5b8b1912d1b1be5d0dc92aaa4c71be21324019e0bc28cc3144166519e
|
data/README.md
CHANGED
@@ -119,6 +119,20 @@ order.submit!
|
|
119
119
|
|
120
120
|
See `MgeWholesale::Order` for details on required options.
|
121
121
|
|
122
|
+
### MgeWholesale::Tracking
|
123
|
+
|
124
|
+
For fetching tracking data for individual order fulfillments.
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
tracking_details = MgeWholesale::Tracking.fetch_data(options)
|
128
|
+
|
129
|
+
# [
|
130
|
+
# {:po_number=>"12345", :carrier=>"UPS", :tracking_numbers=>['123456789']},
|
131
|
+
# {:po_number=>"54321", :carrier=>"UPS", :tracking_numbers=>['987654321']},
|
132
|
+
# ...,
|
133
|
+
# ]
|
134
|
+
```
|
135
|
+
|
122
136
|
## Development
|
123
137
|
|
124
138
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/mge_wholesale.rb
CHANGED
data/lib/mge_wholesale/base.rb
CHANGED
@@ -48,12 +48,12 @@ module MgeWholesale
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
def get_file(filename)
|
51
|
+
def get_file(filename, file_directory = nil)
|
52
52
|
connect(@options) do |ftp|
|
53
53
|
begin
|
54
54
|
tempfile = Tempfile.new
|
55
55
|
|
56
|
-
ftp.chdir(MgeWholesale.config.top_level_dir)
|
56
|
+
ftp.chdir(file_directory || MgeWholesale.config.top_level_dir)
|
57
57
|
ftp.getbinaryfile(filename, tempfile.path)
|
58
58
|
|
59
59
|
tempfile
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module MgeWholesale
|
2
|
+
class Tracking < Base
|
3
|
+
|
4
|
+
BASE_TRACKING_FILE_DIRECTORY = "%s-TRACK".freeze
|
5
|
+
BASE_TRACKING_FILE_NAME = "%s_PackageTracking.csv".freeze
|
6
|
+
CARRIER = 'UPS'.freeze
|
7
|
+
|
8
|
+
def initialize(options = {})
|
9
|
+
requires!(options, :username, :password, :dealer_number)
|
10
|
+
|
11
|
+
@options = options
|
12
|
+
@dealer_number = options[:dealer_number]
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.fetch_data(options = {})
|
16
|
+
requires!(options, :username, :password, :dealer_number)
|
17
|
+
|
18
|
+
new(options).fetch_data
|
19
|
+
end
|
20
|
+
|
21
|
+
def fetch_data
|
22
|
+
tracking_file_name = BASE_TRACKING_FILE_NAME % @dealer_number
|
23
|
+
tracking_file_directory = BASE_TRACKING_FILE_DIRECTORY % @dealer_number
|
24
|
+
tracking_file = get_file(tracking_file_name, tracking_file_directory)
|
25
|
+
|
26
|
+
tracking_details = CSV.foreach(tracking_file, { headers: :first_row }).map do |row|
|
27
|
+
{
|
28
|
+
po_number: row['USR_VEND_ORD_NO'],
|
29
|
+
carrier: CARRIER,
|
30
|
+
tracking_numbers: [row['TRK_NO_1'], row['TRK_NO_2'], row['TRK_NO_3'], row['TRK_NO_4'], row['TRK_NO_5']].reject(&:blank?),
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
tracking_file.unlink
|
35
|
+
|
36
|
+
tracking_details
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mge_wholesale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ken Ebling
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-07-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -105,6 +105,7 @@ files:
|
|
105
105
|
- lib/mge_wholesale/category.rb
|
106
106
|
- lib/mge_wholesale/inventory.rb
|
107
107
|
- lib/mge_wholesale/order.rb
|
108
|
+
- lib/mge_wholesale/tracking.rb
|
108
109
|
- lib/mge_wholesale/user.rb
|
109
110
|
- lib/mge_wholesale/version.rb
|
110
111
|
- mge_wholesale.gemspec
|
@@ -128,7 +129,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
128
129
|
version: '0'
|
129
130
|
requirements: []
|
130
131
|
rubyforge_project:
|
131
|
-
rubygems_version: 2.
|
132
|
+
rubygems_version: 2.6.14
|
132
133
|
signing_key:
|
133
134
|
specification_version: 4
|
134
135
|
summary: Ruby library for MGE Wholesale
|