weighflow_cli 0.2.6 → 0.2.7
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 +4 -4
- data/Gemfile.lock +1 -1
- data/exe/weighflow_cli +2 -1
- data/lib/weighflow_cli.rb +1 -0
- data/lib/weighflow_cli/cli.rb +6 -123
- data/lib/weighflow_cli/cli_weights.rb +111 -0
- data/lib/weighflow_cli/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 963cc22724b95f0392a78886af4db5615247fac9c6f2df3d3fe7012b9ff4f5a3
|
4
|
+
data.tar.gz: 6408e424292209cbaada4f62718a380d4e7052ccb9aadcdf3548e63ed0a7932f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0db4c48496094db993dd0ea24bd9452e5e61ab2894f406fd2e935030ba5707665ff9a8b86a06425f720dc241b623d0115e80569e34a803703ab3f52b105bce16
|
7
|
+
data.tar.gz: 6ef4ce49145d58247a5230b3229ef45da023a8abebbd65424e6dfcc01e6e30afb5c6932770bda3971c760e08c6af5c7acadf0ece59a9ce6e97ce990f78affcda
|
data/Gemfile.lock
CHANGED
data/exe/weighflow_cli
CHANGED
data/lib/weighflow_cli.rb
CHANGED
@@ -6,6 +6,7 @@ require 'httparty'
|
|
6
6
|
require_relative "weighflow_cli/version"
|
7
7
|
require_relative 'weighflow_cli/rendering'
|
8
8
|
require_relative 'weighflow_cli/client'
|
9
|
+
#require_relative 'weighflow_cli/cli_weights'
|
9
10
|
require_relative 'weighflow_cli/cli'
|
10
11
|
require_relative 'weighflow_cli/credentials'
|
11
12
|
require_relative 'weighflow_cli/order_handler'
|
data/lib/weighflow_cli/cli.rb
CHANGED
@@ -1,123 +1,18 @@
|
|
1
|
-
|
1
|
+
require_relative 'cli_weights'
|
2
2
|
|
3
3
|
module WeighflowCli
|
4
4
|
|
5
|
-
|
5
|
+
|
6
|
+
class Cli < Thor
|
6
7
|
include Rendering
|
7
8
|
|
8
|
-
desc 'from_index [INDEX ID]', 'create weight from index'
|
9
|
-
#option :index, required: true, banner: 'ie. CommodityOrder-T-I-002-3340455-01'
|
10
|
-
option :gross, aliases: '-g', type: :numeric, required: true
|
11
|
-
option :tare, aliases: '-t', type: :numeric, required: true
|
12
|
-
option :certificate, aliases: '-c', required: true
|
13
|
-
def from_index(index_id)
|
14
|
-
raise 'index_id required' unless index_id
|
15
|
-
index = WeighflowCli.find_order(index_id)
|
16
|
-
raise 'index not found for id' unless index && index.data
|
17
|
-
#
|
18
|
-
# parse external id parts
|
19
|
-
order_type, transport, io, location, order_num, lin = index.data[:external_unique_id].to_s.split('-')
|
20
|
-
#
|
21
|
-
# correct for diff in type between order and weight processor
|
22
|
-
order_type = 'Inventory' if order_type == 'BulkInventory'
|
23
|
-
#
|
24
|
-
weight_params = {
|
25
|
-
io: index.data[:i_o],
|
26
|
-
order_id: index.data[:order_id],
|
27
|
-
order_type: order_type,
|
28
|
-
gross_weight: options[:gross].to_i,
|
29
|
-
tare_weight: options[:tare].to_i,
|
30
|
-
weighed_at: Time.now.round,
|
31
|
-
certificate_number: options[:certificate].to_s
|
32
|
-
}
|
33
|
-
|
34
|
-
options_renderer(WeighflowCli.create_weight(params: weight_params), options)
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
desc 'template [INDEX_ID]', 'create weight template'
|
39
|
-
def template(index_id)
|
40
|
-
aise 'index_id required' unless index_id
|
41
|
-
index = WeighflowCli.find_order(index_id)
|
42
|
-
raise 'index not found for id' unless index && index.data
|
43
|
-
#
|
44
|
-
# parse external id parts
|
45
|
-
order_type, transport, io, location, order_num, lin = index.data[:external_unique_id].to_s.split('-')
|
46
|
-
#
|
47
|
-
# correct for diff in type between order and weight processor
|
48
|
-
order_type = 'Inventory' if order_type == 'BulkInventory'
|
49
|
-
#
|
50
|
-
weight_params = {
|
51
|
-
io: index.data[:i_o],
|
52
|
-
order_id: index.data[:order_id],
|
53
|
-
order_type: order_type,
|
54
|
-
gross_weight: 0,
|
55
|
-
tare_weight: 0,
|
56
|
-
weighed_at: Time.now.round,
|
57
|
-
certificate_number: "{cert number}"
|
58
|
-
}
|
59
|
-
options_renderer(weight_params, options)
|
60
|
-
end
|
61
|
-
|
62
|
-
|
63
|
-
desc 'list', 'List weights within the last 24 hours'
|
64
|
-
def list
|
65
|
-
options_renderer(WeighflowCli.weights, options)
|
66
|
-
end
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
desc 'create', 'Create a weight given an order'
|
71
|
-
long_desc <<~DESC
|
72
|
-
|
73
|
-
weighflow_cli --file weight.json
|
74
|
-
|
75
|
-
This file should contain a minimum of :
|
76
|
-
|
77
|
-
{
|
78
|
-
order_type: "Commodity",
|
79
|
-
io: "O",
|
80
|
-
order_id: "{integer}",
|
81
|
-
gross_weight: "75000",
|
82
|
-
tare_weight: "25444",
|
83
|
-
weighed_at: "2021-02-26 10:15:41 am",
|
84
|
-
release_number: "",
|
85
|
-
truck_license_number: "",
|
86
|
-
trailer1_license_number: "",
|
87
|
-
trailer2_license_number: "",
|
88
|
-
truck_number: "",
|
89
|
-
driver_name: "",
|
90
|
-
driver_number: ""
|
91
|
-
}
|
92
|
-
|
93
|
-
--
|
94
|
-
DESC
|
95
|
-
option :file, aliases: '-f', required: true, banner: '[File name] json format'
|
96
|
-
def create
|
97
|
-
weight_params = JSON.parse(File.read(options[:file]), symbolize_names: true)
|
98
|
-
puts weight_params
|
99
|
-
|
100
|
-
options_renderer(WeighflowCli.create_weight(params: weight_params), options)
|
101
|
-
#options_renderer(options, options)
|
102
|
-
end
|
103
|
-
|
104
|
-
|
105
|
-
desc 'void', 'Voided a weight within 24 hours'
|
106
|
-
option :weight_id, required: true
|
107
|
-
option :reason, required: true
|
108
|
-
def void
|
109
|
-
options_renderer(WeighflowCli.void_weight(options[:weight_id], options[:reason]), options)
|
110
|
-
end
|
111
9
|
|
112
|
-
end
|
113
10
|
|
114
|
-
class Cli < Thor
|
115
|
-
include Rendering
|
116
11
|
package_name "WeighflowCli"
|
117
12
|
class_option :yaml, type: :boolean
|
118
13
|
|
119
14
|
desc 'weights', 'weights commands'
|
120
|
-
subcommand 'weights',
|
15
|
+
subcommand 'weights', CliWeights
|
121
16
|
|
122
17
|
def self.exit_on_failure?
|
123
18
|
false
|
@@ -139,17 +34,13 @@
|
|
139
34
|
def login
|
140
35
|
Credentials.login
|
141
36
|
end
|
142
|
-
|
143
|
-
|
144
|
-
|
37
|
+
|
145
38
|
|
146
39
|
desc "pull", "Pull Orders from Weighflow"
|
147
40
|
def pull
|
148
41
|
options_renderer(WeighflowCli.pull, options)
|
149
42
|
end
|
150
|
-
|
151
|
-
|
152
|
-
|
43
|
+
|
153
44
|
|
154
45
|
desc 'list', "List currently pulled orders"
|
155
46
|
def list
|
@@ -160,14 +51,6 @@
|
|
160
51
|
def indexes
|
161
52
|
options_renderer(WeighflowCli.list(indexes_only: true), options)
|
162
53
|
end
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
54
|
|
172
55
|
|
173
56
|
desc 'find_order', 'Find order details'
|
@@ -0,0 +1,111 @@
|
|
1
|
+
|
2
|
+
module WeighflowCli
|
3
|
+
class CliWeights < Thor
|
4
|
+
include Rendering
|
5
|
+
|
6
|
+
desc 'from_index [INDEX ID]', 'create weight from index'
|
7
|
+
#option :index, required: true, banner: 'ie. CommodityOrder-T-I-002-3340455-01'
|
8
|
+
option :gross, aliases: '-g', type: :numeric, required: true
|
9
|
+
option :tare, aliases: '-t', type: :numeric, required: true
|
10
|
+
option :certificate, aliases: '-c', required: true
|
11
|
+
def from_index(index_id)
|
12
|
+
raise 'index_id required' unless index_id
|
13
|
+
index = WeighflowCli.find_order(index_id)
|
14
|
+
raise 'index not found for id' unless index && index.data
|
15
|
+
#
|
16
|
+
# parse external id parts
|
17
|
+
order_type, transport, io, location, order_num, lin = index.data[:external_unique_id].to_s.split('-')
|
18
|
+
#
|
19
|
+
# correct for diff in type between order and weight processor
|
20
|
+
order_type = 'Inventory' if order_type == 'BulkInventory'
|
21
|
+
#
|
22
|
+
weight_params = {
|
23
|
+
io: index.data[:i_o],
|
24
|
+
order_id: index.data[:order_id],
|
25
|
+
order_type: order_type,
|
26
|
+
gross_weight: options[:gross].to_i,
|
27
|
+
tare_weight: options[:tare].to_i,
|
28
|
+
weighed_at: Time.now.round,
|
29
|
+
certificate_number: options[:certificate].to_s
|
30
|
+
}
|
31
|
+
|
32
|
+
options_renderer(WeighflowCli.create_weight(params: weight_params), options)
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
desc 'template [INDEX_ID]', 'create weight template'
|
37
|
+
def template(index_id)
|
38
|
+
aise 'index_id required' unless index_id
|
39
|
+
index = WeighflowCli.find_order(index_id)
|
40
|
+
raise 'index not found for id' unless index && index.data
|
41
|
+
#
|
42
|
+
# parse external id parts
|
43
|
+
order_type, transport, io, location, order_num, lin = index.data[:external_unique_id].to_s.split('-')
|
44
|
+
#
|
45
|
+
# correct for diff in type between order and weight processor
|
46
|
+
order_type = 'Inventory' if order_type == 'BulkInventory'
|
47
|
+
#
|
48
|
+
weight_params = {
|
49
|
+
io: index.data[:i_o],
|
50
|
+
order_id: index.data[:order_id],
|
51
|
+
order_type: order_type,
|
52
|
+
gross_weight: 0,
|
53
|
+
tare_weight: 0,
|
54
|
+
weighed_at: Time.now.round,
|
55
|
+
certificate_number: "{cert number}"
|
56
|
+
}
|
57
|
+
options_renderer(weight_params, options)
|
58
|
+
end
|
59
|
+
|
60
|
+
|
61
|
+
desc 'list', 'List weights within the last 24 hours'
|
62
|
+
def list
|
63
|
+
options_renderer(WeighflowCli.weights, options)
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
desc 'create', 'Create a weight given an order'
|
69
|
+
long_desc <<~DESC
|
70
|
+
|
71
|
+
weighflow_cli --file weight.json
|
72
|
+
|
73
|
+
This file should contain a minimum of :
|
74
|
+
|
75
|
+
{
|
76
|
+
order_type: "Commodity",
|
77
|
+
io: "O",
|
78
|
+
order_id: "{integer}",
|
79
|
+
gross_weight: "75000",
|
80
|
+
tare_weight: "25444",
|
81
|
+
weighed_at: "2021-02-26 10:15:41 am",
|
82
|
+
release_number: "",
|
83
|
+
truck_license_number: "",
|
84
|
+
trailer1_license_number: "",
|
85
|
+
trailer2_license_number: "",
|
86
|
+
truck_number: "",
|
87
|
+
driver_name: "",
|
88
|
+
driver_number: ""
|
89
|
+
}
|
90
|
+
|
91
|
+
--
|
92
|
+
DESC
|
93
|
+
option :file, aliases: '-f', required: true, banner: '[File name] json format'
|
94
|
+
def create
|
95
|
+
weight_params = JSON.parse(File.read(options[:file]), symbolize_names: true)
|
96
|
+
puts weight_params
|
97
|
+
|
98
|
+
options_renderer(WeighflowCli.create_weight(params: weight_params), options)
|
99
|
+
#options_renderer(options, options)
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
desc 'void', 'Voided a weight within 24 hours'
|
104
|
+
option :weight_id, required: true
|
105
|
+
option :reason, required: true
|
106
|
+
def void
|
107
|
+
options_renderer(WeighflowCli.void_weight(options[:weight_id], options[:reason]), options)
|
108
|
+
end
|
109
|
+
|
110
|
+
end
|
111
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weighflow_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruce Martin
|
@@ -60,6 +60,7 @@ files:
|
|
60
60
|
- exe/weighflow_cli
|
61
61
|
- lib/weighflow_cli.rb
|
62
62
|
- lib/weighflow_cli/cli.rb
|
63
|
+
- lib/weighflow_cli/cli_weights.rb
|
63
64
|
- lib/weighflow_cli/client.rb
|
64
65
|
- lib/weighflow_cli/credentials.rb
|
65
66
|
- lib/weighflow_cli/order_handler.rb
|