public async Task FollowFeed(StreamFeed feedToFollow, int activityCopyLimit = StreamClient.ActivityCopyLimitDefault) { if (feedToFollow == null) { throw new ArgumentNullException("feedToFollow", "Must have a feed to follow"); } if (feedToFollow.FeedTokenId == this.FeedTokenId) { throw new ArgumentException("Cannot follow myself"); } if (activityCopyLimit < 1) { throw new ArgumentOutOfRangeException("activityCopyLimit", "Activity copy limit must be greater than 0"); } if (activityCopyLimit > StreamClient.ActivityCopyLimitMax) { throw new ArgumentOutOfRangeException("activityCopyLimit", string.Format("Activity copy limit must be less than or equal to {0}", StreamClient.ActivityCopyLimitMax)); } var request = _client.BuildFeedRequest(this, "/following/", HttpMethod.POST); request.SetJsonBody(JsonConvert.SerializeObject(new { target = feedToFollow.FeedId, activity_copy_limit = activityCopyLimit, target_token = feedToFollow.Token })); var response = await _client.MakeRequest(request); if (response.StatusCode != System.Net.HttpStatusCode.Created) { throw StreamException.FromResponse(response); } }
public async Task FollowFeed(StreamFeed feedToFollow) { if (feedToFollow == null) { throw new ArgumentNullException("feedToFollow", "Must have a feed to follow"); } if (feedToFollow.FeedTokenId == this.FeedTokenId) { throw new ArgumentException("Cannot follow myself"); } var request = _client.BuildRequest(this, "/follows/", Method.POST); request.AddJsonBody(new { target = feedToFollow.FeedId, target_token = feedToFollow.Token }); var response = await _client.MakeRequest(request); if (response.StatusCode != System.Net.HttpStatusCode.Created) { throw StreamException.FromResponse(response); } }
internal RestSharp.RestRequest BuildRequest(StreamFeed feed, String path, Method method) { var request = new RestRequest(BaseUrlPath + feed.UrlPath + path, method); request.AddHeader("Authorization", feed.FeedTokenId + " " + feed.Token); request.AddHeader("Content-Type", "application/json"); request.AddQueryParameter("api_key", _apiKey); request.Timeout = _options.Timeout; return(request); }
public void Setup() { _client = new Stream.StreamClient( "hcppd32schhy", "8e9smyj47fbkm2eezq8fxhr2bw45j8x88kqx3pzb9z4jbnxfs99tttkzsus8d8ym", new Stream.StreamClientOptions() { Location = Stream.StreamApiLocation.AsiaJapan }); _user1 = _client.Feed("user", "11"); _flat3 = _client.Feed("flat", "333"); //System.Threading.Thread.Sleep(3000); }
public async Task UnfollowFeed(StreamFeed feedToUnfollow) { if (feedToUnfollow == null) { throw new ArgumentNullException("feedToUnfollow", "Must have a feed to unfollow"); } if (feedToUnfollow.FeedTokenId == this.FeedTokenId) { throw new ArgumentException("Cannot unfollow myself"); } var request = _client.BuildRequest(this, "/follows/" + feedToUnfollow.FeedId + "/", Method.DELETE); var response = await _client.MakeRequest(request); if (response.StatusCode != System.Net.HttpStatusCode.OK) { throw StreamException.FromResponse(response); } }
public void Setup() { _client = new Stream.StreamClient( "98a6bhskrrwj", "t3nj7j8m6dtdbbakzbu9p7akjk5da8an5wxwyt6g73nt5hf9yujp8h4jw244r67p", new Stream.StreamClientOptions() { Location = Stream.StreamApiLocation.USEast }); _user1 = _client.Feed("user", "11"); _flat3 = _client.Feed("flat", "333"); _agg4 = _client.Feed("aggregate", "444"); _not5 = _client.Feed("notification", "555"); _user1.Delete().Wait(); _agg4.Delete().Wait(); _not5.Delete().Wait(); //System.Threading.Thread.Sleep(3000); }
public async Task UnfollowFeed(StreamFeed feedToUnfollow, bool keepHistory = false) { if (feedToUnfollow == null) { throw new ArgumentNullException("feedToUnfollow", "Must have a feed to unfollow"); } if (feedToUnfollow.FeedTokenId == this.FeedTokenId) { throw new ArgumentException("Cannot unfollow myself"); } var request = _client.BuildFeedRequest(this, "/following/" + feedToUnfollow.FeedId + "/", HttpMethod.DELETE); request.AddQueryParameter("keep_history", keepHistory.ToString()); var response = await _client.MakeRequest(request); if (response.StatusCode != System.Net.HttpStatusCode.OK) { throw StreamException.FromResponse(response); } }
public void Setup() { _client = new Stream.StreamClient( "ea7xzzkj6kc4", "zd8cdv9rhxcpmkx9zx4jqt7q9qhawpgsfpay2gy7jaubym32crs9kaux2pm67wrx", new Stream.StreamClientOptions() { Location = Stream.StreamApiLocation.USWest }); _user1 = _client.Feed("user", "11"); _user2 = _client.Feed("user", "22"); _flat3 = _client.Feed("flat", "333"); _agg4 = _client.Feed("aggregate", "444"); _not5 = _client.Feed("notification", "555"); _user1.Delete().GetAwaiter().GetResult(); _user2.Delete().GetAwaiter().GetResult(); _flat3.Delete().GetAwaiter().GetResult(); _agg4.Delete().GetAwaiter().GetResult(); _not5.Delete().GetAwaiter().GetResult(); System.Threading.Thread.Sleep(SetupDelay); }
internal RestRequest BuildActivitiesRequest(StreamFeed feed) { return(BuildRestRequest(BaseUrlPath + ActivitiesUrlPath, HttpMethod.POST)); }
internal RestRequest BuildEnrichedFeedRequest(StreamFeed feed, string path, HttpMethod method) { return(BuildRestRequest(BaseUrlPath + feed.EnrichedPath + path, method)); }
internal RestSharp.RestRequest BuildFeedRequest(StreamFeed feed, string path, Method method) { return(BuildRestRequest(BaseUrlPath + feed.UrlPath + path, method)); }
public Follow(StreamFeed source, StreamFeed target) { Source = source.FeedId; Target = target.FeedId; }