Commit f1ada2c2 authored by Greg Messner's avatar Greg Messner
Browse files

position parameter is now optional for createMergeRequestDiscussion() (#458).

parent 1fd1972f
...@@ -309,15 +309,13 @@ public class DiscussionsApi extends AbstractApi { ...@@ -309,15 +309,13 @@ public class DiscussionsApi extends AbstractApi {
public Discussion createMergeRequestDiscussion(Object projectIdOrPath, Integer mergeRequestIid, public Discussion createMergeRequestDiscussion(Object projectIdOrPath, Integer mergeRequestIid,
String body, Date createdAt, String positionHash, Position position) throws GitLabApiException { String body, Date createdAt, String positionHash, Position position) throws GitLabApiException {
if (position == null) {
throw new GitLabApiException("position instance can not be null");
}
GitLabApiForm formData = new GitLabApiForm() GitLabApiForm formData = new GitLabApiForm()
.withParam("body", body, true) .withParam("body", body, true)
.withParam("created_at", createdAt) .withParam("created_at", createdAt)
.withParam("position", positionHash) .withParam("position", positionHash);
.withParam("position[base_sha]", position.getBaseSha(), true)
if (position != null) {
formData.withParam("position[base_sha]", position.getBaseSha(), true)
.withParam("position[start_sha]", position.getStartSha(), true) .withParam("position[start_sha]", position.getStartSha(), true)
.withParam("position[head_sha]", position.getHeadSha(), true) .withParam("position[head_sha]", position.getHeadSha(), true)
.withParam("position[position_type]", position.getPositionType(), true) .withParam("position[position_type]", position.getPositionType(), true)
...@@ -329,6 +327,7 @@ public class DiscussionsApi extends AbstractApi { ...@@ -329,6 +327,7 @@ public class DiscussionsApi extends AbstractApi {
.withParam("position[height]", position.getHeight()) .withParam("position[height]", position.getHeight())
.withParam("position[x]", position.getX()) .withParam("position[x]", position.getX())
.withParam("position[y]", position.getY()); .withParam("position[y]", position.getY());
}
Response response = post(Response.Status.CREATED, formData, Response response = post(Response.Status.CREATED, formData,
"projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "discussions"); "projects", getProjectIdOrPath(projectIdOrPath), "merge_requests", mergeRequestIid, "discussions");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment