Module: Stream::Batch

Included in:
Client
Defined in:
lib/stream/batch.rb

Instance Method Summary collapse

Instance Method Details

#add_to_many(activity_data, feeds) ⇒ nil

Adds an activity to many feeds in one single request

Parameters:

  • activity_data (Hash)

    the activity do add

  • feeds (Array<string>)

    list of feeds (eg. ‘user:1’, ‘flat:2’)

Returns:

  • (nil)


51
52
53
54
55
56
57
58
# File 'lib/stream/batch.rb', line 51

def add_to_many(activity_data, feeds)
  data = {
    feeds: feeds,
    activity: activity_data
  }
  signature = Stream::Signer.create_jwt_token('feed', '*', @api_secret, '*')
  make_request(:post, '/feed/add_to_many/', signature, {}, data)
end

#follow_many(follows, activity_copy_limit = nil) ⇒ nil

Follows many feeds in one single request

Examples:

follows = [
  {:source => 'flat:1', :target => 'user:1'},
  {:source => 'flat:1', :target => 'user:3'}
]
@client.follow_many(follows)

Parameters:

  • follows (Array<Hash<:source, :target>>)

    the list of follows

Returns:

  • (nil)


17
18
19
20
21
22
# File 'lib/stream/batch.rb', line 17

def follow_many(follows, activity_copy_limit = nil)
  query_params = {}
  query_params['activity_copy_limit'] = activity_copy_limit unless activity_copy_limit.nil?
  signature = Stream::Signer.create_jwt_token('follower', '*', @api_secret, '*')
  make_request(:post, '/follow_many/', signature, query_params, follows)
end

#unfollow_many(unfollows) ⇒ Object

Unfollow many feeds in one single request

return [nil]

Examples:

unfollows = [
  {source: 'user:1', target: 'timeline:1'},
  {source: 'user:2', target: 'timeline:2', keep_history: false}
]
@client.unfollow_many(unfollows)

Parameters:

  • unfollows (Array<Hash<:source, :target, :keep_history>>)

    the list of follows to remove.



38
39
40
41
# File 'lib/stream/batch.rb', line 38

def unfollow_many(unfollows)
  signature = Stream::Signer.create_jwt_token('follower', '*', @api_secret, '*')
  make_request(:post, '/unfollow_many/', signature, {}, unfollows)
end