Class: Remind101::Command::Messages

Inherits:
Base
  • Object
show all
Defined in:
lib/remind101/command/messages.rb

Overview

send messages

Instance Method Summary collapse

Instance Method Details

#createObject

messages:create [MESSAGE]

send a new message

-c, –code CODE # the group code to send the message to

Examples

$ remind101 send “Don’t forget to study!” -c math101



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/remind101/command/messages.rb', line 17

def create
  body = shift_argument
  validate_arguments!

  group = remind101.groups.find { |g| g.name == options[:code] }
  error("Unable to find a group with that code") if group.nil?

  attributes = { body: body, group_ids: [ group.id ] }

  action "Sending message: #{body}" do
    remind101.create_message! attributes
  end
end