9
9
import com .crowdin .client .core .model .PatchRequest ;
10
10
import com .crowdin .client .core .model .ResponseList ;
11
11
import com .crowdin .client .core .model .ResponseObject ;
12
- import com .crowdin .client .screenshots .model .AddScreenshotRequest ;
13
- import com .crowdin .client .screenshots .model .AddTagRequest ;
14
- import com .crowdin .client .screenshots .model .ReplaceTagsRequest ;
15
- import com .crowdin .client .screenshots .model .Screenshot ;
16
- import com .crowdin .client .screenshots .model .ScreenshotResponseList ;
17
- import com .crowdin .client .screenshots .model .ScreenshotResponseObject ;
18
- import com .crowdin .client .screenshots .model .Tag ;
19
- import com .crowdin .client .screenshots .model .TagResponseList ;
20
- import com .crowdin .client .screenshots .model .TagResponseObject ;
21
- import com .crowdin .client .screenshots .model .UpdateScreenshotRequest ;
12
+ import com .crowdin .client .screenshots .model .*;
22
13
23
14
import java .util .List ;
24
15
import java .util .Map ;
@@ -46,13 +37,11 @@ public ScreenshotsApi(Credentials credentials, ClientConfig clientConfig) {
46
37
*/
47
38
@ Deprecated
48
39
public ResponseList <Screenshot > listScreenshots (Long projectId , Long stringId , Integer limit , Integer offset ) throws HttpException , HttpBadRequestException {
49
- Map <String , Optional <Object >> queryParams = HttpRequestConfig .buildUrlParams (
50
- "stringId" , Optional .ofNullable (stringId ),
51
- "limit" , Optional .ofNullable (limit ),
52
- "offset" , Optional .ofNullable (offset )
53
- );
54
- ScreenshotResponseList screenshotResponseList = this .httpClient .get (this .url + "/projects/" + projectId + "/screenshots" , new HttpRequestConfig (queryParams ), ScreenshotResponseList .class );
55
- return ScreenshotResponseList .to (screenshotResponseList );
40
+ ListScreenshotsParams screenshotsParams = new ListScreenshotsParams ();
41
+ screenshotsParams .setStringIds (Optional .ofNullable (stringId ).map (Object ::toString ).orElse (null ));
42
+ screenshotsParams .setLimit (limit );
43
+ screenshotsParams .setOffset (offset );
44
+ return this .listScreenshots (projectId , screenshotsParams );
56
45
}
57
46
58
47
/**
@@ -69,12 +58,34 @@ public ResponseList<Screenshot> listScreenshots(Long projectId, Long stringId, I
69
58
* </ul>
70
59
*/
71
60
public ResponseList <Screenshot > listScreenshots (Long projectId , List <String > stringIds , List <String > labelIds , List <String > excludeLabelIds , Integer limit , Integer offset ) throws HttpException , HttpBadRequestException {
61
+ ListScreenshotsParams screenshotsParams = new ListScreenshotsParams ();
62
+ screenshotsParams .setStringIds (Optional .ofNullable (stringIds ).map (l -> String .join ("," , l )).orElse (null ));
63
+ screenshotsParams .setLabelIds (Optional .ofNullable (labelIds ).map (l -> String .join ("," , l )).orElse (null ));
64
+ screenshotsParams .setExcludeLabelIds (Optional .ofNullable (excludeLabelIds ).map (l -> String .join ("," , l )).orElse (null ));
65
+ screenshotsParams .setLimit (limit );
66
+ screenshotsParams .setOffset (offset );
67
+ return this .listScreenshots (projectId , screenshotsParams );
68
+ }
69
+
70
+ /**
71
+ * @param projectId project identifier
72
+ * @param params query params
73
+ * @return list of screenshots
74
+ * @see <ul>
75
+ * <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.screenshots.getMany" target="_blank"><b>API Documentation</b></a></li>
76
+ * <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.screenshots.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li>
77
+ * </ul>
78
+ */
79
+ public ResponseList <Screenshot > listScreenshots (Long projectId , ListScreenshotsParams params ) throws HttpException , HttpBadRequestException {
80
+ ListScreenshotsParams query = Optional .ofNullable (params ).orElse (new ListScreenshotsParams ());
72
81
Map <String , Optional <Object >> queryParams = HttpRequestConfig .buildUrlParams (
73
- "stringIds" , Optional .ofNullable (stringIds ),
74
- "labelIds" , Optional .ofNullable (labelIds ),
75
- "excludeLabelIds" , Optional .ofNullable (excludeLabelIds ),
76
- "limit" , Optional .ofNullable (limit ),
77
- "offset" , Optional .ofNullable (offset )
82
+ "search" , Optional .ofNullable (query .getSearch ()),
83
+ "orderBy" , Optional .ofNullable (query .getOrderBy ()),
84
+ "stringIds" , Optional .ofNullable (query .getStringIds ()),
85
+ "labelIds" , Optional .ofNullable (query .getLabelIds ()),
86
+ "excludeLabelIds" , Optional .ofNullable (query .getExcludeLabelIds ()),
87
+ "limit" , Optional .ofNullable (query .getLimit ()),
88
+ "offset" , Optional .ofNullable (query .getOffset ())
78
89
);
79
90
ScreenshotResponseList screenshotResponseList = this .httpClient .get (this .url + "/projects/" + projectId + "/screenshots" , new HttpRequestConfig (queryParams ), ScreenshotResponseList .class );
80
91
return ScreenshotResponseList .to (screenshotResponseList );
0 commit comments