Class: TweetStream::SiteStreamClient

Inherits:
Object
  • Object
show all
Defined in:
lib/tweetstream/site_stream_client.rb

Instance Method Summary collapse

Constructor Details

#initialize(config_uri, oauth = {}) ⇒ SiteStreamClient

Returns a new instance of SiteStreamClient.



10
11
12
13
14
15
16
17
18
19
# File 'lib/tweetstream/site_stream_client.rb', line 10

def initialize(config_uri, oauth = {})
  @config_uri = config_uri

  options = TweetStream.oauth_options.merge(oauth)
  Configuration::OAUTH_OPTIONS_KEYS.each do |key|
    send("#{key}=", options[key])
  end

  EventMachine::HttpRequest.use EventMachine::Middleware::JSONResponse
end

Instance Method Details

#add_user(user_id, &block) ⇒ Object



35
36
37
38
39
40
41
42
# File 'lib/tweetstream/site_stream_client.rb', line 35

def add_user(user_id, &block)
  options = {
              :error_msg => 'Failed to add user to SiteStream',
              :body => { 'user_id' => normalized_user_ids(user_id) }
            }

  request(:post, add_user_path, options, &block)
end

#friends_ids(user_id, &block) ⇒ Object



53
54
55
56
57
58
# File 'lib/tweetstream/site_stream_client.rb', line 53

def friends_ids(user_id, &block)
  options = { :error_msg => 'Failed to retrieve SiteStream friends ids.',
              :body => { 'user_id' => user_id }
            }
  request(:post, friends_ids_path, options, &block)
end

#info(&block) ⇒ Object



30
31
32
33
# File 'lib/tweetstream/site_stream_client.rb', line 30

def info(&block)
  options = { :error_msg => 'Failed to retrieve SiteStream info.' }
  request(:get, info_path, options, &block)
end

#on_error(&block) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/tweetstream/site_stream_client.rb', line 21

def on_error(&block)
  if block_given?
    @on_error = block
    self
  else
    @on_error
  end
end

#remove_user(user_id, &block) ⇒ Object



44
45
46
47
48
49
50
51
# File 'lib/tweetstream/site_stream_client.rb', line 44

def remove_user(user_id, &block)
  options = {
              :error_msg => 'Failed to remove user from SiteStream.',
              :body => { 'user_id' => normalized_user_ids(user_id) }
            }

  request(:post, remove_user_path, options, &block)
end