private async Task <Resource> getPartnership(string partnerLink)
        {
            var response = await SecuredApiGetRequest(partnerLink);

            Logger.Log(response);
            Resource org = await PartnershipWorkflow.DeserialiseAsync <Resource>(response.Content);

            return(org);
        }
        public async Task <Resource> getResource(string resourceLink)
        {
            Logger.Log("RESOURCE", "getResource");
            var response = await SecuredApiGetRequest(resourceLink);

            Logger.Log(response);
            Resource r = await PartnershipWorkflow.DeserialiseAsync <Resource>(response.Content);

            return(r);
        }
        private async Task <List <Permission> > getPermissions(string link)
        {
            Logger.Log("RESOURCE", "getPermissions");
            var response = await SecuredApiGetRequest(link);

            Logger.Log(response);
            Permissions p = await PartnershipWorkflow.DeserialiseAsync <Permissions>(response.Content);

            return(p.permissions);
        }
        public async Task retrieveApiCatalog(string endpoint)
        {
            apiCataloglinks = (Dictionary <String, Link>)CacheManager.GetCacheItem("api_catalog_links");

            if (apiCataloglinks == null)
            {
                var response = await SecuredApiGetRequest(endpoint);

                ApiCatalog apiCatalog = await PartnershipWorkflow.DeserialiseAsync <ApiCatalog>(response.Content);

                apiCataloglinks = OAuthWorkFlow.linksFrom(apiCatalog);
                CacheManager.AddCacheItem("api_catalog_links", apiCataloglinks, 60 * 6);
            }
        }
        public async Task <Resource> getResourceFromCache(string resourceLink)
        {
            Resource r = (Resource)CacheManager.GetCacheItem(resourceLink);

            if (r == null)
            {
                Logger.Log("RESOURCE", "getResourceFromCache");

                var response = await SecuredApiGetRequest(resourceLink);

                r = await PartnershipWorkflow.DeserialiseAsync <Resource>(response.Content);

                Logger.Log(response);
                CacheManager.AddCacheItem(resourceLink, r, 5);
            }
            return(r);
        }
        public async Task <User> getCurrentUser(bool fillChildOrgs)
        {
            string cacheKey    = "current_user_childorgs_" + fillChildOrgs.ToString();
            User   currentUser = (User)CacheManager.GetCacheItem(cacheKey);

            if (currentUser == null)
            {
                var response = await SecuredApiGetRequest(apiCataloglinks["currentUser"].uri);

                currentUser = await PartnershipWorkflow.DeserialiseAsync <User>(response.Content);

                if (fillChildOrgs)
                {
                    currentUser.Organizations = await getList <Organization>(OAuthWorkFlow.linksFrom(currentUser)["organizations"].uri);
                }
                CacheManager.AddCacheItem(cacheKey, currentUser, 30);
            }
            return(currentUser);
        }
        private async Task <Organization> getOrganization(Link orgLink, bool allowFetchFromCache)
        {
            Organization org = null;

            if (allowFetchFromCache)
            {
                org = (Organization)CacheManager.GetCacheItem(orgLink.uri);
            }

            if (org == null)
            {
                Logger.Log("RESOURCE", "getOrganization");
                var response = await SecuredApiGetRequest(orgLink.uri);

                Logger.Log(response);
                org = await PartnershipWorkflow.DeserialiseAsync <Organization>(response.Content);

                CacheManager.AddCacheItem(orgLink.uri, org, 5);
            }

            return(org);
        }