public Task<string> PostHighlightAsync(Highlight highlight) { if (!this.isOpen) throw new InvalidOperationException("Session Closed."); return client.PostReadingHighlightAsync(this.accessToken, this.readingId, highlight); }
/// <summary> /// Must only be called after the actual operation on Readmill has succeeded. /// </summary> /// <param name="highlight"></param> public void TryCollectHighlight(Highlight highlight) { lock (this) { if (collectedHighlights == null) collectedHighlights = new Dictionary<string, Highlight>(); if(!collectedHighlights.ContainsKey(highlight.Id)) collectedHighlights.Add(highlight.Id, highlight); } }
public Task<string> UpdateHighlightAsync(string accessToken, string highlightId, Highlight updatedHighlight) { IDictionary<string, string> parameters = GetInitializedParameterCollection(); parameters.Add(ReadmillConstants.AccessToken, accessToken); parameters.Add(HighlightsClient.HighlightId, highlightId); WrappedHighlight wrappedUpdate = new WrappedHighlight(); wrappedUpdate.Highlight = updatedHighlight; var highlightUrl = highlightsUriTemplates[HighlightsUriTemplateType.SingleHighlight].BindByName(this.readmillBaseUri, parameters); return PutAsync<WrappedHighlight>(wrappedUpdate, highlightUrl); }
public void TestReadingActions() { ReadmillClient client = new ReadmillClient(this.clientId); BookMatchOptions options = new BookMatchOptions(); options.TitleValue = "Zen and the Art of Motorcycle Maintenance"; options.AuthorValue = "Robert M. Pirsig"; Book book = client.Books.GetBestMatchAsync(options).Result; //Create a new reading and retrieve it using the permalink string permalink = client.Books.PostBookReadingAsync(this.accessToken, book.Id, Reading.ReadingState.Open).Result; Reading r = client.Readings.GetFromPermalinkAsync<Reading>(permalink).Result; try { //Create a new Reading Session ReadingSession session = client.Readings.GetReadingSession(this.accessToken, r.Id); session.PingAsync(0.1, 52.53826, 13.41268).Wait(); Thread.Sleep(5000); session.PingAsync(0.12, 52.53826, 13.41268).Wait(); Highlight testHighlight = new Highlight() { Content = "When one person suffers from a delusion, it is called insanity. When many people suffer from a delusion it is called a Religion." }; session.PostHighlightAsync(testHighlight).Wait(); string content = @"It’s a fascinating tale of a journey, both physically and metaphysically, into the world of quality and values"; session.PostReadingCommentAsync(content).Wait(); session.Close(); } finally { //Comment this line or set a breakpoint here if you want to check the Reading on Readmill client.Readings.DeleteReadingAsync(this.accessToken, r.Id); } }
public Task<string> PostReadingHighlightAsync(string accessToken, string readingId, Highlight highlight) { IDictionary<string, string> parameters = GetInitializedParameterCollection(); parameters.Add(ReadmillConstants.AccessToken, accessToken); parameters.Add(ReadingsClient.ReadingId, readingId); //Wrap in InternalHighlight var wrappedHighlight = new WrappedHighlight() { Highlight = highlight}; var highlightUrl = readingsUriTemplates[ReadingsUriTemplateType.ReadingHighlights].BindByName(this.readmillBaseUri, parameters); return PostAsync<WrappedHighlight>(wrappedHighlight, highlightUrl); }