Skip to content

Commit

Permalink
Merge pull request #3 from contentstack/develop
Browse files Browse the repository at this point in the history
Multi Content type feature
  • Loading branch information
uttamukkoji authored Jul 29, 2019
2 parents 8670c21 + 051ffd9 commit 8d9c913
Show file tree
Hide file tree
Showing 8 changed files with 145 additions and 75 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ packages/
*.config
*.nupkg
*.nuspec
*.trx
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
### Version: 2.0
### Version: 2.1.0
#### Date: Jul-29-2019

##### New Features:
- Query
- added method 'includeReferenceContentTypeUid'
- Entry
- added method 'includeReferenceContentTypeUid'

### Version: 2.0
#### Date: Jun-28-2019

##### New Features:
Expand Down
4 changes: 2 additions & 2 deletions Contentstack.AspNetCore/Contentstack.AspNetCore.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
<PackOnBuild>true</PackOnBuild>
<PackageId>contentstack.aspnetcore</PackageId>
<Authors>Contentstack</Authors>
<Owners>Contentstack</Owners>
<ReleaseVersion>2.0</ReleaseVersion>
<ReleaseVersion>2.1.0</ReleaseVersion>
<PackageVersion>1.0.0</PackageVersion>
<Description>Main release</Description>
<Copyright>Copyright (c) 2012-2019 Contentstack (http://app.contentstack.com). All Rights Reserved
Expand Down
4 changes: 2 additions & 2 deletions Contentstack.Core.Tests/Contentstack.Core.Tests.csproj
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>

<IsPackable>false</IsPackable>
<ReleaseVersion>2.0</ReleaseVersion>
<ReleaseVersion>2.1.0</ReleaseVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
72 changes: 36 additions & 36 deletions Contentstack.Core.Tests/SyncStackTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ public class SyncStackTest
ContentstackClient client = StackConfig.GetSyncStack();

//STAG
//String PaginationToken = "***REMOVED***";
//String SyncToken = "***REMOVED***";


//PROD
String PaginationToken = "***REMOVED***";
String SyncToken = "***REMOVED***";


// //PROD
// String PaginationToken = "***REMOVED***";
// String SyncToken = "***REMOVED***";
[Fact]
public async Task SyncInit()
{
Expand Down Expand Up @@ -111,36 +111,36 @@ public async Task SyncTypeWithStartFrom()
}
}

[Fact]
public async Task SyncPaginationToken()
{

SyncStack result = await client.SyncPaginationToken(PaginationToken);

if (result == null)
{
Assert.False(true, "Entry.Fetch is not match with expected result.");
}
else
{
Assert.True(true);
}
}

[Fact]
public async Task SyncToketest()
{

SyncStack result = await client.SyncToken(SyncToken);

if (result == null)
{
Assert.False(true, "Entry.Fetch is not match with expected result.");
}
else
{
Assert.True(true);
}
}
// [Fact]
// public async Task SyncPaginationToken()
// {

// SyncStack result = await client.SyncPaginationToken(PaginationToken);

// if (result == null)
// {
// Assert.False(true, "Entry.Fetch is not match with expected result.");
// }
// else
// {
// Assert.True(true);
// }
// }

// [Fact]
// public async Task SyncToketest()
// {

// SyncStack result = await client.SyncToken(SyncToken);

// if (result == null)
// {
// Assert.False(true, "Entry.Fetch is not match with expected result.");
// }
// else
// {
// Assert.True(true);
// }
// }
}
}
8 changes: 5 additions & 3 deletions Contentstack.Core/Contentstack.Core.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard1.4</TargetFramework>
Expand All @@ -8,11 +8,13 @@
<PackageVersion>2.0</PackageVersion>
<Owners>Contentstack</Owners>
<PackageReleaseNotes>Query Find method, Entry Fetch method returns ContentstackCollection of Model.</PackageReleaseNotes>
<ReleaseVersion>2.0</ReleaseVersion>
<ReleaseVersion>2.1.0</ReleaseVersion>
<Copyright>Copyright © 2012-2019 Contentstack. All Rights Reserved
</Copyright>
<PackOnBuild>true</PackOnBuild>
<PackageTags>v2.0</PackageTags>
<PackageTags>v2.1.0</PackageTags>
<PackageProjectUrl>https://github.com/contentstack/contentstack-dotnet</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/contentstack/contentstack-dotnet/blob/master/LICENSE</PackageLicenseUrl>
</PropertyGroup>

<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
Expand Down
90 changes: 59 additions & 31 deletions Contentstack.Core/Models/Entry.cs
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class Entry
private CachePolicy _CachePolicy;
private Dictionary<string, object> UrlQueries = new Dictionary<string, object>();
private bool _IsCachePolicySet;
private JObject jObject;
private JObject jObject;
private string _Url
{
get
Expand Down Expand Up @@ -429,8 +429,8 @@ public void RemoveHeader(string key)
public Dictionary<string, Object> GetMetadata()
{
return Metadata;
}

}

/// <summary>
/// Set Language instance
/// </summary>
Expand Down Expand Up @@ -479,8 +479,8 @@ public Entry SetLanguage(Language language)


return this;
}

}

/// <summary>
/// Sets the locale.
/// </summary>
Expand All @@ -499,18 +499,18 @@ public Entry SetLanguage(Language language)
/// });
/// </code>
/// </example>
public Entry SetLocale(String Locale)
{
if (ObjectValueJson != null && !ObjectValueJson.ContainsKey("locale"))
{
UrlQueries.Remove("locale");
UrlQueries.Add("locale", Locale);
}
else
{
UrlQueries["locale"] = Locale;
public Entry SetLocale(String Locale)
{
if (ObjectValueJson != null && !ObjectValueJson.ContainsKey("locale"))
{
UrlQueries.Remove("locale");
UrlQueries.Add("locale", Locale);
}
return this;
else
{
UrlQueries["locale"] = Locale;
}
return this;
}

/// <summary>
Expand Down Expand Up @@ -836,8 +836,8 @@ public String GetDeletedBy()
{

return _ObjectAttributes["deleted_by"].ToString();
}

}

/// <summary>
/// Get key/value pairs in json of current instance.
/// </summary>
Expand Down Expand Up @@ -911,14 +911,14 @@ private List<Asset> GetAssets(String key)
JArray assetArray = (Newtonsoft.Json.Linq.JArray)jObject.GetValue(key);
//Dictionary<string, object> assetArray = (Dictionary<string, object>)_ObjectAttributes[key];

foreach (JToken v in assetArray)
{
JObject assetobj = (JObject)v;
Asset asset = ContentTypeInstance.StackInstance.Asset();
asset.ParseObject(assetobj);
assets.Add(asset);
}

foreach (JToken v in assetArray)
{
JObject assetobj = (JObject)v;
Asset asset = ContentTypeInstance.StackInstance.Asset();
asset.ParseObject(assetobj);
assets.Add(asset);
}

return assets;
}

Expand Down Expand Up @@ -1071,6 +1071,34 @@ public Entry IncludeOnlyReference(string[] keys, string referenceKey)
return this;
}

/// <summary>
/// This method also includes the content type UIDs of the referenced entries returned in the response.
/// </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.IncludeReferenceContentTypeUID();
/// entry.Fetch&lt;Product&gt;().ContinueWith((entryResult) =&gt; {
/// //Your callback code.
/// });
/// </code>
/// </example>
public Entry IncludeReferenceContentTypeUID()
{
try
{
UrlQueries.Add("include_reference_content_type_uid", true);
}
catch (Exception e)
{
throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e);
}
return this;
}

/// <summary>
/// Include schemas of all returned objects along with objects themselves.
Expand Down Expand Up @@ -1246,12 +1274,12 @@ public async Task<T> Fetch<T>()
if (_IsCachePolicySet)
{
cachePolicy = _CachePolicy;
}

}

HTTPRequestHandler RequestHandler = new HTTPRequestHandler();
var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson);
JObject obj = JObject.Parse(ContentstackConvert.ToString(outputResult, "{}"));
return obj.SelectToken("$.entry").ToObject<T>(this.ContentTypeInstance.StackInstance.Serializer);
var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson);
JObject obj = JObject.Parse(ContentstackConvert.ToString(outputResult, "{}"));
return obj.SelectToken("$.entry").ToObject<T>(this.ContentTypeInstance.StackInstance.Serializer);
}
catch (Exception ex)
{
Expand Down
30 changes: 30 additions & 0 deletions Contentstack.Core/Models/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -930,6 +930,36 @@ public Query NotExists(String key)
}

return this;
}

/// <summary>
/// This method also includes the content type UIDs of the referenced entries returned in the response.
/// </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.IncludeReferenceContentTypeUID();
/// csQuery.Find&lt;Product&gt;().ContinueWith((queryResult) =&gt; {
/// //Your callback code.
/// });
/// </code>
/// </example>
public Query IncludeReferenceContentTypeUID()
{
try
{
UrlQueries.Add("include_reference_content_type_uid", true);
}
catch (Exception e)
{
throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e);
}
return this;
}

/// <summary>
Expand Down

0 comments on commit 8d9c913

Please sign in to comment.