Skip to content

Commit 98f2402

Browse files
committed
Add direction support to resource listing.
1 parent 0c09f4c commit 98f2402

File tree

3 files changed

+18
-2
lines changed

3 files changed

+18
-2
lines changed

cloudinary-core/src/main/java/com/cloudinary/Api.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ public Map resources(Map options) throws Exception {
121121
uri.add(resourceType);
122122
if (type != null)
123123
uri.add(type);
124-
return callApi(HttpMethod.GET, uri, only(options, "next_cursor", "max_results", "prefix", "tags", "context"), options);
124+
return callApi(HttpMethod.GET, uri, only(options, "next_cursor", "direction", "max_results", "prefix", "tags", "context"), options);
125125
}
126126

127127
public Map resourcesByTag(String tag, Map options) throws Exception {
128128
if (options == null) options = Cloudinary.emptyMap();
129129
String resourceType = Cloudinary.asString(options.get("resource_type"), "image");
130-
return callApi(HttpMethod.GET, Arrays.asList("resources", resourceType, "tags", tag), only(options, "next_cursor", "max_results", "tags", "context"), options);
130+
return callApi(HttpMethod.GET, Arrays.asList("resources", resourceType, "tags", tag), only(options, "next_cursor", "direction", "max_results", "tags", "context"), options);
131131
}
132132

133133
public Map resourcesByIds(Iterable<String> publicIds, Map options) throws Exception {

cloudinary-core/src/test/java/com/cloudinary/test/ApiTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,17 @@ public void test05ResourcesByPrefix() throws Exception {
137137
assertTrue(found);
138138
}
139139

140+
@Test
141+
public void testResourcesListingDirection() throws Exception {
142+
// should allow listing resources in both directions
143+
Map result = api.resources(Cloudinary.asMap("type", "upload", "prefix", "api_test", "direction", "asc"));
144+
List<Map> resources = (List<Map>) result.get("resources");
145+
result = api.resources(Cloudinary.asMap("type", "upload", "prefix", "api_test", "direction", -1));
146+
List<Map> resourcesDesc = (List<Map>) result.get("resources");
147+
Collections.reverse(resources);
148+
assertEquals(resources, resourcesDesc);
149+
}
150+
140151
@Test
141152
public void testResourcesByPublicIds() throws Exception {
142153
// should allow listing resources by public ids

cloudinary-core/src/test/java/com/cloudinary/test/CloudinaryTest.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,6 +433,11 @@ public void testSignedUrl() {
433433
generate("image.jpg");
434434
assertEquals(expected, actual);
435435
}
436+
437+
public void testUtils() {
438+
assertEquals(Cloudinary.asBoolean(true, null), true);
439+
assertEquals(Cloudinary.asBoolean(false, null), false);
440+
}
436441

437442
public static Map<String, String> getUrlParameters(URI uri) throws UnsupportedEncodingException {
438443
Map<String, String> params = new HashMap<String, String>();

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy