From 6a0be8c4e0ecc0e1a5e4c96b250bcd2e7e1ad3f6 Mon Sep 17 00:00:00 2001 From: Nadeem Patwekar Date: Thu, 6 Jun 2024 15:26:10 +0530 Subject: [PATCH 1/9] fix: SRE fix --- Contentstack.Core/Internals/ContentstackRegion.cs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/Contentstack.Core/Internals/ContentstackRegion.cs b/Contentstack.Core/Internals/ContentstackRegion.cs index 1ad09cd..7df9b68 100644 --- a/Contentstack.Core/Internals/ContentstackRegion.cs +++ b/Contentstack.Core/Internals/ContentstackRegion.cs @@ -1,5 +1,4 @@ -using System; -namespace Contentstack.Core.Internals +namespace Contentstack.Core.Internals { /// /// Contentstack region. From 5f516d10a80272d5231823ef80afdbb3ecab0958 Mon Sep 17 00:00:00 2001 From: Nadeem Patwekar Date: Fri, 12 Jul 2024 16:52:37 +0530 Subject: [PATCH 2/9] feat: :sparkles: add variant method implementation on Entry and Query --- .talismanrc | 2 +- Contentstack.Core/Models/Entry.cs | 50 +++++++++++++++++++ Contentstack.Core/Models/Query.cs | 80 ++++++++++++++++++++++++------- 3 files changed, 115 insertions(+), 17 deletions(-) diff --git a/.talismanrc b/.talismanrc index 944a831..0b42628 100644 --- a/.talismanrc +++ b/.talismanrc @@ -10,4 +10,4 @@ fileignoreconfig: - filename: Contentstack.Core/Models/Asset.cs checksum: 98b819cb9b1e6a9a9e5394ac23c07bc642a41c0c7512d169afc63afe3baa6fb3 - filename: Contentstack.Core/Models/Query.cs - checksum: 9237bb4d3e862fad7f3c6d9bad47873758a18617dc9c90d28015dcea267fcd9e \ No newline at end of file + checksum: ceea632e4ea870f35ad3bd313e9f8b4e5ec21aa86f006fca2e0a32945999ba67 \ No newline at end of file diff --git a/Contentstack.Core/Models/Entry.cs b/Contentstack.Core/Models/Entry.cs index 5460b29..20bed0c 100644 --- a/Contentstack.Core/Models/Entry.cs +++ b/Contentstack.Core/Models/Entry.cs @@ -378,6 +378,56 @@ public void RemoveHeader(string key) } + + + /// + /// To set variants header using Entry instance. + /// + /// Entry instance + /// Current instance of Entry, this will be useful for a chaining calls. + /// + /// + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry csEntry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// + /// csEntry.Variant("variant_entry_1"); + /// csEntry.Fetch<Product>().ContinueWith((entryResult) => { + /// //Your callback code. + /// //var result = entryResult.Result.GetMetadata(); + /// }); + /// + /// + public Entry Variant(string variant_header) + { + this.SetHeader("x-cs-variant-uid", variant_header); + return this; + } + + + + /// + /// To set multiple variants headers using Entry instance. + /// + /// Entry instance + /// Current instance of Entry, this will be useful for a chaining calls. + /// + /// + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry csEntry = stack.ContentType("contentType_id").Query(); + /// + /// csEntry.Variant(new List { "variant_entry_1", "variant_entry_2", "variant_entry_3" }); + /// csEntry.Fetch<Product>().ContinueWith((entryResult) => { + /// //Your callback code. + /// //var result = entryResult.Result.GetMetadata(); + /// }); + /// + /// + public Entry Variant(List variant_headers) + { + this.SetHeader("x-cs-variant-uid", string.Join(",", variant_headers)); + return this; + } + /// /// Get metadata of entry. /// diff --git a/Contentstack.Core/Models/Query.cs b/Contentstack.Core/Models/Query.cs index 202c529..5bad6bf 100644 --- a/Contentstack.Core/Models/Query.cs +++ b/Contentstack.Core/Models/Query.cs @@ -1242,8 +1242,8 @@ public Query Only(String[] fieldUid) } return this; - } - + } + /// /// Specifies an array of only keys that would be included in the response. /// @@ -1266,14 +1266,14 @@ public Query IncludeOnlyReference(string[] keys, string referenceKey) if (keys != null && keys.Length > 0) { var referenceKeys = new string[] { referenceKey }; - if (UrlQueries.ContainsKey("include[]") == false) - { + if (UrlQueries.ContainsKey("include[]") == false) + { UrlQueries.Add("include[]", referenceKeys); - - } - if (UrlQueries.ContainsKey($"only[{ referenceKey}][]") == false) - { - UrlQueries.Add($"only[{referenceKey}][]", keys); + + } + if (UrlQueries.ContainsKey($"only[{ referenceKey}][]") == false) + { + UrlQueries.Add($"only[{referenceKey}][]", keys); } } return this; @@ -1333,14 +1333,14 @@ public Query IncludeExceptReference(string[] keys, string referenceKey) if (keys != null && keys.Length > 0) { var referenceKeys = new string[] { referenceKey }; - if (UrlQueries.ContainsKey("include[]") == false) - { + if (UrlQueries.ContainsKey("include[]") == false) + { UrlQueries.Add("include[]", referenceKeys); - - } - if (UrlQueries.ContainsKey($"except[{ referenceKey}][]") == false) - { - UrlQueries.Add($"except[{referenceKey}][]", keys); + + } + if (UrlQueries.ContainsKey($"except[{ referenceKey}][]") == false) + { + UrlQueries.Add($"except[{referenceKey}][]", keys); } } return this; @@ -1686,6 +1686,54 @@ public Query SetCachePolicy(CachePolicy cachePolicy) return this; } + + + /// + /// To set variants header using query instance. + /// + /// Query instance + /// Current instance of Query, this will be useful for a chaining calls. + /// + /// + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); + /// + /// csQuery.Variant("variant_entry_1"); + /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// //Your callback code. + /// }); + /// + /// + public Query Variant(string variant_header) + { + this.SetHeader("x-cs-variant-uid", variant_header); + return this; + } + + + + /// + /// To set multiple variants headers using query instance. + /// + /// Query instance + /// Current instance of Query, this will be useful for a chaining calls. + /// + /// + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); + /// + /// csQuery.Variant(new List { "variant_entry_1", "variant_entry_2", "variant_entry_3" }); + /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// //Your callback code. + /// }); + /// + /// + public Query Variant(List variant_headers) + { + this.SetHeader("x-cs-variant-uid", string.Join(",", variant_headers)); + return this; + } + /// /// Execute a Query and Caches its result (Optional) /// From a5c87cc66e9bd920c842c0ea01e28c3b0f0c1eff Mon Sep 17 00:00:00 2001 From: Nadeem Patwekar Date: Mon, 22 Jul 2024 16:18:35 +0530 Subject: [PATCH 3/9] feat: taxonomy implementation with test cases --- .talismanrc | 4 +- Contentstack.Core.Tests/TaxonomyTest.cs | 86 +++++++ Contentstack.Core/ContentstackClient.cs | 16 ++ Contentstack.Core/Models/Query.cs | 2 - Contentstack.Core/Models/Taxonomy.cs | 302 ++++++++++++++++++++++++ 5 files changed, 407 insertions(+), 3 deletions(-) create mode 100644 Contentstack.Core.Tests/TaxonomyTest.cs create mode 100644 Contentstack.Core/Models/Taxonomy.cs diff --git a/.talismanrc b/.talismanrc index 0b42628..f56eac4 100644 --- a/.talismanrc +++ b/.talismanrc @@ -10,4 +10,6 @@ fileignoreconfig: - filename: Contentstack.Core/Models/Asset.cs checksum: 98b819cb9b1e6a9a9e5394ac23c07bc642a41c0c7512d169afc63afe3baa6fb3 - filename: Contentstack.Core/Models/Query.cs - checksum: ceea632e4ea870f35ad3bd313e9f8b4e5ec21aa86f006fca2e0a32945999ba67 \ No newline at end of file + checksum: ceea632e4ea870f35ad3bd313e9f8b4e5ec21aa86f006fca2e0a32945999ba67 +- filename: Contentstack.Core/Models/Taxonomy.cs + checksum: db8bcefdc7aafde4286e7fb6d67348bec49f1ac27b54d84fddca8124135bd779 \ No newline at end of file diff --git a/Contentstack.Core.Tests/TaxonomyTest.cs b/Contentstack.Core.Tests/TaxonomyTest.cs new file mode 100644 index 0000000..14cd498 --- /dev/null +++ b/Contentstack.Core.Tests/TaxonomyTest.cs @@ -0,0 +1,86 @@ +using System; +using Xunit; +using Contentstack.Core; +using Contentstack.Core.Configuration; +using Contentstack.Core.Models; +using System.Threading.Tasks; +using System.Collections.Generic; +using System.Linq; +using Contentstack.Core.Tests.Models; +using Newtonsoft.Json.Linq; +using System.Reflection.PortableExecutable; + +namespace Contentstack.Core.Tests +{ + + public class TaxonomyTest + { + ContentstackClient client = StackConfig.GetStack(); + + private String numbersContentType = "numbers_content_type"; + String source = "source"; + + public double EPSILON { get; private set; } + + [Fact] + + public async Task GetEntriesWithAnyTaxonomyTerms() + { + Taxonomy query = client.Taxonomies(); + query.Exists("taxonomies.one"); + 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 != null) + { + bool IsTrue = false; + foreach (Entry data in result.Items) + { + IsTrue = data.GetContentType() != null; + if (!IsTrue) + { + break; + } + } + Assert.True(IsTrue); + } + else + { + Assert.False(true, "Result doesn't mathced the count."); + } + } + + [Fact] + public async Task GetEntriesWithTaxonomyTermsandAlsoMatchingItsChildrenTerm() + { + Taxonomy query = client.Taxonomies(); + query.EqualAndBelow("taxonomies.one", "term_one"); + 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 != null) + { + bool IsTrue = false; + foreach (Entry data in result.Items) + { + IsTrue = data.GetContentType() != null; + if (!IsTrue) + { + break; + } + } + Assert.True(IsTrue); + } + else + { + Assert.False(true, "Result doesn't mathced the count."); + } + } + + } +} + diff --git a/Contentstack.Core/ContentstackClient.cs b/Contentstack.Core/ContentstackClient.cs index 8324f7c..b03836e 100644 --- a/Contentstack.Core/ContentstackClient.cs +++ b/Contentstack.Core/ContentstackClient.cs @@ -409,6 +409,22 @@ public AssetLibrary AssetLibrary() return asset; } + /// + /// Represents a Taxonomy. Creates Taxonomy Instance. + /// + /// Current instance of Taxonomy, this will be useful for a chaining calls. + /// + /// + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Taxonomy taxonomy = stack.Taxonomy(); + /// + /// + public Taxonomy Taxonomies() + { + Taxonomy tx = new Taxonomy(this); + return tx; + } + /// /// Get version. /// diff --git a/Contentstack.Core/Models/Query.cs b/Contentstack.Core/Models/Query.cs index 5bad6bf..636ebbd 100644 --- a/Contentstack.Core/Models/Query.cs +++ b/Contentstack.Core/Models/Query.cs @@ -590,7 +590,6 @@ public Query LessThan(String key, Object value) /// public Query LessThanOrEqualTo(String key, Object value) { - if (key != null && value != null) { @@ -745,7 +744,6 @@ public Query NotEqualTo(String key, Object value) { throw new Exception(StackConstants.ErrorMessage_QueryFilterException, null); } - return this; } diff --git a/Contentstack.Core/Models/Taxonomy.cs b/Contentstack.Core/Models/Taxonomy.cs new file mode 100644 index 0000000..ff979da --- /dev/null +++ b/Contentstack.Core/Models/Taxonomy.cs @@ -0,0 +1,302 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Net; +using System.Threading.Tasks; +using Contentstack.Core.Configuration; +using Contentstack.Core.Internals; +using Newtonsoft.Json.Linq; + +namespace Contentstack.Core.Models +{ + public class Taxonomy: Query + { + + + #region Internal Variables + private Dictionary _ObjectAttributes = new Dictionary(); + private Dictionary _Headers = new Dictionary(); + private Dictionary _StackHeaders = new Dictionary(); + private Dictionary UrlQueries = new Dictionary(); + private Dictionary QueryValueJson = new Dictionary(); + + private string _Url + { + get + { + Config config = this.Stack.Config; + return String.Format("{0}/taxonomies/entries", config.BaseUrl); + } + } + #endregion + + public ContentstackClient Stack + { + get; + set; + } + + #region Internal Constructors + + internal Taxonomy() + { + } + internal Taxonomy(ContentstackClient stack) + { + this.Stack = stack; + this._StackHeaders = stack._LocalHeaders; + } + + #endregion + #region Public Functions + + /// + /// Add a constraint to the query that requires a particular key entry to be less than the provided value. + /// + /// the key to be constrained. + /// the value that provides an upper bound. + /// Current instance of Query, this will be useful for a chaining calls. + /// + /// + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); + /// + /// csQuery.LessThan("due_date", "2013-06-25T00:00:00+05:30"); + /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// //Your callback code. + /// }); + /// + /// + public Taxonomy Above(String key, Object value) + { + if (key != null && value != null) + { + try + { + Dictionary queryValue = new Dictionary{ { "$above", value } }; + QueryValueJson.Add(key, queryValue); + } catch (Exception e) { + throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e); + } + } + else + { + throw new Exception(StackConstants.ErrorMessage_QueryFilterException, null); + } + + return this; + } + + /// + /// Add a constraint to the query that requires a particular key entry to be less than the provided value. + /// + /// the key to be constrained. + /// the value that provides an upper bound. + /// Current instance of Query, this will be useful for a chaining calls. + /// + /// + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); + /// + /// csQuery.LessThan("due_date", "2013-06-25T00:00:00+05:30"); + /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// //Your callback code. + /// }); + /// + /// + public Taxonomy EqualAndAbove(String key, Object value) + { + if (key != null && value != null) + { + try + { + Dictionary queryValue = new Dictionary{ { "$eq_above", value } }; + QueryValueJson.Add(key, queryValue); + } + catch (Exception e) + { + throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e); + } + } + else + { + throw new Exception(StackConstants.ErrorMessage_QueryFilterException, null); + } + + return this; + } + + /// + /// Add a constraint to the query that requires a particular key entry to be less than the provided value. + /// + /// the key to be constrained. + /// the value that provides an upper bound. + /// Current instance of Query, this will be useful for a chaining calls. + /// + /// + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); + /// + /// csQuery.LessThan("due_date", "2013-06-25T00:00:00+05:30"); + /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// //Your callback code. + /// }); + /// + /// + public Taxonomy Below(String key, Object value) + { + if (key != null && value != null) + { + try + { + Dictionary queryValue = new Dictionary { { "$below", value } }; + QueryValueJson.Add(key, queryValue); + } + catch (Exception e) + { + throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e); + } + } + else + { + throw new Exception(StackConstants.ErrorMessage_QueryFilterException, null); + } + + return this; + } + + /// + /// Add a constraint to the query that requires a particular key entry to be less than the provided value. + /// + /// the key to be constrained. + /// the value that provides an upper bound. + /// Current instance of Query, this will be useful for a chaining calls. + /// + /// + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); + /// + /// csQuery.LessThan("due_date", "2013-06-25T00:00:00+05:30"); + /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// //Your callback code. + /// }); + /// + /// + public Taxonomy EqualAndBelow(String key, Object value) + { + if (key != null && value != null) + { + try + { + Dictionary queryValue = new Dictionary { { "eq_$below", value } }; + QueryValueJson.Add(key, queryValue); + } + catch (Exception e) + { + throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e); + } + } + else + { + throw new Exception(StackConstants.ErrorMessage_QueryFilterException, null); + } + + return this; + } + + #endregion + #region Private Functions + + private Dictionary GetHeader(Dictionary localHeader) + { + Dictionary mainHeader = _StackHeaders; + Dictionary classHeaders = new Dictionary(); + + if (localHeader != null && localHeader.Count > 0) + { + if (mainHeader != null && mainHeader.Count > 0) + { + foreach (var entry in localHeader) + { + String key = entry.Key; + classHeaders.Add(key, entry.Value); + } + + foreach (var entry in mainHeader) + { + String key = entry.Key; + if (!classHeaders.ContainsKey(key)) + { + classHeaders.Add(key, entry.Value); + } + } + + return classHeaders; + + } + else + { + return localHeader; + } + + } + else + { + return _StackHeaders; + } + } + internal static ContentstackException GetContentstackError(Exception ex) + { + Int32 errorCode = 0; + string errorMessage = string.Empty; + HttpStatusCode statusCode = HttpStatusCode.InternalServerError; + ContentstackException contentstackError = new ContentstackException(ex); + Dictionary errors = null; + + try + { + System.Net.WebException webEx = (System.Net.WebException)ex; + + using (var exResp = webEx.Response) + using (var stream = exResp.GetResponseStream()) + using (var reader = new StreamReader(stream)) + { + errorMessage = reader.ReadToEnd(); + JObject data = JObject.Parse(errorMessage.Replace("\r\n", "")); + + JToken token = data["error_code"]; + if (token != null) + errorCode = token.Value(); + + token = data["error_message"]; + if (token != null) + errorMessage = token.Value(); + + token = data["errors"]; + if (token != null) + errors = token.ToObject>(); + + var response = exResp as HttpWebResponse; + if (response != null) + statusCode = response.StatusCode; + } + } + catch + { + errorMessage = ex.Message; + } + + contentstackError = new ContentstackException() + { + ErrorCode = errorCode, + ErrorMessage = errorMessage, + StatusCode = statusCode, + Errors = errors + }; + + return contentstackError; + } + #endregion + } +} From c023a30efddfefd2d8ac5bccbb88957e1c4ff167 Mon Sep 17 00:00:00 2001 From: Nadeem Patwekar Date: Wed, 24 Jul 2024 13:56:11 +0530 Subject: [PATCH 4/9] test: adds test cases for other functions --- Contentstack.Core.Tests/TaxonomyTest.cs | 104 ++++++++++++++++++++++-- 1 file changed, 98 insertions(+), 6 deletions(-) diff --git a/Contentstack.Core.Tests/TaxonomyTest.cs b/Contentstack.Core.Tests/TaxonomyTest.cs index 14cd498..b5d49aa 100644 --- a/Contentstack.Core.Tests/TaxonomyTest.cs +++ b/Contentstack.Core.Tests/TaxonomyTest.cs @@ -24,14 +24,15 @@ public class TaxonomyTest [Fact] - public async Task GetEntriesWithAnyTaxonomyTerms() + public async Task TaxonomyExists() { + // Description: Taxonomy Exists - Get Entries With Any Taxonomy Terms ($exists) Taxonomy query = client.Taxonomies(); query.Exists("taxonomies.one"); var result = await query.Find(); if (result == null && result.Items.Count() == 0) { - Assert.False(true, "Query.Exec is not match with expected result."); + Assert.Fail("Query.Exec is not match with expected result."); } else if (result != null) { @@ -48,19 +49,20 @@ public async Task GetEntriesWithAnyTaxonomyTerms() } else { - Assert.False(true, "Result doesn't mathced the count."); + Assert.Fail("Result doesn't mathced the count."); } } [Fact] - public async Task GetEntriesWithTaxonomyTermsandAlsoMatchingItsChildrenTerm() + public async Task TaxonomyEqualAndBelow() { + // Description: Taxonomy EqualAndBelow - Get Entries With Taxonomy Terms and Also Matching Its Children Term ($eq_below, level) Taxonomy query = client.Taxonomies(); query.EqualAndBelow("taxonomies.one", "term_one"); var result = await query.Find(); if (result == null && result.Items.Count() == 0) { - Assert.False(true, "Query.Exec is not match with expected result."); + Assert.Fail("Query.Exec is not match with expected result."); } else if (result != null) { @@ -77,7 +79,97 @@ public async Task GetEntriesWithTaxonomyTermsandAlsoMatchingItsChildrenTerm() } else { - Assert.False(true, "Result doesn't mathced the count."); + Assert.Fail("Result doesn't mathced the count."); + } + } + + [Fact] + public async Task TaxonomyBelow() + { + // Description: Taxonomy Below - Get Entries With Taxonomy Terms Children\'s and Excluding the term itself ($below, level) + Taxonomy query = client.Taxonomies(); + query.Below("taxonomies.one", "term_one"); + var result = await query.Find(); + if (result == null && result.Items.Count() == 0) + { + Assert.Fail("Query.Exec is not match with expected result."); + } + else if (result != null) + { + bool IsTrue = false; + foreach (Entry data in result.Items) + { + IsTrue = data.GetContentType() != null; + if (!IsTrue) + { + break; + } + } + Assert.True(IsTrue); + } + else + { + Assert.Fail("Result doesn't mathced the count."); + } + } + + [Fact] + public async Task TaxonomyEqualAndAbove() + { + // Description: Taxonomy EqualAndAbove - Get Entries With Taxonomy Terms and Also Matching Its Parent Term ($eq_above, level) + Taxonomy query = client.Taxonomies(); + query.EqualAndAbove("taxonomies.one", "term_one"); + var result = await query.Find(); + if (result == null && result.Items.Count() == 0) + { + Assert.Fail("Query.Exec is not match with expected result."); + } + else if (result != null) + { + bool IsTrue = false; + foreach (Entry data in result.Items) + { + IsTrue = data.GetContentType() != null; + if (!IsTrue) + { + break; + } + } + Assert.True(IsTrue); + } + else + { + Assert.Fail("Result doesn't mathced the count."); + } + } + + [Fact] + public async Task TaxonomyAbove() + { + // Description: Taxonomy Above - Get Entries With Taxonomy Terms Parent and Excluding the term itself ($above, level) + Taxonomy query = client.Taxonomies(); + query.Above("taxonomies.one", "term_one"); + var result = await query.Find(); + if (result == null && result.Items.Count() == 0) + { + Assert.Fail("Query.Exec is not match with expected result."); + } + else if (result != null) + { + bool IsTrue = false; + foreach (Entry data in result.Items) + { + IsTrue = data.GetContentType() != null; + if (!IsTrue) + { + break; + } + } + Assert.True(IsTrue); + } + else + { + Assert.Fail("Result doesn't mathced the count."); } } From f34e49689f1797f03d37b061d5c5f35732a3f1af Mon Sep 17 00:00:00 2001 From: Nadeem Patwekar Date: Wed, 24 Jul 2024 14:04:36 +0530 Subject: [PATCH 5/9] chore: update changelog and version --- CHANGELOG.md | 6 ++++++ Directory.Build.props | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63e3f73..8429910 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### Version: 2.15.0 +#### Date: Jul-30-2024 + +##### New Feature: +- Taxonomy class added + ### Version: 2.14.0 #### Date: May-28-2024 diff --git a/Directory.Build.props b/Directory.Build.props index 3221139..c39d590 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 2.14.0 + 2.15.0 From d2cc80d9f066b0126e8ccbbe99d179025eeb279f Mon Sep 17 00:00:00 2001 From: Nadeem Patwekar Date: Wed, 7 Aug 2024 12:31:58 +0530 Subject: [PATCH 6/9] test: add Variants tests --- Contentstack.Core.Tests/EntryTest.cs | 47 +++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/Contentstack.Core.Tests/EntryTest.cs b/Contentstack.Core.Tests/EntryTest.cs index 17e5491..e35bcba 100644 --- a/Contentstack.Core.Tests/EntryTest.cs +++ b/Contentstack.Core.Tests/EntryTest.cs @@ -71,7 +71,8 @@ public async Task FetchEntryByUIDPublishFallback() list.Add("ja-jp"); ContentType contenttype = client.ContentType(source); string uid = await GetUID("source1"); - Entry sourceEntry = await contenttype.Entry(uid) + Entry sourceEntry = contenttype.Entry(uid); + await sourceEntry .SetLocale("ja-jp") .IncludeFallback() .Fetch(); @@ -79,6 +80,50 @@ public async Task FetchEntryByUIDPublishFallback() Assert.Contains((string)(sourceEntry.Get("publish_details") as JObject).GetValue("locale"), list); } + [Fact] + public async Task FetchEntryByVariant() + { + ContentType contenttype = client.ContentType(source); + string uid = await GetUID("source1"); + Entry sourceEntry = contenttype.Entry(uid); + await sourceEntry + .Variant("variant1") + .Fetch().ContinueWith((t) => + { + Entry result = t.Result; + if (result == null) + { + Assert.False(true, "Entry.Fetch is not match with expected result."); + } + else + { + Assert.True(result.Uid == sourceEntry.Uid); + } + }); + } + + [Fact] + public async Task FetchEntryByVariants() + { + ContentType contenttype = client.ContentType(source); + string uid = await GetUID("source1"); + Entry sourceEntry = contenttype.Entry(uid); + await sourceEntry + .Variant(new List { "variant1", "variant2" }) + .Fetch().ContinueWith((t) => + { + Entry result = t.Result; + if (result == null) + { + Assert.False(true, "Entry.Fetch is not match with expected result."); + } + else + { + Assert.True(result.Uid == sourceEntry.Uid); + } + }); + } + [Fact] public async Task FetchEntryByUIDPublishWithoutFallback() { From ed2bed92ca7db7a403cb926cf0189770a27efa95 Mon Sep 17 00:00:00 2001 From: Nadeem Patwekar Date: Tue, 13 Aug 2024 20:54:42 +0530 Subject: [PATCH 7/9] fix: workflow fix --no-symbols doesnt need boolean value --- .github/workflows/nuget-publish.yml | 4 ++-- .talismanrc | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/nuget-publish.yml b/.github/workflows/nuget-publish.yml index 5a36532..de2c4af 100644 --- a/.github/workflows/nuget-publish.yml +++ b/.github/workflows/nuget-publish.yml @@ -21,7 +21,7 @@ jobs: - name: Push generated package to GitHub registry run: | cd out - dotnet nuget push "contentstack.csharp.*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate --no-symbols true --source https://api.nuget.org/v3/index.json + dotnet nuget push "contentstack.csharp.*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate --no-symbols --source https://api.nuget.org/v3/index.json publish-git: runs-on: windows-latest @@ -41,4 +41,4 @@ jobs: - name: Push generated package to GitHub registry run: | cd out - dotnet nuget push "contentstack.csharp.*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate --no-symbols true --source https://api.nuget.org/v3/index.json + dotnet nuget push "contentstack.csharp.*.nupkg" --api-key ${{ secrets.NUGET_API_KEY }} --skip-duplicate --no-symbols --source https://api.nuget.org/v3/index.json diff --git a/.talismanrc b/.talismanrc index f56eac4..00c0fba 100644 --- a/.talismanrc +++ b/.talismanrc @@ -12,4 +12,6 @@ fileignoreconfig: - filename: Contentstack.Core/Models/Query.cs checksum: ceea632e4ea870f35ad3bd313e9f8b4e5ec21aa86f006fca2e0a32945999ba67 - filename: Contentstack.Core/Models/Taxonomy.cs - checksum: db8bcefdc7aafde4286e7fb6d67348bec49f1ac27b54d84fddca8124135bd779 \ No newline at end of file + checksum: db8bcefdc7aafde4286e7fb6d67348bec49f1ac27b54d84fddca8124135bd779 +- filename: .github/workflows/nuget-publish.yml + checksum: 53ba4ce874c4d2362ad00deb23f5a6ec219318860352f997b945e9161a580651 \ No newline at end of file From 8415c5900ce1b8df8dd61c592c1aa9b7ce3dee6a Mon Sep 17 00:00:00 2001 From: raj pandey Date: Tue, 3 Sep 2024 18:30:01 +0530 Subject: [PATCH 8/9] added early access header --- CHANGELOG.md | 6 ++++++ Contentstack.Core/Configuration/ContentstackOptions.cs | 7 ++++++- Contentstack.Core/ContentstackClient.cs | 4 ++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8429910..967fa85 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### Version: 2.16.0 +#### Date: Sep-3-2024 + +##### New Feature: +- Added Early Access Header Support + ### Version: 2.15.0 #### Date: Jul-30-2024 diff --git a/Contentstack.Core/Configuration/ContentstackOptions.cs b/Contentstack.Core/Configuration/ContentstackOptions.cs index 73f2455..62c1cf5 100644 --- a/Contentstack.Core/Configuration/ContentstackOptions.cs +++ b/Contentstack.Core/Configuration/ContentstackOptions.cs @@ -74,8 +74,13 @@ public ContentstackOptions() { Timeout = 30000; // Set default value } - } + /// + /// TheEarlyAccessHeader used to set service which the user has early access to. + /// + public string[] EarlyAccessHeader { get; set; } + } + internal class ContentstackRegionConverter : TypeConverter { public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) diff --git a/Contentstack.Core/ContentstackClient.cs b/Contentstack.Core/ContentstackClient.cs index b03836e..436c82a 100644 --- a/Contentstack.Core/ContentstackClient.cs +++ b/Contentstack.Core/ContentstackClient.cs @@ -87,6 +87,10 @@ public ContentstackClient(IOptions options) { this.SetHeader("access_token", _options.DeliveryToken); } + if(_options.EarlyAccessHeader !=null) + { + this.SetHeader("x-header-ea", string.Join(",", _options.EarlyAccessHeader)); + } Config cnfig = new Config(); cnfig.Environment = _options.Environment; if (_options.Host != null) From 55a1e82c489cb7100989827847c220ae8c3b07d0 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Wed, 4 Sep 2024 11:12:35 +0530 Subject: [PATCH 9/9] version bump --- Directory.Build.props | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Directory.Build.props b/Directory.Build.props index c39d590..0b3a5c9 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 2.15.0 + 2.16.0