Skip to content

Commit 7f93513

Browse files
authored
Merge pull request #212 from crowdin/strings-based-api
feat: Strings-based API
2 parents bf013a7 + e0434c6 commit 7f93513

128 files changed

Lines changed: 1540 additions & 371 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

src/main/java/com/crowdin/client/Client.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import com.crowdin.client.applications.ApplicationsApi;
44
import com.crowdin.client.bundles.BundlesApi;
5+
import com.crowdin.client.clients.ClientsApi;
56
import com.crowdin.client.core.CrowdinApi;
67
import com.crowdin.client.core.model.ClientConfig;
78
import com.crowdin.client.core.model.Credentials;
@@ -64,6 +65,7 @@ public class Client extends CrowdinApi {
6465
private final BundlesApi bundlesApi;
6566
private final NotificationsApi notificationsApi;
6667
private final ApplicationsApi applicationsApi;
68+
private final ClientsApi clientsApi;
6769

6870
public Client(Credentials credentials) {
6971
super(credentials);
@@ -95,6 +97,7 @@ public Client(Credentials credentials) {
9597
this.bundlesApi = new BundlesApi(credentials);
9698
this.notificationsApi = new NotificationsApi(credentials);
9799
this.applicationsApi = new ApplicationsApi(credentials);
100+
this.clientsApi = new ClientsApi(credentials);
98101
}
99102

100103
public Client(Credentials credentials, ClientConfig clientConfig) {
@@ -127,6 +130,7 @@ public Client(Credentials credentials, ClientConfig clientConfig) {
127130
this.bundlesApi = new BundlesApi(credentials, clientConfig);
128131
this.notificationsApi = new NotificationsApi(credentials, clientConfig);
129132
this.applicationsApi = new ApplicationsApi(credentials, clientConfig);
133+
this.clientsApi = new ClientsApi(credentials, clientConfig);
130134
}
131135

132136
}

src/main/java/com/crowdin/client/applications/ApplicationsApi.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import com.crowdin.client.core.model.Credentials;
1010
import com.crowdin.client.core.model.ResponseObject;
1111

12+
import java.util.Map;
13+
1214

1315
public class ApplicationsApi extends CrowdinApi {
1416
public ApplicationsApi(Credentials credentials) {
@@ -28,7 +30,7 @@ public ApplicationsApi(Credentials credentials, ClientConfig clientConfig) {
2830
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.applications.api.get" target="_blank"><b>Enterprise API Documentation</b></a></li>
2931
* </ul>
3032
*/
31-
public ResponseObject<ApplicationData> getApplicationData(String applicationIdentifier, String path) throws HttpException, HttpBadRequestException {
33+
public ResponseObject<Map<String, Object>> getApplicationData(String applicationIdentifier, String path) throws HttpException, HttpBadRequestException {
3234
String builtUrl = String.format("%s/applications/%s/api/%s", this.url, applicationIdentifier, path);
3335
ApplicationDataResponseObject response = this.httpClient.get(builtUrl, new HttpRequestConfig(), ApplicationDataResponseObject.class);
3436
return ResponseObject.of(response.getData());
@@ -44,7 +46,7 @@ public ResponseObject<ApplicationData> getApplicationData(String applicationIden
4446
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.applications.api.put" target="_blank"><b>Enterprise API Documentation</b></a></li>
4547
* </ul>
4648
*/
47-
public ResponseObject<ApplicationData> updateOrRestoreApplicationData(String applicationIdentifier, String path, UpdateOrRestoreApplicationDataRequest request) throws HttpException, HttpBadRequestException {
49+
public ResponseObject<Map<String, Object>> updateOrRestoreApplicationData(String applicationIdentifier, String path, Map<String, Object> request) throws HttpException, HttpBadRequestException {
4850
String builtUrl = String.format("%s/applications/%s/api/%s", this.url, applicationIdentifier, path);
4951
ApplicationDataResponseObject response = this.httpClient.put(builtUrl, request, new HttpRequestConfig(), ApplicationDataResponseObject.class);
5052
return ResponseObject.of(response.getData());
@@ -60,7 +62,7 @@ public ResponseObject<ApplicationData> updateOrRestoreApplicationData(String app
6062
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.applications.api.post" target="_blank"><b>Enterprise API Documentation</b></a></li>
6163
* </ul>
6264
*/
63-
public ResponseObject<ApplicationData> addApplicationData(String applicationIdentifier, String path, AddApplicationDataRequest request) throws HttpException, HttpBadRequestException {
65+
public ResponseObject<Map<String, Object>> addApplicationData(String applicationIdentifier, String path, Map<String, Object> request) throws HttpException, HttpBadRequestException {
6466
String builtUrl = String.format("%s/applications/%s/api/%s", this.url, applicationIdentifier, path);
6567
ApplicationDataResponseObject response = this.httpClient.post(builtUrl, request, new HttpRequestConfig(), ApplicationDataResponseObject.class);
6668
return ResponseObject.of(response.getData());
@@ -89,7 +91,7 @@ public void deleteApplicationData(String applicationIdentifier, String path) thr
8991
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.applications.api.put" target="_blank"><b>Enterprise API Documentation</b></a></li>
9092
* </ul>
9193
*/
92-
public ResponseObject<ApplicationData> editApplicationData(String applicationIdentifier, String path, EditApplicationDataRequest request) throws HttpException, HttpBadRequestException {
94+
public ResponseObject<Map<String, Object>> editApplicationData(String applicationIdentifier, String path, Map<String, Object> request) throws HttpException, HttpBadRequestException {
9395
String builtUrl = String.format("%s/applications/%s/api/%s", this.url, applicationIdentifier, path);
9496
ApplicationDataResponseObject response = this.httpClient.patch(builtUrl, request, new HttpRequestConfig(), ApplicationDataResponseObject.class);
9597
return ResponseObject.of(response.getData());

src/main/java/com/crowdin/client/applications/model/AddApplicationDataRequest.java

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/main/java/com/crowdin/client/applications/model/ApplicationData.java

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/main/java/com/crowdin/client/applications/model/ApplicationDataResponseObject.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import lombok.Data;
44

5+
import java.util.Map;
6+
57
@Data
68
public class ApplicationDataResponseObject {
7-
private ApplicationData data;
9+
private Map<String, Object> data;
810
}

src/main/java/com/crowdin/client/applications/model/EditApplicationDataRequest.java

Lines changed: 0 additions & 11 deletions
This file was deleted.

src/main/java/com/crowdin/client/applications/model/UpdateOrRestoreApplicationDataRequest.java

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/main/java/com/crowdin/client/bundles/BundlesApi.java

Lines changed: 43 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,24 @@
11
package com.crowdin.client.bundles;
22

3-
import com.crowdin.client.bundles.model.*;
3+
import com.crowdin.client.bundles.model.AddBundleRequest;
4+
import com.crowdin.client.bundles.model.Bundle;
5+
import com.crowdin.client.bundles.model.BundleExport;
6+
import com.crowdin.client.bundles.model.BundleExportResponseObject;
7+
import com.crowdin.client.bundles.model.BundleResponseList;
8+
import com.crowdin.client.bundles.model.BundleResponseObject;
49
import com.crowdin.client.core.CrowdinApi;
510
import com.crowdin.client.core.http.HttpRequestConfig;
611
import com.crowdin.client.core.http.exceptions.HttpBadRequestException;
712
import com.crowdin.client.core.http.exceptions.HttpException;
8-
import com.crowdin.client.core.model.*;
13+
import com.crowdin.client.core.model.ClientConfig;
14+
import com.crowdin.client.core.model.Credentials;
15+
import com.crowdin.client.core.model.DownloadLink;
16+
import com.crowdin.client.core.model.DownloadLinkResponseObject;
17+
import com.crowdin.client.core.model.PatchRequest;
18+
import com.crowdin.client.core.model.ResponseList;
19+
import com.crowdin.client.core.model.ResponseObject;
20+
import com.crowdin.client.sourcefiles.model.Branch;
21+
import com.crowdin.client.sourcefiles.model.BranchResponseList;
922
import com.crowdin.client.sourcefiles.model.FileInfo;
1023
import com.crowdin.client.sourcefiles.model.FileInfoResponseList;
1124

@@ -39,7 +52,7 @@ public ResponseList<Bundle> listBundles(Long projectId) throws HttpException, Ht
3952

4053
/**
4154
* @param projectId project identifier
42-
* @param request request object
55+
* @param request request object
4356
* @return newly created bundle
4457
* @see <ul>
4558
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.post" target="_blank"><b>API Documentation</b></a></li>
@@ -53,7 +66,7 @@ public ResponseObject<Bundle> addBundle(Long projectId, AddBundleRequest request
5366

5467
/**
5568
* @param projectId project identifier
56-
* @param bundleId bundle identifier
69+
* @param bundleId bundle identifier
5770
* @return bundle object
5871
* @see <ul>
5972
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.get" target="_blank"><b>API Documentation</b></a></li>
@@ -67,7 +80,7 @@ public ResponseObject<Bundle> getBundle(Long projectId, Long bundleId) throws Ht
6780

6881
/**
6982
* @param projectId project identifier
70-
* @param bundleId bundle identifier
83+
* @param bundleId bundle identifier
7184
* @see <ul>
7285
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.delete" target="_blank"><b>API Documentation</b></a></li>
7386
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.projects.bundles.delete" target="_blank"><b>Enterprise API Documentation</b></a></li>
@@ -79,8 +92,8 @@ public void deleteBundle(Long projectId, Long bundleId) throws HttpException, Ht
7992

8093
/**
8194
* @param projectId project identifier
82-
* @param bundleId bundle identifier
83-
* @param request request object
95+
* @param bundleId bundle identifier
96+
* @param request request object
8497
* @return updated bundle
8598
* @see <ul>
8699
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.patch" target="_blank"><b>API Documentation</b></a></li>
@@ -94,9 +107,9 @@ public ResponseObject<Bundle> editBundle(Long projectId, Long bundleId, List<Pat
94107

95108
/**
96109
* @param projectId project identifier
97-
* @param bundleId bundle identifier
98-
* @param limit maximum number of items to retrieve (default 25)
99-
* @param offset starting offset in the collection (default 0)
110+
* @param bundleId bundle identifier
111+
* @param limit maximum number of items to retrieve (default 25)
112+
* @param offset starting offset in the collection (default 0)
100113
* @return list of bundles file resource
101114
* @see <ul>
102115
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.files.getMany" target="_blank"><b>API Documentation</b></a></li>
@@ -114,8 +127,23 @@ public ResponseList<? extends FileInfo> listBundleFiles(Long projectId, Long bun
114127

115128
/**
116129
* @param projectId project identifier
117-
* @param bundleId bundle identifier
118-
* @param exportId export identifier, consists of 36 characters
130+
* @param bundleId bundle identifier
131+
* @param limit maximum number of items to retrieve (default 25)
132+
* @param offset starting offset in the collection (default 0)
133+
*/
134+
public ResponseList<Branch> listBundleBranches(Long projectId, Long bundleId, Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
135+
Map<String, Optional<Object>> queryParams = HttpRequestConfig.buildUrlParams(
136+
"limit", Optional.ofNullable(limit),
137+
"offset", Optional.ofNullable(offset)
138+
);
139+
BranchResponseList response = this.httpClient.get(this.url + "/projects/" + projectId + "/bundles/" + bundleId + "/branches", new HttpRequestConfig(queryParams), BranchResponseList.class);
140+
return BranchResponseList.to(response);
141+
}
142+
143+
/**
144+
* @param projectId project identifier
145+
* @param bundleId bundle identifier
146+
* @param exportId export identifier, consists of 36 characters
119147
* @return download link to bundle
120148
* @see <ul>
121149
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.exports.download.get" target="_blank"><b>API Documentation</b></a></li>
@@ -132,7 +160,7 @@ public ResponseObject<DownloadLink> downloadBundle(Long projectId, Long bundleId
132160

133161
/**
134162
* @param projectId project identifier
135-
* @param bundleId bundle identifier
163+
* @param bundleId bundle identifier
136164
* @return freshly created bundle export object
137165
* @see <ul>
138166
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.exports.post" target="_blank"><b>API Documentation</b></a></li>
@@ -149,8 +177,8 @@ public ResponseObject<BundleExport> exportBundle(Long projectId, Long bundleId)
149177

150178
/**
151179
* @param projectId project identifier
152-
* @param bundleId bundle identifier
153-
* @param exportId export identifier, consists of 36 characters
180+
* @param bundleId bundle identifier
181+
* @param exportId export identifier, consists of 36 characters
154182
* @return requested bundle export object
155183
* @see <ul>
156184
* <li><a href="https://developer.crowdin.com/api/v2/#operation/api.projects.bundles.exports.get" target="_blank"><b>API Documentation</b></a></li>

src/main/java/com/crowdin/client/bundles/model/Bundle.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class Bundle {
1717
private boolean isMultilingual;
1818
private Boolean includeProjectSourceLanguage;
1919
private List<Long> labelIds;
20+
private List<Long> excludeLabelIds;
2021
private Date createdAt;
2122
private Date updatedAt;
2223
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package com.crowdin.client.clients;
2+
3+
import com.crowdin.client.clients.model.Client;
4+
import com.crowdin.client.clients.model.ClientResponseList;
5+
import com.crowdin.client.core.CrowdinApi;
6+
import com.crowdin.client.core.http.HttpRequestConfig;
7+
import com.crowdin.client.core.http.exceptions.HttpBadRequestException;
8+
import com.crowdin.client.core.http.exceptions.HttpException;
9+
import com.crowdin.client.core.model.ClientConfig;
10+
import com.crowdin.client.core.model.Credentials;
11+
import com.crowdin.client.core.model.ResponseList;
12+
13+
import java.util.Map;
14+
import java.util.Optional;
15+
16+
public class ClientsApi extends CrowdinApi {
17+
public ClientsApi(Credentials credentials) {
18+
super(credentials);
19+
}
20+
21+
public ClientsApi(Credentials credentials, ClientConfig clientConfig) {
22+
super(credentials, clientConfig);
23+
}
24+
25+
/**
26+
* @param limit maximum number of items to retrieve (default 25)
27+
* @param offset starting offset in the collection (default 0)
28+
* @return list of vendors
29+
* @see <ul>
30+
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.clients.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li>
31+
* </ul>
32+
*/
33+
public ResponseList<Client> listClients(Integer limit, Integer offset) throws HttpException, HttpBadRequestException {
34+
Map<String, Optional<Integer>> queryParams = HttpRequestConfig.buildUrlParams(
35+
"limit", Optional.ofNullable(limit),
36+
"offset", Optional.ofNullable(offset)
37+
);
38+
ClientResponseList vendorResponseList = this.httpClient.get(this.url + "/clients", new HttpRequestConfig(queryParams), ClientResponseList.class);
39+
return ClientResponseList.to(vendorResponseList);
40+
}
41+
}

0 commit comments

Comments
 (0)