Class: WeighflowCli::CliWeights
- Inherits:
-
Thor
- Object
- Thor
- WeighflowCli::CliWeights
- Includes:
- Rendering
- Defined in:
- lib/weighflow_cli/cli_weights.rb
Instance Method Summary collapse
- #create ⇒ Object
- #from_index(index_id) ⇒ Object
- #list ⇒ Object
- #template(index_id) ⇒ Object
- #void ⇒ Object
Methods included from Rendering
Instance Method Details
#create ⇒ Object
94 95 96 97 98 99 100 |
# File 'lib/weighflow_cli/cli_weights.rb', line 94 def create weight_params = JSON.parse(File.read([:file]), symbolize_names: true) puts weight_params (WeighflowCli.create_weight(params: weight_params), ) #options_renderer(options, options) end |
#from_index(index_id) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# 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: [:gross].to_i, tare_weight: [:tare].to_i, weighed_at: Time.now.round, certificate_number: [:certificate].to_s } (WeighflowCli.create_weight(params: weight_params), ) end |
#list ⇒ Object
62 63 64 |
# File 'lib/weighflow_cli/cli_weights.rb', line 62 def list (WeighflowCli.weights, ) end |
#template(index_id) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# 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}" } (weight_params, ) end |
#void ⇒ Object
106 107 108 |
# File 'lib/weighflow_cli/cli_weights.rb', line 106 def void (WeighflowCli.void_weight([:weight_id], [:reason]), ) end |