Skip to content

Commit 8401949

Browse files
committed
Add methods to the BitbucketAuthenticatedClient to avoid consumer of API to configure a JSON parser
1 parent aee8f05 commit 8401949

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

src/main/java/com/cloudbees/jenkins/plugins/bitbucket/api/BitbucketAuthenticatedClient.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
*/
2424
package com.cloudbees.jenkins.plugins.bitbucket.api;
2525

26+
import com.cloudbees.jenkins.plugins.bitbucket.impl.util.JsonParser;
2627
import edu.umd.cs.findbugs.annotations.CheckForNull;
2728
import edu.umd.cs.findbugs.annotations.NonNull;
2829
import java.io.IOException;
@@ -60,7 +61,11 @@ public interface BitbucketAuthenticatedClient extends AutoCloseable {
6061
* @return the JSON string of the response
6162
* @throws IOException in case of connection failures
6263
*/
63-
String post(@NonNull String path, @CheckForNull String payload) throws IOException;
64+
String post(@NonNull String path, @NonNull String payload) throws IOException;
65+
66+
default String post(@NonNull String path, @NonNull Object payload) throws IOException {
67+
return post(path, JsonParser.toString(payload));
68+
}
6469

6570
/**
6671
* Perform an HTTP PUT to the configured endpoint.
@@ -72,7 +77,11 @@ public interface BitbucketAuthenticatedClient extends AutoCloseable {
7277
* @return the JSON string of the response
7378
* @throws IOException in case of connection failures
7479
*/
75-
String put(@NonNull String path, @CheckForNull String payload) throws IOException;
80+
String put(@NonNull String path, @NonNull String payload) throws IOException;
81+
82+
default String put(@NonNull String path, @NonNull Object payload) throws IOException {
83+
return put(path, JsonParser.toString(payload));
84+
}
7685

7786
/**
7887
* Perform an HTTP DELETE to the configured endpoint.

0 commit comments

Comments
 (0)