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



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

  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



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

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



54
55
56
57
58
59
60
61
62
# File 'lib/tweetstream/site_stream_client.rb', line 54

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



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

def info(&block)
  options = {:error_msg => 'Failed to retrieve SiteStream info.'}
  request(:get, info_path, options, &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



44
45
46
47
48
49
50
51
52
# 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