Class: Holivia::Commands::Enterprise

Inherits:
Base
  • Object
show all
Defined in:
lib/holivia/commands/enterprise.rb

Constant Summary collapse

BASE_PATH =
"/api/v1/backoffice/enterprises"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.route(args) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/holivia/commands/enterprise.rb', line 10

def self.route(args)
  subcommand = args.shift
  case subcommand
  when "index", "lookup", "search" then new.index(args)
  else warn "Unknown enterprise command: #{subcommand}"
       exit 1
  end
end

Instance Method Details

#index(args = []) ⇒ Object

rubocop:disable Metrics/AbcSize



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/holivia/commands/enterprise.rb', line 19

def index(args = []) # rubocop:disable Metrics/AbcSize
  params = {}
  OptionParser.new do |opts|
    opts.banner = "Usage: holivia enterprise index [options]"
    opts.on("--query TEXT") { |v| params[:query] = v }
    opts.on("--headquarter-id ID", Integer) { |v| params[:headquarter_id] = v }
    opts.on("--user-id ID", Integer) { |v| params[:user_id] = v }
    opts.on("--page N", Integer) { |v| params[:page] = v }
    opts.on("--per-page N", Integer) { |v| params[:per_page] = v }
  end.parse!(args)

  output(client.get(BASE_PATH, params: params))
end