Class: TweetStream::SiteStreamClient
- Inherits:
-
Object
- Object
- TweetStream::SiteStreamClient
- Defined in:
- lib/tweetstream/site_stream_client.rb
Instance Method Summary collapse
- #add_user(user_id, &block) ⇒ Object
- #friends_ids(user_id, &block) ⇒ Object
- #info(&block) ⇒ Object
-
#initialize(config_uri, oauth = {}) ⇒ SiteStreamClient
constructor
A new instance of SiteStreamClient.
- #on_error(&block) ⇒ Object
- #remove_user(user_id, &block) ⇒ Object
Constructor Details
#initialize(config_uri, oauth = {}) ⇒ SiteStreamClient
Returns a new instance of SiteStreamClient.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/tweetstream/site_stream_client.rb', line 9 def initialize(config_uri, oauth = {}) @config_uri = config_uri = TweetStream..merge(oauth) Configuration::OAUTH_OPTIONS_KEYS.each do |key| send("#{key}=", [key]) end EventMachine::HttpRequest.use EventMachine::Middleware::JSONResponse end |
Instance Method Details
#add_user(user_id, &block) ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/tweetstream/site_stream_client.rb', line 34 def add_user(user_id, &block) = { :error_msg => 'Failed to add user to SiteStream', :body => {'user_id' => normalized_user_ids(user_id)} } request(:post, add_user_path, , &block) end |
#friends_ids(user_id, &block) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/tweetstream/site_stream_client.rb', line 52 def friends_ids(user_id, &block) = {:error_msg => 'Failed to retrieve SiteStream friends ids.', :body => {'user_id' => user_id} } request(:post, friends_ids_path, , &block) end |
#info(&block) ⇒ Object
29 30 31 32 |
# File 'lib/tweetstream/site_stream_client.rb', line 29 def info(&block) = {:error_msg => 'Failed to retrieve SiteStream info.'} request(:get, info_path, , &block) end |
#on_error(&block) ⇒ Object
20 21 22 23 24 25 26 27 |
# File 'lib/tweetstream/site_stream_client.rb', line 20 def on_error(&block) if block_given? @on_error = block self else @on_error end end |
#remove_user(user_id, &block) ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/tweetstream/site_stream_client.rb', line 43 def remove_user(user_id, &block) = { :error_msg => 'Failed to remove user from SiteStream.', :body => {'user_id' => normalized_user_ids(user_id)} } request(:post, remove_user_path, , &block) end |