lib/hall.rb in hall-0.0.3 vs lib/hall.rb in hall-0.0.4
- old
+ new
@@ -17,14 +17,17 @@
#
# +room_token+:: token for your room grab it through the Add integration -> Other or https://hall.com/docs/integrations/generic/
#
# +from_name+:: defines the name used for message posting
#
+ # +from_picture+:: optional add picture to the post
+ #
- def initialize(room_token, from_name)
- @room_token = room_token
- @from_name = from_name
+ def initialize(room_token, from_name, from_picture = nil)
+ @room_token = room_token
+ @from_name = from_name
+ @from_picture = from_picture
end
# Post a message.
#
# Usage:
@@ -36,21 +39,24 @@
#
# +text+:: plain text to be send to the chat
def post_message(text)
body ={
- "title" => @from_name,
+ "title" => @from_name,
+ "picture" => @from_picture,
"message" => text
}
- options = {body: body, options: { headers: { 'ContentType' => 'application/json' } } }
-
- self.class.post(room_path, options)
+ self.class.post(room_path, request_options(body))
end
private
def room_path
'/services/generic/' + @room_token
+ end
+
+ def request_options(body)
+ {body: body, options: { headers: { 'ContentType' => 'application/json' } } }
end
end
end