Sha256: 5867e29239f0d3dc5caabc7378c3c1f4e1c6e2a0a6076d88a65a1c6a7d5a1d94
Contents?: true
Size: 1.24 KB
Versions: 2
Compression:
Stored size: 1.24 KB
Contents
module GlipSdk module REST class Posts def initialize(rc_sdk) @api = rc_sdk end def post(opts = {}) unless opts.key? :text raise ArgumentError, "Text must be provided to post message" end unless opts.key?(:groupId) || opts.key?(:groupName) raise ArgumentError, "Group Id or Group Name must be provided" end group_id = (opts.key?(:groupName) && !opts.key?(:groupId)) \ ? @groups.groups_name2id[opts[:groupName]] : opts[:groupId] @api.http.post do |req| req.url 'glip/posts' req.headers['Content-Type'] = 'application/json' req.body = { groupId: group_id, text: opts[:text] } end end def get(opts = {}) if opts.key? :postId return @api.http.get "glip/posts/#{opts[:postId]}" end @api.http.get do |req| req.url "glip/posts" req.headers['Content-Type'] = 'application/json' req.body = opts end end def observe(observer) @subscription = @api.create_subscription() @subscription.subscribe(['/restapi/v1.0/account/~/extension/~/glip/posts']) @subscription.add_observer observer end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
glip_sdk-0.0.2 | lib/glip_sdk/rest/posts.rb |
glip_sdk-0.0.1 | lib/glip_sdk/rest/posts.rb |