diff --git a/.gitignore b/.gitignore index 0c85ec1..25d18aa 100644 --- a/.gitignore +++ b/.gitignore @@ -18,3 +18,4 @@ packages/ *.config *.nupkg *.nuspec +*.trx diff --git a/CHANGELOG.md b/CHANGELOG.md index 049839b..6988b61 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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: diff --git a/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj b/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj index a232d04..c70adc4 100644 --- a/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj +++ b/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj @@ -1,4 +1,4 @@ - + netstandard1.4 @@ -6,7 +6,7 @@ contentstack.aspnetcore Contentstack Contentstack - 2.0 + 2.1.0 1.0.0 Main release Copyright (c) 2012-2019 Contentstack (http://app.contentstack.com). All Rights Reserved diff --git a/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj b/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj index 5fd7c4f..0c2dfec 100644 --- a/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj +++ b/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj @@ -1,10 +1,10 @@ - + netcoreapp2.0 false - 2.0 + 2.1.0 diff --git a/Contentstack.Core.Tests/SyncStackTest.cs b/Contentstack.Core.Tests/SyncStackTest.cs index 653d180..92377fa 100644 --- a/Contentstack.Core.Tests/SyncStackTest.cs +++ b/Contentstack.Core.Tests/SyncStackTest.cs @@ -12,13 +12,13 @@ public class SyncStackTest ContentstackClient client = StackConfig.GetSyncStack(); //STAG - //String PaginationToken = "blt222be844e75a1fca332e39"; - //String SyncToken = "blt529b16590d4646bfce31ce"; + String PaginationToken = "blt222be844e75a1fca332e39"; + String SyncToken = "blt37f6aa8e41cbb327c6c6d3"; - //PROD - String PaginationToken = "blt99c1e34e65f6cc0fd1d82b"; - String SyncToken = "blt08854bd48e43a740951809"; + // //PROD + // String PaginationToken = "blt99c1e34e65f6cc0fd1d82b"; + // String SyncToken = "blt08854bd48e43a740951809"; [Fact] public async Task SyncInit() { @@ -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); + // } + // } } } diff --git a/Contentstack.Core/Contentstack.Core.csproj b/Contentstack.Core/Contentstack.Core.csproj index 6152e98..79237b8 100644 --- a/Contentstack.Core/Contentstack.Core.csproj +++ b/Contentstack.Core/Contentstack.Core.csproj @@ -1,4 +1,4 @@ - + netstandard1.4 @@ -8,11 +8,13 @@ 2.0 Contentstack Query Find method, Entry Fetch method returns ContentstackCollection of Model. - 2.0 + 2.1.0 Copyright © 2012-2019 Contentstack. All Rights Reserved true - v2.0 + v2.1.0 + https://github.com/contentstack/contentstack-dotnet + https://github.com/contentstack/contentstack-dotnet/blob/master/LICENSE diff --git a/Contentstack.Core/Models/Entry.cs b/Contentstack.Core/Models/Entry.cs old mode 100755 new mode 100644 index 06ce270..5c1f2e2 --- a/Contentstack.Core/Models/Entry.cs +++ b/Contentstack.Core/Models/Entry.cs @@ -24,7 +24,7 @@ public class Entry private CachePolicy _CachePolicy; private Dictionary UrlQueries = new Dictionary(); private bool _IsCachePolicySet; - private JObject jObject; + private JObject jObject; private string _Url { get @@ -429,8 +429,8 @@ public void RemoveHeader(string key) public Dictionary GetMetadata() { return Metadata; - } - + } + /// /// Set Language instance /// @@ -479,8 +479,8 @@ public Entry SetLanguage(Language language) return this; - } - + } + /// /// Sets the locale. /// @@ -499,18 +499,18 @@ public Entry SetLanguage(Language language) /// }); /// /// - 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; } /// @@ -836,8 +836,8 @@ public String GetDeletedBy() { return _ObjectAttributes["deleted_by"].ToString(); - } - + } + /// /// Get key/value pairs in json of current instance. /// @@ -911,14 +911,14 @@ private List GetAssets(String key) JArray assetArray = (Newtonsoft.Json.Linq.JArray)jObject.GetValue(key); //Dictionary assetArray = (Dictionary)_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; } @@ -1071,6 +1071,34 @@ public Entry IncludeOnlyReference(string[] keys, string referenceKey) return this; } + /// + /// This method also includes the content type UIDs of the referenced entries returned in the response. + /// + /// 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.IncludeReferenceContentTypeUID(); + /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// //Your callback code. + /// }); + /// + /// + public Entry IncludeReferenceContentTypeUID() + { + try + { + UrlQueries.Add("include_reference_content_type_uid", true); + } + catch (Exception e) + { + throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e); + } + return this; + } /// /// Include schemas of all returned objects along with objects themselves. @@ -1246,12 +1274,12 @@ public async Task Fetch() 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(this.ContentTypeInstance.StackInstance.Serializer); + var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson); + JObject obj = JObject.Parse(ContentstackConvert.ToString(outputResult, "{}")); + return obj.SelectToken("$.entry").ToObject(this.ContentTypeInstance.StackInstance.Serializer); } catch (Exception ex) { diff --git a/Contentstack.Core/Models/Query.cs b/Contentstack.Core/Models/Query.cs index 470ced5..fdbc47f 100644 --- a/Contentstack.Core/Models/Query.cs +++ b/Contentstack.Core/Models/Query.cs @@ -930,6 +930,36 @@ public Query NotExists(String key) } return this; + } + + /// + /// This method also includes the content type UIDs of the referenced entries returned in the response. + /// + /// 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.IncludeReferenceContentTypeUID(); + /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// //Your callback code. + /// }); + /// + /// + public Query IncludeReferenceContentTypeUID() + { + try + { + UrlQueries.Add("include_reference_content_type_uid", true); + } + catch (Exception e) + { + throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e); + } + return this; } ///