Skip to content

Commit

Permalink
Merge pull request #10 from contentstack/embedded_object
Browse files Browse the repository at this point in the history
Embedded object
  • Loading branch information
uttamukkoji authored Apr 6, 2021
2 parents f5dfedb + 27325cf commit 7edc775
Show file tree
Hide file tree
Showing 10 changed files with 107 additions and 18 deletions.
2 changes: 1 addition & 1 deletion Contentstack.AspNetCore/Contentstack.AspNetCore.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<Copyright>Copyright (c) 2012-2020 Contentstack (http://app.contentstack.com). All Rights Reserved</Copyright>
<PackageProjectUrl>https://github.com/contentstack/contentstack-dotnet</PackageProjectUrl>
<PackageTags>v2.5.0</PackageTags>
<ReleaseVersion>2.5.0</ReleaseVersion>
<ReleaseVersion>2.6.0</ReleaseVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
Expand Down
2 changes: 1 addition & 1 deletion Contentstack.Core.Tests/Contentstack.Core.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<TargetFramework>netcoreapp2.1</TargetFramework>

<IsPackable>false</IsPackable>
<ReleaseVersion>2.5.0</ReleaseVersion>
<ReleaseVersion>2.6.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
24 changes: 24 additions & 0 deletions Contentstack.Core.Tests/QueryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<SourceModelIncludeRef>();
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()
{
Expand Down
9 changes: 5 additions & 4 deletions Contentstack.Core/Contentstack.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<PackageId>contentstack.csharp</PackageId>
<Authors>Contentstack</Authors>
<Description>.NET SDK for the Contentstack Content Delivery API.</Description>
<PackageVersion>2.5.0</PackageVersion>
<PackageVersion>2.6.0</PackageVersion>
<Owners>Contentstack</Owners>
<PackageReleaseNotes>Publish content fallback </PackageReleaseNotes>
<PackageReleaseNotes>Embedded Objects fearure added</PackageReleaseNotes>
<Copyright>Copyright © 2012-2020 Contentstack. All Rights Reserved</Copyright>
<PackOnBuild>true</PackOnBuild>
<PackageTags>v2.5.0</PackageTags>
<PackageTags>v2.6.0</PackageTags>
<PackageProjectUrl>https://github.com/contentstack/contentstack-dotnet</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/contentstack/contentstack-dotnet/blob/master/LICENSE</PackageLicenseUrl>
<ReleaseVersion>2.5.0</ReleaseVersion>
<ReleaseVersion>2.6.0</ReleaseVersion>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand All @@ -29,6 +29,7 @@
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="Microsoft.Extensions.Options" Version="3.1.5" />
<PackageReference Include="Markdig" Version="0.22.0" />
<PackageReference Include="contentstack.utils" Version="1.0.0" />
</ItemGroup>
<ItemGroup>
<Folder Include="Internals\" />
Expand Down
2 changes: 1 addition & 1 deletion Contentstack.Core/ContentstackClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
using System.Net;
using System.IO;
using System.Collections;

using Contentstack.Utils;
namespace Contentstack.Core
{
/// <summary>
Expand Down
2 changes: 1 addition & 1 deletion Contentstack.Core/Models/Asset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ public void SetHeader(string key, string value)
/// </example>
public Asset includeFallback()
{
this.UrlQueries.Add("include_fallback", true);
this.UrlQueries.Add("include_fallback", "true");
return this;
}

Expand Down
31 changes: 30 additions & 1 deletion Contentstack.Core/Models/Entry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/// <summary>
/// Include Embedded Objects (Entries and Assets) along with entry/entries details.
/// </summary>
/// <returns>Current instance of Entry, this will be useful for a chaining calls.</returns>
/// <example>
/// <code>
/// //&quot;blt5d4sample2633b&quot; is a dummy Stack API key
/// //&quot;blt6d0240b5sample254090d&quot; is dummy access token.
/// ContentstackClient stack = new ContentstackClinet(&quot;blt5d4sample2633b&quot;, &quot;blt6d0240b5sample254090d&quot;, &quot;stag&quot;);
/// Entry entry = stack.ContentType(&quot;contentType_id&quot;).Entry(&quot;entry_uid&quot;);
/// entry.includeEmbeddedItems();
/// entry.Fetch&lt;Product&gt;().ContinueWith((entryResult) =&gt; {
/// //Your callback code.
/// });
/// </code>
/// </example>
public Entry includeEmbeddedItems()
{
try
{
UrlQueries.Add("include_embedded_items[]", "BASE");
}
catch (Exception e)
{
Expand Down
46 changes: 38 additions & 8 deletions Contentstack.Core/Models/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/// <summary>
/// Include schemas of all returned objects along with objects themselves.
/// </summary>
}

/// <summary>
/// Include Embedded Objects (Entries and Assets) along with entry/entries details.
/// </summary>
/// <returns>Current instance of Query, this will be useful for a chaining calls.</returns>
/// <example>
/// <code>
Expand All @@ -1358,12 +1358,42 @@ public Query IncludeFallback()
/// ContentstackClient stack = new ContentstackClinet(&quot;blt5d4sample2633b&quot;, &quot;blt6d0240b5sample254090d&quot;, &quot;stag&quot;);
/// Query csQuery = stack.ContentType(&quot;contentType_id&quot;).Query();
///
/// csQuery.IncludeSchema();
/// csQuery.includeEmbeddedItems();
/// csQuery.Find&lt;Product&gt;().ContinueWith((queryResult) =&gt; {
/// //Your callback code.
/// });
/// </code>
/// </example>
/// </example>
public Query includeEmbeddedItems()
{
try
{
UrlQueries.Add("include_embedded_items[]", "BASE");
}
catch (Exception e)
{
throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e);
}
return this;
}

/// <summary>
/// Include schemas of all returned objects along with objects themselves.
/// </summary>
/// <returns>Current instance of Query, this will be useful for a chaining calls.</returns>
/// <example>
/// <code>
/// //&quot;blt5d4sample2633b&quot; is a dummy Stack API key
/// //&quot;blt6d0240b5sample254090d&quot; is dummy access token.
/// ContentstackClient stack = new ContentstackClinet(&quot;blt5d4sample2633b&quot;, &quot;blt6d0240b5sample254090d&quot;, &quot;stag&quot;);
/// Query csQuery = stack.ContentType(&quot;contentType_id&quot;).Query();
///
/// csQuery.IncludeSchema();
/// csQuery.Find&lt;Product&gt;().ContinueWith((queryResult) =&gt; {
/// //Your callback code.
/// });
/// </code>
/// </example>
public Query IncludeSchema()
{
try
Expand Down
2 changes: 1 addition & 1 deletion Contentstack.Net.sln
Original file line number Diff line number Diff line change
Expand Up @@ -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
5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "3.1.404"
}
}

0 comments on commit 7edc775

Please sign in to comment.