public async Task <NextcloudNewsItems> getItems(Boolean getRead = false, int batchSize = -1, int offset = 0)
        {
            if (itemCache != null)
            {
                return(itemCache);
            }
            var getReadString = "false";

            if (getRead)
            {
                getReadString = "true";
            }
            String         url     = String.Format(buildFullURL("items") + "?batchSize={0}&offset={1}&getRead={2}", batchSize, offset, getReadString);
            HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
            String         hash    = Convert.ToBase64String(Encoding.GetEncoding("ISO-8859-1").GetBytes(username + ":" + password));

            request.Headers["Authorization"] = "Basic " + hash;
            using (HttpWebResponse response = await request.GetResponseAsync() as HttpWebResponse)
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    throw new Exception(String.Format(
                                            "Server error (HTTP {0}: {1}).",
                                            response.StatusCode,
                                            response.StatusDescription));
                }
                DataContractJsonSerializer jsonSerializer = new DataContractJsonSerializer(typeof(NextcloudNewsItems));
                NextcloudNewsItems         jsonResponse   = jsonSerializer.ReadObject(response.GetResponseStream()) as NextcloudNewsItems;
                itemCache = jsonResponse;
                return(jsonResponse);
            }
            throw new Exception("getItems failed.");
        }
 public void invalidateCache()
 {
     itemCache = null;
 }