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

Enh/dx 59 fetch asset with any field #124

Merged
merged 2 commits into from
Jul 19, 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
7 changes: 7 additions & 0 deletions src/main/java/com/contentstack/sdk/AssetLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -208,4 +208,11 @@ public enum ORDERBY {
ASCENDING, DESCENDING
}

public AssetLibrary where(String key, String value) {
JSONObject queryParams= new JSONObject();
queryParams.put(key,value);
urlQueries.put("query", queryParams);
return this;
}

}
12 changes: 12 additions & 0 deletions src/test/java/com/contentstack/sdk/TestAssetLibrary.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import org.junit.jupiter.api.*;


import java.util.List;
import java.util.logging.Logger;

Expand Down Expand Up @@ -95,4 +96,15 @@ void testIncludeOwner() {
AssetLibrary assetLibrary = stack.assetLibrary().includeMetadata();
Assertions.assertFalse(assetLibrary.headers.containsKey("include_owner"));
}

@Test
void testAssetQueryOtherThanUID() {
AssetLibrary query = stack.assetLibrary().where("tags","tag1");
query.fetchAll(new FetchAssetsCallback() {
@Override
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
System.out.println(assets);
}
});
}
}
Loading