Skip to content

Commit

Permalink
Add support for sending options to /channels API
Browse files Browse the repository at this point in the history
* Removed the presence API: it has been replaced by extending /channels
  • Loading branch information
mloughran committed Sep 20, 2012
1 parent 4a06439 commit 8323220
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
2 changes: 1 addition & 1 deletion lib/pusher.rb
Expand Up @@ -30,7 +30,7 @@ class << self
def_delegators :default_client, :authentication_token, :url
def_delegators :default_client, :encrypted=, :url=

def_delegators :default_client, :channels, :presence_channels, :trigger
def_delegators :default_client, :channels, :trigger

attr_writer :logger

Expand Down
25 changes: 4 additions & 21 deletions lib/pusher/client.rb
Expand Up @@ -76,35 +76,18 @@ def [](channel_name)
#
# GET /apps/[id]/channels
#
# @return [Hash] See Pusher api docs
# @param options [Hash] Hash of options for the API - see Pusher API docs
# @return [Hash] See Pusher API docs
# @raise [Pusher::Error] on invalid Pusher response - see the error message for more details
# @raise [Pusher::HTTPError] on any error raised inside Net::HTTP - the original error is available in the original_error attribute
#
def channels
def channels(options = {})
@_channels_url ||= begin
uri = url.dup
uri.path = uri.path + '/channels'
uri
end
request = Pusher::Request.new(:get, @_channels_url, {}, nil, nil, self)
return request.send_sync
end

# Request presence channels from the API
#
# GET /apps/[id]/channels/presence
#
# @return [Hash] See Pusher api docs
# @raise [Pusher::Error] on invalid Pusher response - see the error message for more details
# @raise [Pusher::HTTPError] on any error raised inside Net::HTTP - the original error is available in the original_error attribute
#
def presence_channels
@_pc_url ||= begin
uri = url.dup
uri.path = uri.path + '/channels/presence'
uri
end
request = Pusher::Request.new(:get, @_pc_url, {}, nil, nil, self)
request = Pusher::Request.new(:get, @_channels_url, options, nil, nil, self)
return request.send_sync
end

Expand Down

0 comments on commit 8323220

Please sign in to comment.