Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DX | 21-10-2024 | Release #69

Merged
merged 4 commits into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
Loading