Class: TweetStream::SiteStreamClient

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

Instance Method Summary (collapse)

Constructor Details

- (SiteStreamClient) initialize(config_uri, oauth = {})

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

- (Object) add_user(user_id, &block)



34
35
36
37
38
39
40
41
42
43
# 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

- (Object) friends_ids(user_id, &block)



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

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

- (Object) info(&block)



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

- (Object) on_error(&block)



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

- (Object) remove_user(user_id, &block)



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

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