class WeighflowCli::CliWeights
Public Instance Methods
create()
click to toggle source
# File lib/weighflow_cli/cli_weights.rb, line 94 def create weight_params = JSON.parse(File.read(options[:file]), symbolize_names: true) puts weight_params options_renderer(WeighflowCli.create_weight(params: weight_params), options) #options_renderer(options, options) end
from_index(index_id)
click to toggle source
# File lib/weighflow_cli/cli_weights.rb, line 11 def from_index(index_id) raise 'index_id required' unless index_id index = WeighflowCli.find_order(index_id) raise 'index not found for id' unless index && index.data # # parse external id parts order_type, transport, io, location, order_num, lin = index.data[:external_unique_id].to_s.split('-') # # correct for diff in type between order and weight processor order_type = 'Inventory' if order_type == 'BulkInventory' # weight_params = { io: index.data[:i_o], order_id: index.data[:order_id], order_type: order_type, gross_weight: options[:gross].to_i, tare_weight: options[:tare].to_i, weighed_at: Time.now.round, certificate_number: options[:certificate].to_s } options_renderer(WeighflowCli.create_weight(params: weight_params), options) end
list()
click to toggle source
# File lib/weighflow_cli/cli_weights.rb, line 62 def list options_renderer(WeighflowCli.weights, options) end
template(index_id)
click to toggle source
# File lib/weighflow_cli/cli_weights.rb, line 37 def template(index_id) aise 'index_id required' unless index_id index = WeighflowCli.find_order(index_id) raise 'index not found for id' unless index && index.data # # parse external id parts order_type, transport, io, location, order_num, lin = index.data[:external_unique_id].to_s.split('-') # # correct for diff in type between order and weight processor order_type = 'Inventory' if order_type == 'BulkInventory' # weight_params = { io: index.data[:i_o], order_id: index.data[:order_id], order_type: order_type, gross_weight: 0, tare_weight: 0, weighed_at: Time.now.round, certificate_number: "{cert number}" } options_renderer(weight_params, options) end
void()
click to toggle source
# File lib/weighflow_cli/cli_weights.rb, line 106 def void options_renderer(WeighflowCli.void_weight(options[:weight_id], options[:reason]), options) end