Esempio n. 1
0
        public async Task AddToMany(Activity activity, IEnumerable<string> feedIds)
        {
            var request = _client.BuildAppRequest("feed/add_to_many/", HttpMethod.POST);
            request.SetJsonBody(
                "{" + string.Format("\"activity\": {0}, \"feeds\": {1}", activity.ToJson(this._client), JsonConvert.SerializeObject(feedIds)) + "}"
            );
            _client.SignRequest(request);

            var response = await _client.MakeRequest(request);

            if (response.StatusCode != System.Net.HttpStatusCode.Created)
                throw StreamException.FromResponse(response);
        }
Esempio n. 2
0
        /// <summary>
        /// Add an activity to the feed
        /// </summary>
        /// <param name="activity"></param>
        /// <returns>An activity with ID and Date supplied</returns>
        public async Task <Activity> AddActivity(Activity activity)
        {
            if (activity == null)
            {
                throw new ArgumentNullException("activity", "Must have an activity to add");
            }

            var request = _client.BuildRequest(this, "/", Method.POST);

            request.AddParameter("application/json", activity.ToJson(this._client), ParameterType.RequestBody);

            var response = await _client.MakeRequest(request);

            if (response.StatusCode == System.Net.HttpStatusCode.Created)
            {
                return(Activity.FromJson(response.Content));
            }

            throw StreamException.FromResponse(response);
        }