for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
require 'multi_json'
module GlipSdk
module REST
class Posts
attr_accessor :groups_cache
def initialize(rc_sdk)
@api = rc_sdk
end
def post(opts = {})
unless opts.key? :text
raise ArgumentError, "Text must be provided to post message"
unless opts.key?(:groupId) || opts.key?(:groupName)
raise ArgumentError, "Group Id or Group Name must be provided"
group_id = opts[:groupId]
if group_id.nil? && @groups_cache && opts.key?(:groupName)
group_id = @groups_cache.id_by_name(opts[:groupName])
params = { groupId: group_id, text: opts[:text] }
puts MultiJson.encode params
@api.http.post do |req|
req.url 'glip/posts'
req.headers['Content-Type'] = 'application/json'
req.body = { groupId: group_id, text: opts[:text] }
def get(opts = {})
if opts.key? :postId
return @api.http.get "glip/posts/#{opts[:postId]}"
@api.http.get do |req|
req.url "glip/posts"
req.body = opts
def observe(observer)
@subscription = @api.create_subscription()
@subscription.subscribe(['/restapi/v1.0/account/~/extension/~/glip/posts'])
@subscription.add_observer observer