/// <summary>
 /// Returns content types as JSON data.
 /// </summary>
 /// <param name="parameters">An array that contains zero or more query parameters, for example for paging.</param>
 /// <returns>The <see cref="JObject"/> instance that represents the content types. If no query parameters are specified, all content types are returned.</returns>
 public async Task <JObject> GetTypesJsonAsync(params string[] parameters)
 {
     return(await _deliveryCacheManager.GetOrAddAsync(
                CacheHelpers.GetTypesJsonKey(parameters),
                () => _deliveryClient.GetTypesJsonAsync(parameters),
                response => response["types"].Any(),
                CacheHelpers.GetTypesJsonDependencies));
 }
 /// <summary>
 /// Returns a content type as JSON data.
 /// </summary>
 /// <param name="codename">The codename of a content type.</param>
 /// <returns>The <see cref="JObject"/> instance that represents the content type with the specified codename.</returns>
 public async Task <JObject> GetTypeJsonAsync(string codename)
 {
     return(await _deliveryCacheManager.GetOrAddAsync(
                CacheHelpers.GetTypeJsonKey(codename),
                () => _deliveryClient.GetTypeJsonAsync(codename),
                response => response != null,
                CacheHelpers.GetTypeJsonDependencies));
 }
Example #3
0
 /// <summary>
 /// Returns a taxonomy group.
 /// </summary>
 /// <param name="codename">The codename of a taxonomy group.</param>
 /// <returns>The taxonomy group with the specified codename.</returns>
 public async Task <IDeliveryTaxonomyResponse> GetTaxonomyAsync(string codename)
 {
     return(await _deliveryCacheManager.GetOrAddAsync(
                CacheHelpers.GetTaxonomyKey(codename),
                () => _deliveryClient.GetTaxonomyAsync(codename),
                response => response != null,
                CacheHelpers.GetTaxonomyDependencies));
 }
Example #4
0
 /// <summary>
 /// Returns a content element.
 /// </summary>
 /// <param name="contentTypeCodename">The codename of the content type.</param>
 /// <param name="contentElementCodename">The codename of the content element.</param>
 /// <returns>A content element with the specified codename that is a part of a content type with the specified codename.</returns>
 public async Task <IDeliveryElementResponse> GetContentElementAsync(string contentTypeCodename, string contentElementCodename)
 {
     return(await _deliveryCacheManager.GetOrAddAsync(
                CacheHelpers.GetContentElementKey(contentTypeCodename, contentElementCodename),
                () => _deliveryClient.GetContentElementAsync(contentTypeCodename, contentElementCodename),
                response => response != null,
                CacheHelpers.GetContentElementDependencies));
 }
Example #5
0
 /// <summary>
 /// Returns a content type.
 /// </summary>
 /// <param name="codename">The codename of a content type.</param>
 /// <param name="shouldBeTrue">Should be true.</param>
 /// <returns>The content type with the specified codename.</returns>
 public async Task <IDeliveryTypeResponse> GetTypeAsync(string codename, bool shouldBeTrue)
 {
     return(await _deliveryCacheManager.GetOrAddAsync(
                CacheHelpers.GetTypeKey(codename),
                () => _deliveryClient.GetTypeAsync(codename, true),
                response => response != null,
                CacheHelpers.GetTypeDependencies));
 }
        /// <summary>
        /// Returns a content item.
        /// </summary>
        /// <param name="codename">The codename of a content item.</param>
        /// <param name="parameters">A collection of query parameters, for example for projection or depth of linked items.</param>
        /// <returns>The <see cref="DeliveryItemResponse"/> instance that contains the content item with the specified codename.</returns>
        public async Task <DeliveryItemResponse> GetItemAsync(string codename, IEnumerable <IQueryParameter> parameters)
        {
            var queryParameters = parameters?.ToList();

            return(await _deliveryCacheManager.GetOrAddAsync(
                       CacheHelpers.GetItemKey(codename, queryParameters),
                       () => _deliveryClient.GetItemAsync(codename, queryParameters),
                       response => response != null,
                       CacheHelpers.GetItemDependencies));
        }
        /// <summary>
        /// Returns taxonomy groups.
        /// </summary>
        /// <param name="parameters">A collection of query parameters, for example, for paging.</param>
        /// <returns>The <see cref="DeliveryTaxonomyListingResponse"/> instance that represents the taxonomy groups. If no query parameters are specified, all taxonomy groups are returned.</returns>
        public async Task <DeliveryTaxonomyListingResponse> GetTaxonomiesAsync(IEnumerable <IQueryParameter> parameters)
        {
            var queryParameters = parameters?.ToList();

            return(await _deliveryCacheManager.GetOrAddAsync(
                       CacheHelpers.GetTaxonomiesKey(queryParameters),
                       () => _deliveryClient.GetTaxonomiesAsync(queryParameters),
                       response => response.Taxonomies.Any(),
                       CacheHelpers.GetTaxonomiesDependencies));
        }
        /// <summary>
        /// Returns strongly typed content items that match the optional filtering parameters. By default, retrieves one level of linked items.
        /// </summary>
        /// <typeparam name="T">Type of the model. (Or <see cref="object" /> if the return type is not yet known.)</typeparam>
        /// <param name="parameters">A collection of query parameters, for example, for filtering, ordering, or setting the depth of linked items.</param>
        /// <returns>The <see cref="DeliveryItemListingResponse{T}" /> instance that contains the content items. If no query parameters are specified, all content items are returned.</returns>
        public async Task <DeliveryItemListingResponse <T> > GetItemsAsync <T>(IEnumerable <IQueryParameter> parameters)
        {
            var queryParameters = parameters?.ToList();

            return(await _deliveryCacheManager.GetOrAddAsync(
                       CacheHelpers.GetItemsTypedKey(queryParameters),
                       () => _deliveryClient.GetItemsAsync <T>(queryParameters),
                       response => response.Items.Any(),
                       CacheHelpers.GetItemsDependencies));
        }