Class: CiscoSpark::Messages
- Inherits:
-
Collection
- Object
- Collection
- CiscoSpark::Messages
- Defined in:
- lib/messages.rb
Instance Attribute Summary
Attributes inherited from Collection
Class Method Summary collapse
Methods inherited from Collection
#[], #each, #initialize, #length, #push, #to_s
Constructor Details
This class inherits a constructor from CiscoSpark::Collection
Class Method Details
.CLI(options = {}) ⇒ Object
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/messages.rb', line 4 def CLI( = {}) case [:action] when 'list' params = {} i[before roomId mentionedPeople beforeMessage].each { |k| params[k] = [k] if [k] } raise 'roomId must be specified' unless [:roomId] = CiscoSpark::Messages::list(params) return when 'get' raise 'Specify message ID with --id' unless [:id] = CiscoSpark::Message::get([:id]) return when 'create' raise 'Specify room ID with --roomid' unless [:roomId] params = {} i[toPersonId toPersonEmail text markdown files].each { |k| params[k] = [k] if [k] } = CiscoSpark::Message::create(params) return when 'delete' raise 'Specify message ID with --id' unless [:id] = CiscoSpark::Message::get([:id]) .delete return else raise "action not specified or not one of list, get, create, delete" end end |
.list(params = {}) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/messages.rb', line 31 def list(params = {}) out = CiscoSpark::Messages.new res = CiscoSpark.rest('GET', '/messages', params: params) if res.ok data = JSON.parse(res.body) data['items'].each do |r| = CiscoSpark::Message.new(r) out.push() end end out end |