@@ -19,10 +19,10 @@ public class Query
1919
2020 internal Dictionary < string , object > _FormHeaders = new Dictionary < string , object > ( ) ;
2121 private Dictionary < string , object > _Headers = new Dictionary < string , object > ( ) ;
22- private Dictionary < string , object > UrlQueries = new Dictionary < string , object > ( ) ;
22+ private Dictionary < string , object > UrlQueries = new Dictionary < string , object > ( ) ;
2323
2424 protected Dictionary < string , object > QueryValueJson = new Dictionary < string , object > ( ) ;
25- private string _ResultJson = string . Empty ; private CachePolicy _CachePolicy ;
25+ private string _ResultJson = string . Empty ; private CachePolicy _CachePolicy ;
2626 private ContentType ContentTypeInstance { get ; set ; }
2727 private ContentstackClient TaxonomyInstance { get ; set ; }
2828 protected virtual string _Url
@@ -54,11 +54,11 @@ protected virtual string _Url
5454 /// });
5555 /// </code>
5656 /// </example>
57- public string ContentTypeId { get ; set ; }
58- public ContentstackClient Stack { get ; private set ; }
59-
57+ public string ContentTypeId { get ; set ; }
58+ public ContentstackClient Stack { get ; private set ; }
59+
6060 #endregion
61-
61+
6262 #region Internal Constructors
6363 internal Query ( )
6464 {
@@ -67,7 +67,7 @@ internal Query()
6767 internal Query ( string contentTypeName )
6868 {
6969 this . ContentTypeId = contentTypeName ;
70- }
70+ }
7171 internal Query ( ContentstackClient Tax )
7272 {
7373 SetTaxonomyInstance ( Tax ) ;
@@ -136,13 +136,13 @@ internal void SetTaxonomyInstance(ContentstackClient Tax)
136136 {
137137 this . TaxonomyInstance = Tax ;
138138 //SetLocale("en-us");
139- }
140-
141-
139+ }
140+
141+
142142 #endregion
143-
143+
144144 #region Public Functions
145-
145+
146146 /// <summary>
147147 /// Set Language instance
148148 /// </summary>
@@ -1822,33 +1822,26 @@ public async Task<ContentstackCollection<T>> FindOne<T>()
18221822 private ContentstackCollection < T > parseJObject < T > ( JObject jObject )
18231823 {
18241824
1825- if ( this . TaxonomyInstance != null )
1826- {
1827- var entries = jObject . SelectToken ( "$.entries" ) . ToObject < IEnumerable < T > > ( this . TaxonomyInstance . Serializer ) ;
1828- var collection = jObject . ToObject < ContentstackCollection < T > > ( this . TaxonomyInstance . Serializer ) ;
1829- foreach ( var entry in entries )
1830- {
1831- if ( entry . GetType ( ) == typeof ( Entry ) )
1832- {
1833- ( entry as Entry ) . SetContentTypeInstance ( this . ContentTypeInstance ) ;
1834- }
1835- }
1836- collection . Items = entries ;
1837- return collection ;
1838-
1839- } else
1840- {
1841- var entries = jObject . SelectToken ( "$.entries" ) . ToObject < IEnumerable < T > > ( this . ContentTypeInstance . StackInstance . Serializer ) ;
1842- var collection = jObject . ToObject < ContentstackCollection < T > > ( this . ContentTypeInstance . StackInstance . Serializer ) ;
1843- foreach ( var entry in entries )
1844- {
1845- if ( entry . GetType ( ) == typeof ( Entry ) )
1846- {
1847- ( entry as Entry ) . SetContentTypeInstance ( this . ContentTypeInstance ) ;
1848- }
1849- }
1850- collection . Items = entries ;
1851- return collection ;
1825+ if ( this . TaxonomyInstance != null )
1826+ {
1827+ var entries = jObject . SelectToken ( "$.entries" ) . ToObject < IEnumerable < T > > ( this . TaxonomyInstance . Serializer ) ;
1828+ var collection = jObject . ToObject < ContentstackCollection < T > > ( this . TaxonomyInstance . Serializer ) ;
1829+ collection . Items = entries ;
1830+ return collection ;
1831+
1832+ } else
1833+ {
1834+ var entries = jObject . SelectToken ( "$.entries" ) . ToObject < IEnumerable < T > > ( this . ContentTypeInstance . StackInstance . Serializer ) ;
1835+ var collection = jObject . ToObject < ContentstackCollection < T > > ( this . ContentTypeInstance . StackInstance . Serializer ) ;
1836+ foreach ( var entry in entries )
1837+ {
1838+ if ( entry . GetType ( ) == typeof ( Entry ) )
1839+ {
1840+ ( entry as Entry ) . SetContentTypeInstance ( this . ContentTypeInstance ) ;
1841+ }
1842+ }
1843+ collection . Items = entries ;
1844+ return collection ;
18521845 }
18531846
18541847 }
@@ -1874,13 +1867,13 @@ private async Task<JObject> Exec()
18741867 throw new InvalidOperationException ( "Either ManagementToken or PreviewToken is required in LivePreviewConfig" ) ;
18751868 }
18761869
1877- if ( ! string . IsNullOrEmpty ( this . ContentTypeInstance . StackInstance . LivePreviewConfig . releaseId ) )
1870+ if ( ! string . IsNullOrEmpty ( this . ContentTypeInstance . StackInstance . LivePreviewConfig . ReleaseId ) )
18781871 {
1879- headerAll [ "release_id" ] = this . ContentTypeInstance . StackInstance . LivePreviewConfig . releaseId ;
1880- }
1881- if ( ! string . IsNullOrEmpty ( this . ContentTypeInstance . StackInstance . LivePreviewConfig . previewTimestamp ) )
1872+ headerAll [ "release_id" ] = this . ContentTypeInstance . StackInstance . LivePreviewConfig . ReleaseId ;
1873+ }
1874+ if ( ! string . IsNullOrEmpty ( this . ContentTypeInstance . StackInstance . LivePreviewConfig . PreviewTimestamp ) )
18821875 {
1883- headerAll [ "preview_timestamp" ] = this . ContentTypeInstance . StackInstance . LivePreviewConfig . previewTimestamp ;
1876+ headerAll [ "preview_timestamp" ] = this . ContentTypeInstance . StackInstance . LivePreviewConfig . PreviewTimestamp ;
18841877 }
18851878
18861879 isLivePreview = true ;
@@ -1901,12 +1894,12 @@ private async Task<JObject> Exec()
19011894 }
19021895 }
19031896
1904- if ( this . TaxonomyInstance != null && this . TaxonomyInstance . _LocalHeaders != null )
1905- {
1897+ if ( this . TaxonomyInstance != null && this . TaxonomyInstance . _LocalHeaders != null )
1898+ {
19061899 foreach ( var header in this . TaxonomyInstance . _LocalHeaders )
19071900 {
19081901 headerAll . Add ( header . Key , ( string ) header . Value ) ;
1909- }
1902+ }
19101903 }
19111904 if ( ! isLivePreview && headerAll . ContainsKey ( "preview_token" ) )
19121905 {
@@ -1921,13 +1914,13 @@ private async Task<JObject> Exec()
19211914 headerAll . Remove ( "preview_timestamp" ) ;
19221915 }
19231916
1924- if ( this . ContentTypeInstance != null )
1925- {
1926- mainJson . Add ( "environment" , this . ContentTypeInstance ? . StackInstance . Config . Environment ) ;
1917+ if ( this . ContentTypeInstance != null )
1918+ {
1919+ mainJson . Add ( "environment" , this . ContentTypeInstance ? . StackInstance . Config . Environment ) ;
19271920 }
1928- if ( this . TaxonomyInstance != null && this . TaxonomyInstance . Config . Environment != null )
1929- {
1930- mainJson . Add ( "environment" , this . TaxonomyInstance ? . Config . Environment ) ;
1921+ else if ( this . TaxonomyInstance != null && this . TaxonomyInstance . Config . Environment != null )
1922+ {
1923+ mainJson . Add ( "environment" , this . TaxonomyInstance ? . Config . Environment ) ;
19311924 }
19321925 if ( QueryValueJson != null && QueryValueJson . Count > 0 )
19331926 mainJson . Add ( "query" , QueryValueJson ) ;
@@ -1938,28 +1931,28 @@ private async Task<JObject> Exec()
19381931 }
19391932
19401933 try
1941- {
1942- if ( this . TaxonomyInstance != null )
1943- {
1944- HttpRequestHandler requestHandler = new HttpRequestHandler ( this . TaxonomyInstance ) ;
1945- var branch = this . TaxonomyInstance . Config . Branch != null ? this . TaxonomyInstance . Config . Branch : "main" ;
1946- var outputResult = await requestHandler . ProcessRequest ( this . _Url , headerAll , mainJson , Branch : branch , isLivePreview : isLivePreview , timeout : this . TaxonomyInstance . Config . Timeout ) ;
1947- return JObject . Parse ( ContentstackConvert . ToString ( outputResult , "{}" ) ) ;
1948- }
1949- else
1950- {
1951- HttpRequestHandler requestHandler = new HttpRequestHandler ( this . ContentTypeInstance . StackInstance ) ;
1952- var outputResult = await requestHandler . ProcessRequest ( _Url , headerAll , mainJson , Branch : this . ContentTypeInstance . StackInstance . Config . Branch , isLivePreview : isLivePreview , timeout : this . ContentTypeInstance . StackInstance . Config . Timeout ) ;
1953- return JObject . Parse ( ContentstackConvert . ToString ( outputResult , "{}" ) ) ;
1934+ {
1935+ if ( this . TaxonomyInstance != null )
1936+ {
1937+ HttpRequestHandler requestHandler = new HttpRequestHandler ( this . TaxonomyInstance ) ;
1938+ var branch = this . TaxonomyInstance . Config . Branch != null ? this . TaxonomyInstance . Config . Branch : "main" ;
1939+ var outputResult = await requestHandler . ProcessRequest ( this . _Url , headerAll , mainJson , Branch : branch , isLivePreview : isLivePreview , timeout : this . TaxonomyInstance . Config . Timeout ) ;
1940+ return JObject . Parse ( ContentstackConvert . ToString ( outputResult , "{}" ) ) ;
1941+ }
1942+ else
1943+ {
1944+ HttpRequestHandler requestHandler = new HttpRequestHandler ( this . ContentTypeInstance . StackInstance ) ;
1945+ var outputResult = await requestHandler . ProcessRequest ( _Url , headerAll , mainJson , Branch : this . ContentTypeInstance . StackInstance . Config . Branch , isLivePreview : isLivePreview , timeout : this . ContentTypeInstance . StackInstance . Config . Timeout ) ;
1946+ return JObject . Parse ( ContentstackConvert . ToString ( outputResult , "{}" ) ) ;
19541947 }
19551948 }
19561949 catch ( Exception ex )
19571950 {
19581951 throw GetContentstackError ( ex ) ;
19591952 }
1960- }
1961-
1962-
1953+ }
1954+
1955+
19631956 #region Private Functions
19641957 private Dictionary < string , object > GetHeader ( Dictionary < string , object > localHeader )
19651958 {
0 commit comments