Skip to content

Commit ad8f19f

Browse files
committed
added getfileequest
1 parent bfaede5 commit ad8f19f

File tree

3 files changed

+46
-44
lines changed

3 files changed

+46
-44
lines changed

imagekit-sdk/src/main/java/io/imagekit/sdk/ImageKit.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,9 @@ public Result updateFileDetail(FileUpdateRequest fileUpdateRequest)
110110
* "includeFolder", "name", "limit", "skip"]
111111
* @return ResultList class that contains list of BaseFile
112112
*/
113-
public ResultList getFileList(Map<String, String> options) throws ForbiddenException, TooManyRequestsException,
113+
public ResultList getFileList(GetFileListRequest getFileListRequest) throws ForbiddenException, TooManyRequestsException,
114114
InternalServerException, UnauthorizedException, BadRequestException, UnknownException, IllegalAccessException, InstantiationException {
115-
return restClient.getFileList(options);
115+
return restClient.getFileList(getFileListRequest);
116116
}
117117

118118
/**

imagekit-sdk/src/main/java/io/imagekit/sdk/models/BaseFile.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package io.imagekit.sdk.models;
22

33
import com.google.gson.JsonArray;
4-
import com.google.gson.JsonObject;
4+
import com.google.gson.JsonElement;
55

66
import java.util.Date;
77
import java.util.List;
@@ -20,10 +20,11 @@ public class BaseFile {
2020
protected String customCoordinates;
2121
protected String fileType;
2222
protected JsonArray aiTags;
23-
protected JsonObject versionInfo;
24-
protected JsonObject customMetadata;
25-
protected JsonObject embeddedMetadata;
26-
protected JsonObject extensionStatus;
23+
protected JsonElement versionInfo;
24+
protected JsonElement customMetadata;
25+
26+
protected JsonElement embeddedMetadata;
27+
protected JsonElement extensionStatus;
2728
protected String type;
2829
protected String mime;
2930
protected Boolean hasAlpha;
@@ -35,8 +36,8 @@ public BaseFile() {
3536

3637
public BaseFile(String fileId, String name, String url, String thumbnail, int height, int width, long size,
3738
String filePath, List<String> tags, boolean isPrivateFile, String customCoordinates, String fileType,
38-
JsonArray aiTags, JsonObject versionInfo, JsonObject customMetadata, JsonObject embeddedMetadata,
39-
JsonObject extensionStatus, String type, String mime, Boolean hasAlpha, Date createdAt, Date updatedAt) {
39+
JsonArray aiTags, JsonElement versionInfo, JsonElement customMetadata, JsonElement embeddedMetadata,
40+
JsonElement extensionStatus, String type, String mime, Boolean hasAlpha, Date createdAt, Date updatedAt) {
4041
this.fileId = fileId;
4142
this.name = name;
4243
this.url = url;
@@ -165,35 +166,35 @@ public void setAiTags(JsonArray aiTags) {
165166
this.aiTags = aiTags;
166167
}
167168

168-
public JsonObject getVersionInfo() {
169+
public JsonElement getVersionInfo() {
169170
return versionInfo;
170171
}
171172

172-
public void setVersionInfo(JsonObject versionInfo) {
173+
public void setVersionInfo(JsonElement versionInfo) {
173174
this.versionInfo = versionInfo;
174175
}
175176

176-
public JsonObject getCustomMetadata() {
177+
public JsonElement getCustomMetadata() {
177178
return customMetadata;
178179
}
179180

180-
public void setCustomMetadata(JsonObject customMetadata) {
181+
public void setCustomMetadata(JsonElement customMetadata) {
181182
this.customMetadata = customMetadata;
182183
}
183184

184-
public JsonObject getEmbeddedMetadata() {
185+
public JsonElement getEmbeddedMetadata() {
185186
return embeddedMetadata;
186187
}
187188

188-
public void setEmbeddedMetadata(JsonObject embeddedMetadata) {
189+
public void setEmbeddedMetadata(JsonElement embeddedMetadata) {
189190
this.embeddedMetadata = embeddedMetadata;
190191
}
191192

192-
public JsonObject getExtensionStatus() {
193+
public JsonElement getExtensionStatus() {
193194
return extensionStatus;
194195
}
195196

196-
public void setExtensionStatus(JsonObject extensionStatus) {
197+
public void setExtensionStatus(JsonElement extensionStatus) {
197198
this.extensionStatus = extensionStatus;
198199
}
199200

imagekit-sdk/src/main/java/io/imagekit/sdk/tasks/RestClient.java

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import com.fasterxml.jackson.databind.JavaType;
44
import com.fasterxml.jackson.databind.ObjectMapper;
55
import com.google.gson.Gson;
6+
import com.google.gson.GsonBuilder;
67
import com.google.gson.JsonElement;
78
import com.google.gson.JsonParser;
89
import com.google.gson.reflect.TypeToken;
@@ -119,37 +120,37 @@ public Result updateFileDetail(FileUpdateRequest fileUpdateRequest)
119120
return result;
120121
}
121122

122-
public ResultList getFileList(Map<String, String> options) throws ForbiddenException, TooManyRequestsException,
123+
public ResultList getFileList(GetFileListRequest getFileListRequest) throws ForbiddenException, TooManyRequestsException,
123124
InternalServerException, UnauthorizedException, BadRequestException, UnknownException, InstantiationException, IllegalAccessException {
124125
ResultList resultList = new ResultList();
125126
Map<String, String> headers = Utils.getHeaders(imageKit);
126127

127128
QueryMaker queryMaker = new QueryMaker();
128-
// Map<String, String> options = new HashMap<>();
129-
// if (getFileListRequest.getType() != null) {
130-
// options.put("type", getFileListRequest.getType());
131-
// }
132-
// if (getFileListRequest.getSort() != null) {
133-
// options.put("sort", getFileListRequest.getSort());
134-
// }
135-
// if (getFileListRequest.getPath() != null) {
136-
// options.put("path", getFileListRequest.getPath());
137-
// }
138-
// if (getFileListRequest.getSearchQuery() != null) {
139-
// options.put("searchQuery", getFileListRequest.getSearchQuery());
140-
// }
141-
// if (getFileListRequest.getFileType() != null) {
142-
// options.put("fileType", getFileListRequest.getFileType());
143-
// }
144-
// if (getFileListRequest.getLimit() != null) {
145-
// options.put("limit", getFileListRequest.getLimit());
146-
// }
147-
// if (getFileListRequest.getSkip() != null) {
148-
// options.put("skip", getFileListRequest.getSkip());
149-
// }
150-
// if (getFileListRequest.getTags() != null) {
151-
// options.put("tags", Arrays.toString(getFileListRequest.getTags()));
152-
// }
129+
Map<String, String> options = new HashMap<>();
130+
if (getFileListRequest.getType() != null) {
131+
options.put("type", getFileListRequest.getType());
132+
}
133+
if (getFileListRequest.getSort() != null) {
134+
options.put("sort", getFileListRequest.getSort());
135+
}
136+
if (getFileListRequest.getPath() != null) {
137+
options.put("path", getFileListRequest.getPath());
138+
}
139+
if (getFileListRequest.getSearchQuery() != null) {
140+
options.put("searchQuery", getFileListRequest.getSearchQuery());
141+
}
142+
if (getFileListRequest.getFileType() != null) {
143+
options.put("fileType", getFileListRequest.getFileType());
144+
}
145+
if (getFileListRequest.getLimit() != null) {
146+
options.put("limit", getFileListRequest.getLimit());
147+
}
148+
if (getFileListRequest.getSkip() != null) {
149+
options.put("skip", getFileListRequest.getSkip());
150+
}
151+
if (getFileListRequest.getTags() != null) {
152+
options.put("tags", Arrays.toString(getFileListRequest.getTags()));
153+
}
153154
System.out.println("options:==> " + options);
154155
for (Map.Entry<String, String> entry : options.entrySet()) {
155156
queryMaker.put(String.format("%s=%s", entry.getKey(), entry.getValue()));
@@ -167,7 +168,7 @@ public ResultList getFileList(Map<String, String> options) throws ForbiddenExcep
167168
String respBody = "";
168169
if (response.code() == 200) {
169170
respBody = response.body().string();
170-
// System.out.println("respBody:==> " + respBody);
171+
System.out.println("respBody:==> " + respBody);
171172
List<BaseFile> files = new Gson().fromJson(respBody,
172173
new TypeToken<List<BaseFile>>() {
173174
}.getType());

0 commit comments

Comments
 (0)