|
| 1 | +package com.crowdin.client.branches; |
| 2 | + |
| 3 | +import com.crowdin.client.branches.model.*; |
| 4 | +import com.crowdin.client.core.CrowdinApi; |
| 5 | +import com.crowdin.client.core.http.HttpRequestConfig; |
| 6 | +import com.crowdin.client.core.http.exceptions.HttpBadRequestException; |
| 7 | +import com.crowdin.client.core.http.exceptions.HttpException; |
| 8 | +import com.crowdin.client.core.model.ClientConfig; |
| 9 | +import com.crowdin.client.core.model.Credentials; |
| 10 | +import com.crowdin.client.core.model.ResponseObject; |
| 11 | + |
| 12 | +public class BranchesApi extends CrowdinApi { |
| 13 | + |
| 14 | + public BranchesApi(Credentials credentials) { |
| 15 | + super(credentials); |
| 16 | + } |
| 17 | + |
| 18 | + public BranchesApi(Credentials credentials, ClientConfig clientConfig) { |
| 19 | + super(credentials, clientConfig); |
| 20 | + } |
| 21 | + |
| 22 | + /** |
| 23 | + * @param projectId project identifier |
| 24 | + * @param branchId branch identifier |
| 25 | + * @param request request object |
| 26 | + * @return clone status |
| 27 | + * @see <ul> |
| 28 | + * <li><a href="https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.branches.clones.post" target="_blank"><b>API Documentation</b></a></li> |
| 29 | + * </ul> |
| 30 | + */ |
| 31 | + public ResponseObject<BranchCloneStatus> cloneBranch(Long projectId, Long branchId, CloneBranchRequest request) throws HttpException, HttpBadRequestException { |
| 32 | + BranchCloneStatusResponseObject branchResponseObject = this.httpClient.post(this.url + "/projects/" + projectId + "/branches/" + branchId + "/clones", request, new HttpRequestConfig(), BranchCloneStatusResponseObject.class); |
| 33 | + return ResponseObject.of(branchResponseObject.getData()); |
| 34 | + } |
| 35 | + |
| 36 | + /** |
| 37 | + * @param projectId project identifier |
| 38 | + * @param branchId branch identifier |
| 39 | + * @param cloneId clone identifier |
| 40 | + * @return clone status |
| 41 | + * @see <ul> |
| 42 | + * <li><a href="https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.branches.clones.get" target="_blank"><b>API Documentation</b></a></li> |
| 43 | + * </ul> |
| 44 | + */ |
| 45 | + public ResponseObject<BranchCloneStatus> checkCloneBranchStatus(Long projectId, Long branchId, String cloneId) throws HttpException, HttpBadRequestException { |
| 46 | + BranchCloneStatusResponseObject branchResponseObject = this.httpClient.get(this.url + "/projects/" + projectId + "/branches/" + branchId + "/clones/" + cloneId, new HttpRequestConfig(), BranchCloneStatusResponseObject.class); |
| 47 | + return ResponseObject.of(branchResponseObject.getData()); |
| 48 | + } |
| 49 | + |
| 50 | + /** |
| 51 | + * @param projectId project identifier |
| 52 | + * @param branchId branch identifier |
| 53 | + * @param cloneId clone identifier |
| 54 | + * @return cloned branch |
| 55 | + * @see <ul> |
| 56 | + * <li><a href="https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.branches.clones.branch.get" target="_blank"><b>API Documentation</b></a></li> |
| 57 | + * </ul> |
| 58 | + */ |
| 59 | + public ResponseObject<ClonedBranch> getClonedBranch(Long projectId, Long branchId, String cloneId) throws HttpException, HttpBadRequestException { |
| 60 | + ClonedBranchResponseObject branchResponseObject = this.httpClient.get(this.url + "/projects/" + projectId + "/branches/" + branchId + "/clones/" + cloneId + "/branch", new HttpRequestConfig(), ClonedBranchResponseObject.class); |
| 61 | + return ResponseObject.of(branchResponseObject.getData()); |
| 62 | + } |
| 63 | + |
| 64 | + /** |
| 65 | + * @param projectId project identifier |
| 66 | + * @param branchId branch identifier |
| 67 | + * @param request request object |
| 68 | + * @return merge status |
| 69 | + * @see <ul> |
| 70 | + * <li><a href="https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.branches.merges.post" target="_blank"><b>API Documentation</b></a></li> |
| 71 | + * </ul> |
| 72 | + */ |
| 73 | + public ResponseObject<BranchMergeStatus> mergeBranch(Long projectId, Long branchId, MergeBranchRequest request) throws HttpException, HttpBadRequestException { |
| 74 | + BranchMergeStatusResponseObject branchResponseObject = this.httpClient.post(this.url + "/projects/" + projectId + "/branches/" + branchId + "/merges", request, new HttpRequestConfig(), BranchMergeStatusResponseObject.class); |
| 75 | + return ResponseObject.of(branchResponseObject.getData()); |
| 76 | + } |
| 77 | + |
| 78 | + /** |
| 79 | + * @param projectId project identifier |
| 80 | + * @param branchId branch identifier |
| 81 | + * @param mergeId merge identifier |
| 82 | + * @return merge status |
| 83 | + * @see <ul> |
| 84 | + * <li><a href="https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.branches.clones.get" target="_blank"><b>API Documentation</b></a></li> |
| 85 | + * </ul> |
| 86 | + */ |
| 87 | + public ResponseObject<BranchMergeStatus> checkMergeBranchStatus(Long projectId, Long branchId, String mergeId) throws HttpException, HttpBadRequestException { |
| 88 | + BranchMergeStatusResponseObject branchResponseObject = this.httpClient.get(this.url + "/projects/" + projectId + "/branches/" + branchId + "/merges/" + mergeId, new HttpRequestConfig(), BranchMergeStatusResponseObject.class); |
| 89 | + return ResponseObject.of(branchResponseObject.getData()); |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * @param projectId project identifier |
| 94 | + * @param branchId branch identifier |
| 95 | + * @param mergeId merge identifier |
| 96 | + * @return merge summary |
| 97 | + * @see <ul> |
| 98 | + * <li><a href="https://developer.crowdin.com/api/v2/string-based/#operation/api.projects.branches.merges.summary.get" target="_blank"><b>API Documentation</b></a></li> |
| 99 | + * </ul> |
| 100 | + */ |
| 101 | + public ResponseObject<BranchMergeSummary> getMergeBranchSummary(Long projectId, Long branchId, String mergeId) throws HttpException, HttpBadRequestException { |
| 102 | + BranchMergeSummaryResponseObject branchResponseObject = this.httpClient.get(this.url + "/projects/" + projectId + "/branches/" + branchId + "/merges/" + mergeId + "/summary", new HttpRequestConfig(), BranchMergeSummaryResponseObject.class); |
| 103 | + return ResponseObject.of(branchResponseObject.getData()); |
| 104 | + } |
| 105 | +} |
0 commit comments