Class: Holivia::Commands::Slide
- Defined in:
- lib/holivia/commands/slide.rb
Constant Summary collapse
- BASE_PATH =
"/api/v1/backoffice/slides"
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/slide.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 slide command: #{subcommand}" exit 1 end end |
Instance Method Details
#create(args = []) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/holivia/commands/slide.rb', line 20 def create(args = []) = {} OptionParser.new do |opts| opts. = "Usage: holivia selfcare slide create [options]" opts.on("--content-format-id ID", Integer) { |v| [:content_format_id] = v } opts.on("--title TITLE") { |v| [:title] = v } opts.on("--duration DURATION", Integer) { |v| [:duration] = 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
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/holivia/commands/slide.rb', line 34 def update(args = []) id = args.shift abort "Usage: holivia selfcare slide update <id> [options]" unless id = {} OptionParser.new do |opts| opts. = "Usage: holivia selfcare slide update <id> [options]" opts.on("--title TITLE") { |v| [:title] = v } opts.on("--duration DURATION", Integer) { |v| [:duration] = 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 |