From 8248f90b5b97176a8b3fc5117f56b2fae730dc71 Mon Sep 17 00:00:00 2001 From: Tobias Klika Date: Mon, 2 Jul 2018 16:41:18 +0200 Subject: [PATCH] remove JSON prop from PocketItem and introduce an AfterRequest action with the passed raw response --- PocketSharp/Models/PocketItem.cs | 9 --------- PocketSharp/PocketClient.cs | 18 +++++++++++++----- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/PocketSharp/Models/PocketItem.cs b/PocketSharp/Models/PocketItem.cs index f204c7f..aff44ee 100644 --- a/PocketSharp/Models/PocketItem.cs +++ b/PocketSharp/Models/PocketItem.cs @@ -372,15 +372,6 @@ namespace PocketSharp.Models get { return Images != null && Images.Count() > 0 ? Images.First() : null; } } - /// - /// Gets and sets the JSON the model was deserialized from - /// - /// - /// Model's original JSON representation - /// - [JsonIgnore] - public string Json { get; set; } - /// /// Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object. /// diff --git a/PocketSharp/PocketClient.cs b/PocketSharp/PocketClient.cs index a72f75f..6e987fc 100644 --- a/PocketSharp/PocketClient.cs +++ b/PocketSharp/PocketClient.cs @@ -1,4 +1,4 @@ -using Newtonsoft.Json; +using Newtonsoft.Json; using Newtonsoft.Json.Serialization; using PocketSharp.Models; using System; @@ -103,6 +103,14 @@ namespace PocketSharp /// public Action PreRequest { get; set; } + /// + /// Action which is executed after every request + /// + /// + /// The after request callback. + /// + public Action AfterRequest { get; set; } + /// /// Initializes a new instance of the class. @@ -233,10 +241,7 @@ namespace PocketSharp request.Content = new FormUrlEncodedContent(parameters); // call pre request action - if (PreRequest != null) - { - PreRequest(method); - } + PreRequest?.Invoke(method); // make async request try @@ -280,6 +285,9 @@ namespace PocketSharp } } + // call after request action + AfterRequest?.Invoke(responseString); + // cache response if (cacheHTTPResponseData) {