diff --git a/.talismanrc b/.talismanrc
index f810629..420960a 100644
--- a/.talismanrc
+++ b/.talismanrc
@@ -1,5 +1,7 @@
fileignoreconfig:
-- filename: Contentstack.Core/ContentstackClient.cs
- checksum: f960fff17b452a71e39e51ae8b92759dd1e30638d379155185e3e8bd63f407a4
- filename: Contentstack.Core/Internals/HttpRequestHandler.cs
- checksum: 93c1659f3bc7527956f0fd12db46441297fac3a4366d273bcbb3425d2351300e
\ No newline at end of file
+ checksum: 93c1659f3bc7527956f0fd12db46441297fac3a4366d273bcbb3425d2351300e
+- filename: Contentstack.Core/Models/Entry.cs
+ checksum: bc0da69dde3bebecf09aa319aa961f82d7637e200bb8539821fa6116c0129f1b
+- filename: Contentstack.Core/ContentstackClient.cs
+ checksum: 1cb7c9bd62881ae71406449c948b1e85aa865d0c7191013f77f9b9a60df700d9
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 5795d7f..030599c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+### Version: 2.13.0
+#### Date: April-02-2024
+
+##### New Feature:
+- Proxy support added
+
### Version: 2.12.0
#### Date: Feb-01-2024
diff --git a/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj b/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj
index dcd4138..9aef7ea 100644
--- a/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj
+++ b/Contentstack.Core.Tests/Contentstack.Core.Tests.csproj
@@ -4,7 +4,7 @@
net7.0
false
- 2.12.0
+ $(Version)
diff --git a/Contentstack.Core.Tests/StackConfig.cs b/Contentstack.Core.Tests/StackConfig.cs
index 0a67f1f..23bc494 100644
--- a/Contentstack.Core.Tests/StackConfig.cs
+++ b/Contentstack.Core.Tests/StackConfig.cs
@@ -37,7 +37,8 @@ public static ContentstackClient GetStack()
DeliveryToken = delivery_token,
Environment = environment,
Host = host,
- Timeout = 4500
+ Timeout = 4500,
+ Proxy = new System.Net.WebProxy("http://example.com:8080")
};
ContentstackClient contentstackClient = new ContentstackClient(new OptionsWrapper(contentstackOptions));
diff --git a/Contentstack.Core/Configuration/Config.cs b/Contentstack.Core/Configuration/Config.cs
index a7ef1a2..4bdd342 100644
--- a/Contentstack.Core/Configuration/Config.cs
+++ b/Contentstack.Core/Configuration/Config.cs
@@ -1,10 +1,8 @@
using System;
-using System.Collections.Generic;
using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Contentstack.Core.Internals;
-
+using System.Net;
+using Contentstack.Core.Internals;
+
namespace Contentstack.Core.Configuration
{
internal class Config
@@ -17,6 +15,7 @@ internal class Config
private string _Environment;
private string _Branch;
private int _Timeout;
+ private WebProxy _proxy;
#endregion
#region Public Properties
@@ -32,7 +31,7 @@ public string Port {
}
public string Protocol {
- get { return this._Protocol ?? "https"; }
+ get { return this._Protocol ?? "https"; }
set { this._Protocol = value; }
}
@@ -67,56 +66,62 @@ public int Timeout
set { this._Timeout = value; }
}
+ public WebProxy Proxy
+ {
+ get { return this._proxy; }
+ set { this._proxy = value; }
+ }
+
public string BaseUrl
{
get
{
- string BaseURL = string.Format("{0}://{1}{2}/{3}",
- this.Protocol.Trim('/').Trim('\\'),
- regionCode(),
- this.Host.Trim('/').Trim('\\'),
+ string BaseURL = string.Format("{0}://{1}{2}/{3}",
+ this.Protocol.Trim('/').Trim('\\'),
+ regionCode(),
+ this.Host.Trim('/').Trim('\\'),
this.Version.Trim('/').Trim('\\'));
return BaseURL;
}
- }
-
+ }
+
#endregion
-
+
#region Internal
- internal string getLivePreviewUrl(LivePreviewConfig livePreviewConfig)
- {
-
- return string.Format("{0}://{1}/{2}",
- this.Protocol.Trim('/').Trim('\\'),
- livePreviewConfig.Host.Trim('/').Trim('\\'),
- this.Version.Trim('/').Trim('\\'));
+ internal string getLivePreviewUrl(LivePreviewConfig livePreviewConfig)
+ {
+
+ return string.Format("{0}://{1}/{2}",
+ this.Protocol.Trim('/').Trim('\\'),
+ livePreviewConfig.Host.Trim('/').Trim('\\'),
+ this.Version.Trim('/').Trim('\\'));
}
- internal string getBaseUrl (LivePreviewConfig livePreviewConfig, string contentTypeUID)
- {
- if (livePreviewConfig != null && livePreviewConfig.Enable && livePreviewConfig.ContentTypeUID == contentTypeUID)
- {
- return getLivePreviewUrl(livePreviewConfig);
- }
- return BaseUrl;
+ internal string getBaseUrl (LivePreviewConfig livePreviewConfig, string contentTypeUID)
+ {
+ if (livePreviewConfig != null && livePreviewConfig.Enable && livePreviewConfig.ContentTypeUID == contentTypeUID)
+ {
+ return getLivePreviewUrl(livePreviewConfig);
+ }
+ return BaseUrl;
}
- internal string regionCode()
- {
- if (Region == ContentstackRegion.US) return "";
- ContentstackRegionCode[] regionCodes = Enum.GetValues(typeof(ContentstackRegionCode)).Cast().ToArray();
- return string.Format("{0}-", regionCodes[(int)Region].ToString().Replace("_", "-"));
+ internal string regionCode()
+ {
+ if (Region == ContentstackRegion.US) return "";
+ ContentstackRegionCode[] regionCodes = Enum.GetValues(typeof(ContentstackRegionCode)).Cast().ToArray();
+ return string.Format("{0}-", regionCodes[(int)Region].ToString().Replace("_", "-"));
}
- internal string HostURL
- {
- get
- {
- if (Region == ContentstackRegion.EU || Region == ContentstackRegion.AZURE_EU || Region == ContentstackRegion.AZURE_NA)
- return "cdn.contentstack.com";
- return "cdn.contentstack.io";
- }
- }
+ internal string HostURL
+ {
+ get
+ {
+ if (Region == ContentstackRegion.EU || Region == ContentstackRegion.AZURE_EU || Region == ContentstackRegion.AZURE_NA)
+ return "cdn.contentstack.com";
+ return "cdn.contentstack.io";
+ }
+ }
#endregion
}
}
diff --git a/Contentstack.Core/Configuration/ContentstackOptions.cs b/Contentstack.Core/Configuration/ContentstackOptions.cs
index 079a996..73f2455 100644
--- a/Contentstack.Core/Configuration/ContentstackOptions.cs
+++ b/Contentstack.Core/Configuration/ContentstackOptions.cs
@@ -2,6 +2,7 @@
using System.ComponentModel;
using System.Globalization;
using System.Linq;
+using System.Net;
using Contentstack.Core.Internals;
namespace Contentstack.Core.Configuration
@@ -38,6 +39,11 @@ public class ContentstackOptions
///
public string Host { get; set; }
+ ///
+ /// The Proxy used when communicating with the Contentstack API.
+ ///
+ public WebProxy Proxy { get; set; }
+
///
/// The Region used to set region for the Contentstack API.
///
@@ -63,6 +69,11 @@ public class ContentstackOptions
/// The Timeout used to set Timeout for the Contentstack API.
///
public int Timeout { get; set; }
+
+ public ContentstackOptions()
+ {
+ Timeout = 30000; // Set default value
+ }
}
internal class ContentstackRegionConverter : TypeConverter
diff --git a/Contentstack.Core/Contentstack.Core.csproj b/Contentstack.Core/Contentstack.Core.csproj
index 1532d3e..eada550 100644
--- a/Contentstack.Core/Contentstack.Core.csproj
+++ b/Contentstack.Core/Contentstack.Core.csproj
@@ -5,15 +5,15 @@
contentstack.csharp
Contentstack
.NET SDK for the Contentstack Content Delivery API.
- 2.12.0
+ $(Version)
Contentstack
Reference in entry Live preview support added
Copyright © 2012-2024 Contentstack. All Rights Reserved
true
- v2.12.0
+ v$(Version)
https://github.com/contentstack/contentstack-dotnet
LICENSE.txt
- 2.12.0
+ $(Version)
@@ -36,6 +36,12 @@
+
+ CHANGELOG.md
+
+
+ README.md
+
diff --git a/Contentstack.Core/ContentstackClient.cs b/Contentstack.Core/ContentstackClient.cs
index bbd5235..8324f7c 100644
--- a/Contentstack.Core/ContentstackClient.cs
+++ b/Contentstack.Core/ContentstackClient.cs
@@ -97,12 +97,13 @@ public ContentstackClient(IOptions options)
{
cnfig.Version = _options.Version;
}
- cnfig.Region = _options.Region;
- cnfig.Branch = _options.Branch;
- if (_options.Timeout != null)
+ if (_options.Proxy != null)
{
- cnfig.Timeout = _options.Timeout;
+ cnfig.Proxy = _options.Proxy;
}
+ cnfig.Region = _options.Region;
+ cnfig.Branch = _options.Branch;
+ cnfig.Timeout = _options.Timeout;
this.SetConfig(cnfig);
if (_options.LivePreview != null)
{
@@ -150,7 +151,7 @@ public ContentstackClient(ContentstackOptions options) :
/// 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 = 100000) :
+ public ContentstackClient(string apiKey, string deliveryToken, string environment, string host = null, ContentstackRegion region = ContentstackRegion.US, string version = null, int? timeout = null, WebProxy proxy = null) :
this(new OptionsWrapper(new ContentstackOptions()
{
ApiKey = apiKey,
@@ -159,7 +160,8 @@ public ContentstackClient(string apiKey, string deliveryToken, string environmen
Host = host,
Region = region,
Version = version,
- Timeout = timeout
+ Timeout = timeout ?? 30000,
+ Proxy = proxy
}
))
{
@@ -270,7 +272,7 @@ internal Asset Asset()
///
///
/// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
- /// var param = new Dictionary<string, object>();
+ /// var param = new Dictionary<string, object>();
/// param.Add("include_global_field_schema",true);
/// param.Add("limit", 10);
/// param.Add("skip", 10);
@@ -304,14 +306,14 @@ public async Task GetContentTypes(Dictionary param = null
if (param != null && param.Count() > 0)
{
foreach (var kvp in param)
- {
- mainJson.Add(kvp.Key, kvp.Value);
+ {
+ mainJson.Add(kvp.Key, kvp.Value);
}
}
try
{
HttpRequestHandler RequestHandler = new HttpRequestHandler(this);
- var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson, Branch: this.Config.Branch, timeout: this.Config.Timeout);
+ var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson, Branch: this.Config.Branch, timeout: this.Config.Timeout, proxy: this.Config.Proxy);
JObject data = JsonConvert.DeserializeObject(outputResult.Replace("\r\n", ""), this.SerializerSettings);
IList contentTypes = (IList)data["content_types"];
return contentTypes;
@@ -346,7 +348,7 @@ private async Task GetLivePreviewData()
try
{
HttpRequestHandler RequestHandler = new HttpRequestHandler(this);
- var outputResult = await RequestHandler.ProcessRequest(String.Format("{0}/content_types/{1}/entries/{2}", this.Config.getLivePreviewUrl(this.LivePreviewConfig), this.LivePreviewConfig.ContentTypeUID, this.LivePreviewConfig.EntryUID), headerAll, mainJson, Branch: this.Config.Branch, isLivePreview: true, timeout: this.Config.Timeout);
+ var outputResult = await RequestHandler.ProcessRequest(String.Format("{0}/content_types/{1}/entries/{2}", this.Config.getLivePreviewUrl(this.LivePreviewConfig), this.LivePreviewConfig.ContentTypeUID, this.LivePreviewConfig.EntryUID), headerAll, mainJson, Branch: this.Config.Branch, isLivePreview: true, timeout: this.Config.Timeout, proxy: this.Config.Proxy);
JObject data = JsonConvert.DeserializeObject(outputResult.Replace("\r\n", ""), this.SerializerSettings);
return (JObject)data["entry"];
}
@@ -744,7 +746,7 @@ private async Task GetResultAsync(string Init = "false", SyncType Syn
try
{
HttpRequestHandler requestHandler = new HttpRequestHandler(this);
- string js = await requestHandler.ProcessRequest(_SyncUrl, _LocalHeaders, mainJson, Branch: this.Config.Branch, timeout: this.Config.Timeout);
+ string js = await requestHandler.ProcessRequest(_SyncUrl, _LocalHeaders, mainJson, Branch: this.Config.Branch, timeout: this.Config.Timeout, proxy: this.Config.Proxy);
SyncStack stackSyncOutput = JsonConvert.DeserializeObject(js);
return stackSyncOutput;
}
diff --git a/Contentstack.Core/Internals/HttpRequestHandler.cs b/Contentstack.Core/Internals/HttpRequestHandler.cs
index 2817fec..70410c6 100644
--- a/Contentstack.Core/Internals/HttpRequestHandler.cs
+++ b/Contentstack.Core/Internals/HttpRequestHandler.cs
@@ -1,13 +1,12 @@
-using Contentstack.Core.Configuration;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-using System;
+using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
namespace Contentstack.Core.Internals
{
@@ -21,7 +20,8 @@ internal HttpRequestHandler(ContentstackClient contentstackClient)
{
client = contentstackClient;
}
- public async Task ProcessRequest(string Url, Dictionary Headers, Dictionary BodyJson, string FileName = null, string Branch = null, bool isLivePreview = false, int timeout = 30000) {
+ public async Task ProcessRequest(string Url, Dictionary Headers, Dictionary BodyJson, string FileName = null, string Branch = null, bool isLivePreview = false, int timeout = 30000, WebProxy proxy = null)
+ {
String queryParam = String.Join("&", BodyJson.Select(kvp => {
var value = "";
@@ -50,6 +50,12 @@ public async Task ProcessRequest(string Url, Dictionary
request.ContentType = "application/json";
request.Headers["x-user-agent"]="contentstack-delivery-dotnet/2.12.0";
request.Timeout = timeout;
+
+ if (proxy != null)
+ {
+ request.Proxy = proxy;
+ }
+
if (Branch != null)
{
request.Headers["branch"] = Branch;
diff --git a/Contentstack.Core/Models/Asset.cs b/Contentstack.Core/Models/Asset.cs
index 9310fe6..afffc2b 100644
--- a/Contentstack.Core/Models/Asset.cs
+++ b/Contentstack.Core/Models/Asset.cs
@@ -1,15 +1,15 @@
using System;
using System.Collections.Generic;
-using System.IO;
+using System.IO;
using System.Linq;
-using System.Net;
-using System.Threading.Tasks;
-using Contentstack.Core.Configuration;
+using System.Net;
+using System.Threading.Tasks;
+using Contentstack.Core.Configuration;
using Contentstack.Core.Internals;
-using Contentstack.Utils.Interfaces;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Linq;
-
+using Contentstack.Utils.Interfaces;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
namespace Contentstack.Core.Models
{
///
@@ -20,9 +20,9 @@ public class Asset : IEmbeddedObject
#region Internal & Private Properties
private Dictionary _ObjectAttributes = new Dictionary();
private readonly Dictionary _Headers = new Dictionary();
- private readonly Dictionary _StackHeaders = new Dictionary();
- private readonly Dictionary UrlQueries = new Dictionary();
-
+ private readonly Dictionary _StackHeaders = new Dictionary();
+ private readonly Dictionary UrlQueries = new Dictionary();
+
private string _Url
{
get
@@ -61,11 +61,11 @@ public object this[string key]
this._ObjectAttributes[key] = value;
}
catch (Exception e)
- {
- if (e.Source != null)
- {
- Console.WriteLine("IOException source: {0}", e.Source);
- }
+ {
+ if (e.Source != null)
+ {
+ Console.WriteLine("IOException source: {0}", e.Source);
+ }
}
}
}
@@ -83,24 +83,24 @@ public string Url
url = ContentstackConvert.ToString(this["url"]);
}
return url;
- }
- set
- {
- this["url"] = value;
+ }
+ set
+ {
+ this["url"] = value;
}
}
///
/// This is Asset Uid of an Asset.
///
- public string Uid { get; set; }
-
+ public string Uid { get; set; }
+
///
/// This is Asset type uid.
- ///
- [JsonProperty(propertyName: "_content_type_uid")]
- public string ContentTypeUid { get; set; }
-
+ ///
+ [JsonProperty(propertyName: "_content_type_uid")]
+ public string ContentTypeUid { get; set; }
+
///
/// The size of the file in bytes.
///
@@ -110,38 +110,38 @@ public string Url
///
/// The original name of the file.
///
- public string FileName { get; set; }
-
+ public string FileName { get; set; }
+
///
/// This is Asset description.
- ///
- public string Description { get; set; }
-
+ ///
+ public string Description { get; set; }
+
///
/// Set array of Tags
///
- public Object[] Tags { get; set; }
-
+ public Object[] Tags { get; set; }
+
#region Internal Constructors
internal Asset(ContentstackClient stack, string uid)
{
this.StackInstance = stack;
- this.Uid = uid;
+ this.Uid = uid;
this._StackHeaders = stack._LocalHeaders;
}
-
+
internal Asset(ContentstackClient stack)
{
this.StackInstance = stack;
this._StackHeaders = stack._LocalHeaders;
}
-
- internal Asset()
- {
-
- }
+
+ internal Asset()
+ {
+
+ }
#endregion
-
+
///
/// To set headers for Backend rest calls.
///
@@ -157,10 +157,10 @@ public void SetHeader(string key, string value)
}
}
-
- ///
- /// Include fallback locale publish content, if specified locale content is not publish.
- ///
+
+ ///
+ /// Include fallback locale publish content, if specified locale content is not publish.
+ ///
/// Current instance of Entry, this will be useful for a chaining calls.
///
///
@@ -171,15 +171,15 @@ public void SetHeader(string key, string value)
/// //Your callback code.
/// });
///
- ///
- public Asset includeFallback()
- {
- this.UrlQueries.Add("include_fallback", "true");
- return this;
- }
-
-
-
+ ///
+ public Asset includeFallback()
+ {
+ this.UrlQueries.Add("include_fallback", "true");
+ return this;
+ }
+
+
+
///
/// This call includes metadata in the response.
///
@@ -205,12 +205,12 @@ public Asset IncludeMetadata()
throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e);
}
return this;
- }
-
-
- ///
- /// Include branch for publish content.
- ///
+ }
+
+
+ ///
+ /// Include branch for publish content.
+ ///
/// Current instance of Entry, this will be useful for a chaining calls.
///
///
@@ -221,11 +221,11 @@ public Asset IncludeMetadata()
/// //Your callback code.
/// });
///
- ///
- public Asset includeBranch()
- {
- this.UrlQueries.Add("include_branch", "true");
- return this;
+ ///
+ public Asset includeBranch()
+ {
+ this.UrlQueries.Add("include_branch", "true");
+ return this;
}
public void RemoveHeader(string key)
@@ -248,10 +248,10 @@ public DateTime GetCreateAt()
String value = _ObjectAttributes["created_at"].ToString();
return ContentstackConvert.ToDateTime(value);
}
- catch (Exception e)
- {
- if (e.Source != null)
- Console.WriteLine("IOException source: {0}", e.Source);
+ catch (Exception e)
+ {
+ if (e.Source != null)
+ Console.WriteLine("IOException source: {0}", e.Source);
}
return DateTime.MinValue;
}
@@ -288,10 +288,10 @@ public DateTime GetUpdateAt()
String value = _ObjectAttributes["updated_at"].ToString();
return ContentstackConvert.ToDateTime(value);
}
- catch (Exception e)
- {
- if (e.Source != null)
- Console.WriteLine("IOException source: {0}", e.Source);
+ catch (Exception e)
+ {
+ if (e.Source != null)
+ Console.WriteLine("IOException source: {0}", e.Source);
}
return DateTime.MinValue;
}
@@ -309,11 +309,11 @@ public DateTime GetDeleteAt()
{
String value = _ObjectAttributes["deleted_at"].ToString();
return ContentstackConvert.ToDateTime(value);
- }
- catch (Exception e)
- {
- if (e.Source != null)
- Console.WriteLine("IOException source: {0}", e.Source);
+ }
+ catch (Exception e)
+ {
+ if (e.Source != null)
+ Console.WriteLine("IOException source: {0}", e.Source);
}
return DateTime.MinValue;
}
@@ -324,10 +324,10 @@ public String GetDeletedBy()
return _ObjectAttributes["deleted_by"].ToString();
}
- public async Task Fetch()
- {
+ public async Task Fetch()
+ {
Dictionary headers = GetHeader(_Headers);
-
+
Dictionary headerAll = new Dictionary();
Dictionary mainJson = new Dictionary();
@@ -337,7 +337,7 @@ public async Task Fetch()
{
headerAll.Add(header.Key, (String)header.Value);
}
- }
+ }
mainJson.Add("environment", this.StackInstance.Config.Environment);
foreach (var kvp in UrlQueries)
@@ -347,19 +347,19 @@ public async Task Fetch()
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);
+ var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson, Branch: this.StackInstance.Config.Branch, timeout: this.StackInstance.Config.Timeout, proxy: this.StackInstance.Config.Proxy);
JObject obj = JObject.Parse(ContentstackConvert.ToString(outputResult, "{}"));
- return obj.SelectToken("$.asset").ToObject(this.StackInstance.Serializer);
+ return obj.SelectToken("$.asset").ToObject(this.StackInstance.Serializer);
}
catch (Exception ex)
{
throw GetContentstackError(ex);
}
- }
-
-
+ }
+
+
#region Private Functions
-
+
private Dictionary GetHeader(Dictionary localHeader)
{
Dictionary mainHeader = _StackHeaders;
@@ -432,17 +432,17 @@ internal static ContentstackException GetContentstackError(Exception ex)
errors = token.ToObject>();
var response = exResp as HttpWebResponse;
- if (response != null)
- {
- statusCode = response.StatusCode;
- }
+ if (response != null)
+ {
+ statusCode = response.StatusCode;
+ }
}
}
catch
- {
- if (errorMessage != null)
- {
- errorMessage = ex.Message;
+ {
+ if (errorMessage != null)
+ {
+ errorMessage = ex.Message;
}
}
diff --git a/Contentstack.Core/Models/AssetLibrary.cs b/Contentstack.Core/Models/AssetLibrary.cs
index adeb12a..97a9f30 100644
--- a/Contentstack.Core/Models/AssetLibrary.cs
+++ b/Contentstack.Core/Models/AssetLibrary.cs
@@ -95,15 +95,15 @@ public async Task Count()
///
/// Include fallback locale publish content, if specified locale content is not publish.
///
- /// Current instance of AssetLibrary, this will be useful for a chaining calls.
+ /// Current instance of AssetLibrary, this will be useful for a chaining calls.
///
///
/// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
/// AssetLibrary assetLibrary = stack.AssetLibrary();
/// assetLibrary.IncludeFallback();
/// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll();
- ///
- ///
+ ///
+ ///
public AssetLibrary IncludeFallback()
{
try
@@ -120,15 +120,15 @@ public AssetLibrary IncludeFallback()
///
/// Include branch for publish content.
///
- /// Current instance of AssetLibrary, this will be useful for a chaining calls.
+ /// Current instance of AssetLibrary, this will be useful for a chaining calls.
///
///
/// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
/// AssetLibrary assetLibrary = stack.AssetLibrary();
/// assetLibrary.IncludeBranch();
/// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll();
- ///
- ///
+ ///
+ ///
public AssetLibrary IncludeBranch()
{
try
@@ -142,31 +142,31 @@ public AssetLibrary IncludeBranch()
return this;
}
- ///
- /// Sets the locale.
- ///
- /// The locale.
- /// Locale.
- ///
- ///
- /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
- /// AssetLibrary assetLibrary = stack.AssetLibrary();
- /// assetLibrary.SetLocale("en-us");
- /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll();
- ///
- ///
- public AssetLibrary SetLocale(String Locale)
- {
- if (UrlQueries != null && !UrlQueries.ContainsKey("locale"))
- {
- UrlQueries.Remove("locale");
- UrlQueries.Add("locale", Locale);
- }
- else
- {
- UrlQueries["locale"] = Locale;
- }
- return this;
+ ///
+ /// Sets the locale.
+ ///
+ /// The locale.
+ /// Locale.
+ ///
+ ///
+ /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
+ /// AssetLibrary assetLibrary = stack.AssetLibrary();
+ /// assetLibrary.SetLocale("en-us");
+ /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll();
+ ///
+ ///
+ public AssetLibrary SetLocale(String Locale)
+ {
+ if (UrlQueries != null && !UrlQueries.ContainsKey("locale"))
+ {
+ UrlQueries.Remove("locale");
+ UrlQueries.Add("locale", Locale);
+ }
+ else
+ {
+ UrlQueries["locale"] = Locale;
+ }
+ return this;
}
///
@@ -188,29 +188,29 @@ public void IncludeCount()
- ///
- /// This call includes metadata in the response.
- ///
- /// Current instance of AssetLibrary, this will be useful for a chaining calls.
- ///
+ ///
+ /// This call includes metadata in the response.
+ ///
+ /// Current instance of AssetLibrary, this will be useful for a chaining calls.
+ ///
///
/// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
/// AssetLibrary assetLibrary = stack.AssetLibrary();
/// assetLibrary.IncludeMetadata();
/// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll();
- ///
- ///
- public AssetLibrary IncludeMetadata()
- {
- try
- {
- UrlQueries.Add("include_metadata", "true");
- }
- catch (Exception e)
- {
- throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e);
- }
- return this;
+ ///
+ ///
+ public AssetLibrary IncludeMetadata()
+ {
+ try
+ {
+ UrlQueries.Add("include_metadata", "true");
+ }
+ catch (Exception e)
+ {
+ throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e);
+ }
+ return this;
}
@@ -231,117 +231,117 @@ public void IncludeRelativeUrls()
UrlQueries.Add("relative_urls", "true");
}
- ///
- /// The number of objects to skip before returning any.
- ///
- /// No of objects to skip from returned objects.
- /// Current instance of AssetLibrary, this will be useful for a chaining calls.
- ///
- ///
- /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
+ ///
+ /// The number of objects to skip before returning any.
+ ///
+ /// No of objects to skip from returned objects.
+ /// Current instance of AssetLibrary, this will be useful for a chaining calls.
+ ///
+ ///
+ /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
/// AssetLibrary assetLibrary = stack.AssetLibrary();
/// assetLibrary.Skip(2);
- /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll();
- ///
- ///
- public AssetLibrary Skip(int number)
- {
- try
- {
- UrlQueries.Add("skip", number);
- }
- catch (Exception e)
- {
- throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e);
- }
- return this;
- }
-
- ///
- /// A limit on the number of objects to return.
- ///
- /// No of objects to limit.
- /// Current instance of AssetLibrary, this will be useful for a chaining calls.
- ///
- ///
- /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
+ /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll();
+ ///
+ ///
+ public AssetLibrary Skip(int number)
+ {
+ try
+ {
+ UrlQueries.Add("skip", number);
+ }
+ catch (Exception e)
+ {
+ throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e);
+ }
+ return this;
+ }
+
+ ///
+ /// A limit on the number of objects to return.
+ ///
+ /// No of objects to limit.
+ /// Current instance of AssetLibrary, this will be useful for a chaining calls.
+ ///
+ ///
+ /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
/// AssetLibrary assetLibrary = stack.AssetLibrary();
/// assetLibrary.Limit(20);
- /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll();
- ///
- ///
- public AssetLibrary Limit(int number)
- {
- try
- {
- UrlQueries.Add("limit", number);
- }
- catch (Exception e)
- {
- throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e);
- }
- return this;
+ /// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll();
+ ///
+ ///
+ public AssetLibrary Limit(int number)
+ {
+ try
+ {
+ UrlQueries.Add("limit", number);
+ }
+ catch (Exception e)
+ {
+ throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e);
+ }
+ return this;
+ }
+
+ ///
+ /// Specifies an array of 'only' keys in BASE object that would be 'included' in the response.
+ ///
+ /// Array of the 'only' keys to be included in response.
+ /// Current instance of AssetLibrary, this will be useful for a chaining calls.
+ ///
+ ///
+ /// 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();
+ ///
+ ///
+ public AssetLibrary Only(String[] fieldUid)
+ {
+ try
+ {
+ if (fieldUid != null && fieldUid.Length > 0)
+ {
+ UrlQueries.Add("only[BASE][]", fieldUid);
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("IOException source: {0}", e.Source);
+ }
+
+ return this;
}
- ///
- /// Specifies an array of 'only' keys in BASE object that would be 'included' in the response.
- ///
- /// Array of the 'only' keys to be included in response.
- /// Current instance of AssetLibrary, this will be useful for a chaining calls.
- ///
- ///
- /// 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();
- ///
- ///
- public AssetLibrary Only(String[] fieldUid)
- {
- try
- {
- if (fieldUid != null && fieldUid.Length > 0)
- {
- UrlQueries.Add("only[BASE][]", fieldUid);
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("IOException source: {0}", e.Source);
- }
-
- return this;
- }
-
- ///
- /// Specifies list of field uids that would be excluded from the response.
- ///
- /// field uid which get excluded from the response.
- /// Current instance of AssetLibrary, this will be useful for a chaining calls.
- ///
- ///
- /// 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();
- ///
- ///
- public AssetLibrary Except(String[] fieldUids)
- {
- try
- {
- List objectUidForExcept = new List();
- Dictionary exceptValueJson = new Dictionary();
- if (fieldUids != null && fieldUids.Length > 0)
- {
- UrlQueries.Add("except[BASE][]", fieldUids);
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("IOException source: {0}", e.Source);
- }
- return this;
+ ///
+ /// Specifies list of field uids that would be excluded from the response.
+ ///
+ /// field uid which get excluded from the response.
+ /// Current instance of AssetLibrary, this will be useful for a chaining calls.
+ ///
+ ///
+ /// 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();
+ ///
+ ///
+ public AssetLibrary Except(String[] fieldUids)
+ {
+ try
+ {
+ List objectUidForExcept = new List();
+ Dictionary exceptValueJson = new Dictionary();
+ if (fieldUids != null && fieldUids.Length > 0)
+ {
+ UrlQueries.Add("except[BASE][]", fieldUids);
+ }
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("IOException source: {0}", e.Source);
+ }
+ return this;
}
///
@@ -389,16 +389,16 @@ public AssetLibrary RemoveHeader(string key)
return this;
}
- ///
- /// Execute a AssetLibrary and Caches its result (Optional)
- ///
- /// Current instance of AssetLibrary, this will be useful for a chaining calls.
- ///
- ///
- /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
+ ///
+ /// Execute a AssetLibrary and Caches its result (Optional)
+ ///
+ /// Current instance of AssetLibrary, this will be useful for a chaining calls.
+ ///
+ ///
+ /// ContentstackClient stack = new ContentstackClinet("api_key", "delivery_token", "environment");
/// AssetLibrary assetLibrary = stack.AssetLibrary();
/// ContentstackCollection>Asset< contentstackCollection = await assetLibrary.FetchAll();
- ///
+ ///
///
public async Task> FetchAll()
{
@@ -440,7 +440,7 @@ private async Task Exec()
try
{
HttpRequestHandler RequestHandler = new HttpRequestHandler(this.Stack);
- var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson, Branch: this.Stack.Config.Branch, timeout: this.Stack.Config.Timeout);
+ var outputResult = await RequestHandler.ProcessRequest(_Url, headers, mainJson, Branch: this.Stack.Config.Branch, timeout: this.Stack.Config.Timeout, proxy: this.Stack.Config.Proxy);
return JObject.Parse(ContentstackConvert.ToString(outputResult, "{}"));
}
diff --git a/Contentstack.Core/Models/ContentType.cs b/Contentstack.Core/Models/ContentType.cs
index db85011..837d15a 100644
--- a/Contentstack.Core/Models/ContentType.cs
+++ b/Contentstack.Core/Models/ContentType.cs
@@ -1,14 +1,14 @@
using System;
using System.Collections.Generic;
-using Contentstack.Core.Configuration;
-using Contentstack.Core.Internals;
+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;
-
+using System.Net;
+using Newtonsoft.Json.Linq;
+using System.Linq;
+using System.IO;
+using Newtonsoft.Json;
+
namespace Contentstack.Core.Models
{
///
@@ -18,7 +18,7 @@ public class ContentType
{
#region Public Properties
internal ContentstackClient StackInstance { get; set; }
- internal string Uid { get; set; }
+ internal string Uid { get; set; }
private Dictionary UrlQueries = new Dictionary();
///
@@ -32,16 +32,16 @@ public string ContentTypeId
#endregion
#region Private Properties
- private Dictionary _Headers = new Dictionary();
-
- private Dictionary _StackHeaders = new Dictionary();
-
+ private Dictionary _Headers = new Dictionary();
+
+ private Dictionary _StackHeaders = new Dictionary();
+
private string _Url
{
get
{
Config config = this.StackInstance.Config;
- return String.Format("{0}/content_types/{1}", config.BaseUrl, this.ContentTypeId);
+ return String.Format("{0}/content_types/{1}", config.BaseUrl, this.ContentTypeId);
}
}
#endregion
@@ -50,8 +50,8 @@ private string _Url
///
///
///
- protected ContentType() { }
-
+ protected ContentType() { }
+
///
///
///
@@ -121,9 +121,9 @@ 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 content type.
@@ -139,8 +139,8 @@ internal void SetStackInstance(ContentstackClient stack)
///
/// is dictionary of additional parameter
/// The Content-Type Schema Object.
- public async Task Fetch(Dictionary param = null)
- {
+ public async Task Fetch(Dictionary param = null)
+ {
Dictionary headers = GetHeader(_Headers);
Dictionary headerAll = new Dictionary();
Dictionary mainJson = new Dictionary();
@@ -155,25 +155,25 @@ public async Task Fetch(Dictionary param = null)
}
}
mainJson.Add("environment", this.StackInstance.Config.Environment);
- foreach (var kvp in UrlQueries)
+ foreach (var kvp in UrlQueries)
{
mainJson.Add(kvp.Key, kvp.Value);
}
- if (param != null && param.Count() > 0)
- {
- foreach (var kvp in param)
+ 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);
+ 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 contentTypes = (Newtonsoft.Json.Linq.JObject)data["content_type"];
- return contentTypes;
- }
+ return contentTypes;
+ }
catch (Exception ex)
{
throw GetContentstackError(ex);
@@ -219,8 +219,8 @@ public void RemoveHeader(string key)
if (this._Headers.ContainsKey(key))
this._Headers.Remove(key);
- }
-
+ }
+
///
/// Represents a Entry.
/// Create Entry Instance.
diff --git a/Contentstack.Core/Models/Entry.cs b/Contentstack.Core/Models/Entry.cs
index 37c3d8f..6f9c6e8 100644
--- a/Contentstack.Core/Models/Entry.cs
+++ b/Contentstack.Core/Models/Entry.cs
@@ -986,14 +986,14 @@ public Entry IncludeOnlyReference(string[] keys, string referenceKey)
if (keys != null && keys.Length > 0)
{
var referenceKeys = new string[] { referenceKey };
- if (UrlQueries.ContainsKey("include[]") == false)
- {
+ if (UrlQueries.ContainsKey("include[]") == false)
+ {
UrlQueries.Add("", referenceKeys);
-
- }
- if (UrlQueries.ContainsKey($"only[{referenceKey}][]") == false)
- {
- UrlQueries.Add($"only[{referenceKey}][]", keys);
+
+ }
+ if (UrlQueries.ContainsKey($"only[{referenceKey}][]") == false)
+ {
+ UrlQueries.Add($"only[{referenceKey}][]", keys);
}
}
@@ -1213,18 +1213,18 @@ public Entry IncludeOwner()
///
public Entry IncludeExceptReference(string[] keys, string referenceKey)
{
-
+
if (keys != null && keys.Length > 0)
{
var referenceKeys = new string[] { referenceKey };
- if (UrlQueries.ContainsKey("include[]") == false)
- {
+ if (UrlQueries.ContainsKey("include[]") == false)
+ {
UrlQueries.Add("include[]", referenceKeys);
-
- }
- if (UrlQueries.ContainsKey($"except[{ referenceKey}][]") == false)
- {
- UrlQueries.Add($"except[{referenceKey}][]", keys);
+
+ }
+ if (UrlQueries.ContainsKey($"except[{ referenceKey}][]") == false)
+ {
+ UrlQueries.Add($"except[{referenceKey}][]", keys);
}
}
return this;
@@ -1325,7 +1325,7 @@ public async Task Fetch()
}
HttpRequestHandler RequestHandler = new HttpRequestHandler(this.ContentTypeInstance.StackInstance);
- var outputResult = await RequestHandler.ProcessRequest(_Url, headerAll, mainJson, Branch: this.ContentTypeInstance.StackInstance.Config.Branch, isLivePreview: isLivePreview, timeout: this.ContentTypeInstance.StackInstance.Config.Timeout);
+ var outputResult = await RequestHandler.ProcessRequest(_Url, headerAll, mainJson, Branch: this.ContentTypeInstance.StackInstance.Config.Branch, isLivePreview: isLivePreview, timeout: this.ContentTypeInstance.StackInstance.Config.Timeout, proxy: this.ContentTypeInstance.StackInstance.Config.Proxy);
JObject obj = JObject.Parse(ContentstackConvert.ToString(outputResult, "{}"));
var serializedObject = obj.SelectToken("$.entry").ToObject(this.ContentTypeInstance.StackInstance.Serializer);
if (serializedObject.GetType() == typeof(Entry))
diff --git a/Directory.Build.props b/Directory.Build.props
new file mode 100644
index 0000000..49efd35
--- /dev/null
+++ b/Directory.Build.props
@@ -0,0 +1,5 @@
+
+
+ 2.13.0
+
+