Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/sockudo/channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,21 @@ def append_message(message_serial, params = {})
@client.append_message(name, message_serial, params)
end

# Publish an annotation for a versioned message.
def publish_annotation(message_serial, params = {})
@client.publish_annotation(name, message_serial, params)
end

# Delete an annotation from a versioned message.
def delete_annotation(message_serial, annotation_serial, params = {})
@client.delete_annotation(name, message_serial, annotation_serial, params)
end

# List raw annotation events for a versioned message.
def list_annotations(message_serial, params = {})
@client.list_annotations(name, message_serial, params)
end

# Request users for a presence channel
# Only works on presence channels (see: http://sockudo.com/docs/client_api_guide/client_presence_channels and https://sockudo.com/docs/rest_api)
#
Expand Down
21 changes: 21 additions & 0 deletions lib/sockudo/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ def post(path, params = {}, headers = {})
resource(path).post(params, headers)
end

# DELETE arbitrary REST API resource using a synchronous http client.
# All request signing is handled automatically.
def delete(path, params = {})
resource(path).delete(params)
end

# POST arbitrary REST API resource using an asynchronous http client.
# Works identially to get_async method, but posts params as JSON in post
# body.
Expand Down Expand Up @@ -336,6 +342,21 @@ def append_message(channel_name, message_serial, params = {})
post("/channels/#{channel_name}/messages/#{message_serial}/append", params)
end

# Publish an annotation for a versioned message
def publish_annotation(channel_name, message_serial, params = {})
post("/channels/#{channel_name}/messages/#{message_serial}/annotations", params)
end

# Delete an annotation from a versioned message
def delete_annotation(channel_name, message_serial, annotation_serial, params = {})
delete("/channels/#{channel_name}/messages/#{message_serial}/annotations/#{annotation_serial}", params)
end

# List raw annotation events for a versioned message
def list_annotations(channel_name, message_serial, params = {})
get("/channels/#{channel_name}/messages/#{message_serial}/annotations", params)
end

# Request info for users of a presence channel
#
# GET /apps/[id]/channels/[channel_name]/users
Expand Down
4 changes: 4 additions & 0 deletions lib/sockudo/request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ def send_async
http_client.get({
query: @params, head: @head
})
when :delete
http_client.delete({
query: @params, head: @head
})
else
raise 'Unsupported verb'
end
Expand Down
4 changes: 4 additions & 0 deletions lib/sockudo/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ def post_async(params, headers = {})
create_request(:post, {}, body, headers).send_async
end

def delete(params)
create_request(:delete, params).send_sync
end

private

def create_request(verb, params, body = nil, extra_headers = {})
Expand Down
Loading