@@ -87,8 +87,10 @@ public ApiResponse resources(Map options) throws Exception {
8787 uri .add (resourceType );
8888 if (type != null )
8989 uri .add (type );
90-
91- ApiResponse response = callApi (HttpMethod .GET , uri , ObjectUtils .only (options , "next_cursor" , "direction" , "max_results" , "prefix" , "tags" , "context" , "moderations" , "start_at" , "metadata" ), options );
90+ if (options .get ("fields" ) != null ) {
91+ options .put ("fields" , StringUtils .join (ObjectUtils .asArray (options .get ("fields" )), "," ));
92+ }
93+ ApiResponse response = callApi (HttpMethod .GET , uri , ObjectUtils .only (options , "next_cursor" , "direction" , "max_results" , "prefix" , "tags" , "context" , "moderations" , "start_at" , "metadata" , "fields" ), options );
9294 return response ;
9395 }
9496
@@ -106,8 +108,10 @@ public ApiResponse visualSearch(Map options) throws Exception {
106108 public ApiResponse resourcesByTag (String tag , Map options ) throws Exception {
107109 if (options == null ) options = ObjectUtils .emptyMap ();
108110 String resourceType = ObjectUtils .asString (options .get ("resource_type" ), "image" );
109-
110- ApiResponse response = callApi (HttpMethod .GET , Arrays .asList ("resources" , resourceType , "tags" , tag ), ObjectUtils .only (options , "next_cursor" , "direction" , "max_results" , "tags" , "context" , "moderations" , "metadata" ), options );
111+ if (options .get ("fields" ) != null ) {
112+ options .put ("fields" , StringUtils .join (ObjectUtils .asArray (options .get ("fields" )), "," ));
113+ }
114+ ApiResponse response = callApi (HttpMethod .GET , Arrays .asList ("resources" , resourceType , "tags" , tag ), ObjectUtils .only (options , "next_cursor" , "direction" , "max_results" , "tags" , "context" , "moderations" , "metadata" , "fields" ), options );
111115 return response ;
112116 }
113117
@@ -118,7 +122,10 @@ public ApiResponse resourcesByContext(String key, Map options) throws Exception
118122 public ApiResponse resourcesByContext (String key , String value , Map options ) throws Exception {
119123 if (options == null ) options = ObjectUtils .emptyMap ();
120124 String resourceType = ObjectUtils .asString (options .get ("resource_type" ), "image" );
121- Map params = ObjectUtils .only (options , "next_cursor" , "direction" , "max_results" , "tags" , "context" , "moderations" , "metadata" );
125+ if (options .get ("fields" ) != null ) {
126+ options .put ("fields" , StringUtils .join (ObjectUtils .asArray (options .get ("fields" )), "," ));
127+ }
128+ Map params = ObjectUtils .only (options , "next_cursor" , "direction" , "max_results" , "tags" , "context" , "moderations" , "metadata" , "fields" );
122129 params .put ("key" , key );
123130 if (StringUtils .isNotBlank (value )) {
124131 params .put ("value" , value );
@@ -128,7 +135,10 @@ public ApiResponse resourcesByContext(String key, String value, Map options) thr
128135
129136 public ApiResponse resourceByAssetID (String assetId , Map options ) throws Exception {
130137 if (options == null ) options = ObjectUtils .emptyMap ();
131- Map params = ObjectUtils .only (options , "tags" , "context" , "moderations" );
138+ if (options .get ("fields" ) != null ) {
139+ options .put ("fields" , StringUtils .join (ObjectUtils .asArray (options .get ("fields" )), "," ));
140+ }
141+ Map params = ObjectUtils .only (options , "tags" , "context" , "moderations" , "fields" );
132142 ApiResponse response = callApi (HttpMethod .GET , Arrays .asList ("resources" , assetId ), params , options );
133143 return response ;
134144 }
@@ -142,7 +152,10 @@ public ApiResponse resourcesByAssetIDs(Iterable<String> assetIds, Map options) t
142152
143153 public ApiResponse resourcesByAssetFolder (String assetFolder , Map options ) throws Exception {
144154 if (options == null ) options = ObjectUtils .emptyMap ();
145- Map params = ObjectUtils .only (options , "next_cursor" , "direction" , "max_results" , "tags" , "context" , "moderations" );
155+ if (options .get ("fields" ) != null ) {
156+ options .put ("fields" , StringUtils .join (ObjectUtils .asArray (options .get ("fields" )), "," ));
157+ }
158+ Map params = ObjectUtils .only (options , "next_cursor" , "direction" , "max_results" , "tags" , "context" , "moderations" , "fields" );
146159 params .put ("asset_folder" , assetFolder );
147160 ApiResponse response = callApi (HttpMethod .GET , Arrays .asList ("resources/by_asset_folder" ), params , options );
148161 return response ;
@@ -161,8 +174,10 @@ public ApiResponse resourcesByIds(Iterable<String> publicIds, Map options) throw
161174 public ApiResponse resourcesByModeration (String kind , String status , Map options ) throws Exception {
162175 if (options == null ) options = ObjectUtils .emptyMap ();
163176 String resourceType = ObjectUtils .asString (options .get ("resource_type" ), "image" );
164-
165- ApiResponse response = callApi (HttpMethod .GET , Arrays .asList ("resources" , resourceType , "moderations" , kind , status ), ObjectUtils .only (options , "next_cursor" , "direction" , "max_results" , "tags" , "context" , "moderations" , "metadata" ), options );
177+ if (options .get ("fields" ) != null ) {
178+ options .put ("fields" , StringUtils .join (ObjectUtils .asArray (options .get ("fields" )), "," ));
179+ }
180+ ApiResponse response = callApi (HttpMethod .GET , Arrays .asList ("resources" , resourceType , "moderations" , kind , status ), ObjectUtils .only (options , "next_cursor" , "direction" , "max_results" , "tags" , "context" , "moderations" , "metadata" , "fields" ), options );
166181 return response ;
167182 }
168183
0 commit comments