diff --git a/CHANGELOG.md b/CHANGELOG.md index 8e5cf09..b77db77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +### Version: 2.22.0 +#### Date: March-03-2025 + +##### Feat: +- Added Support for Global Fields + ### Version: 2.21.0 #### Date: March-03-2025 diff --git a/Contentstack.Core.Tests/ContentTypeTest.cs b/Contentstack.Core.Tests/ContentTypeTest.cs index 2b7cc87..cca56d6 100644 --- a/Contentstack.Core.Tests/ContentTypeTest.cs +++ b/Contentstack.Core.Tests/ContentTypeTest.cs @@ -3,6 +3,7 @@ using Contentstack.Core.Models; using System.Threading.Tasks; using System.Collections.Generic; +using Newtonsoft.Json.Linq; namespace Contentstack.Core.Tests { @@ -79,5 +80,130 @@ public async Task GetContentTypesIncludeGlobalFields() } } + + [Fact] + public async Task FetchGlobalFieldSchema() + { + string globalFieldUid = "global_field_uid"; + GlobalField globalField = client.GlobalField(globalFieldUid); + + var result = await globalField.Fetch(); + Assert.NotNull(result); + Assert.True(result.HasValues, "GlobalField.Fetch() did not return expected schema."); + } + + [Fact] + public async Task FetchGlobalFieldSchema_InvalidUid_ThrowsOrReturnsNull() + { + string invalidUid = "invalid_uid"; + GlobalField globalField = client.GlobalField(invalidUid); + await Assert.ThrowsAnyAsync(async () => await globalField.Fetch()); + } + + [Fact] + public async Task FetchGlobalFieldSchema_WithParameters_ReturnsSchema() + { + string globalFieldUid = "global_field_uid"; + GlobalField globalField = client.GlobalField(globalFieldUid); + var param = new Dictionary { { "include_global_field_schema", true } }; + var result = await globalField.Fetch(param); + Assert.NotNull(result); + Assert.True(result.HasValues, "GlobalField.Fetch() with params did not return expected schema."); + } + + [Fact] + public void SetAndRemoveHeader_WorksCorrectly() + { + string globalFieldUid = "global_field_uid"; + GlobalField globalField = client.GlobalField(globalFieldUid); + globalField.SetHeader("custom_key", "custom_value"); + globalField.RemoveHeader("custom_key"); + Assert.True(true); + } + + [Fact] + public async Task FetchGlobalFieldSchema_WithCustomHeader() + { + string globalFieldUid = "global_field_uid"; + GlobalField globalField = client.GlobalField(globalFieldUid); + globalField.SetHeader("custom_key", "custom_value"); + var result = await globalField.Fetch(); + Assert.NotNull(result); + } + + [Fact] + public async Task FetchGlobalFieldSchema_NullParameters_Succeeds() + { + string globalFieldUid = "global_field_uid"; + GlobalField globalField = client.GlobalField(globalFieldUid); + var result = await globalField.Fetch(null); + Assert.NotNull(result); + } + + [Fact] + public void GlobalField_EmptyUid_Throws() + { + Assert.Throws(() => { + GlobalField globalField = client.GlobalField(""); + }); + } + + [Fact] + public async Task GlobalFieldQuery_Find_ReturnsArray() + { + var query = client.GlobalFieldQuery(); + var result = await query.Find(); + + Assert.NotNull(result); + } + + [Fact] + public async Task GlobalFieldQuery_Find_WithParameters_ReturnsArray() + { + var query = client.GlobalFieldQuery(); + var param = new Dictionary { { "include_global_field_schema", true } }; + var result = await query.Find(param); + Assert.NotNull(result); + } + + [Fact] + public async Task GlobalFieldQuery_Find_WithSkipAndLimit_ReturnsArray() + { + var query = client.GlobalFieldQuery(); + var param = new Dictionary { { "skip", 1 }, { "limit", 2 } }; + var result = await query.Find(param); + Assert.Empty(result["global_fields"]); + } + + [Fact] + public void GlobalFieldQuery_IncludeBranch_SetsQueryParam() + { + var query = client.GlobalFieldQuery(); + var result = query.IncludeBranch(); + Assert.NotNull(result); + Assert.Equal(query, result); + } + + [Fact] + public void GlobalFieldQuery_IncludeGlobalFieldSchema_SetsQueryParam() + { + var query = client.GlobalFieldQuery(); + var result = query.IncludeGlobalFieldSchema(); + Assert.NotNull(result); + } + + [Fact] + public async Task GlobalFieldQuery_Find_InvalidParams_ThrowsOrReturnsEmpty() + { + var query = client.GlobalFieldQuery(); + var invalidParams = new Dictionary { { "invalid_param", true } }; + + var result = await query.Find(invalidParams); + + Assert.NotNull(result); + Assert.IsType(result); + var globalFields = result["global_fields"] as JArray; + Assert.NotNull(globalFields); + } } } \ No newline at end of file diff --git a/Contentstack.Core/ContentstackClient.cs b/Contentstack.Core/ContentstackClient.cs index 2811773..1bd1a1e 100644 --- a/Contentstack.Core/ContentstackClient.cs +++ b/Contentstack.Core/ContentstackClient.cs @@ -65,12 +65,12 @@ private string _Url /// /// var options = new ContentstackOptions() /// { - /// ApiKey = "api_key", - /// DeliveryToken = "delivery_token" - /// Environment = "environment" + /// ApiKey = "api_key", + /// DeliveryToken = "delivery_token" + /// Environment = "environment" /// } /// ContentstackClient stack = new ContentstackClient(options); - /// ContentType contentType = stack.ContentType("contentType_name"); + /// ContentType contentType = stack.ContentType("contentType_name"); /// /// public ContentstackClient(IOptions options) @@ -82,11 +82,12 @@ public ContentstackClient(IOptions options) if (_options.AccessToken != null) { this.SetHeader("access_token", _options.AccessToken); - } else if (_options.DeliveryToken != null) + } + else if (_options.DeliveryToken != null) { this.SetHeader("access_token", _options.DeliveryToken); } - if(_options.EarlyAccessHeader !=null) + if (_options.EarlyAccessHeader != null) { this.SetHeader("x-header-ea", string.Join(",", _options.EarlyAccessHeader)); } @@ -128,7 +129,9 @@ public ContentstackClient(IOptions options) else if (this.LivePreviewConfig.PreviewToken != null) { this.LivePreviewConfig.Host = "rest-preview.contentstack.com"; - } else { + } + else + { throw new InvalidOperationException("Add PreviewToken or ManagementToken in LivePreviewConfig"); } } @@ -158,8 +161,8 @@ public ContentstackClient(ContentstackOptions options) : /// Environment name /// /// - /// ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment"); - /// ContentType contentType = stack.ContentType("contentType_name"); + /// ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment"); + /// ContentType contentType = stack.ContentType("contentType_name"); /// /// public ContentstackClient(string apiKey, string deliveryToken, string environment, string host = null, ContentstackRegion region = ContentstackRegion.US, string version = null, int? timeout = null, WebProxy proxy = null) : @@ -264,7 +267,7 @@ internal void SetConfig(Config cnfig) /// Current instance of Asset, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// Asset asset = stack.Asset(); /// /// @@ -282,8 +285,8 @@ internal Asset Asset() /// /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// var param = new Dictionary<string, object>(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// var param = new Dictionary(); /// param.Add("include_global_field_schema",true); /// param.Add("limit", 10); /// param.Add("skip", 10); @@ -337,7 +340,7 @@ public async Task GetContentTypes(Dictionary param = null private async Task GetLivePreviewData() { - + Dictionary headerAll = new Dictionary(); Dictionary mainJson = new Dictionary(); Dictionary headers = GetHeader(_LocalHeaders); @@ -354,12 +357,17 @@ private async Task GetLivePreviewData() } } mainJson.Add("live_preview", this.LivePreviewConfig.LivePreview ?? "init"); - - if (!string.IsNullOrEmpty(this.LivePreviewConfig.ManagementToken)) { + + if (!string.IsNullOrEmpty(this.LivePreviewConfig.ManagementToken)) + { headerAll["authorization"] = this.LivePreviewConfig.ManagementToken; - } else if (!string.IsNullOrEmpty(this.LivePreviewConfig.PreviewToken)) { + } + else if (!string.IsNullOrEmpty(this.LivePreviewConfig.PreviewToken)) + { headerAll["preview_token"] = this.LivePreviewConfig.PreviewToken; - } else { + } + else + { throw new InvalidOperationException("Either ManagementToken or PreviewToken is required in LivePreviewConfig"); } @@ -393,8 +401,8 @@ private async Task GetLivePreviewData() /// Current instance of ContentType, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// ContentType contentType = stack.ContentType("contentType_name"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentType contentType = stack.ContentType("contentType_name"); /// /// public ContentType ContentType(String contentTypeName) @@ -405,14 +413,29 @@ public ContentType ContentType(String contentTypeName) return contentType; } + + public GlobalField GlobalField(String globalFieldName) + { + GlobalField globalField = new GlobalField(globalFieldName); + globalField.SetStackInstance(this); + return globalField; + } + + public GlobalFieldQuery GlobalFieldQuery() + { + GlobalFieldQuery globalField = new GlobalFieldQuery(); + globalField.SetStackInstance(this); + return globalField; + } + /// /// Represents a Asset. Creates Asset Instance. /// /// Current instance of Asset, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Asset asset = stack.Asset("asset_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Asset asset = stack.Asset("asset_uid"); /// /// public Asset Asset(String Uid) @@ -427,7 +450,7 @@ public Asset Asset(String Uid) /// Current instance of Asset, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// AssetLibrary assetLibrary = stack.AssetLibrary(); /// /// @@ -443,7 +466,7 @@ public AssetLibrary AssetLibrary() /// Current instance of Taxonomy, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// Taxonomy taxonomy = stack.Taxonomy(); /// /// @@ -459,7 +482,7 @@ public Taxonomy Taxonomies() /// Version /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// String url = stack.GetVersion(); /// /// @@ -474,7 +497,7 @@ public string GetVersion() /// stack application key /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// String url = stack.GetApplicationKey(); /// /// @@ -496,7 +519,7 @@ public LivePreviewConfig GetLivePreviewConfig() /// access token /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// String accessToken = stack.GetAccessToken(); /// /// @@ -511,7 +534,7 @@ public string GetAccessToken() /// stack environment /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// String environment = stack.GetEnvironment(); /// /// @@ -526,8 +549,8 @@ public string GetEnvironment() /// key to be remove from header /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// stack.RemoveHeader("custom_header_key"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// stack.RemoveHeader("custom_header_key"); /// /// public void RemoveHeader(string key) @@ -544,8 +567,8 @@ public void RemoveHeader(string key) /// header value against given header name. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// stack.SetHeader("custom_key", "custom_value"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// stack.SetHeader("custom_key", "custom_value"); /// /// public void SetHeader(string key, string value) @@ -565,7 +588,7 @@ public void SetHeader(string key, string value) /// Query parameter containing hash and content type UID /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// stack.LivePreviewQuery(query); /// /// @@ -592,13 +615,15 @@ public async Task LivePreviewQueryAsync(Dictionary query) string hash = null; query.TryGetValue("live_preview", out hash); this.LivePreviewConfig.LivePreview = hash; - } - if (query.Keys.Contains("release_id")) { + } + if (query.Keys.Contains("release_id")) + { string ReleaseId = null; query.TryGetValue("release_id", out ReleaseId); this.LivePreviewConfig.ReleaseId = ReleaseId; } - if (query.Keys.Contains("preview_timestamp")) { + if (query.Keys.Contains("preview_timestamp")) + { string PreviewTimestamp = null; query.TryGetValue("preview_timestamp", out PreviewTimestamp); this.LivePreviewConfig.PreviewTimestamp = PreviewTimestamp; @@ -616,8 +641,8 @@ public async Task LivePreviewQueryAsync(Dictionary query) /// Start from. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// stack.SyncRecursiveLanguage("SyncType", "Locale"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// stack.SyncRecursiveLanguage("SyncType", "Locale"); /// /// public async Task SyncRecursive(String Locale = null, SyncType SyncType = SyncType.All, string ContentTypeUid = null, DateTime? StartFrom = null) @@ -634,8 +659,8 @@ public async Task SyncRecursive(String Locale = null, SyncType SyncTy /// Pagination token. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// stack.SyncPaginationTokenn("pagination_token"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// stack.SyncPaginationTokenn("pagination_token"); /// /// @@ -651,8 +676,8 @@ public async Task SyncPaginationToken(string paginationToken) /// Sync token. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// stack.SyncToken("sync_token"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// stack.SyncToken("sync_token"); /// /// public async Task SyncToken(string SyncToken) diff --git a/Contentstack.Core/Internals/HttpRequestHandler.cs b/Contentstack.Core/Internals/HttpRequestHandler.cs index 3f5e45e..00ffaf1 100644 --- a/Contentstack.Core/Internals/HttpRequestHandler.cs +++ b/Contentstack.Core/Internals/HttpRequestHandler.cs @@ -48,7 +48,7 @@ public async Task ProcessRequest(string Url, Dictionary var request = (HttpWebRequest)WebRequest.Create(uri); request.Method = "GET"; request.ContentType = "application/json"; - request.Headers["x-user-agent"]="contentstack-delivery-dotnet/2.21.0"; + request.Headers["x-user-agent"]="contentstack-delivery-dotnet/2.22.0"; request.Timeout = timeout; if (proxy != null) diff --git a/Contentstack.Core/Models/Asset.cs b/Contentstack.Core/Models/Asset.cs index ac49192..dcc07e9 100644 --- a/Contentstack.Core/Models/Asset.cs +++ b/Contentstack.Core/Models/Asset.cs @@ -214,10 +214,10 @@ public void SetHeader(string key, string value) /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Asset asset = stack.Asset("asset_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Asset asset = stack.Asset("asset_uid"); /// asset.IncludeFallback(); - /// asset.Fetch<Product>().ContinueWith((assetResult) => { + /// asset.Fetch().ContinueWith((assetResult) => { /// //Your callback code. /// }); /// @@ -236,10 +236,10 @@ public Asset IncludeFallback() /// Current instance of Asset, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Asset asset = stack.Asset("asset_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Asset asset = stack.Asset("asset_uid"); /// asset.IncludeMetadata(); - /// asset.Fetch<Product>().ContinueWith((assetResult) => { + /// asset.Fetch().ContinueWith((assetResult) => { /// //Your callback code. /// }); /// @@ -264,10 +264,10 @@ public Asset IncludeMetadata() /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Asset asset = stack.Asset("asset_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Asset asset = stack.Asset("asset_uid"); /// asset.IncludeBranch(); - /// asset.Fetch<Product>().ContinueWith((assetResult) => { + /// asset.Fetch().ContinueWith((assetResult) => { /// //Your callback code. /// }); /// @@ -285,10 +285,10 @@ public Asset IncludeBranch() /// Current instance of Asset, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Asset asset = stack.Asset("asset_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Asset asset = stack.Asset("asset_uid"); /// asset.AddParam("include_branch", "true"); - /// asset.Fetch<Product>().ContinueWith((assetResult) => { + /// asset.Fetch().ContinueWith((assetResult) => { /// //Your callback code. /// }); /// diff --git a/Contentstack.Core/Models/AssetLibrary.cs b/Contentstack.Core/Models/AssetLibrary.cs index 2c7e88d..adb01dd 100644 --- a/Contentstack.Core/Models/AssetLibrary.cs +++ b/Contentstack.Core/Models/AssetLibrary.cs @@ -57,10 +57,10 @@ internal AssetLibrary(ContentstackClient stack) /// Order. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// AssetLibrary assetLibrary = stack.AssetLibrary(); - /// assetLibrary.SortWithKeyAndOrderBy("custom_key", "custom_value"); - /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll(); + /// assetLibrary.SortWithKeyAndOrderBy("custom_key", "custom_value"); + /// ContentstackCollection contentstackCollection = await assetLibrary.FetchAll(); /// /// public void SortWithKeyAndOrderBy(String key, OrderBy order) @@ -81,7 +81,7 @@ public void SortWithKeyAndOrderBy(String key, OrderBy order) /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// AssetLibrary assetLibrary = stack.AssetLibrary(); /// JObject jObject = await assetLibrary.Count(); /// @@ -110,10 +110,10 @@ public AssetLibrary Query(JObject QueryObject) /// Current instance of AssetLibrary, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// AssetLibrary assetLibrary = stack.AssetLibrary(); /// assetLibrary.IncludeFallback(); - /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll(); + /// ContentstackCollection contentstackCollection = await assetLibrary.FetchAll(); /// /// public AssetLibrary IncludeFallback() @@ -135,10 +135,10 @@ public AssetLibrary IncludeFallback() /// Current instance of AssetLibrary, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// AssetLibrary assetLibrary = stack.AssetLibrary(); /// assetLibrary.IncludeBranch(); - /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll(); + /// ContentstackCollection contentstackCollection = await assetLibrary.FetchAll(); /// /// public AssetLibrary IncludeBranch() @@ -161,10 +161,10 @@ public AssetLibrary IncludeBranch() /// Current instance of Asset, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// AssetLibrary assetLibrary = stack.AssetLibrary(); /// assetLibrary.AddParam("include_branch", "true"); - /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll(); + /// ContentstackCollection contentstackCollection = await assetLibrary.FetchAll(); /// /// /// Where function @@ -182,10 +182,10 @@ public AssetLibrary AddParam(string key, string value) /// Locale. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// AssetLibrary assetLibrary = stack.AssetLibrary(); /// assetLibrary.SetLocale("en-us"); - /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll(); + /// ContentstackCollection contentstackCollection = await assetLibrary.FetchAll(); /// /// public AssetLibrary SetLocale(String Locale) @@ -207,10 +207,10 @@ public AssetLibrary SetLocale(String Locale) /// /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// AssetLibrary assetLibrary = stack.AssetLibrary(); /// assetLibrary.IncludeCount(); - /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll(); + /// ContentstackCollection contentstackCollection = await assetLibrary.FetchAll(); /// /// public void IncludeCount() @@ -227,10 +227,10 @@ public void IncludeCount() /// Current instance of AssetLibrary, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// AssetLibrary assetLibrary = stack.AssetLibrary(); /// assetLibrary.IncludeMetadata(); - /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll(); + /// ContentstackCollection contentstackCollection = await assetLibrary.FetchAll(); /// /// public AssetLibrary IncludeMetadata() @@ -253,10 +253,10 @@ public AssetLibrary IncludeMetadata() /// /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// AssetLibrary assetLibrary = stack.AssetLibrary(); /// assetLibrary.IncludeRelativeUrls(); - /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll(); + /// ContentstackCollection contentstackCollection = await assetLibrary.FetchAll(); /// /// public void IncludeRelativeUrls() @@ -271,10 +271,10 @@ public void IncludeRelativeUrls() /// Current instance of AssetLibrary, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// AssetLibrary assetLibrary = stack.AssetLibrary(); /// assetLibrary.Skip(2); - /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll(); + /// ContentstackCollection contentstackCollection = await assetLibrary.FetchAll(); /// /// public AssetLibrary Skip(int number) @@ -297,10 +297,10 @@ public AssetLibrary Skip(int number) /// Current instance of AssetLibrary, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// AssetLibrary assetLibrary = stack.AssetLibrary(); /// assetLibrary.Limit(20); - /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll(); + /// ContentstackCollection contentstackCollection = await assetLibrary.FetchAll(); /// /// public AssetLibrary Limit(int number) @@ -323,10 +323,10 @@ public AssetLibrary Limit(int number) /// Current instance of AssetLibrary, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// AssetLibrary assetLibrary = stack.AssetLibrary(); - /// assetLibrary.Only(new String[]{"name", "description"}); - /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll(); + /// assetLibrary.Only(new String[]{"name", "description"}); + /// ContentstackCollection contentstackCollection = await assetLibrary.FetchAll(); /// /// public AssetLibrary Only(String[] fieldUid) @@ -353,10 +353,10 @@ public AssetLibrary Only(String[] fieldUid) /// Current instance of AssetLibrary, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// AssetLibrary assetLibrary = stack.AssetLibrary(); - /// assetLibrary.Except(new String[]{"name", "description"}); - /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll(); + /// assetLibrary.Except(new String[]{"name", "description"}); + /// ContentstackCollection contentstackCollection = await assetLibrary.FetchAll(); /// /// public AssetLibrary Except(String[] fieldUids) @@ -384,10 +384,10 @@ public AssetLibrary Except(String[] fieldUids) /// custom_header_value /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// AssetLibrary assetLibrary = stack.AssetLibrary(); - /// assetLibrary.SetHeaderForKey("custom_header_key", "custom_header_value"); - /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll(); + /// assetLibrary.SetHeaderForKey("custom_header_key", "custom_header_value"); + /// ContentstackCollection contentstackCollection = await assetLibrary.FetchAll(); /// /// public AssetLibrary SetHeaderForKey(String key, String value) @@ -407,10 +407,10 @@ public AssetLibrary SetHeaderForKey(String key, String value) /// custom_header_key /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// AssetLibrary assetLibrary = stack.AssetLibrary(); - /// assetLibrary.RemoveHeader("custom_key"); - /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll(); + /// assetLibrary.RemoveHeader("custom_key"); + /// ContentstackCollection contentstackCollection = await assetLibrary.FetchAll(); /// /// public AssetLibrary RemoveHeader(string key) @@ -428,9 +428,9 @@ public AssetLibrary RemoveHeader(string key) /// Current instance of AssetLibrary, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// AssetLibrary assetLibrary = stack.AssetLibrary(); - /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll(); + /// ContentstackCollection contentstackCollection = await assetLibrary.FetchAll(); /// /// public async Task> FetchAll() diff --git a/Contentstack.Core/Models/ContentType.cs b/Contentstack.Core/Models/ContentType.cs index 837d15a..b01760f 100644 --- a/Contentstack.Core/Models/ContentType.cs +++ b/Contentstack.Core/Models/ContentType.cs @@ -130,9 +130,9 @@ internal void SetStackInstance(ContentstackClient stack) /// /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); /// ContentType contenttype = stack.ContentType("contentType_name"); - /// var param = new Dictionary<string, object>(); + /// var param = new Dictionary(); /// param.Add("include_global_field_schema",true); /// var result = await contenttype.Fetch(param); /// @@ -187,9 +187,9 @@ public async Task Fetch(Dictionary param = null) /// header value against given header name. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// ContentType contentType = stack.ContentType("contentType_name"); - /// contentType.SetHeader("custom_key", "custom_value"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentType contentType = stack.ContentType("contentType_name"); + /// contentType.SetHeader("custom_key", "custom_value"); /// /// public void SetHeader(string key, string value) @@ -209,9 +209,9 @@ public void SetHeader(string key, string value) /// custom_header_key /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// ContentType contentType = stack.ContentType("contentType_name"); - /// contentType.RemoveHeader("custom_header_key"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentType contentType = stack.ContentType("contentType_name"); + /// contentType.RemoveHeader("custom_header_key"); /// /// public void RemoveHeader(string key) @@ -229,9 +229,9 @@ public void RemoveHeader(string key) /// Entry Instance /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// ContentType contentType = stack.ContentType("contentType_name"); - /// Entry entry = contentType.Entry("entry_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentType contentType = stack.ContentType("contentType_name"); + /// Entry entry = contentType.Entry("entry_uid"); /// /// public Entry Entry(String entryUid) @@ -250,8 +250,8 @@ public Entry Entry(String entryUid) /// Query Instance. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// ContentType contentType = stack.ContentType("contentType_name"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentType contentType = stack.ContentType("contentType_name"); /// Query csQuery = contentType.Query(); /// /// diff --git a/Contentstack.Core/Models/ContentstackCollection.cs b/Contentstack.Core/Models/ContentstackCollection.cs index 9a1086d..524c4b1 100644 --- a/Contentstack.Core/Models/ContentstackCollection.cs +++ b/Contentstack.Core/Models/ContentstackCollection.cs @@ -4,9 +4,9 @@ namespace Contentstack.Core.Models { - [JsonObject] - public class ContentstackCollection : IEnumerable - { + [JsonObject] + public class ContentstackCollection : IEnumerable + { /// /// The number of items skipped in this resultset. /// @@ -23,9 +23,9 @@ public class ContentstackCollection : IEnumerable public int Count { get; set; } /// - /// The System.Collections.Generic.IEnumerable<T> of items to be serialized from the API response. + /// The System.Collections.Generic.IEnumerable of items to be serialized from the API response. /// - /// System.Collections.Generic.IEnumerable<T> + /// System.Collections.Generic.IEnumerable public IEnumerable Items { get; set; } /// diff --git a/Contentstack.Core/Models/Entry.cs b/Contentstack.Core/Models/Entry.cs index b1d8391..24bac9c 100644 --- a/Contentstack.Core/Models/Entry.cs +++ b/Contentstack.Core/Models/Entry.cs @@ -8,8 +8,8 @@ using System.Threading.Tasks; using Contentstack.Core.Internals; using Contentstack.Core.Configuration; -using Newtonsoft.Json; - +using Newtonsoft.Json; + namespace Contentstack.Core.Models { /// @@ -55,9 +55,9 @@ private string _Url /// /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.Title; /// }); @@ -70,9 +70,9 @@ private string _Url /// /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.Uid; /// }); @@ -85,9 +85,9 @@ private string _Url /// /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.Tags; /// }); @@ -100,9 +100,9 @@ private string _Url /// /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.Metadata; /// }); @@ -121,9 +121,9 @@ private string _Url /// /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.Object; /// }); @@ -137,9 +137,9 @@ private string _Url /// /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.Object; /// }); @@ -238,9 +238,9 @@ internal void SetContentTypeInstance(ContentType contentTypeInstance) /// Array of tags. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.GetTags(); /// }); @@ -290,10 +290,10 @@ public void SetUid(String uid) /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); /// entry.SetCachePolicy(CachePolicy.NetworkElseCache); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// }); /// @@ -311,9 +311,9 @@ public Entry SetCachePolicy(CachePolicy cachePolicy) /// title /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.GetTitle(); /// }); @@ -330,8 +330,8 @@ public string GetTitle() /// contentType name /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); /// entry.GetContentType() /// /// @@ -346,9 +346,9 @@ public String GetContentType() /// Uid /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.GetUid(); /// }); @@ -366,9 +366,9 @@ public String GetUid() /// custom_header_value /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.SetHeader("custom_key", "custom_value"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.SetHeader("custom_key", "custom_value"); /// /// public void SetHeader(string key, string value) @@ -388,9 +388,9 @@ public void SetHeader(string key, string value) /// custom_header_key /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.RemoveHeader("custom_key"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.RemoveHeader("custom_key"); /// /// public void RemoveHeader(string key) @@ -409,11 +409,11 @@ public void RemoveHeader(string key) /// 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"); + /// 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) => { + /// csEntry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.GetMetadata(); /// }); @@ -434,11 +434,11 @@ public Entry Variant(string variant_header) /// 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(); + /// 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) => { + /// csEntry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.GetMetadata(); /// }); @@ -456,9 +456,9 @@ public Entry Variant(List variant_headers) /// key/value attributes of metadata /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.GetMetadata(); /// }); @@ -476,10 +476,10 @@ public Dictionary GetMetadata() /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); /// entry.SetLanguage(Language.ENGLISH_UNITED_STATES); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.GetMetadata(); /// }); @@ -524,10 +524,10 @@ public Entry SetLanguage(Language language) /// Locale. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); /// entry.SetLocale("en-us"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.GetMetadata(); /// }); @@ -554,11 +554,11 @@ public Entry SetLocale(String Locale) /// html text in string format. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. - /// //var result = entryResult.Result.GetHTMLText("markdownKey") + /// //var result = entryResult.Result.GetHTMLText("markdownKey") /// }); /// /// @@ -586,11 +586,11 @@ public String GetHTMLText(string markdownKey) /// html text in string format. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. - /// //var result = entryResult.Result.GetMultipleHTMLText("markdownKey") + /// //var result = entryResult.Result.GetMultipleHTMLText("markdownKey") /// }); /// /// @@ -625,11 +625,11 @@ public List GetMultipleHTMLText(string markdownKey) /// object value /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. - /// //var result = entryResult.Result.Get("key"); + /// //var result = entryResult.Result.Get("key"); /// }); /// /// @@ -658,9 +658,9 @@ public Object Get(String key) /// created date time in datetime format /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.GetCreateAt(); /// }); @@ -687,9 +687,9 @@ public DateTime GetCreateAt() /// uid who created this entry /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.GetCreatedBy(); /// }); @@ -735,9 +735,9 @@ private Entry IncludeCreatedBy() /// updated date time in datetime format /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.GetUpdateAt(); /// }); @@ -764,9 +764,9 @@ public DateTime GetUpdateAt() /// uid who updated this entry /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.GetUpdatedBy(); /// }); @@ -812,9 +812,9 @@ private Entry IncludeUpdatedBy() /// deleted date time in datetime format /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.GetDeletedAt(); /// }); @@ -840,9 +840,9 @@ public DateTime GetDeletedAt() /// uid who deleted this entry /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.GetDeletedBy(); /// }); @@ -860,9 +860,9 @@ public String GetDeletedBy() /// json in string format /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// //var result = entryResult.Result.ToJson(); /// }); @@ -882,11 +882,11 @@ public JObject ToJson() /// Asset instance /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. - /// //var result = entryResult.Result.GetAsset("field_uid"); + /// //var result = entryResult.Result.GetAsset("field_uid"); /// }); /// /// @@ -906,11 +906,11 @@ private Asset GetAsset(String key) /// List of Asset instance /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. - /// //var result = entryResult.Result.GetAssets("field_uid"); + /// //var result = entryResult.Result.GetAssets("field_uid"); /// }); /// /// @@ -940,10 +940,10 @@ private List GetAssets(String key) /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Except(new String[]{"name", "description"}); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Except(new String[]{"name", "description"}); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// }); /// @@ -979,10 +979,10 @@ public Entry Except(String[] fieldUid) /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.IncludeReference("name"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.IncludeReference("name"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// }); /// @@ -1011,10 +1011,10 @@ public Entry IncludeReference(String referenceField) /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.IncludeReference(new String[]{"name", "description"}); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.IncludeReference(new String[]{"name", "description"}); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// }); /// @@ -1045,10 +1045,10 @@ public Entry IncludeReference(String[] referenceFields) /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.IncludeOnlyReference(new String[]{"name", "description"}, "referenceUid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.IncludeOnlyReference(new String[]{"name", "description"}, "referenceUid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// }); /// @@ -1078,10 +1078,10 @@ public Entry IncludeOnlyReference(string[] keys, string referenceKey) /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); /// entry.IncludeReferenceContentTypeUID(); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// }); /// @@ -1105,10 +1105,10 @@ public Entry IncludeReferenceContentTypeUID() /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); /// entry.IncludeFallback(); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// }); /// @@ -1133,10 +1133,10 @@ public Entry IncludeFallback() /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); /// entry.IncludeMetadata(); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your Metadata code. /// }); /// @@ -1161,10 +1161,10 @@ public Entry IncludeMetadata() /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); /// entry.AddParam("include_branch", "true"); - /// entry.Fetch<Product>().ContinueWith((assetResult) => { + /// entry.Fetch().ContinueWith((assetResult) => { /// //Your callback code. /// }); /// @@ -1188,10 +1188,10 @@ public Entry AddParam(string key, string value) /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); /// entry.IncludeBranch(); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// }); /// @@ -1215,10 +1215,10 @@ public Entry IncludeBranch() /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); /// entry.includeEmbeddedItems(); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// }); /// @@ -1242,10 +1242,10 @@ public Entry includeEmbeddedItems() /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); /// entry.IncludeSchema(); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// }); /// @@ -1270,10 +1270,10 @@ private Entry IncludeSchema() /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); /// entry.IncludeOwner(); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// }); /// @@ -1300,10 +1300,10 @@ public Entry IncludeOwner() /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.IncludeExceptReference(new String[]{"name", "description"},"referenceUid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.IncludeExceptReference(new String[]{"name", "description"},"referenceUid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// }); /// @@ -1334,10 +1334,10 @@ public Entry IncludeExceptReference(string[] keys, string referenceKey) /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Only(new String[]{"name", "description"}); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Only(new String[]{"name", "description"}); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// }); /// @@ -1367,9 +1367,9 @@ public Entry Only(String[] fieldUid) /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); - /// entry.Fetch<Product>().ContinueWith((entryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// entry.Fetch().ContinueWith((entryResult) => { /// //Your callback code. /// }); /// diff --git a/Contentstack.Core/Models/GlobalField.cs b/Contentstack.Core/Models/GlobalField.cs new file mode 100644 index 0000000..3d8efd2 --- /dev/null +++ b/Contentstack.Core/Models/GlobalField.cs @@ -0,0 +1,291 @@ +using System; +using System.Collections.Generic; +using Contentstack.Core.Configuration; +using Contentstack.Core.Internals; +using System.Threading.Tasks; +using System.Net; +using Newtonsoft.Json.Linq; +using System.Linq; +using System.IO; +using Newtonsoft.Json; + +namespace Contentstack.Core.Models +{ + /// + /// GlobalField provides Entry and Query instances for working with global fields in Contentstack. + /// + public class GlobalField + { + #region Public Properties + internal ContentstackClient StackInstance { get; set; } + internal string Uid { get; set; } + private Dictionary UrlQueries = new Dictionary(); + + /// + /// GlobalField uid + /// + public string GlobalFieldId + { + get + { + return this.Uid; + } + set + { + if (String.IsNullOrEmpty(value)) + throw new ArgumentNullException("GlobalFieldId cannot be null or empty."); + this.Uid = value; + } + } + + #endregion + + #region Private Properties + private Dictionary _Headers = new Dictionary(); + + private Dictionary _StackHeaders = new Dictionary(); + + private string _Url + { + get + { + Config config = this.StackInstance.Config; + return String.Format("{0}/global_fields/{1}", config.BaseUrl, this.GlobalFieldId); + } + } + #endregion + + #region Internal Constructors + /// + /// + /// + protected GlobalField() { } + + /// + /// + /// + /// + internal GlobalField(String globalFieldId = null) + { + if (globalFieldId != null) + { + this.GlobalFieldId = globalFieldId; + } + this._Headers = new Dictionary(); + } + + #endregion + + + #region Internal Functions + + 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; + } + + internal void SetStackInstance(ContentstackClient stack) + { + this.StackInstance = stack; + this._StackHeaders = stack._LocalHeaders; + } + #endregion + + #region Public Functions + /// + /// This method returns the complete information of a specific global field. + /// + /// + /// + /// ContentstackClient stack = new ContentstackClient(api_key, delivery_token, environment); + /// GlobalField globalField = stack.GlobalField("globalField_uid"); + /// var param = new Dictionary(); + /// param.Add("include_global_field_schema", true); + /// var result = await globalField.Fetch(param); + /// + /// + /// A dictionary of additional parameters. + /// The Global Field schema object. + public async Task Fetch(Dictionary param = null) + { + Dictionary headers = GetHeader(_Headers); + Dictionary headerAll = new Dictionary(); + Dictionary mainJson = new Dictionary(); + + if (headers != null && headers.Count() > 0) + { + foreach (var header in headers) + { + headerAll.Add(header.Key, (String)header.Value); + } + } + mainJson.Add("environment", this.StackInstance.Config.Environment); + foreach (var kvp in UrlQueries) + { + mainJson.Add(kvp.Key, kvp.Value); + } + if (param != null && param.Count() > 0) + { + foreach (var kvp in param) + { + mainJson.Add(kvp.Key, kvp.Value); + } + } + try + { + HttpRequestHandler RequestHandler = new HttpRequestHandler(this.StackInstance); + var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson, Branch: this.StackInstance.Config.Branch, timeout: this.StackInstance.Config.Timeout, proxy: this.StackInstance.Config.Proxy); + JObject data = JsonConvert.DeserializeObject(outputResult.Replace("\r\n", ""), this.StackInstance.SerializerSettings); + + JObject globalTypes = (Newtonsoft.Json.Linq.JObject)data["global_field"]; + return globalTypes; + } + catch (Exception ex) + { + throw GetContentstackError(ex); + } + } + + public GlobalField IncludeBranch() + { + this.UrlQueries.Add("include_branch", true); + return this; + } + + public GlobalField IncludeGlobalFieldSchema() + { + this.UrlQueries.Add("include_global_field_schema", true); + return this; + } + /// + /// Sets a header for Contentstack REST calls. + /// + /// Header name. + /// Header value for the given header name. + /// + /// + /// ContentstackClient stack = new ContentstackClient(api_key, delivery_token, environment); + /// GlobalField globalField = stack.GlobalField(globalField_name); + /// globalField.SetHeader(custom_header_key, custom_header_value); + /// + /// + public void SetHeader(string key, string value) + { + if (key != null && value != null) + { + if (this._Headers.ContainsKey(key)) + this._Headers.Remove(key); + this._Headers.Add(key, value); + } + + } + + /// + /// Removes a header key. + /// + /// Custom header key to remove. + /// + /// + /// ContentstackClient stack = new ContentstackClient(api_key, delivery_token, environment); + /// GlobalField globalField = stack.GlobalField(globalField_name); + /// globalField.RemoveHeader(custom_header_key); + /// + /// + public void RemoveHeader(string key) + { + if (this._Headers.ContainsKey(key)) + this._Headers.Remove(key); + } + + + #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; + } + } + #endregion + } +} diff --git a/Contentstack.Core/Models/GlobalFieldQuery.cs b/Contentstack.Core/Models/GlobalFieldQuery.cs new file mode 100644 index 0000000..270af47 --- /dev/null +++ b/Contentstack.Core/Models/GlobalFieldQuery.cs @@ -0,0 +1,219 @@ +using System; +using System.Collections.Generic; +using Contentstack.Core.Configuration; +using Contentstack.Core.Internals; +using System.Threading.Tasks; +using System.Net; +using Newtonsoft.Json.Linq; +using System.Linq; +using System.IO; +using Newtonsoft.Json; + +namespace Contentstack.Core.Models +{ + /// + /// GlobalFieldQuery provides query options for working with global fields in Contentstack. + /// + public class GlobalFieldQuery + { + #region Public Properties + internal ContentstackClient StackInstance { get; set; } + private Dictionary UrlQueries = new Dictionary(); + + #endregion + + #region Private Properties + private Dictionary _Headers = new Dictionary(); + + private Dictionary _StackHeaders = new Dictionary(); + + private string _Url + { + get + { + Config config = this.StackInstance.Config; + return String.Format("{0}/global_fields", config.BaseUrl); + } + } + #endregion + + #region Internal Constructors + + internal GlobalFieldQuery() + { + this._Headers = new Dictionary(); + } + + #endregion + + + #region Internal Functions + + 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; + } + + internal void SetStackInstance(ContentstackClient stack) + { + this.StackInstance = stack; + this._StackHeaders = stack._LocalHeaders; + } + #endregion + + #region Public Functions + /// + /// This method returns the complete information for all global fields. + /// + /// + /// + /// ContentstackClient stack = new ContentstackClient("api_key", "delivery_token", "environment"); + /// GlobalFieldQuery globalFieldQuery = stack.GlobalFieldQuery(); + /// var param = new Dictionary(); + /// param.Add("include_global_field_schema", true); + /// var result = await globalFieldQuery.Find(param); + /// + /// + /// A dictionary of additional parameters. + /// The global field schema object. + public async Task Find(Dictionary param = null) + { + Dictionary headers = GetHeader(_Headers); + Dictionary headerAll = new Dictionary(); + Dictionary mainJson = new Dictionary(); + if (headers != null && headers.Count() > 0) + { + foreach (var header in headers) + { + headerAll.Add(header.Key, (String)header.Value); + } + } + mainJson.Add("environment", this.StackInstance.Config.Environment); + foreach (var kvp in UrlQueries) + { + mainJson.Add(kvp.Key, kvp.Value); + } + if (param != null && param.Count() > 0) + { + foreach (var kvp in param) + { + mainJson.Add(kvp.Key, kvp.Value); + } + } + try + { + HttpRequestHandler RequestHandler = new HttpRequestHandler(this.StackInstance); + var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson, Branch: this.StackInstance.Config.Branch, timeout: this.StackInstance.Config.Timeout, proxy: this.StackInstance.Config.Proxy); + JObject data = JsonConvert.DeserializeObject(outputResult.Replace("\r\n", ""), this.StackInstance.SerializerSettings); + + return data; + } + catch (Exception ex) + { + throw GetContentstackError(ex); + } + } + + public GlobalFieldQuery IncludeBranch() + { + this.UrlQueries.Add("include_branch", true); + return this; + } + + public GlobalFieldQuery IncludeGlobalFieldSchema() + { + this.UrlQueries.Add("include_global_field_schema", true); + 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; + } + } + #endregion + } +} diff --git a/Contentstack.Core/Models/Query.cs b/Contentstack.Core/Models/Query.cs index dba3aac..0ca904b 100644 --- a/Contentstack.Core/Models/Query.cs +++ b/Contentstack.Core/Models/Query.cs @@ -46,9 +46,9 @@ protected virtual string _Url /// /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Query csQuery = stack.ContentType("contentType_id").Query(); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// var result = queryResult.Result.ContentTypeId; /// }); @@ -150,10 +150,10 @@ internal void SetTaxonomyInstance(ContentstackClient Tax) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// csQuery.SetLanguage(Language.ENGLISH_UNITED_STATES); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -197,10 +197,10 @@ public Query SetLanguage(Language language) /// Locale. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Query csQuery = stack.ContentType("contentType_id").Query(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// csQuery.SetLocale("en-us"); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -226,9 +226,9 @@ public Query SetLocale(String Locale) /// header value against given header name. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Query csQuery = stack.ContentType("contentType_id").Query(); - /// csQuery.SetHeader("custom_key", "custom_value"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); + /// csQuery.SetHeader("custom_key", "custom_value"); /// /// public void SetHeader(String key, String value) @@ -245,9 +245,9 @@ public void SetHeader(String key, String value) /// header name. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Query csQuery = stack.ContentType("contentType_id").Query(); - /// csQuery.RemoveHeader("custom_key"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); + /// csQuery.RemoveHeader("custom_key"); /// /// public void RemoveHeader(String key) @@ -266,10 +266,10 @@ public void RemoveHeader(String key) /// 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.Where("uid", "entry_uid"); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); + /// csQuery.Where("uid", "entry_uid"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -349,10 +349,10 @@ public Query ReferenceNotIn(String key, Query query) /// 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.AddQuery("query_param_key", "query_param_value"); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); + /// csQuery.AddQuery("query_param_key", "query_param_value"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -384,10 +384,10 @@ public Query AddQuery(String key, String value) /// 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.RemoveQuery("Query_Key"); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); + /// csQuery.RemoveQuery("Query_Key"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -415,22 +415,22 @@ public Query RemoveQuery(String key) /// Current instance of Query, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// ContentType contentTypeObj = stack.ContentType("contentType_id"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentType contentTypeObj = stack.ContentType("contentType_id"); /// Query csQuery = contentTypeObj.Query(); /// /// Query query1 = contentTypeObj.Query(); - /// query1.Where("username","content"); + /// query1.Where("username","content"); /// /// Query query2 = contentTypeObj.Query(); - /// query2.Where("email_address","content@email.com"); + /// query2.Where("email_address","content@email.com"); /// - /// List<Query> queryList = new List<Query>(); + /// List queryList = new List(); /// queryList.Add(query1); /// queryList.Add(query2); /// /// csQuery.And(queryList); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -479,22 +479,22 @@ public Query And(List queryObjects) /// Current instance of Query, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// ContentType contentTypeObj = stack.ContentType("contentType_id"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// ContentType contentTypeObj = stack.ContentType("contentType_id"); /// Query csQuery = contentTypeObj.Query(); /// /// Query query1 = contentTypeObj.Query(); - /// query1.Where("username","content"); + /// query1.Where("username","content"); /// /// Query query2 = contentTypeObj.Query(); - /// query2.Where("email_address","content@email.com"); + /// query2.Where("email_address","content@email.com"); /// - /// List<Query> queryList = new List<Query>(); + /// List queryList = new List(); /// queryList.Add(query1); /// queryList.Add(query2); /// /// csQuery.Or(queryList); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -546,11 +546,11 @@ public Query Or(List queryObjects) /// 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(); + /// 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) => { + /// csQuery.LessThan("due_date", "2013-06-25T00:00:00+05:30"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -590,11 +590,11 @@ public Query LessThan(String key, Object value) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.LessThanOrEqualTo("due_date", "2013-06-25T00:00:00+05:30"); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.LessThanOrEqualTo("due_date", "2013-06-25T00:00:00+05:30"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -633,11 +633,11 @@ public Query LessThanOrEqualTo(String key, Object value) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.GreaterThan("due_date", "2013-06-25T00:00:00+05:30"); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.GreaterThan("due_date", "2013-06-25T00:00:00+05:30"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -677,11 +677,11 @@ public Query GreaterThan(String key, Object value) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.GreaterThanOrEqualTo("due_date", "2013-06-25T00:00:00+05:30"); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.GreaterThanOrEqualTo("due_date", "2013-06-25T00:00:00+05:30"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -721,11 +721,11 @@ public Query GreaterThanOrEqualTo(String key, Object value) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.NotEqualTo("due_date", "2013-06-25T00:00:00+05:30"); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.NotEqualTo("due_date", "2013-06-25T00:00:00+05:30"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -767,11 +767,11 @@ public Query NotEqualTo(String key, Object value) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.ContainedIn("severity", new Object[]{"Show Stopper", "Critical"}); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.ContainedIn("severity", new Object[]{"Show Stopper", "Critical"}); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -816,11 +816,11 @@ public Query ContainedIn(String key, Object[] values) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.NotContainedIn("severity", new Object[]{"Show Stopper", "Critical"}); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.NotContainedIn("severity", new Object[]{"Show Stopper", "Critical"}); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -864,11 +864,11 @@ public Query NotContainedIn(String key, Object[] values) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.Exists("severity"); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Exists("severity"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -905,11 +905,11 @@ public Query Exists(String key) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.NotExists("severity"); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.NotExists("severity"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -945,11 +945,11 @@ public Query NotExists(String key) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// /// csQuery.IncludeReferenceContentTypeUID(); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -974,11 +974,11 @@ public Query IncludeReferenceContentTypeUID() /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.IncludeReference("for_bug"); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.IncludeReference("for_bug"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1001,11 +1001,11 @@ public Query IncludeReference(String filed_uid) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.IncludeReference(new String[]{"for_bug", "assignee"}); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.IncludeReference(new String[]{"for_bug", "assignee"}); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1027,11 +1027,11 @@ public Query IncludeReference(String[] filed_uids) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.Tags(new String[]{"tag1", "tag2"}); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Tags(new String[]{"tag1", "tag2"}); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1070,11 +1070,11 @@ private Query Tags(String[] tags) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.Ascending("name"); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Ascending("name"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1106,11 +1106,11 @@ public Query Ascending(String key) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.Descending("name"); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Descending("name"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1141,11 +1141,11 @@ public Query Descending(String key) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// /// csQuery.IncludeCount(); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1171,10 +1171,10 @@ public Query IncludeCount() /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// csQuery.IncludeMetadata(); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your metadata code. /// }); /// @@ -1198,11 +1198,11 @@ public Query IncludeMetadata() /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// /// csQuery.IncludeOwner(); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1227,11 +1227,11 @@ public Query IncludeOwner() /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.Only(new String[]{"name", "description"}); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Only(new String[]{"name", "description"}); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1261,11 +1261,11 @@ public Query Only(String[] fieldUid) /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Query csQuery = stack.ContentType("contentType_id").Query(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.IncludeOnlyReference(new String[]{"name", "description"}, "referenceUid"); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.IncludeOnlyReference(new String[]{"name", "description"}, "referenceUid"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1294,11 +1294,11 @@ public Query IncludeOnlyReference(string[] keys, string referenceKey) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.Except(new String[]{"name", "description"}); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Except(new String[]{"name", "description"}); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1329,10 +1329,10 @@ public Query Except(String[] fieldUids) /// Current instance of Entry, 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.IncludeExceptReference(new String[]{"name", "description"},"referenceUid"); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); + /// csQuery.IncludeExceptReference(new String[]{"name", "description"},"referenceUid"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1361,11 +1361,11 @@ public Query IncludeExceptReference(string[] keys, string referenceKey) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// /// csQuery.IncludeFallback(); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1389,11 +1389,11 @@ public Query IncludeFallback() /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// /// csQuery.IncludeBranch(); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1418,10 +1418,10 @@ public Query IncludeBranch() /// Current instance of Entry, this will be useful for a chaining calls. /// /// - /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); - /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Entry entry = stack.ContentType("contentType_id").Entry("entry_uid"); /// entry.AddParam("include_branch", "true"); - /// entry.Fetch<Product>().ContinueWith((assetResult) => { + /// entry.Fetch().ContinueWith((assetResult) => { /// //Your callback code. /// }); /// @@ -1445,11 +1445,11 @@ public Query AddParam(string key, string value) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// /// csQuery.includeEmbeddedItems(); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1473,11 +1473,11 @@ public Query includeEmbeddedItems() /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// /// csQuery.IncludeSchema(); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1503,11 +1503,11 @@ public Query IncludeSchema() /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// /// csQuery.Skip(2); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1532,11 +1532,11 @@ public Query Skip(int number) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// /// csQuery.Limit(2); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1562,11 +1562,11 @@ public Query Limit(int number) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.Regex("name", "^browser"); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Regex("name", "^browser"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1601,17 +1601,17 @@ public Query Regex(String key, String regex) /// The key to be constrained. /// The regular expression pattern to match. /// Any of the following supported Regular expression modifiers. - /// <li>use<b> i </b> for case-insensitive matching.</li> - /// <li>use<b> m </b> for making dot match newlines.</li> - /// <li>use<b> x </b> for ignoring whitespace in regex</li> + ///
  • use i for case-insensitive matching.
  • + ///
  • use m for making dot match newlines.
  • + ///
  • use x for ignoring whitespace in regex
  • /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.Regex("name", "^browser", "i"); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Regex("name", "^browser", "i"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1651,11 +1651,11 @@ public Query Regex(String key, String regex, String modifiers) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.WhereTags(new String[]{"tag1", "tag2"}); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.WhereTags(new String[]{"tag1", "tag2"}); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1680,11 +1680,11 @@ public Query WhereTags(string[] tags) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// /// csQuery.SetCachePolicy(CachePolicy.CacheElseNetwork); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1704,11 +1704,11 @@ public Query SetCachePolicy(CachePolicy cachePolicy) /// 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(); + /// 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) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1728,11 +1728,11 @@ public Query Variant(string variant_header) /// 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(); + /// 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) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1749,10 +1749,10 @@ public Query Variant(List variant_headers) /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1769,11 +1769,11 @@ public async Task> Find() /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// /// csQuery.Count(); - /// csQuery.Find<Product>().ContinueWith((queryResult) => { + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -1798,10 +1798,10 @@ public async Task Count() /// 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(); + /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment"); + /// Query csQuery = stack.ContentType("contentType_id").Query(); /// - /// csQuery.FindOne<Product>().ContinueWith((queryResult) => { + /// csQuery.FindOne().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// diff --git a/Contentstack.Core/Models/Taxonomy.cs b/Contentstack.Core/Models/Taxonomy.cs index f9d63cd..f30dc13 100644 --- a/Contentstack.Core/Models/Taxonomy.cs +++ b/Contentstack.Core/Models/Taxonomy.cs @@ -24,7 +24,7 @@ protected override string _Url Config config = this.Stack.Config; return String.Format("{0}/taxonomies/entries", config.BaseUrl); } - } + } #endregion public ContentstackClient Stack { @@ -55,11 +55,11 @@ internal Taxonomy(ContentstackClient stack): base(stack) /// 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(); + /// 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) => { + /// csQuery.LessThan("due_date", "2013-06-25T00:00:00+05:30"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -92,11 +92,11 @@ public Taxonomy Above(String key, Object value) /// 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(); + /// 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) => { + /// csQuery.LessThan("due_date", "2013-06-25T00:00:00+05:30"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -131,11 +131,11 @@ public Taxonomy EqualAndAbove(String key, Object value) /// 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(); + /// 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) => { + /// csQuery.LessThan("due_date", "2013-06-25T00:00:00+05:30"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// @@ -170,11 +170,11 @@ public Taxonomy Below(String key, Object value) /// 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(); + /// 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) => { + /// csQuery.LessThan("due_date", "2013-06-25T00:00:00+05:30"); + /// csQuery.Find().ContinueWith((queryResult) => { /// //Your callback code. /// }); /// diff --git a/Directory.Build.props b/Directory.Build.props index 402aa0e..cf65843 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -1,5 +1,5 @@ - 2.21.0 + 2.22.0