Skip to content

Commit 0bc60a3

Browse files
authored
Merge pull request #66 from contentstack/feat/DX-1217
Feat: Added Support for fetch Asset by Query
2 parents 2a34195 + b34abf1 commit 0bc60a3

File tree

5 files changed

+38
-2
lines changed

5 files changed

+38
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
### Version: 2.17.0
2+
#### Date: Oct-21-2024
3+
4+
##### Feat:
5+
- Added support for fetch asset by Query
6+
17
### Version: 2.16.0
28
#### Date: Oct-11-2024
39

Contentstack.Core.Tests/AssetTest.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using System.Collections.Generic;
66
using System.Linq;
77
using Newtonsoft.Json.Linq;
8+
89
namespace Contentstack.Core.Tests
910
{
1011
public class AssetTest
@@ -121,6 +122,22 @@ public async Task FetchAssetsIncludeRelativeURL()
121122
}
122123
}
123124

125+
[Fact]
126+
public async Task FetchAssetWithQuery()
127+
{
128+
JObject queryObject = new JObject
129+
{
130+
{ "filename", "image3.png" }
131+
};
132+
ContentstackCollection<Asset> assets = await client.AssetLibrary().Query(queryObject).FetchAll();
133+
Assert.True(assets.Count() > 0);
134+
foreach (Asset asset in assets)
135+
{
136+
Assert.DoesNotContain(asset.Url, "http");
137+
Assert.True(asset.FileName.Length > 0);
138+
}
139+
}
140+
124141
[Fact]
125142
public async Task FetchAssetCountAsync()
126143
{

Contentstack.Core/Internals/HttpRequestHandler.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public async Task<string> ProcessRequest(string Url, Dictionary<string, object>
4848
var request = (HttpWebRequest)WebRequest.Create(uri);
4949
request.Method = "GET";
5050
request.ContentType = "application/json";
51-
request.Headers["x-user-agent"]="contentstack-delivery-dotnet/2.16.0";
51+
request.Headers["x-user-agent"]="contentstack-delivery-dotnet/2.17.0";
5252
request.Timeout = timeout;
5353

5454
if (proxy != null)

Contentstack.Core/Models/AssetLibrary.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ public async Task<JObject> Count()
9292
return await Exec();
9393
}
9494

95+
public AssetLibrary Query(JObject QueryObject)
96+
{
97+
try
98+
{
99+
UrlQueries.Add("query", QueryObject);
100+
}
101+
catch (Exception e)
102+
{
103+
throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e);
104+
}
105+
return this;
106+
}
95107
/// <summary>
96108
/// Include fallback locale publish content, if specified locale content is not publish.
97109
/// </summary>
@@ -155,6 +167,7 @@ public AssetLibrary IncludeBranch()
155167
/// ContentstackCollection&gt;Asset&lt; contentstackCollection = await assetLibrary.FetchAll();
156168
/// </code>
157169
/// </example>
170+
/// Where function
158171
public AssetLibrary AddParam(string key, string value)
159172
{
160173
UrlQueries.Add(key, value);

Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<Project>
22
<PropertyGroup>
3-
<Version>2.16.0</Version>
3+
<Version>2.17.0</Version>
44
</PropertyGroup>
55
</Project>

0 commit comments

Comments
 (0)