@@ -87,8 +87,10 @@ public ApiResponse resources(Map options) throws Exception {
87
87
uri .add (resourceType );
88
88
if (type != null )
89
89
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 );
92
94
return response ;
93
95
}
94
96
@@ -106,8 +108,10 @@ public ApiResponse visualSearch(Map options) throws Exception {
106
108
public ApiResponse resourcesByTag (String tag , Map options ) throws Exception {
107
109
if (options == null ) options = ObjectUtils .emptyMap ();
108
110
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 );
111
115
return response ;
112
116
}
113
117
@@ -118,7 +122,10 @@ public ApiResponse resourcesByContext(String key, Map options) throws Exception
118
122
public ApiResponse resourcesByContext (String key , String value , Map options ) throws Exception {
119
123
if (options == null ) options = ObjectUtils .emptyMap ();
120
124
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" );
122
129
params .put ("key" , key );
123
130
if (StringUtils .isNotBlank (value )) {
124
131
params .put ("value" , value );
@@ -128,7 +135,10 @@ public ApiResponse resourcesByContext(String key, String value, Map options) thr
128
135
129
136
public ApiResponse resourceByAssetID (String assetId , Map options ) throws Exception {
130
137
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" );
132
142
ApiResponse response = callApi (HttpMethod .GET , Arrays .asList ("resources" , assetId ), params , options );
133
143
return response ;
134
144
}
@@ -142,7 +152,10 @@ public ApiResponse resourcesByAssetIDs(Iterable<String> assetIds, Map options) t
142
152
143
153
public ApiResponse resourcesByAssetFolder (String assetFolder , Map options ) throws Exception {
144
154
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" );
146
159
params .put ("asset_folder" , assetFolder );
147
160
ApiResponse response = callApi (HttpMethod .GET , Arrays .asList ("resources/by_asset_folder" ), params , options );
148
161
return response ;
@@ -161,8 +174,10 @@ public ApiResponse resourcesByIds(Iterable<String> publicIds, Map options) throw
161
174
public ApiResponse resourcesByModeration (String kind , String status , Map options ) throws Exception {
162
175
if (options == null ) options = ObjectUtils .emptyMap ();
163
176
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 );
166
181
return response ;
167
182
}
168
183
0 commit comments