diff --git a/.gitignore b/.gitignore index 31dc5b3..82b2f04 100644 --- a/.gitignore +++ b/.gitignore @@ -9,5 +9,6 @@ Gemfile.lock .ruby-version .ruby-gemset .idea +.vscode *.DS_Store .envrc diff --git a/lib/stream/feed.rb b/lib/stream/feed.rb index 214cfe0..2a8b461 100644 --- a/lib/stream/feed.rb +++ b/lib/stream/feed.rb @@ -158,6 +158,19 @@ def unfollow(target_feed_slug, target_user_id, keep_history: false) @client.make_request(:delete, uri, auth_token, params) end + def follow_stats(followers_slugs = nil, following_slugs = nil) + uri = '/stats/follow' + params = { + followers: @id, + following: @id + } + params[:followers_slugs] = followers_slugs.join(',') if followers_slugs + params[:following_slugs] = following_slugs.join(',') if following_slugs + auth_token = create_jwt_token('*', 'read', '*') + + @client.make_request(:get, uri, auth_token, params) + end + private def create_jwt_token(resource, action, feed_id = nil, user_id = nil) diff --git a/spec/integration_spec.rb b/spec/integration_spec.rb index c194d92..2ea0aca 100644 --- a/spec/integration_spec.rb +++ b/spec/integration_spec.rb @@ -288,6 +288,16 @@ expect(follower.get['results'][0]['id']).to eq response['id'] end + example 'get followers statistics' do + f = @client.feed('flat', generate_uniq_feed_name) + f.follow('flat', generate_uniq_feed_name) + f.follow('flat', generate_uniq_feed_name) + f.follow('flat', generate_uniq_feed_name) + stats = f.follow_stats + expect(stats['results']['following']['count']).to eq 3 + expect(stats['results']['followers']['count']).to eq 0 + end + example 'posting activity using to' do recipient = 'flat', 'toruby11' activity = {