aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketApiClient.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketApiClient.java')
-rwxr-xr-x[-rw-r--r--]src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketApiClient.java25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketApiClient.java b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketApiClient.java
index b6d3155..71fc861 100644..100755
--- a/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketApiClient.java
+++ b/src/main/java/bitbucketpullrequestbuilder/bitbucketpullrequestbuilder/bitbucket/BitbucketApiClient.java
@@ -80,6 +80,22 @@ public class BitbucketApiClient {
return null;
}
+ public void deletePullRequestApproval(String pullRequestId) {
+ String path = V2_API_BASE_URL + this.owner + "/" + this.repositoryName + "/pullrequests/" + pullRequestId + "/approve";
+ deleteRequest(path);
+ }
+
+ public BitbucketPullRequestApproval postPullRequestApproval(String pullRequestId) {
+ String path = V2_API_BASE_URL + this.owner + "/" + this.repositoryName + "/pullrequests/" + pullRequestId + "/approve";
+ try {
+ String response = postRequest(path, new NameValuePair[]{});
+ return parseApprovalJson(response);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return null;
+ }
+
private HttpClient getHttpClient() {
HttpClient client = new HttpClient();
if (Jenkins.getInstance() != null) {
@@ -175,5 +191,14 @@ public class BitbucketApiClient {
BitbucketPullRequestComment.class);
return parsedResponse;
}
+
+ private BitbucketPullRequestApproval parseApprovalJson(String response) throws IOException {
+ ObjectMapper mapper = new ObjectMapper();
+ BitbucketPullRequestApproval parsedResponse;
+ parsedResponse = mapper.readValue(
+ response,
+ BitbucketPullRequestApproval.class);
+ return parsedResponse;
+ }
}