module WeighflowCli

Constants

Configuration
ROOT_PATH
VERSION

Public Class Methods

client() click to toggle source

Creates an instance of the API client lib for direct access to the api

# File lib/weighflow_cli.rb, line 70
def self.client    
  @client ||= Client.new(configuration)  
end
configuration() { |configuration| ... } click to toggle source

This can be used to set the secret and url for api credentials this setting can be done at the console, via

weighflow_cli login

or through in code if using the gem within your own code by supplying a block and passing in the credientials.

# File lib/weighflow_cli.rb, line 58
def self.configuration
 if block_given?
   configuration = Configuration.new
   yield(configuration)      
   @config = configuration.to_h
 end      
 @config ||= Credentials.load_config!    
end
create_weight(params: {}) click to toggle source
# File lib/weighflow_cli.rb, line 101
def self.create_weight(params: {})
  client.create_weight(params: params)
end
data_path() click to toggle source

Provide an override to relocate data directory

# File lib/weighflow_cli.rb, line 35
def self.data_path     
  return @data_path if defined?(@data_path)
  @data_path ||= ENV.fetch('WEIGHFLOW_CLI_PATH') { File.join(WeighflowCli::ROOT_PATH, 'data') }
  ensure_data_path
  @data_path
end
ensure_data_path() click to toggle source

Ensure data path

# File lib/weighflow_cli.rb, line 44
def self.ensure_data_path
  Dir.mkdir(data_path) unless Dir.exists?(data_path)
end
find_order(external_id) click to toggle source

Find a specific order based on the external_id given withing the orders + Helps to pull order details when needed.

# File lib/weighflow_cli.rb, line 87
def self.find_order(external_id)
  WeighflowCli::OrderHandler.find_order(external_id)
end
list(indexes_only: false) click to toggle source
# File lib/weighflow_cli.rb, line 92
def self.list(indexes_only: false)
  WeighflowCli::OrderHandler.list(indexes_only: indexes_only)
end
pull() click to toggle source

Pull down the orders and store in the local repository data path

  • This is used to management order changes

# File lib/weighflow_cli.rb, line 79
def self.pull
  WeighflowCli::OrderHandler.pull
end
void_weight(weight_id, reason) click to toggle source
# File lib/weighflow_cli.rb, line 105
def self.void_weight(weight_id, reason)
  client.void_weight(weight_id, reason)
end
weights() click to toggle source
# File lib/weighflow_cli.rb, line 96
def self.weights
  client.weights
end