diff --git a/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj b/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj index 523d2ae..fc78f9b 100644 --- a/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj +++ b/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj @@ -12,7 +12,7 @@ Copyright (c) 2012-2020 Contentstack (http://app.contentstack.com). All Rights Reserved https://github.com/contentstack/contentstack-dotnet v2.5.0 - 2.5.0 + 2.6.0 diff --git a/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj b/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj index 8b3619a..acbceb2 100644 --- a/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj +++ b/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj @@ -4,7 +4,7 @@ netcoreapp2.1 false - 2.5.0 + 2.6.0 diff --git a/Contentstack.Core.Tests/QueryTest.cs b/Contentstack.Core.Tests/QueryTest.cs index f22c87f..6ff70ce 100644 --- a/Contentstack.Core.Tests/QueryTest.cs +++ b/Contentstack.Core.Tests/QueryTest.cs @@ -1178,6 +1178,30 @@ public async Task Limit() } + [Fact] + public async Task IncludeEmbeddedItems() + { + ContentType contenttype = client.ContentType("rte_embed"); + Query query = contenttype.Query(); + query.includeEmbeddedItems(); + var result = await query.Find(); + if (result == null && result.Items.Count() == 0) + { + Assert.False(true, "Query.Exec is not match with expected result."); + } + else + { + if (result.Items != null) + { + Assert.True(true); + } + else + { + Assert.False(true, "Doesn't mached the expected count."); + } + } + } + [Fact] public async Task IncludeReference() { diff --git a/Contentstack.Core/Contentstack.Core.csproj b/Contentstack.Core/Contentstack.Core.csproj index 880caf5..b679261 100644 --- a/Contentstack.Core/Contentstack.Core.csproj +++ b/Contentstack.Core/Contentstack.Core.csproj @@ -5,15 +5,15 @@ contentstack.csharp Contentstack .NET SDK for the Contentstack Content Delivery API. - 2.5.0 + 2.6.0 Contentstack - Publish content fallback + Embedded Objects fearure added Copyright © 2012-2020 Contentstack. All Rights Reserved true - v2.5.0 + v2.6.0 https://github.com/contentstack/contentstack-dotnet https://github.com/contentstack/contentstack-dotnet/blob/master/LICENSE - 2.5.0 + 2.6.0 @@ -29,6 +29,7 @@ + diff --git a/Contentstack.Core/ContentstackClient.cs b/Contentstack.Core/ContentstackClient.cs index 4ddf1d6..9bbb4eb 100644 --- a/Contentstack.Core/ContentstackClient.cs +++ b/Contentstack.Core/ContentstackClient.cs @@ -11,7 +11,7 @@ using System.Net; using System.IO; using System.Collections; - +using Contentstack.Utils; namespace Contentstack.Core { /// diff --git a/Contentstack.Core/Models/Asset.cs b/Contentstack.Core/Models/Asset.cs index ef00864..3bab041 100644 --- a/Contentstack.Core/Models/Asset.cs +++ b/Contentstack.Core/Models/Asset.cs @@ -166,7 +166,7 @@ public void SetHeader(string key, string value) /// public Asset includeFallback() { - this.UrlQueries.Add("include_fallback", true); + this.UrlQueries.Add("include_fallback", "true"); return this; } diff --git a/Contentstack.Core/Models/Entry.cs b/Contentstack.Core/Models/Entry.cs index 4bc4c57..9946c5a 100644 --- a/Contentstack.Core/Models/Entry.cs +++ b/Contentstack.Core/Models/Entry.cs @@ -1118,7 +1118,36 @@ public Entry IncludeFallback() { try { - UrlQueries.Add("include_fallback", true); + UrlQueries.Add("include_fallback", "true"); + } + catch (Exception e) + { + throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e); + } + return this; + } + + /// + /// Include Embedded Objects (Entries and Assets) along with entry/entries details. + /// + /// Current instance of Entry, this will be useful for a chaining calls. + /// + /// + /// //"blt5d4sample2633b" is a dummy Stack API key + /// //"blt6d0240b5sample254090d" is dummy access token. + /// ContentstackClient stack = new ContentstackClinet("blt5d4sample2633b", "blt6d0240b5sample254090d", "stag"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.includeEmbeddedItems(); + /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// //Your callback code. + /// }); + /// + /// + public Entry includeEmbeddedItems() + { + try + { + UrlQueries.Add("include_embedded_items[]", "BASE"); } catch (Exception e) { diff --git a/Contentstack.Core/Models/Query.cs b/Contentstack.Core/Models/Query.cs index 26248f3..12cd611 100644 --- a/Contentstack.Core/Models/Query.cs +++ b/Contentstack.Core/Models/Query.cs @@ -1338,18 +1338,18 @@ public Query IncludeFallback() { try { - UrlQueries.Add("include_fallback", true); + UrlQueries.Add("include_fallback", "true"); } catch (Exception e) { throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e); } return this; - } - - /// - /// Include schemas of all returned objects along with objects themselves. - /// + } + + /// + /// Include Embedded Objects (Entries and Assets) along with entry/entries details. + /// /// Current instance of Query, this will be useful for a chaining calls. /// /// @@ -1358,12 +1358,42 @@ public Query IncludeFallback() /// ContentstackClient stack = new ContentstackClinet("blt5d4sample2633b", "blt6d0240b5sample254090d", "stag"); /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.IncludeSchema(); + /// csQuery.includeEmbeddedItems(); /// csQuery.Find<Product>().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// - /// + /// + public Query includeEmbeddedItems() + { + try + { + UrlQueries.Add("include_embedded_items[]", "BASE"); + } + catch (Exception e) + { + throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e); + } + return this; + } + + /// + /// Include schemas of all returned objects along with objects themselves. + /// + /// Current instance of Query, this will be useful for a chaining calls. + /// + /// + /// //"blt5d4sample2633b" is a dummy Stack API key + /// //"blt6d0240b5sample254090d" is dummy access token. + /// ContentstackClient stack = new ContentstackClinet("blt5d4sample2633b", "blt6d0240b5sample254090d", "stag"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); + /// + /// csQuery.IncludeSchema(); + /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// //Your callback code. + /// }); + /// + /// public Query IncludeSchema() { try diff --git a/Contentstack.Net.sln b/Contentstack.Net.sln index f1499b4..68df4db 100644 --- a/Contentstack.Net.sln +++ b/Contentstack.Net.sln @@ -132,6 +132,6 @@ Global $0.XmlFormattingPolicy = $9 $9.scope = application/xml $0.StandardHeader = $10 - version = 2.5.0 + version = 2.6.0 EndGlobalSection EndGlobal diff --git a/global.json b/global.json new file mode 100644 index 0000000..79893f3 --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "sdk": { + "version": "3.1.404" + } +}