-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #212 from crowdin/strings-based-api
feat: Strings-based API
- Loading branch information
Showing
128 changed files
with
1,540 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
src/main/java/com/crowdin/client/applications/model/AddApplicationDataRequest.java
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
src/main/java/com/crowdin/client/applications/model/ApplicationData.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 0 additions & 11 deletions
11
src/main/java/com/crowdin/client/applications/model/EditApplicationDataRequest.java
This file was deleted.
Oops, something went wrong.
10 changes: 0 additions & 10 deletions
10
...ain/java/com/crowdin/client/applications/model/UpdateOrRestoreApplicationDataRequest.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.crowdin.client.clients; | ||
|
||
import com.crowdin.client.clients.model.Client; | ||
import com.crowdin.client.clients.model.ClientResponseList; | ||
import com.crowdin.client.core.CrowdinApi; | ||
import com.crowdin.client.core.http.HttpRequestConfig; | ||
import com.crowdin.client.core.http.exceptions.HttpBadRequestException; | ||
import com.crowdin.client.core.http.exceptions.HttpException; | ||
import com.crowdin.client.core.model.ClientConfig; | ||
import com.crowdin.client.core.model.Credentials; | ||
import com.crowdin.client.core.model.ResponseList; | ||
|
||
import java.util.Map; | ||
import java.util.Optional; | ||
|
||
public class ClientsApi extends CrowdinApi { | ||
public ClientsApi(Credentials credentials) { | ||
super(credentials); | ||
} | ||
|
||
public ClientsApi(Credentials credentials, ClientConfig clientConfig) { | ||
super(credentials, clientConfig); | ||
} | ||
|
||
/** | ||
* @param limit maximum number of items to retrieve (default 25) | ||
* @param offset starting offset in the collection (default 0) | ||
* @return list of vendors | ||
* @see <ul> | ||
* <li><a href="https://developer.crowdin.com/enterprise/api/v2/#operation/api.clients.getMany" target="_blank"><b>Enterprise API Documentation</b></a></li> | ||
* </ul> | ||
*/ | ||
public ResponseList<Client> listClients(Integer limit, Integer offset) throws HttpException, HttpBadRequestException { | ||
Map<String, Optional<Integer>> queryParams = HttpRequestConfig.buildUrlParams( | ||
"limit", Optional.ofNullable(limit), | ||
"offset", Optional.ofNullable(offset) | ||
); | ||
ClientResponseList vendorResponseList = this.httpClient.get(this.url + "/clients", new HttpRequestConfig(queryParams), ClientResponseList.class); | ||
return ClientResponseList.to(vendorResponseList); | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/main/java/com/crowdin/client/clients/model/Client.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.crowdin.client.clients.model; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class Client { | ||
|
||
private Long id; | ||
private String name; | ||
private String description; | ||
private Status status; | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/crowdin/client/clients/model/ClientResponseList.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.crowdin.client.clients.model; | ||
|
||
import com.crowdin.client.core.model.Pagination; | ||
import com.crowdin.client.core.model.ResponseList; | ||
import com.crowdin.client.core.model.ResponseObject; | ||
import lombok.Data; | ||
|
||
import java.util.List; | ||
import java.util.stream.Collectors; | ||
|
||
@Data | ||
public class ClientResponseList { | ||
|
||
private List<ClientResponseObject> data; | ||
private Pagination pagination; | ||
|
||
public static ResponseList<Client> to(ClientResponseList vendorResponseList) { | ||
return ResponseList.of( | ||
vendorResponseList.getData().stream() | ||
.map(ClientResponseObject::getData) | ||
.map(ResponseObject::of) | ||
.collect(Collectors.toList()), | ||
vendorResponseList.getPagination() | ||
); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
src/main/java/com/crowdin/client/clients/model/ClientResponseObject.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package com.crowdin.client.clients.model; | ||
|
||
import lombok.Data; | ||
|
||
@Data | ||
public class ClientResponseObject { | ||
|
||
private Client data; | ||
} |
17 changes: 17 additions & 0 deletions
17
src/main/java/com/crowdin/client/clients/model/Status.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.crowdin.client.clients.model; | ||
|
||
import com.crowdin.client.core.model.EnumConverter; | ||
|
||
public enum Status implements EnumConverter<Status> { | ||
|
||
PENDING, CONFIRMED, REJECTED; | ||
|
||
public static Status from(String value) { | ||
return Status.valueOf(value.toUpperCase()); | ||
} | ||
|
||
@Override | ||
public String to(Status v) { | ||
return v.name().toLowerCase(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.