Class: BooticCli::Commands::Orders

Inherits:
BooticCli::Command show all
Defined in:
lib/bootic_cli/commands/orders.rb

Defined Under Namespace

Classes: OrdersTable

Constant Summary collapse

MAPPERS =
{
  'table' => OrdersTable,
  'csv' => OrdersTable,
  'json' => ->(orders) { orders.to_hash }
}

Constants included from BooticCli::Connectivity

BooticCli::Connectivity::DEFAULT_ENV

Instance Method Summary collapse

Methods inherited from BooticCli::Command

declare, #help

Instance Method Details

#listObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/bootic_cli/commands/orders.rb', line 58

def list
  logged_in_action do
    opts = {}
    opts[:status] = options['s'] if options['s']
    opts[:q] = options['q'] if options['q']
    opts[:sort] = options['so'] if options['so']
    opts[:updated_on_gte] = options['ugte'] if options['ugte']
    opts[:updated_on_lte] = options['ulte'] if options['ugte']
    opts[:total_gte] = options['tgte'] if options['tgte']
    opts[:total_lte] = options['tlte'] if options['tlte']
    opts[:discount_total_gte] = options['dgte'] if options['dgte']
    opts[:discount_total_lte] = options['dlte'] if options['dlte']
    opts[:code] = options['c'] if options['c']

    orders = shop.orders(opts)
    orders = orders.full_set if options[:a]
    puts Formatters.format(options['o'], MAPPERS[options['o']].call(orders))
  end
end