Class: Holivia::Commands::Format
- Defined in:
- lib/holivia/commands/format.rb
Constant Summary collapse
- BASE_PATH =
"/api/v1/backoffice/content_formats"
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.route(args) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/holivia/commands/format.rb', line 10 def self.route(args) subcommand = args.shift case subcommand when "create" then new.create(args) when "update" then new.update(args) else warn "Unknown selfcare format command: #{subcommand}" exit 1 end end |
Instance Method Details
#create(args = []) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/holivia/commands/format.rb', line 20 def create(args = []) = {} OptionParser.new do |opts| opts. = "Usage: holivia selfcare format create [options]" opts.on("--selfcare-content-id ID", Integer) { |v| [:selfcare_content_id] = v } opts.on("--format-type TYPE") { |v| [:format_type] = v } end.parse!(args) = .merge(piped_json) abort "No options provided. Use --help for usage." if .empty? output(client.post(BASE_PATH, body: )) end |
#update(args = []) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/holivia/commands/format.rb', line 33 def update(args = []) id = args.shift abort "Usage: holivia selfcare format update <id> [options]" unless id = {} OptionParser.new do |opts| opts. = "Usage: holivia selfcare format update <id> [options]" opts.on("--format-type TYPE") { |v| [:format_type] = v } end.parse!(args) = .merge(piped_json) abort "No options provided. Use --help for usage." if .empty? output(client.patch("#{BASE_PATH}/#{id}", body: )) end |