From 4137bcf9ad61bae0f9d7b7f0ce3a43c413fab029 Mon Sep 17 00:00:00 2001 From: Uttam K Ukkoji Date: Mon, 4 Mar 2019 16:25:07 +0530 Subject: [PATCH 01/13] Added functionality to override Host and version --- .../Contentstack.Core.Tests.csproj | 2 + Contentstack.Core.Tests/StackConfig.cs | 9 +- .../Configuration/ContentstackOptions.cs | 9 + Contentstack.Core/ContentstackClient.cs | 23 +- README.md | 224 +++++++++--------- 5 files changed, 145 insertions(+), 122 deletions(-) mode change 100644 => 100755 README.md diff --git a/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj b/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj index d30d430..c087835 100644 --- a/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj +++ b/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj @@ -12,6 +12,7 @@ + @@ -33,6 +34,7 @@ + diff --git a/Contentstack.Core.Tests/StackConfig.cs b/Contentstack.Core.Tests/StackConfig.cs index 72fe74c..d537d1f 100644 --- a/Contentstack.Core.Tests/StackConfig.cs +++ b/Contentstack.Core.Tests/StackConfig.cs @@ -2,6 +2,7 @@ using Contentstack.Core; using Contentstack.Core.Models; using System.Configuration; +using Microsoft.Extensions.Options; namespace Contentstack.Core.Tests { @@ -30,16 +31,16 @@ public static ContentstackClient GetStack() string apiKey = ConfigurationManager.AppSettings["api_key"]; string accessToken = ConfigurationManager.AppSettings["access_token"]; string environment = ConfigurationManager.AppSettings["environment"]; - + string host = ConfigurationManager.AppSettings["host"]; Configuration.ContentstackOptions contentstackOptions = new Configuration.ContentstackOptions { ApiKey = apiKey, AccessToken = accessToken, - Environment = environment + Environment = environment, + Host = host }; - ContentstackClient contentstackClient = new ContentstackClient(apiKey, accessToken, environment); - + ContentstackClient contentstackClient = new ContentstackClient(new OptionsWrapper(contentstackOptions)); return contentstackClient; } diff --git a/Contentstack.Core/Configuration/ContentstackOptions.cs b/Contentstack.Core/Configuration/ContentstackOptions.cs index 4793b34..c95fc57 100644 --- a/Contentstack.Core/Configuration/ContentstackOptions.cs +++ b/Contentstack.Core/Configuration/ContentstackOptions.cs @@ -21,5 +21,14 @@ public class ContentstackOptions /// public string Environment { get; set; } + /// + /// The Host used to set host url for the ContentStack API. + /// + public string Host { get; set; } + + /// + /// The Version number for the ContentStack API. + /// + public string Version { get; set; } } } diff --git a/Contentstack.Core/ContentstackClient.cs b/Contentstack.Core/ContentstackClient.cs index f65f964..20a255b 100644 --- a/Contentstack.Core/ContentstackClient.cs +++ b/Contentstack.Core/ContentstackClient.cs @@ -49,6 +49,14 @@ public ContentstackClient(IOptions options) this.SetHeader("access_token", _options.AccessToken); Config cnfig = new Config(); cnfig.Environment = _options.Environment; + if (_options.Host != null) + { + cnfig.Host = _options.Host; + } + if (_options.Version != null) + { + cnfig.Version = _options.Version; + } this.SetConfig(cnfig); } @@ -74,13 +82,16 @@ public ContentstackClient(ContentstackOptions options) : /// ContentType contentType = stack.ContentType("contentType_name"); /// /// - public ContentstackClient(string apiKey, string accessToken, string environment) : + public ContentstackClient(string apiKey, string accessToken, string environment, string host = null, string version = null) : this(new OptionsWrapper(new ContentstackOptions() - { - ApiKey = apiKey, - AccessToken = accessToken, - Environment = environment - })) + { + ApiKey = apiKey, + AccessToken = accessToken, + Environment = environment, + Host = host, + Version = version + } + )) { } diff --git a/README.md b/README.md old mode 100644 new mode 100755 index 782eb1d..c506e3f --- a/README.md +++ b/README.md @@ -1,113 +1,113 @@ -[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/) -# Contentstack dotnet - -.NET SDK for Contentstack's Content Delivery API - -## Getting Started - -This guide will help you get started with our .NET SDK to build apps powered by Contentstack. - -## SDK Installation and Setup - -To use the .NET SDK, download it from here - -Open the terminal and install the contentstack module via ‘Package Manager’ command - -``` console -PM> Install-Package contentstack.csharp -``` -And via ‘.Net CLI’ -``` console -dotnet add package contentstack.csharp -``` -To use the module in your application, you need to first Add Namespace to your class - -``` cs -using Contentstack.Core; // ContentstackClient -using Contentstack.Core.Models; // Stack, Query, Entry, Asset, ContentType -using Contentstack.Core.Configuration; // ContentstackOptions -``` - -## Initialize SDK - -You will need to specify the API key, Access token, and Environment Name of your stack to initialize the SDK: - -``` cs -// Initialize the Contentstack -ContentstackClient stack = new ContentstackClient("api_key", "access_token", "enviroment_name"); -``` -or: - -``` cs -// -var options = new ContentstackOptions() -{ - ApiKey = "", - AccessToken = "" - Environment = "" -} -ContentstackClient stack = new ContentstackClient(options); -``` - -Once you have initialized the SDK, you can start getting content in your app. - -## Basic Queries - -### Get a Single Entry - -To retrieve a single entry from a content type, use the code snippet given below: -``` cs -Entry entry = client.ContentType("blog").Entry("blta464e9fbd048668c"); -entry.Fetch().ContinueWith((t) => { - if (!t.IsFaulted) { - Console.WriteLine("entry:" + t.Result); - } -}); -``` - -### Get Multiple Entries - -To retrieve multiple entries of a particular content type, use the code snippet given below: - -``` cs - -Query query = client.ContentType("blog").Query(); -query.Where("title", "welcome"); -query.IncludeSchema(); -query.IncludeCount(); -query.ToJSON(); -query.Find().ContinueWith((t) => { - if (!t.IsFaulted) { - Entry[] result = t.Result.Result; - Console.WriteLine("result" + result); - } -}); -``` -These were example of some of the basic queries of the SDK. For advanced queries, refer to our API reference documentation by visiting the link given below. - -## API Reference -Go through our .NET SDK API Reference guide to know about the methods that can be used to query your content in Contentstack. - -[Read .NET API Reference Guide](https://www.contentstack.com/docs/platforms/dot-net/api-reference/api/index.html) - -## Example -To help you get started, we have created a sample application that is powered by Contentstack .NET SDK. Click on the link below to read the tutorial of the app. - -[.NET News Console App](https://www.contentstack.com/docs/example-apps/build-a-news-app-using-contentstack-dot-net-sdk) - - -### Helpful Links - -- [Contentstack Website](https://www.contentstack.com) -- [Official Documentation](https://contentstack.com/docs) -- [Content Delivery API Docs](https://contentstack.com/docs/apis/content-delivery-api/) - -### The MIT License (MIT) - -Copyright © 2012-2018 [Contentstack](https://www.contentstack.com/). All Rights Reserved - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - +[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/) +# Contentstack dotnet + +.NET SDK for Contentstack's Content Delivery API + +## Getting Started + +This guide will help you get started with our .NET SDK to build apps powered by Contentstack. + +## SDK Installation and Setup + +To use the .NET SDK, download it from here + +Open the terminal and install the contentstack module via ‘Package Manager’ command + +``` console +PM> Install-Package contentstack.csharp +``` +And via ‘.Net CLI’ +``` console +dotnet add package contentstack.csharp +``` +To use the module in your application, you need to first Add Namespace to your class + +``` cs +using Contentstack.Core; // ContentstackClient +using Contentstack.Core.Models; // Stack, Query, Entry, Asset, ContentType +using Contentstack.Core.Configuration; // ContentstackOptions +``` + +## Initialize SDK + +You will need to specify the API key, Access token, and Environment Name of your stack to initialize the SDK: + +``` cs +// Initialize the Contentstack +ContentstackClient stack = new ContentstackClient("api_key", "access_token", "enviroment_name"); +``` +or: + +``` cs +// +var options = new ContentstackOptions() +{ + ApiKey = "", + AccessToken = "" + Environment = "" +} +ContentstackClient stack = new ContentstackClient(options); +``` + +Once you have initialized the SDK, you can start getting content in your app. + +## Basic Queries + +### Get a Single Entry + +To retrieve a single entry from a content type, use the code snippet given below: +``` cs +Entry entry = client.ContentType("blog").Entry("blta464e9fbd048668c"); +entry.Fetch().ContinueWith((t) => { + if (!t.IsFaulted) { + Console.WriteLine("entry:" + t.Result); + } +}); +``` + +### Get Multiple Entries + +To retrieve multiple entries of a particular content type, use the code snippet given below: + +``` cs + +Query query = client.ContentType("blog").Query(); +query.Where("title", "welcome"); +query.IncludeSchema(); +query.IncludeCount(); +query.ToJSON(); +query.Find().ContinueWith((t) => { + if (!t.IsFaulted) { + Entry[] result = t.Result.Result; + Console.WriteLine("result" + result); + } +}); +``` +These were example of some of the basic queries of the SDK. For advanced queries, refer to our API reference documentation by visiting the link given below. + +## API Reference +Go through our .NET SDK API Reference guide to know about the methods that can be used to query your content in Contentstack. + +[Read .NET API Reference Guide](https://www.contentstack.com/docs/platforms/dot-net/api-reference/api/index.html) + +## Example +To help you get started, we have created a sample application that is powered by Contentstack .NET SDK. Click on the link below to read the tutorial of the app. + +[.NET News Console App](https://www.contentstack.com/docs/example-apps/build-a-news-app-using-contentstack-dot-net-sdk) + + +### Helpful Links + +- [Contentstack Website](https://www.contentstack.com) +- [Official Documentation](https://contentstack.com/docs) +- [Content Delivery API Docs](https://contentstack.com/docs/apis/content-delivery-api/) + +### The MIT License (MIT) + +Copyright © 2012-2018 [Contentstack](https://www.contentstack.com/). All Rights Reserved + +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file From 03f397b95a64a79f836064054408de8742360cd6 Mon Sep 17 00:00:00 2001 From: Uttam K Ukkoji Date: Thu, 14 Mar 2019 11:56:53 +0530 Subject: [PATCH 02/13] stack schema fetch implemented --- .../TestResults/Prod_2019-03-08_14_48_46.trx | 347 ++++++++++++++++++ ...Uttams-MacBook-Pro_2019-03-08_14_48_46.trx | 347 ++++++++++++++++++ 2 files changed, 694 insertions(+) create mode 100644 Contentstack.Core.Tests/TestResults/Prod_2019-03-08_14_48_46.trx create mode 100644 Contentstack.Core.Tests/TestResults/_Uttams-MacBook-Pro_2019-03-08_14_48_46.trx diff --git a/Contentstack.Core.Tests/TestResults/Prod_2019-03-08_14_48_46.trx b/Contentstack.Core.Tests/TestResults/Prod_2019-03-08_14_48_46.trx new file mode 100644 index 0000000..e2293f2 --- /dev/null +++ b/Contentstack.Core.Tests/TestResults/Prod_2019-03-08_14_48_46.trx @@ -0,0 +1,347 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [xUnit.net 00:00:00.5946316] Discovering: Contentstack.Core.Tests[xUnit.net 00:00:00.6691032] Discovered: Contentstack.Core.Tests[xUnit.net 00:00:00.6759638] Starting: Contentstack.Core.Tests[xUnit.net 00:00:30.9190659] Finished: Contentstack.Core.Tests + + + \ No newline at end of file diff --git a/Contentstack.Core.Tests/TestResults/_Uttams-MacBook-Pro_2019-03-08_14_48_46.trx b/Contentstack.Core.Tests/TestResults/_Uttams-MacBook-Pro_2019-03-08_14_48_46.trx new file mode 100644 index 0000000..e2293f2 --- /dev/null +++ b/Contentstack.Core.Tests/TestResults/_Uttams-MacBook-Pro_2019-03-08_14_48_46.trx @@ -0,0 +1,347 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [xUnit.net 00:00:00.5946316] Discovering: Contentstack.Core.Tests[xUnit.net 00:00:00.6691032] Discovered: Contentstack.Core.Tests[xUnit.net 00:00:00.6759638] Starting: Contentstack.Core.Tests[xUnit.net 00:00:30.9190659] Finished: Contentstack.Core.Tests + + + \ No newline at end of file From a442494a1e6efdabe56c528c2cd534da343ac095 Mon Sep 17 00:00:00 2001 From: Uttam K Ukkoji Date: Thu, 14 Mar 2019 11:57:36 +0530 Subject: [PATCH 03/13] stack schema fetch implemented --- .../TestResults/Prod_2019-03-08_14_48_46.trx | 347 ------------------ ...Uttams-MacBook-Pro_2019-03-08_14_48_46.trx | 347 ------------------ Contentstack.Core/ContentstackClient.cs | 165 ++++++++- 3 files changed, 163 insertions(+), 696 deletions(-) delete mode 100644 Contentstack.Core.Tests/TestResults/Prod_2019-03-08_14_48_46.trx delete mode 100644 Contentstack.Core.Tests/TestResults/_Uttams-MacBook-Pro_2019-03-08_14_48_46.trx diff --git a/Contentstack.Core.Tests/TestResults/Prod_2019-03-08_14_48_46.trx b/Contentstack.Core.Tests/TestResults/Prod_2019-03-08_14_48_46.trx deleted file mode 100644 index e2293f2..0000000 --- a/Contentstack.Core.Tests/TestResults/Prod_2019-03-08_14_48_46.trx +++ /dev/null @@ -1,347 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [xUnit.net 00:00:00.5946316] Discovering: Contentstack.Core.Tests[xUnit.net 00:00:00.6691032] Discovered: Contentstack.Core.Tests[xUnit.net 00:00:00.6759638] Starting: Contentstack.Core.Tests[xUnit.net 00:00:30.9190659] Finished: Contentstack.Core.Tests - - - \ No newline at end of file diff --git a/Contentstack.Core.Tests/TestResults/_Uttams-MacBook-Pro_2019-03-08_14_48_46.trx b/Contentstack.Core.Tests/TestResults/_Uttams-MacBook-Pro_2019-03-08_14_48_46.trx deleted file mode 100644 index e2293f2..0000000 --- a/Contentstack.Core.Tests/TestResults/_Uttams-MacBook-Pro_2019-03-08_14_48_46.trx +++ /dev/null @@ -1,347 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [xUnit.net 00:00:00.5946316] Discovering: Contentstack.Core.Tests[xUnit.net 00:00:00.6691032] Discovered: Contentstack.Core.Tests[xUnit.net 00:00:00.6759638] Starting: Contentstack.Core.Tests[xUnit.net 00:00:30.9190659] Finished: Contentstack.Core.Tests - - - \ No newline at end of file diff --git a/Contentstack.Core/ContentstackClient.cs b/Contentstack.Core/ContentstackClient.cs index 20a255b..c1bbd9d 100644 --- a/Contentstack.Core/ContentstackClient.cs +++ b/Contentstack.Core/ContentstackClient.cs @@ -4,6 +4,13 @@ using Contentstack.Core.Configuration; using Microsoft.Extensions.Options; using Contentstack.Core.Models; +using Newtonsoft.Json.Linq; +using Newtonsoft.Json; +using System.Linq; +using System.Threading.Tasks; +using System.Net; +using System.IO; +using System.Collections; namespace Contentstack.Core { @@ -20,8 +27,17 @@ internal string StackApiKey set; } private ContentstackOptions _options; - - + private Dictionary UrlQueries = new Dictionary(); + private Dictionary _Headers = new Dictionary(); + private string _Url + { + get + { + Config config = this.config; + return String.Format("{0}/content_types/", config.BaseUrl); + } + } + private Dictionary _StackHeaders = new Dictionary(); /// /// Initializes a instance of the class. /// @@ -61,6 +77,62 @@ public ContentstackClient(IOptions options) } + + internal static ContentstackError GetContentstackError(Exception ex) + { + Int32 errorCode = 0; + string errorMessage = string.Empty; + HttpStatusCode statusCode = HttpStatusCode.InternalServerError; + ContentstackError contentstackError = new ContentstackError(ex); + Dictionary errors = null; + //ContentstackError.OtherErrors 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", "")); + //errorCode = ContentstackConvert.ToInt32(data.Property("error_code").Value); + //errorMessage = ContentstackConvert.ToString(data.Property("error_message").Value); + + 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 ContentstackError() + { + ErrorCode = errorCode, + ErrorMessage = errorMessage, + StatusCode = statusCode, + Errors = errors + }; + + return contentstackError; + } + public ContentstackClient(ContentstackOptions options) : this(new OptionsWrapper(options)) { @@ -125,6 +197,55 @@ internal void SetConfig(Config cnfig) #endregion #region Public Functions + public async Task getContentTypes() + { + Dictionary headers = GetHeader(_LocalHeaders); + Dictionary headerAll = new Dictionary(); + Dictionary mainJson = new Dictionary(); + + //Dictionary urlQueries = new Dictionary(); + + if (headers != null && headers.Count() > 0) + { + foreach (var header in headers) + { + headerAll.Add(header.Key, (String)header.Value); + } + + if (headers.ContainsKey("environment")) + { + UrlQueries.Add("environment", headers["environment"]); + //Url = Url + "?environment=" + headers["environment"]; + } + else if (headers.ContainsKey("environment_uid")) + { + UrlQueries.Add("environment_uid", headers["environment_uid"]); + //Url = Url + "?environment_uid=" + headers["environment_uid"]; + } + else + { + + mainJson.Add("environment", this.config.Environment); + } + } + + foreach (var kvp in UrlQueries) + { + mainJson.Add(kvp.Key, kvp.Value); + } + try + { + HTTPRequestHandler RequestHandler = new HTTPRequestHandler(); + var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson); + JObject data = JsonConvert.DeserializeObject(outputResult.Replace("\r\n", ""), ContentstackConvert.JsonSerializerSettings); + IList contentTypes = (IList)data["content_types"]; + return contentTypes; + } + catch (Exception ex) + { + throw GetContentstackError(ex); + } + } /// /// Represents a ContentType. Creates ContenntType Instance. @@ -353,6 +474,46 @@ public void SetHeader(string key, string value) #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; + } + } + private Dictionary GetHeader() { From 540b746556edb091b9796a814b2d605f062a8d3b Mon Sep 17 00:00:00 2001 From: Uttam K Ukkoji Date: Thu, 11 Apr 2019 11:38:46 +0530 Subject: [PATCH 04/13] Test cases refactor --- Contentstack.Core.Tests/SyncStackTest.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Contentstack.Core.Tests/SyncStackTest.cs diff --git a/Contentstack.Core.Tests/SyncStackTest.cs b/Contentstack.Core.Tests/SyncStackTest.cs new file mode 100644 index 0000000..e3e3b5d --- /dev/null +++ b/Contentstack.Core.Tests/SyncStackTest.cs @@ -0,0 +1,10 @@ +using System; +namespace Contentstack.Core.Tests +{ + public class SyncStackTest + { + public SyncStackTest() + { + } + } +} From 2d26377e7b672ff719e67f23d8bd055895191529 Mon Sep 17 00:00:00 2001 From: Uttam K Ukkoji Date: Thu, 11 Apr 2019 11:39:26 +0530 Subject: [PATCH 05/13] Test cases refactor --- Contentstack.Core.Tests/StackConfig.cs | 24 ++ Contentstack.Core.Tests/SyncStackTest.cs | 128 +++++++- Contentstack.Core/ContentstackClient.cs | 273 ++++++++++++++++-- .../Internals/ContentStackError.cs | 2 +- .../Internals/ContentstackConstants.cs | 2 - .../Internals/ContentstackConvert.cs | 2 +- .../Internals/HTTPRequestHandler.cs | 2 +- Contentstack.Core/Internals/StackOutput.cs | 10 +- docfx_project/Template/styles/main.css | 75 +++++ docfx_project/api/index.md | 54 ++++ docfx_project/api/toc.yml | 31 ++ docfx_project/docfx.json | 68 +++++ docfx_project/filterRules.yml | 24 ++ docfx_project/images/favicon.ico | Bin 0 -> 32038 bytes docfx_project/images/logo.svg | 109 +++++++ docfx_project/index.md | 54 ++++ docfx_project/toc.yml | 3 + 17 files changed, 818 insertions(+), 43 deletions(-) create mode 100644 docfx_project/Template/styles/main.css create mode 100644 docfx_project/api/index.md create mode 100644 docfx_project/api/toc.yml create mode 100644 docfx_project/docfx.json create mode 100644 docfx_project/filterRules.yml create mode 100755 docfx_project/images/favicon.ico create mode 100755 docfx_project/images/logo.svg create mode 100644 docfx_project/index.md create mode 100644 docfx_project/toc.yml diff --git a/Contentstack.Core.Tests/StackConfig.cs b/Contentstack.Core.Tests/StackConfig.cs index d537d1f..05d7b20 100644 --- a/Contentstack.Core.Tests/StackConfig.cs +++ b/Contentstack.Core.Tests/StackConfig.cs @@ -18,6 +18,30 @@ System.Configuration.Configuration assemblyConfiguration } } + public static ContentstackClient GetSyncStack() + { + StackConfig config = new StackConfig(); + if (config.assemblyConfiguration.HasFile && string.Compare(config.assemblyConfiguration.FilePath, config.currentConfiguration.FilePath, true) != 0) + { + config.assemblyConfiguration.SaveAs(config.currentConfiguration.FilePath); + ConfigurationManager.RefreshSection("appSettings"); + ConfigurationManager.RefreshSection("connectionStrings"); + } + string apiKey = ConfigurationManager.AppSettings["sync_api_key"]; + string accessToken = ConfigurationManager.AppSettings["sync_access_token"]; + string environment = ConfigurationManager.AppSettings["sync_environment"]; + string host = ConfigurationManager.AppSettings["host"]; + Configuration.ContentstackOptions contentstackOptions = new Configuration.ContentstackOptions + { + ApiKey = apiKey, + AccessToken = accessToken, + Environment = environment, + Host = host + }; + + ContentstackClient contentstackClient = new ContentstackClient(new OptionsWrapper(contentstackOptions)); + return contentstackClient; + } public static ContentstackClient GetStack() { diff --git a/Contentstack.Core.Tests/SyncStackTest.cs b/Contentstack.Core.Tests/SyncStackTest.cs index e3e3b5d..f4ece25 100644 --- a/Contentstack.Core.Tests/SyncStackTest.cs +++ b/Contentstack.Core.Tests/SyncStackTest.cs @@ -1,10 +1,136 @@ using System; +using Xunit; +using Contentstack.Core.Configuration; +using System.Threading.Tasks; + namespace Contentstack.Core.Tests { public class SyncStackTest { - public SyncStackTest() + ContentstackClient client = StackConfig.GetSyncStack(); + + [Fact] + public async Task SyncInit() { + + var result = await client.SyncRecursive(); + + if (result == null) + { + Assert.False(true, "Entry.Fetch is not match with expected result."); + } + else + { + Assert.True(true); + } + } + + [Fact] + public async Task SyncSyncType() + { + + var result = await client.SyncRecursive(SyncType: Models.SyncType.asset_published); + + if (result == null) + { + Assert.False(true, "Entry.Fetch is not match with expected result."); + } + else + { + Assert.True(true); + } + } + [Fact] + public async Task SyncContentType() + { + + var result = await client.SyncRecursive(ContentTypeUid: "session"); + + if (result == null) + { + Assert.False(true, "Entry.Fetch is not match with expected result."); + } + else + { + Assert.True(true); + } + } + [Fact] + public async Task SyncStartFrom() + { + + var result = await client.SyncRecursive(StartFrom:DateTime.Now); + + if (result == null) + { + Assert.False(true, "Entry.Fetch is not match with expected result."); + } + else + { + Assert.True(true); + } + } + [Fact] + public async Task SyncTypeWithContentType() + { + + var result = await client.SyncRecursive(SyncType: Models.SyncType.entry_published, ContentTypeUid: "session"); + + if (result == null) + { + Assert.False(true, "Entry.Fetch is not match with expected result."); + } + else + { + Assert.True(true); + } + } + [Fact] + public async Task SyncTypeWithStartFrom() + { + + var result = await client.SyncRecursive(SyncType: Models.SyncType.entry_published, StartFrom:DateTime.Now); + + if (result == null) + { + Assert.False(true, "Entry.Fetch is not match with expected result."); + } + else + { + Assert.True(true); + } + } + + [Fact] + public async Task SyncPaginationToken() + { + + var result = await client.SyncPaginationToken("blt99c1e34e65f6cc0fd1d82b"); + + if (result == null) + { + Assert.False(true, "Entry.Fetch is not match with expected result."); + } + else + { + Assert.True(true); + } + } + + [Fact] + public async Task SyncToken() + { + + var result = await client.SyncToken("blt08854bd48e43a740951809"); + + if (result == null) + { + Assert.False(true, "Entry.Fetch is not match with expected result."); + } + else + { + Assert.True(true); + } } } } diff --git a/Contentstack.Core/ContentstackClient.cs b/Contentstack.Core/ContentstackClient.cs index 20a255b..92609a1 100644 --- a/Contentstack.Core/ContentstackClient.cs +++ b/Contentstack.Core/ContentstackClient.cs @@ -4,11 +4,17 @@ using Contentstack.Core.Configuration; using Microsoft.Extensions.Options; using Contentstack.Core.Models; +using System.Threading.Tasks; +using Newtonsoft.Json; +using System.Linq; +using System.Net; +using Newtonsoft.Json.Linq; +using System.IO; namespace Contentstack.Core { /// - /// To fetch stack level information of your application from Built.io Contentstack server. + /// To fetch stack level information of your application from Contentstack server. /// public class ContentstackClient { @@ -22,6 +28,16 @@ internal string StackApiKey private ContentstackOptions _options; + internal string _SyncUrl + { + get + { + Config config = this.config; + return String.Format("{0}/stacks/sync", + config.BaseUrl); + } + } + /// /// Initializes a instance of the class. /// @@ -108,6 +124,60 @@ private ContentstackClient() { } #endregion #region Internal Constructor + internal static ContentstackError GetContentstackError(Exception ex) + { + Int32 errorCode = 0; + string errorMessage = string.Empty; + HttpStatusCode statusCode = HttpStatusCode.InternalServerError; + ContentstackError contentstackError = new ContentstackError(ex); + Dictionary errors = null; + //ContentstackError.OtherErrors 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", "")); + //errorCode = ContentstackConvert.ToInt32(data.Property("error_code").Value); + //errorMessage = ContentstackConvert.ToString(data.Property("error_message").Value); + + 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 ContentstackError() + { + ErrorCode = errorCode, + ErrorMessage = errorMessage, + StatusCode = statusCode, + Errors = errors + }; + + return contentstackError; + } internal ContentstackClient(String stackApiKey) { this.StackApiKey = stackApiKey; @@ -296,7 +366,7 @@ public void RemoveHeader(string key) } /// - /// To set headers for Built.io Contentstack rest calls. + /// To set headers for Contentstack rest calls. /// /// header name. /// header value against given header name. @@ -318,41 +388,136 @@ public void SetHeader(string key, string value) } } + /// + /// Syncs the recursive. + /// + /// The recursive. + /// Sync type. + /// Content type uid. + /// Start from Date. + /// + /// + /// //"blt5d4sample2633b" is a dummy Stack API key + /// //"blt6d0240b5sample254090d" is dummy access token. + /// ContentstackClient stack = new ContentstackClinet("blt5d4sample2633b", "blt6d0240b5sample254090d", "stag"); + /// stack.SyncRecursive("SyncType"); + /// + /// + /// + public async Task SyncRecursive(SyncType SyncType = SyncType.All, string ContentTypeUid = null, DateTime? StartFrom = null) + { + SyncStack syncStack = await Sync(SyncType: SyncType, ContentTypeUid: ContentTypeUid, StartFrom: StartFrom); + syncStack = await SyncPageinationRecursive(syncStack); + return syncStack; + } - ///// - ///// set environment. - ///// - ///// environment uid/name - ///// true - If environment uid is present - ///// false - If environment uid is not present - ///// - ///// - ///// //"blt5d4sample2633b" is a dummy Stack API key - ///// //"blt6d0240b5sample254090d" is dummy access token. - ///// Stack stack = Contentstack.Stack("blt5d4sample2633b", "blt6d0240b5sample254090d", "stag"); - ///// stack.SetEnvironment("stag", false); - ///// - ///// - //public void SetEnvironment(string environment, bool isEnvironmentUid) - //{ - // if (!string.IsNullOrEmpty(environment)) - // { - // if (isEnvironmentUid) - // { - // RemoveHeader("environment"); - // SetHeader("environment_uid", environment); - // } - // else - // { - // RemoveHeader("environment_uid"); - // SetHeader("environment", environment); - // } - // } - //} + /// + /// Syncs the recursive with language. + /// + /// The recursive with language. + /// Sync type. + /// Content type uid. + /// Start from Date. + /// Lang. + /// + /// + /// //"blt5d4sample2633b" is a dummy Stack API key + /// //"blt6d0240b5sample254090d" is dummy access token. + /// ContentstackClient stack = new ContentstackClinet("blt5d4sample2633b", "blt6d0240b5sample254090d", "stag"); + /// stack.SyncRecursiveLanguage("SyncType", "Language"); + /// + /// + /// + public async Task SyncRecursiveLanguage(Language Lang, SyncType SyncType = SyncType.All, string ContentTypeUid = null, DateTime? StartFrom = null) + { + SyncStack syncStack = await SyncLanguage(Lang: Lang, SyncType: SyncType, ContentTypeUid: ContentTypeUid, StartFrom: StartFrom); + syncStack = await SyncPageinationRecursive(syncStack); + return syncStack; + } + /// + /// Syncs the pagination token. + /// + /// The pagination token. + /// Pagination token. + /// + /// + /// //"blt5d4sample2633b" is a dummy Stack API key + /// //"blt6d0240b5sample254090d" is dummy access token. + /// ContentstackClient stack = new ContentstackClinet("blt5d4sample2633b", "blt6d0240b5sample254090d", "stag"); + /// stack.SyncPaginationTokenn("blt123343"); + /// + /// + + public async Task SyncPaginationToken(string paginationToken) + { + return await GetResultAsync(PaginationToken: paginationToken); + } + + /// + /// Syncs the token. + /// + /// The token. + /// Sync token. + /// + /// + /// //"blt5d4sample2633b" is a dummy Stack API key + /// //"blt6d0240b5sample254090d" is dummy access token. + /// ContentstackClient stack = new ContentstackClinet("blt5d4sample2633b", "blt6d0240b5sample254090d", "stag"); + /// stack.SyncToken("blt123343"); + /// + /// + public async Task SyncToken(string SyncToken) + { + return await GetResultAsync(SyncToken: SyncToken); + } #endregion #region Private Functions + + private async Task SyncPageinationRecursive(SyncStack syncStack) + { + while (syncStack.pagination_token != null) + { + SyncStack newSyncStack = await SyncPaginationToken(syncStack.pagination_token); + syncStack.items = syncStack.items.Concat(newSyncStack.items); + syncStack.pagination_token = newSyncStack.pagination_token; + syncStack.skip = newSyncStack.skip; + syncStack.total_count = newSyncStack.total_count; + syncStack.sync_token = newSyncStack.sync_token; + } + return syncStack; + } + + private async Task Sync(SyncType SyncType = SyncType.All, string ContentTypeUid = null, DateTime? StartFrom = null) + { + return await GetResultAsync(Init: "true", ContentTypeUid: ContentTypeUid, StartFrom: StartFrom); + } + + + private async Task SyncLanguage(Language Lang, SyncType SyncType = SyncType.All, string ContentTypeUid = null, DateTime? StartFrom = null) + { + return await GetResultAsync(Init: "true", ContentTypeUid: ContentTypeUid, StartFrom: StartFrom, Lang: GetLocaleCode(Lang)); + } + + //GetLanguage code + private string GetLocaleCode(Language language) + { + string localeCode = null; + try + { + int localeValue = (int)language; + LanguageCode[] languageCodeValues = Enum.GetValues(typeof(LanguageCode)).Cast().ToArray(); + localeCode = languageCodeValues[localeValue].ToString(); + localeCode = localeCode.Replace("_", "-"); + } + catch (Exception e) + { + throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e); + } + return localeCode; + } + private Dictionary GetHeader() { @@ -360,6 +525,50 @@ private Dictionary GetHeader() return mainHeader; } + + + private async Task GetResultAsync(string Init = "false", string ContentTypeUid = null, DateTime? StartFrom = null, string SyncToken = null, string PaginationToken = null, string Lang = null) + { + //mainJson = null; + Dictionary mainJson = new Dictionary(); + if (Init != "false") + { + mainJson.Add("init", "true"); + mainJson.Add("environment", config.Environment); + } + if (StartFrom != null) + { + DateTime startFrom = StartFrom ?? DateTime.MinValue; + mainJson.Add("start_from", startFrom.ToString("yyyy-MM-dd")); + } + if (SyncToken != null) + { + mainJson.Add("sync_token", SyncToken); + } + if (PaginationToken != null) + { + mainJson.Add("pagination_token", PaginationToken); + } + if (ContentTypeUid != null) + { + mainJson.Add("content_type_uid", ContentTypeUid); + } + if (Lang != null) + { + mainJson.Add("locale", Lang); + } + try + { + HTTPRequestHandler requestHandler = new HTTPRequestHandler(); + string js = await requestHandler.ProcessRequest(_SyncUrl, _LocalHeaders, mainJson); + SyncStack stackSyncOutput = JsonConvert.DeserializeObject(js); + return stackSyncOutput; + } + catch (Exception ex) + { + throw GetContentstackError(ex); + } + } #endregion } diff --git a/Contentstack.Core/Internals/ContentStackError.cs b/Contentstack.Core/Internals/ContentStackError.cs index 0b91971..e6ba381 100644 --- a/Contentstack.Core/Internals/ContentStackError.cs +++ b/Contentstack.Core/Internals/ContentStackError.cs @@ -16,7 +16,7 @@ public class ContentstackError : Exception #region Public Variables /// - /// This is http response status code of REST request to built.io. + /// This is http response status code of REST request to Contentstack. /// public HttpStatusCode StatusCode; diff --git a/Contentstack.Core/Internals/ContentstackConstants.cs b/Contentstack.Core/Internals/ContentstackConstants.cs index 25b3448..3ea6e95 100644 --- a/Contentstack.Core/Internals/ContentstackConstants.cs +++ b/Contentstack.Core/Internals/ContentstackConstants.cs @@ -6,8 +6,6 @@ namespace Contentstack.Core.Internals internal class ContentstackConstants { #region Private Variable - private string _Entries = "entries"; - private string _CacheFolderName; private string _ContentTypes = "content_types"; #endregion diff --git a/Contentstack.Core/Internals/ContentstackConvert.cs b/Contentstack.Core/Internals/ContentstackConvert.cs index 0d42809..13dc24f 100644 --- a/Contentstack.Core/Internals/ContentstackConvert.cs +++ b/Contentstack.Core/Internals/ContentstackConvert.cs @@ -326,7 +326,7 @@ public static bool GetResponseTimeFromCacheFile(string filePath, long responseTi } } - catch (Exception e) + catch { //showLog("appUtils", "------------getJsonFromFilec catch-|" + e.toString()); return false; diff --git a/Contentstack.Core/Internals/HTTPRequestHandler.cs b/Contentstack.Core/Internals/HTTPRequestHandler.cs index cfc3de6..41df875 100644 --- a/Contentstack.Core/Internals/HTTPRequestHandler.cs +++ b/Contentstack.Core/Internals/HTTPRequestHandler.cs @@ -44,7 +44,7 @@ public async Task ProcessRequest(string Url, Dictionary foreach (var header in Headers) { try { request.Headers[header.Key] = header.Value.ToString(); - } catch (Exception e) { + } catch { } } diff --git a/Contentstack.Core/Internals/StackOutput.cs b/Contentstack.Core/Internals/StackOutput.cs index 3c5ec26..7ae139b 100644 --- a/Contentstack.Core/Internals/StackOutput.cs +++ b/Contentstack.Core/Internals/StackOutput.cs @@ -15,13 +15,13 @@ internal class StackOutput private object _Output = default(object); private Dictionary _ObjectAttributes = new Dictionary(); private object _Schema = default(object); - private object _Stack = default(object); - private object _ContentType = default(object); - private object _ContentTypes = default(object); + //private object _Stack = default(object); + //private object _ContentType = default(object); + //private object _ContentTypes = default(object); private object _Object = default(object); private object _Objects = default(object); - private object _Asset = default(object); - private object _Assets = default(object); + //private object _Asset = default(object); + //private object _Assets = default(object); private object _Result = default(object); private object _ApplicationUser = default(object); private object _Tags = default(object); diff --git a/docfx_project/Template/styles/main.css b/docfx_project/Template/styles/main.css new file mode 100644 index 0000000..688095a --- /dev/null +++ b/docfx_project/Template/styles/main.css @@ -0,0 +1,75 @@ + +/* Custom Navbar + ------------------------------------------------------- */ +.navbar-inverse { + background-color: #ffffff; + opacity: 0.95; + border-color: #ffffff; +} +.navbar-inverse .navbar-brand { + color: #ffffff; +} +.navbar-inverse .navbar-brand:hover, +.navbar-inverse .navbar-brand:focus { + color: #ecdbff; +} +.navbar-inverse .navbar-text { + color: #ffffff; +} +.navbar-inverse .navbar-nav > li > a { + color: #000000; +} +.navbar-inverse .navbar-nav > li > a:hover, +.navbar-inverse .navbar-nav > li > a:focus { + color: #000000; +} +.navbar-inverse .navbar-nav > .active > a, +.navbar-inverse .navbar-nav > .active > a:hover, +.navbar-inverse .navbar-nav > .active > a:focus { + color: #000000; + background-color: #ffffff; +} +.navbar-inverse .navbar-nav > .open > a, +.navbar-inverse .navbar-nav > .open > a:hover, +.navbar-inverse .navbar-nav > .open > a:focus { + color: #000000; + background-color: #ffffff; +} +.navbar-inverse .navbar-toggle { + border-color: #ffffff; +} +.navbar-inverse .navbar-toggle:hover, +.navbar-inverse .navbar-toggle:focus { + background-color: #ffffff; +} +.navbar-inverse .navbar-toggle .icon-bar { + background-color: #ffffff; +} +.navbar-inverse .navbar-collapse, +.navbar-inverse .navbar-form { + border: none; +} +.navbar-inverse .navbar-link { + color: #ffffff; +} +.navbar-inverse .navbar-link:hover { + color: #ecdbff; +} +svg:hover path { + fill: #444444; +} +@media (max-width: 767px) { + .navbar-inverse .navbar-nav .open .dropdown-menu > li > a { + color: #ffffff; + } + .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:hover, + .navbar-inverse .navbar-nav .open .dropdown-menu > li > a:focus { + color: #ecdbff; + } + .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a, + .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:hover, + .navbar-inverse .navbar-nav .open .dropdown-menu > .active > a:focus { + color: #ecdbff; + background-color: #ffffff; + } +} \ No newline at end of file diff --git a/docfx_project/api/index.md b/docfx_project/api/index.md new file mode 100644 index 0000000..5e4a298 --- /dev/null +++ b/docfx_project/api/index.md @@ -0,0 +1,54 @@ + +# Contentstack - .Net SDK + +.NET SDK for Contentstack's Content Delivery API + +Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. [Read More](https://www.contentstack.com/). + +For more details about the namespaces and classes navigate menu to left. + +## Prerequisites + +To get started with C#, you will need: + +.net platform, IDE (Visual Studio) and NuGet. + +## SDK installation and setup + +The .Net SDK provided by contentstack.io is available for Xamarin, Windows Phone and legacy .Net applications. You can integrate contentstack with your application by following these steps. + +Open the terminal and install the contentstack module via 'Package Manager' command + +And via ‘.Net CLI’ + +To use the module in your application, you need to first Add Namespace to your class + +## Initialize SDK + +You will need to specify the API key, Access token, and Environment Name of your stack to initialize the SDK: + +or: + +Once you have initialized the SDK, you can start getting content in your app. + +## Basic Queries + +### Get a Single Entry + +To retrieve a single entry from a content type, use the code snippet given below: + +### Get Multiple Entries + +To retrieve multiple entries of a particular content type, use the code snippet given below: + +## Example + +To help you get started, we have created a sample console application that is powered by Contentstack .NET SDK. Click on the link below to read the tutorial of the app. + +[.NET News Console App](https://contentstack.com/docs/example-apps/build-a-news-app-using-contentstack-dot-net-sdk) + +## Helpful Links + +- [Contentstack Website](https://www.contentstack.com/) +- [Official Documentation](https://contentstack.com/docs) +- [Content Delivery API Docs](https://contentstack.com/docs/apis/content-delivery-api/) diff --git a/docfx_project/api/toc.yml b/docfx_project/api/toc.yml new file mode 100644 index 0000000..b73a62e --- /dev/null +++ b/docfx_project/api/toc.yml @@ -0,0 +1,31 @@ +### YamlMime:TableOfContent +- uid: Contentstack.AspNetCore + name: Contentstack.AspNetCore + items: + - uid: Contentstack.AspNetCore.IServiceCollectionExtensions + name: IServiceCollectionExtensions +- uid: Contentstack.Core + name: Contentstack.Core + items: + - uid: Contentstack.Core.ContentstackClient + name: ContentstackClient +- uid: Contentstack.Core.Internals + name: Contentstack.Core.Internals + items: + - uid: Contentstack.Core.Internals.CachePolicy + name: CachePolicy + - uid: Contentstack.Core.Internals.Language + name: Language +- uid: Contentstack.Core.Models + name: Contentstack.Core.Models + items: + - uid: Contentstack.Core.Models.ContentType + name: ContentType + - uid: Contentstack.Core.Models.Entry + name: Entry + - uid: Contentstack.Core.Models.Query + name: Query + - uid: Contentstack.Core.Models.SyncStack + name: SyncStack + - uid: Contentstack.Core.Models.SyncType + name: SyncType diff --git a/docfx_project/docfx.json b/docfx_project/docfx.json new file mode 100644 index 0000000..bf4b7dc --- /dev/null +++ b/docfx_project/docfx.json @@ -0,0 +1,68 @@ +{ + "metadata": [ + { + "src": [ + { + "files": [ + "src/**.csproj" + ] + } + ], + "dest": "api", + "disableGitFeatures": false, + "disableDefaultFilter": false, + "filter": "filterRules.yml" + + } + ], + "build": { + "content": [ + { + "files": [ + "toc.yml", + "index.md", + "api/**.yml", + "api/index.md" + ] + } + ], + "resource": [ + { + "files": [ + "images/**" + ] + } + ], + "overwrite": [ + { + "files": [ + "apidoc/**.md" + ], + "exclude": [ + "obj/**", + "_site/**" + ] + } + ], + "globalMetadata": { + "_appTitle": "Contentstack - .NET SDK Documentation", + "_appLogoPath": "images/logo.svg", + "_appFaviconPath": "images/favicon.ico", + "_appFooter": "Copyright © 2012-2019 Contentstack. All Rights Reserved", + "_enableSearch": "true" + }, + "dest": "_site", + "globalMetadataFiles": [], + "fileMetadataFiles": [], + "template": [ + "default", + "Template" + ], + "postProcessors": [], + "markdownEngineName": "markdig", + "noLangKeyword": false, + "keepFileLink": false, + "cleanupCacheHistory": false, + "disableGitFeatures": false + } +} \ No newline at end of file diff --git a/docfx_project/filterRules.yml b/docfx_project/filterRules.yml new file mode 100644 index 0000000..7ec1f19 --- /dev/null +++ b/docfx_project/filterRules.yml @@ -0,0 +1,24 @@ +apiRules: +- exclude: + uidRegex: ^Contentstack\.Core\.Tests +- exclude: + uidRegex: ^Contentstack\.Core\.Internals\.ResponseType + type: Class +- exclude: + uidRegex: ^Contentstack\.Core\.Internals\.OrderBy + type: Class +- exclude: + uidRegex: ^Contentstack\.Core\.Internals\.NetworkStatus + type: Class +- exclude: + uidRegex: ^Contentstack\.Core\.Internals\.HttpMethods + type: Class +- exclude: + uidRegex: ^Contentstack\.Core\.Internals\.ContentstackError + type: Class +- exclude: + uidRegex: ^Contentstack\.Core\.Configuration + type: Class +- exclude: + uidRegex: ^Contentstack\.Core\.Models\.AssetLibrary + type: Class \ No newline at end of file diff --git a/docfx_project/images/favicon.ico b/docfx_project/images/favicon.ico new file mode 100755 index 0000000000000000000000000000000000000000..a1c0f9fa72c068d7f4477460a10df3e81cefeed2 GIT binary patch literal 32038 zcmeI5e~1=E7{^yiL=G`I4iPytL`+2TkPs75(<>xILfn@);))0pkqC(p5rjBIA|xUr zBH{?4I4q8ch!7F~kO&cp5b2LYBtpa)M8rR$uFtdgzIXes`|i%n&hDMQd+>F4XP=)l z&pbOjGw&J%^MWUXr=AMR+GeT`zAeZ&435n}?dE&{^qRR3C!9){+A0zYs)o+z85 z3DvF0zJ}Vy{nIIUgR(;@<eO4p88tPOEhT!jke{mZcdVYfcQ|LZR!GSnk);YWfsgFBJ>m-BkLU3fxgP|RlSLqTW+m7TT6yL~l)EU1{S~pX zn|X-|a-G_r4;}Sq-*tsv@}8c|1O4}$Z`~pfz5B3%{+$PH+}~a7#6RiZlAlen+eJ?& z9`t?$a@%2sMonMWTy_t5<+xN3=?vUJe5B(^sjpbwf}1G;uup6eFZ#6o`Sj4 z2kr^@2aP{W*)iCn>+oYiwTy-12IAF8;Ypdy}%Uo%c{* zeL0fzS5ilr*Vw+%tNo##DAV3F*-am$9em*FG#zPW=#%+m<{&ihz1EPq3*n#7{H&{t zG`(BWY)vae_ZDoBd1i;_PBa&{30|2GbD5Xxr1S4IThq$0eFwT-?HB#6c8doE@B4ea-&k36ILX-jY8XOU%Ke?RN+h2J-*^P@m= z{!%akP8Wp8Semq-GKo>q;RDec9J1v7vDZ;%=DJdf{S)YswI&Zxe<5cHkeG3mcOBmT zq@A6vp>^p;Sv=Bbj}(w=HGhJhzk%@hz-{F8lIJ9cX(ySCDdDpjm+@TH>pUUK&&XN` z);h{u4WIEo9%v{mkMGWeyeAx4`0yfb^PhWCL0-y85{WEl6TU0D(%bS zC-(PY|6z_i6N*5;!Q8F){U|nV5vRo`>F3LVjBjiqe6!lO(f=H{2h!psuj~PBxiMZJ zRiC4O2exB}ll|hKw>`lwzN3Et6sUha;G(zYsn_`H80Z`WQ~QDBH&OCeAFHkh*{8J~ zoB*wTS^>XlP5#v}+&PBpx~c1?j)6J`e8vD{Re5JQ!?>GuC|}So`LwZ2S@^sg{6ih& zy&KuwKUSvAK4sVbNAGL5X#cw&@s`gvDq9wQZv@-?Ao{jPrTewYuAgp_&s-d9!O?FM z&k+ya!J73i$UOjz*Pg1Zf9#?!C|PT?$@jLjQm=Eek6@R~A9l0B|1ZF{SHQt?prr55>Kt?2-}*fJeTuds9@G$VF;Y7C9>82{5B!&X8@~g? z{#}U9c%Nof^@QK6z#rB4udY|+m#H57uCo2Fnc7tq9sbLHheKerRD}8~%@l>gCpVt(^1yOW(a3ivPm zvy)tx^83y9ezyCDv*7_MR5%oqs{hT#Q7-?GV^SbF~*2%{6Fq|)QyZo zUMdf2RjUpe@2@XUj~+z6)qXW>=>g-wZLhZ3-0qK4@y_?YLM{3JZb`rg^%b&>_pd@L z{$BttdEAue%9Q_eZ~mw0zs#AL`r<-2hy9P{WInKj%mBet*YaNT&v|qaYjbP;yY^rI zNgdoNAB;hwwZ7>0V-mBTbgJ9P8ji=b%{ex$W&E|dbi}@~!|!beyy=tQ)$mPP8=q_1 znKcONPR1U$X^-shHW$6$P{+{Y{G2MQ&9KQOm%H#p`M)ebT;w;L2-{i@DgdZ5M{#XLWkv(VEo*17n|D!Hpqh%kr zqQ6{b8y1m`-!lJI$^1_dJImtjcK_x7o1qT&0@nEQ{=XpC`|j`TWwm=P*ZlcHY{1FCqxJ8q{czP+`yZ_g(>Rf&T%;B+B#v literal 0 HcmV?d00001 diff --git a/docfx_project/images/logo.svg b/docfx_project/images/logo.svg new file mode 100755 index 0000000..280c8cc --- /dev/null +++ b/docfx_project/images/logo.svg @@ -0,0 +1,109 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docfx_project/index.md b/docfx_project/index.md new file mode 100644 index 0000000..5e4a298 --- /dev/null +++ b/docfx_project/index.md @@ -0,0 +1,54 @@ + +# Contentstack - .Net SDK + +.NET SDK for Contentstack's Content Delivery API + +Contentstack is a headless CMS with an API-first approach. It is a CMS that developers can use to build powerful cross-platform applications in their favorite languages. Build your application frontend, and Contentstack will take care of the rest. [Read More](https://www.contentstack.com/). + +For more details about the namespaces and classes navigate menu to left. + +## Prerequisites + +To get started with C#, you will need: + +.net platform, IDE (Visual Studio) and NuGet. + +## SDK installation and setup + +The .Net SDK provided by contentstack.io is available for Xamarin, Windows Phone and legacy .Net applications. You can integrate contentstack with your application by following these steps. + +Open the terminal and install the contentstack module via 'Package Manager' command + +And via ‘.Net CLI’ + +To use the module in your application, you need to first Add Namespace to your class + +## Initialize SDK + +You will need to specify the API key, Access token, and Environment Name of your stack to initialize the SDK: + +or: + +Once you have initialized the SDK, you can start getting content in your app. + +## Basic Queries + +### Get a Single Entry + +To retrieve a single entry from a content type, use the code snippet given below: + +### Get Multiple Entries + +To retrieve multiple entries of a particular content type, use the code snippet given below: + +## Example + +To help you get started, we have created a sample console application that is powered by Contentstack .NET SDK. Click on the link below to read the tutorial of the app. + +[.NET News Console App](https://contentstack.com/docs/example-apps/build-a-news-app-using-contentstack-dot-net-sdk) + +## Helpful Links + +- [Contentstack Website](https://www.contentstack.com/) +- [Official Documentation](https://contentstack.com/docs) +- [Content Delivery API Docs](https://contentstack.com/docs/apis/content-delivery-api/) diff --git a/docfx_project/toc.yml b/docfx_project/toc.yml new file mode 100644 index 0000000..5990d63 --- /dev/null +++ b/docfx_project/toc.yml @@ -0,0 +1,3 @@ +- name: Api Documentation + href: api/ + homepage: api/index.md \ No newline at end of file From eb98624e3ee7cdcc05dcee91c1fea4b563768504 Mon Sep 17 00:00:00 2001 From: Uttam K Ukkoji Date: Thu, 11 Apr 2019 11:48:54 +0530 Subject: [PATCH 06/13] Contenttype Schema Fetch test class --- Contentstack.Core.Tests/ContentTypeTest.cs | 50 ++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 Contentstack.Core.Tests/ContentTypeTest.cs diff --git a/Contentstack.Core.Tests/ContentTypeTest.cs b/Contentstack.Core.Tests/ContentTypeTest.cs new file mode 100644 index 0000000..f8d3dbc --- /dev/null +++ b/Contentstack.Core.Tests/ContentTypeTest.cs @@ -0,0 +1,50 @@ +using System; +using Xunit; +using Contentstack.Core.Models; +using System.Threading.Tasks; +using Contentstack.Core.Configuration; +using System.Collections.Generic; +using System.Linq; +using System.Text.RegularExpressions; +using System.Collections; + +namespace Contentstack.Core.Tests +{ + public class ContentTypeTest + + { + ContentstackClient client = StackConfig.GetStack(); + String source = "source"; + + [Fact] + public async Task FetchContenTypeSchema() + { + ContentType contenttype = client.ContentType(source); + var result = await contenttype.Fetch(); + if (result == null) + { + Assert.False(true, "contenttype.FetchSchema() is not match with expected result."); + } + else + { + Assert.True(true); + } + } + + [Fact] + public async Task GetContentTypes() + { + var result = await client.getContentTypes(); + + if (result == null) + { + Assert.False(true, "client.getContentTypes is not match with expected result."); + } + else + { + Assert.True(true); + + } + } + } +} From c704d189a58b4aa6321b2dd4465f7bb52e7085e8 Mon Sep 17 00:00:00 2001 From: Uttam K Ukkoji Date: Thu, 11 Apr 2019 12:03:12 +0530 Subject: [PATCH 07/13] Conflict resolved --- Contentstack.Core/ContentstackClient.cs | 89 +++---------------------- 1 file changed, 10 insertions(+), 79 deletions(-) diff --git a/Contentstack.Core/ContentstackClient.cs b/Contentstack.Core/ContentstackClient.cs index c70e329..f4da0ae 100644 --- a/Contentstack.Core/ContentstackClient.cs +++ b/Contentstack.Core/ContentstackClient.cs @@ -4,14 +4,6 @@ using Contentstack.Core.Configuration; using Microsoft.Extensions.Options; using Contentstack.Core.Models; -<<<<<<< HEAD -using System.Threading.Tasks; -using Newtonsoft.Json; -using System.Linq; -using System.Net; -using Newtonsoft.Json.Linq; -using System.IO; -======= using Newtonsoft.Json.Linq; using Newtonsoft.Json; using System.Linq; @@ -19,7 +11,6 @@ using System.Net; using System.IO; using System.Collections; ->>>>>>> ffb258f91214d1dbdd26af50f3fe80e74ca0082f namespace Contentstack.Core { @@ -36,31 +27,27 @@ internal string StackApiKey set; } private ContentstackOptions _options; -<<<<<<< HEAD internal string _SyncUrl -======= - private Dictionary UrlQueries = new Dictionary(); - private Dictionary _Headers = new Dictionary(); - private string _Url ->>>>>>> ffb258f91214d1dbdd26af50f3fe80e74ca0082f - { + { get { Config config = this.config; -<<<<<<< HEAD return String.Format("{0}/stacks/sync", config.BaseUrl); } } - -======= + private Dictionary UrlQueries = new Dictionary(); + private Dictionary _Headers = new Dictionary(); + private string _Url + { + get { return String.Format("{0}/content_types/", config.BaseUrl); } } private Dictionary _StackHeaders = new Dictionary(); ->>>>>>> ffb258f91214d1dbdd26af50f3fe80e74ca0082f + /// /// Initializes a instance of the class. /// @@ -100,62 +87,6 @@ public ContentstackClient(IOptions options) } - - internal static ContentstackError GetContentstackError(Exception ex) - { - Int32 errorCode = 0; - string errorMessage = string.Empty; - HttpStatusCode statusCode = HttpStatusCode.InternalServerError; - ContentstackError contentstackError = new ContentstackError(ex); - Dictionary errors = null; - //ContentstackError.OtherErrors 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", "")); - //errorCode = ContentstackConvert.ToInt32(data.Property("error_code").Value); - //errorMessage = ContentstackConvert.ToString(data.Property("error_message").Value); - - 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 ContentstackError() - { - ErrorCode = errorCode, - ErrorMessage = errorMessage, - StatusCode = statusCode, - Errors = errors - }; - - return contentstackError; - } - public ContentstackClient(ContentstackOptions options) : this(new OptionsWrapper(options)) { @@ -603,7 +534,7 @@ public async Task SyncToken(string SyncToken) #region Private Functions -<<<<<<< HEAD + private async Task SyncPageinationRecursive(SyncStack syncStack) { while (syncStack.pagination_token != null) @@ -645,7 +576,8 @@ private string GetLocaleCode(Language language) throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e); } return localeCode; -======= + } + private Dictionary GetHeader(Dictionary localHeader) { Dictionary mainHeader = _StackHeaders; @@ -683,7 +615,6 @@ private Dictionary GetHeader(Dictionary localHea { return _StackHeaders; } ->>>>>>> ffb258f91214d1dbdd26af50f3fe80e74ca0082f } private Dictionary GetHeader() From a27744cef7b8c31d2fc77a85287b631eea5e4f5a Mon Sep 17 00:00:00 2001 From: Uttam K Ukkoji Date: Thu, 11 Apr 2019 12:47:53 +0530 Subject: [PATCH 08/13] Content type fetch schema --- Contentstack.Core/ContentstackClient.cs | 11 +++++++++++ README.md | 6 +++--- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/Contentstack.Core/ContentstackClient.cs b/Contentstack.Core/ContentstackClient.cs index f4da0ae..d35e210 100644 --- a/Contentstack.Core/ContentstackClient.cs +++ b/Contentstack.Core/ContentstackClient.cs @@ -205,6 +205,17 @@ internal void SetConfig(Config cnfig) #endregion #region Public Functions + /// + /// This method fetchs information of a all content types. + /// + /// + /// + /// ContentstackClient stack = new ContentstackClinet("blt5d4sample2633b", "blt6d0240b5sample254090d", "stag"); + /// ContentType contentType = stack.ContentType("contentType_name"); + /// var result = await contenttype.Fetch(); + /// + /// + /// The List of content types schema. public async Task getContentTypes() { Dictionary headers = GetHeader(_LocalHeaders); diff --git a/README.md b/README.md index c506e3f..ef7fe02 100755 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/) +[![Contentstack](https://www.contentstack.com/docs/static/images/contentstack.png)](https://www.contentstack.com/) # Contentstack dotnet .NET SDK for Contentstack's Content Delivery API @@ -104,10 +104,10 @@ To help you get started, we have created a sample application that is powered by ### The MIT License (MIT) -Copyright © 2012-2018 [Contentstack](https://www.contentstack.com/). All Rights Reserved +Copyright © 2012-2019 [Contentstack](https://www.contentstack.com/). All Rights Reserved Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. From 6ea41a040a8f39c8ffe69dbbdd56bc32bef17daa Mon Sep 17 00:00:00 2001 From: Uttam K Ukkoji Date: Thu, 11 Apr 2019 13:04:09 +0530 Subject: [PATCH 09/13] Content Type Fetch Schema --- Contentstack.Core.Tests/ContentTypeTest.cs | 2 +- Contentstack.Core/ContentstackClient.cs | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/Contentstack.Core.Tests/ContentTypeTest.cs b/Contentstack.Core.Tests/ContentTypeTest.cs index f8d3dbc..31e6603 100644 --- a/Contentstack.Core.Tests/ContentTypeTest.cs +++ b/Contentstack.Core.Tests/ContentTypeTest.cs @@ -34,7 +34,7 @@ public async Task FetchContenTypeSchema() [Fact] public async Task GetContentTypes() { - var result = await client.getContentTypes(); + var result = await client.GetContentTypes(); if (result == null) { diff --git a/Contentstack.Core/ContentstackClient.cs b/Contentstack.Core/ContentstackClient.cs index d35e210..c9e4612 100644 --- a/Contentstack.Core/ContentstackClient.cs +++ b/Contentstack.Core/ContentstackClient.cs @@ -211,12 +211,11 @@ internal void SetConfig(Config cnfig) /// /// /// ContentstackClient stack = new ContentstackClinet("blt5d4sample2633b", "blt6d0240b5sample254090d", "stag"); - /// ContentType contentType = stack.ContentType("contentType_name"); - /// var result = await contenttype.Fetch(); + /// ContentType contentType = stack.GetContentTypes(); /// /// /// The List of content types schema. - public async Task getContentTypes() + public async Task GetContentTypes() { Dictionary headers = GetHeader(_LocalHeaders); Dictionary headerAll = new Dictionary(); From e2f24a9f46346aa1363c2071543a9486b15853ac Mon Sep 17 00:00:00 2001 From: Uttam K Ukkoji Date: Thu, 11 Apr 2019 13:06:49 +0530 Subject: [PATCH 10/13] git ingnore file updated --- .gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2bdf631..0c85ec1 100644 --- a/.gitignore +++ b/.gitignore @@ -18,4 +18,3 @@ packages/ *.config *.nupkg *.nuspec -Contentstack.core/docfx_project/* From a822b9af3b48d59ad8b6f789e3204e41bb080888 Mon Sep 17 00:00:00 2001 From: Uttam K Ukkoji Date: Thu, 11 Apr 2019 15:24:15 +0530 Subject: [PATCH 11/13] LICENSE file added, Contentstack user-agent changed --- CHANGELOG.md | 23 +++++++++++++++++++ .../Contentstack.AspNetCore.csproj | 6 ++++- .../Contentstack.Core.Tests.csproj | 2 +- Contentstack.Core/Contentstack.Core.csproj | 14 ++++++++--- .../Internals/HTTPRequestHandler.cs | 2 +- Contentstack.Net.sln | 2 +- LICENSE | 21 +++++++++++++++++ README.md | 10 -------- docfx_project/docfx.json | 2 +- 9 files changed, 64 insertions(+), 18 deletions(-) create mode 100755 CHANGELOG.md create mode 100644 LICENSE diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100755 index 0000000..33115b9 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,23 @@ +### Version: 1.1.0 +#### Date: Apr-12-2019 + +##### New Features: +- ContentstackClient + - added method 'GetContentTypes' + - added method 'SyncRecursive' + - added method 'SyncRecursiveLanguage' + - added method 'SyncPaginationToken' + - added method 'SyncToken' + +- CotentType + - added method 'Fetch' + + ### Version: 1.0.6 + #### Date: Apr-12-2019 + +Localization support for Query and Entry is added. + +### Version: 1.0.0 +#### Date: Apr-12-2019 + +- Introduce ContentStack SDK for DOTNET. diff --git a/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj b/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj index 33352ab..a5ea355 100644 --- a/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj +++ b/Contentstack.AspNetCore/Contentstack.AspNetCore.csproj @@ -6,9 +6,13 @@ contentstack.aspnetcore Contentstack Contentstack - 0.0.1 + 1.1.0 1.0.0 Main release + Copyright (c) 2012-2019 Contentstack (http://app.contentstack.com). All Rights Reserved + + https://github.com/contentstack/contentstack-dotnet + v1.0.0 diff --git a/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj b/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj index c087835..dd80891 100644 --- a/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj +++ b/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj @@ -4,7 +4,7 @@ netcoreapp2.0 false - 0.0.1 + 1.1.0 diff --git a/Contentstack.Core/Contentstack.Core.csproj b/Contentstack.Core/Contentstack.Core.csproj index b42e6b0..7bfccc3 100644 --- a/Contentstack.Core/Contentstack.Core.csproj +++ b/Contentstack.Core/Contentstack.Core.csproj @@ -5,10 +5,17 @@ contentstack.csharp Contentstack .NET SDK for the Contentstack Content Delivery API. - 1.0.6 + 1.1.0 Contentstack - Localization support for Query and Entry is added. - 0.0.1 + Fetching Content-Type schema +Stack Sync implemented + 1.1.0 + Copyright © 2012-2019 Contentstack. All Rights Reserved + + true + true + https://github.com/contentstack/contentstack-dotnet + v1.1.0 @@ -40,6 +47,7 @@ + diff --git a/Contentstack.Core/Internals/HTTPRequestHandler.cs b/Contentstack.Core/Internals/HTTPRequestHandler.cs index 41df875..f636209 100644 --- a/Contentstack.Core/Internals/HTTPRequestHandler.cs +++ b/Contentstack.Core/Internals/HTTPRequestHandler.cs @@ -38,7 +38,7 @@ public async Task ProcessRequest(string Url, Dictionary var request = (HttpWebRequest)WebRequest.Create(uri); request.Method = "GET"; request.ContentType = "application/json"; - request.Headers["user-agent"]="DOTNET 1.0.0"; + request.Headers["user-agent"]="DOTNET 1.1.0"; if (Headers != default(IDictionary)) { foreach (var header in Headers) { diff --git a/Contentstack.Net.sln b/Contentstack.Net.sln index dd07403..b6da882 100644 --- a/Contentstack.Net.sln +++ b/Contentstack.Net.sln @@ -132,6 +132,6 @@ Global $0.XmlFormattingPolicy = $9 $9.scope = application/xml $0.StandardHeader = $10 - version = 0.0.1 + version = 1.1.0 EndGlobalSection EndGlobal diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..5180831 --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2012-2019 Contentstack (http://app.contentstack.com). All Rights Reserved + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/README.md b/README.md index ef7fe02..c00d11f 100755 --- a/README.md +++ b/README.md @@ -101,13 +101,3 @@ To help you get started, we have created a sample application that is powered by - [Contentstack Website](https://www.contentstack.com) - [Official Documentation](https://contentstack.com/docs) - [Content Delivery API Docs](https://contentstack.com/docs/apis/content-delivery-api/) - -### The MIT License (MIT) - -Copyright © 2012-2019 [Contentstack](https://www.contentstack.com/). All Rights Reserved - -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/docfx_project/docfx.json b/docfx_project/docfx.json index bf4b7dc..c58b504 100644 --- a/docfx_project/docfx.json +++ b/docfx_project/docfx.json @@ -48,7 +48,7 @@ "_appTitle": "Contentstack - .NET SDK Documentation", "_appLogoPath": "images/logo.svg", "_appFaviconPath": "images/favicon.ico", - "_appFooter": "Copyright © 2012-2019 Contentstack. All Rights Reserved", + "_appFooter": "Copyright © 2012-2019 Contentstack. All Rights Reserved", "_enableSearch": "true" }, "dest": "_site", From d6c488a67852fd21cfc20cc396d2d225356fe9e3 Mon Sep 17 00:00:00 2001 From: Uttam K Ukkoji Date: Thu, 11 Apr 2019 15:51:28 +0530 Subject: [PATCH 12/13] Project setting update --- Contentstack.Core/Contentstack.Core.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Contentstack.Core/Contentstack.Core.csproj b/Contentstack.Core/Contentstack.Core.csproj index 7bfccc3..3b71851 100644 --- a/Contentstack.Core/Contentstack.Core.csproj +++ b/Contentstack.Core/Contentstack.Core.csproj @@ -13,9 +13,9 @@ Stack Sync implemented Copyright © 2012-2019 Contentstack. All Rights Reserved true - true https://github.com/contentstack/contentstack-dotnet v1.1.0 + https://github.com/contentstack/contentstack-dotnet/blob/master/LICENSE From 2762532aa330272c3884df4df0c2916e2420b667 Mon Sep 17 00:00:00 2001 From: Uttam K Ukkoji Date: Fri, 12 Apr 2019 12:40:09 +0530 Subject: [PATCH 13/13] Project file updated --- Contentstack.Core/Contentstack.Core.csproj | 2 -- 1 file changed, 2 deletions(-) diff --git a/Contentstack.Core/Contentstack.Core.csproj b/Contentstack.Core/Contentstack.Core.csproj index 3b71851..0847152 100644 --- a/Contentstack.Core/Contentstack.Core.csproj +++ b/Contentstack.Core/Contentstack.Core.csproj @@ -13,9 +13,7 @@ Stack Sync implemented Copyright © 2012-2019 Contentstack. All Rights Reserved true - https://github.com/contentstack/contentstack-dotnet v1.1.0 - https://github.com/contentstack/contentstack-dotnet/blob/master/LICENSE