Skip to content

Commit

Permalink
Merge pull request #68 from contentstack/development
Browse files Browse the repository at this point in the history
Development to Staging
  • Loading branch information
cs-raj authored Oct 18, 2024
2 parents 04873a9 + 0bc60a3 commit 7567398
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
### Version: 2.17.0
#### Date: Oct-21-2024

##### Feat:
- Added support for fetch asset by Query

### Version: 2.16.0
#### Date: Oct-11-2024

Expand Down
17 changes: 17 additions & 0 deletions Contentstack.Core.Tests/AssetTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Linq;

namespace Contentstack.Core.Tests
{
public class AssetTest
Expand Down Expand Up @@ -121,6 +122,22 @@ public async Task FetchAssetsIncludeRelativeURL()
}
}

[Fact]
public async Task FetchAssetWithQuery()
{
JObject queryObject = new JObject
{
{ "filename", "image3.png" }
};
ContentstackCollection<Asset> assets = await client.AssetLibrary().Query(queryObject).FetchAll();
Assert.True(assets.Count() > 0);
foreach (Asset asset in assets)
{
Assert.DoesNotContain(asset.Url, "http");
Assert.True(asset.FileName.Length > 0);
}
}

[Fact]
public async Task FetchAssetCountAsync()
{
Expand Down
2 changes: 1 addition & 1 deletion Contentstack.Core/Internals/HttpRequestHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public async Task<string> ProcessRequest(string Url, Dictionary<string, object>
var request = (HttpWebRequest)WebRequest.Create(uri);
request.Method = "GET";
request.ContentType = "application/json";
request.Headers["x-user-agent"]="contentstack-delivery-dotnet/2.16.0";
request.Headers["x-user-agent"]="contentstack-delivery-dotnet/2.17.0";
request.Timeout = timeout;

if (proxy != null)
Expand Down
13 changes: 13 additions & 0 deletions Contentstack.Core/Models/AssetLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@ public async Task<JObject> Count()
return await Exec();
}

public AssetLibrary Query(JObject QueryObject)
{
try
{
UrlQueries.Add("query", QueryObject);
}
catch (Exception e)
{
throw new Exception(StackConstants.ErrorMessage_QueryFilterException, e);
}
return this;
}
/// <summary>
/// Include fallback locale publish content, if specified locale content is not publish.
/// </summary>
Expand Down Expand Up @@ -155,6 +167,7 @@ public AssetLibrary IncludeBranch()
/// ContentstackCollection&gt;Asset&lt; contentstackCollection = await assetLibrary.FetchAll();
/// </code>
/// </example>
/// Where function
public AssetLibrary AddParam(string key, string value)
{
UrlQueries.Add(key, value);
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<Project>
<PropertyGroup>
<Version>2.16.0</Version>
<Version>2.17.0</Version>
</PropertyGroup>
</Project>

0 comments on commit 7567398

Please sign in to comment.