Class: Hall::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/hall.rb

Instance Method Summary collapse

Constructor Details

#initialize(room_token, from_name) ⇒ Client

Client initialization

Usage:

Hall::Client.new('room_token', 'from_name')

Parametrs:

room_token

token for your room grab it through the Add integration -> Other or hall.com/docs/integrations/generic/

from_name

defines the name used for message posting



23
24
25
26
# File 'lib/hall.rb', line 23

def initialize(room_token, from_name)
  @room_token = room_token
  @from_name = from_name
end

Instance Method Details

#post_message(text) ⇒ Object

Post a message.

Usage:

post_message 'plain text'

Parametrs:

text

plain text to be send to the chat



39
40
41
42
43
44
45
46
47
48
# File 'lib/hall.rb', line 39

def post_message(text)
  body ={
    "title" => @from_name,
    "message" => text
  }

  options = {body: body, options: { headers: { 'ContentType' => 'application/json' } } }

  self.class.post(room_path, options)
end