Skip to content

Commit 285a4c4

Browse files
committed
feat: added where method in AssetLibrary class
1 parent 11ecb8c commit 285a4c4

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/main/java/com/contentstack/sdk/AssetLibrary.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,4 +208,11 @@ public enum ORDERBY {
208208
ASCENDING, DESCENDING
209209
}
210210

211+
public AssetLibrary where(String key, String value) {
212+
JSONObject queryParams= new JSONObject();
213+
queryParams.put(key,value);
214+
urlQueries.put("query", queryParams);
215+
return this;
216+
}
217+
211218
}

src/test/java/com/contentstack/sdk/TestAssetLibrary.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import org.junit.jupiter.api.*;
44

5+
import com.google.gson.JsonObject;
6+
import org.json.*;
7+
58
import java.util.List;
69
import java.util.logging.Logger;
710

@@ -95,4 +98,15 @@ void testIncludeOwner() {
9598
AssetLibrary assetLibrary = stack.assetLibrary().includeMetadata();
9699
Assertions.assertFalse(assetLibrary.headers.containsKey("include_owner"));
97100
}
101+
102+
@Test
103+
void testAssetQueryOtherThanUID() {
104+
AssetLibrary query = stack.assetLibrary().where("tags","tag1");
105+
query.fetchAll(new FetchAssetsCallback() {
106+
@Override
107+
public void onCompletion(ResponseType responseType, List<Asset> assets, Error error) {
108+
System.out.println(assets);
109+
}
110+
});
111+
}
98112
}

0 commit comments

Comments
 (0)