Class: Rosumi::Messenger

Inherits:
Object
  • Object
show all
Includes:
PostHelper
Defined in:
lib/rosumi/messenger.rb

Constant Summary

Constants included from PostHelper

PostHelper::PORT, PostHelper::URL

Instance Attribute Summary

Attributes included from PostHelper

#devices, #http, #partition

Instance Method Summary collapse

Methods included from PostHelper

#update_devices

Constructor Details

#initialize(user, pass) ⇒ Messenger

Returns a new instance of Messenger.



11
12
13
14
15
# File 'lib/rosumi/messenger.rb', line 11

def initialize(user, pass)
  @user = user
  @pass = pass
  super()
end

Instance Method Details

#send_message(id, subject, message, sound) ⇒ Object

Sends a message to the specified device.

Attributes

  • id - id of the device (0,1,2,3 et cetera).

  • subject - Subject of the message.

  • message - The message to display on the device.

  • sound - If true, plays a sound on the device.



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/rosumi/messenger.rb', line 25

def send_message(id, subject, message, sound)

  update_devices
  device_id = @devices[id]['id']

  data = {'clientContext' => client_context(device_id),
          'device' => device_id,
          'sound' => sound,
          'subject' => subject,
          'text' => message,
          'userText' => true
         };
  
  self.send(:post,"/fmipservice/device/#{@user}/sendMessage", data)

end