public async Task <AnnotationResponse> UpdateAnnotation(AnnotationPayload annotationPayload) { using (var output = new StringWriter()) { JSON.Serialize(annotationPayload, output); var response = await _geniusRestClient.PostASync("/annotations/", output.ToString() + "?text_format=html"); using (var input = new StringReader(response)) { var annotationResponse = JSON.Deserialize <AnnotationResponse>(input); if (annotationResponse.Meta.Status >= 400) { throw new HttpRequestException(annotationResponse.Meta.Status + annotationResponse.Meta.Message); } return(annotationResponse); } } }
/// <inheritdoc /> public async Task <HttpResponse <Annotation> > UpdateAnnotation(string annotationId, AnnotationPayload annotationPayload, TextFormat textFormat) { return(await _apiConnection.Put <Annotation>(textFormat, annotationId, annotationPayload)); }
/// <inheritdoc /> public async Task <HttpResponse <Annotation> > CreateAnnotation(AnnotationPayload annotationPayload, TextFormat textFormat) { return(await _apiConnection.Post <Annotation>(textFormat, annotationPayload)); }
private static async Task Examples() { var geniusClient = new GeniusClient("CLIENT_ACCESS_KEY"); #region Annotations // GET an annotation by Id var getAnnotation = await geniusClient.AnnotationsClient.GetAnnotation("10225840", TextFormat.Dom); // Create/POST an annotation var annotationPayload = new AnnotationPayload { Annotation = new Annotation { Body = new AnnotationBody { MarkDown = "hello **world!**" } }, Referent = new Referent { RawAnnotableUrl = "http://seejohncode.com/2014/01/27/vim-commands-piping/", Fragment = "execute commands", ContextForDisplay = new ContextForDisplay { BeforeHtml = "You may know that you can ", AfterHtml = " from inside of a vim, with a vim command:" } }, WebPage = new WebPage { CanonicalUrl = null, OgUrl = null, Title = "Secret of Mana" } }; var postAnnotation = await geniusClient.AnnotationsClient.CreateAnnotation(annotationPayload, TextFormat.Dom); // Update an annotation var annotationUpdatePayload = new AnnotationPayload { Annotation = new Annotation { Body = new AnnotationBody { MarkDown = "hello **world!** is very generic" } } }; var updatedAnnotation = await geniusClient.AnnotationsClient.UpdateAnnotation(postAnnotation.Response.Id, annotationUpdatePayload, TextFormat.Dom); // Delete an annotation var deletedAnnotation = await geniusClient.AnnotationsClient.DeleteAnnotation(postAnnotation.Response.Id, TextFormat.Dom); #endregion #region Voting // Upvote await geniusClient.VoteClient.Vote(VoteType.Upvote, "Annotation_ID", TextFormat.Dom); //Downvote await geniusClient.VoteClient.Vote(VoteType.Downvote, "Annotation_ID", TextFormat.Dom); //UnVote (Remove the vote) await geniusClient.VoteClient.Vote(VoteType.Unvote, "Annotation_ID", TextFormat.Dom); #endregion #region Referent var referentBySongId = await geniusClient.ReferentsClient.GetReferentBySongId(TextFormat.Dom, "Song_Id", "Created_by_id", "per_page", "page"); var referentByWebPageId = await geniusClient.ReferentsClient.GetReferentByWebPageId(TextFormat.Dom, "Web_page_id"); #endregion #region Songs var song = geniusClient.SongsClient.GetSong(TextFormat.Dom, "SONG_ID"); #endregion #region Artists var artistInfo = geniusClient.ArtistsClient.GetArtist(TextFormat.Dom, "ARTIST_ID"); var songsByArtist = geniusClient.ArtistsClient.GetSongsByArtist(TextFormat.Dom, "ARTIST_ID"); #endregion #region WebPages var webPage = geniusClient.WebPagesClient.GetWebPage(TextFormat.Dom, "URL"); #endregion #region Search var searchResult = geniusClient.SearchClient.Search(TextFormat.Dom, "Kendrick%20Lamar"); #endregion #region Account var accountInfo = geniusClient.AccountsClient.GetAccountInfo(TextFormat.Dom); #endregion }