internal static UpdateToTargetsResponse FromJson(JObject obj) { var result = new UpdateToTargetsResponse(); foreach (var jsonProp in obj.Properties()) { switch (jsonProp.Name) { case "added": result.Added = jsonProp.Value.ToObject <List <string> >(); break; case "removed": result.Removed = jsonProp.Value.ToObject <List <string> >(); break; case "activity": result.Activity = Activity.FromJson(jsonProp.Value.ToObject <JObject>()); break; } } return(result); }
public async Task <UpdateToTargetsResponse> UpdateActivityToTargets(ForeignIDTime foreignIDTime, IEnumerable <string> adds = null, IEnumerable <string> newTargets = null, IEnumerable <string> removed = null) { var payload = new Dictionary <string, object>() { { "foreign_id", foreignIDTime.ForeignID }, { "time", foreignIDTime.Time.ToString("s", System.Globalization.CultureInfo.InvariantCulture) } }; if (adds != null) { payload["added_targets"] = adds.ToList(); } if (newTargets != null) { payload["new_targets"] = newTargets.ToList(); } if (removed != null) { payload["removed_targets"] = removed.ToList(); } var endpoint = string.Format("feed_targets/{0}/{1}/activity_to_targets/", this._feedSlug, this._userId); var request = this._client.BuildJWTAppRequest(endpoint, HttpMethod.POST); request.SetJsonBody(JsonConvert.SerializeObject(payload)); var response = await this._client.MakeRequest(request); if (response.StatusCode == System.Net.HttpStatusCode.Created) { return(UpdateToTargetsResponse.FromJson(response.Content)); } throw StreamException.FromResponse(response); }
internal static UpdateToTargetsResponse FromJson(string json) { return(UpdateToTargetsResponse.FromJson(JObject.Parse(json))); }