Skip to content

Commit

Permalink
Add the "internal" flag to NotesApi
Browse files Browse the repository at this point in the history
  • Loading branch information
hannibal218bc committed Sep 8, 2023
1 parent 2d9a588 commit 65da884
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
22 changes: 20 additions & 2 deletions src/main/java/org/gitlab4j/api/NotesApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public Note getIssueNote(Object projectIdOrPath, Long issueIid, Long noteId) thr
* @throws GitLabApiException if any exception occurs
*/
public Note createIssueNote(Object projectIdOrPath, Long issueIid, String body) throws GitLabApiException {
return (createIssueNote(projectIdOrPath, issueIid, body, null));
return (createIssueNote(projectIdOrPath, issueIid, body, null, false));
}

/**
Expand All @@ -166,10 +166,28 @@ public Note createIssueNote(Object projectIdOrPath, Long issueIid, String body)
* @throws GitLabApiException if any exception occurs
*/
public Note createIssueNote(Object projectIdOrPath, Long issueIid, String body, Date createdAt) throws GitLabApiException {
return (createIssueNote(projectIdOrPath, issueIid, body, null, false)); }

/**
* Create a issues's note.
*
* @param projectIdOrPath the project in the form of an Long(ID), String(path), or Project instance
* @param issueIid the issue IID to create the notes for
* @param body the content of note
* @param createdAt the created time of note
* @param internal whether the note shall be marked 'internal'
* @return the created Note instance
* @throws GitLabApiException if any exception occurs
*/
public Note createIssueNote(Object projectIdOrPath, Long issueIid, String body, Date createdAt, boolean internal) throws GitLabApiException {

GitLabApiForm formData = new GitLabApiForm()
.withParam("body", body, true)
.withParam("created_at", createdAt);
.withParam("created_at", createdAt)
;
if (internal) {
formData.withParam("internal", "true");
}
Response response = post(Response.Status.CREATED, formData,
"projects", getProjectIdOrPath(projectIdOrPath), "issues", issueIid, "notes");
return (response.readEntity(Note.class));
Expand Down
11 changes: 10 additions & 1 deletion src/main/java/org/gitlab4j/api/models/Note.java
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ public String toString() {
private Boolean resolvable;
private Participant resolvedBy;
private Date resolvedAt;
private Boolean internal;
private Type type;

private Position position;
Expand Down Expand Up @@ -270,7 +271,15 @@ public void setPosition(Position position) {
this.position = position;
}

@Override
public Boolean getInternal() {
return internal;
}

public void setInternal(Boolean internal) {
this.internal = internal;
}

@Override
public String toString() {
return (JacksonJson.toJsonString(this));
}
Expand Down

0 comments on commit 65da884

Please sign in to comment.