From f1dc4decc87f21e87f2e40cd9a1b0acb95f62c9d Mon Sep 17 00:00:00 2001 From: Jacob Nguyen <76754747+jacoobes@users.noreply.github.com> Date: Tue, 6 Sep 2022 15:44:51 -0500 Subject: [PATCH] feat: update structures --- src/main/kotlin/structures/api/AutoMerge.kt | 4 +- src/main/kotlin/structures/api/PullRequest.kt | 11 ++-- .../kotlin/structures/api/PullRequests.kt | 4 +- .../api/application/PullRequestAction.kt | 53 +++++++++++++++++++ .../wrapped/{PRManager.kt => PullRequests.kt} | 0 5 files changed, 66 insertions(+), 6 deletions(-) create mode 100644 src/main/kotlin/structures/api/application/PullRequestAction.kt rename src/main/kotlin/structures/wrapped/{PRManager.kt => PullRequests.kt} (100%) diff --git a/src/main/kotlin/structures/api/AutoMerge.kt b/src/main/kotlin/structures/api/AutoMerge.kt index d13f1f6..2c5b39d 100644 --- a/src/main/kotlin/structures/api/AutoMerge.kt +++ b/src/main/kotlin/structures/api/AutoMerge.kt @@ -2,8 +2,8 @@ package structures.api @kotlinx.serialization.Serializable data class AutoMerge( - val commit_message: String, - val commit_title: String, + val commit_message: String?, + val commit_title: String?, val enabled_by: EnabledBy, val merge_method: String ) : Response() \ No newline at end of file diff --git a/src/main/kotlin/structures/api/PullRequest.kt b/src/main/kotlin/structures/api/PullRequest.kt index fa5731d..aab1173 100644 --- a/src/main/kotlin/structures/api/PullRequest.kt +++ b/src/main/kotlin/structures/api/PullRequest.kt @@ -30,16 +30,16 @@ data class PullRequest( val locked: Boolean, val maintainer_can_modify: Boolean, val merge_commit_sha: String, - val mergeable: Boolean, + val mergeable: Boolean?, val mergeable_state: String, val merged: Boolean, val merged_at: String?, - val merged_by: String?, + val merged_by: MergedBy?, val milestone: Milestone?, val node_id: String, val number: Int, val patch_url: String, - val rebaseable: Boolean, + val rebaseable: Boolean?, val requested_reviewers: List, val requested_teams: List, val review_comment_url: String, @@ -51,4 +51,9 @@ data class PullRequest( val updated_at: String, val url: String, val user: User +) + +@kotlinx.serialization.Serializable +data class MergedBy( + val login : String ) \ No newline at end of file diff --git a/src/main/kotlin/structures/api/PullRequests.kt b/src/main/kotlin/structures/api/PullRequests.kt index f90996c..b264c11 100644 --- a/src/main/kotlin/structures/api/PullRequests.kt +++ b/src/main/kotlin/structures/api/PullRequests.kt @@ -1,8 +1,10 @@ package structures.api +import structures.api.application.PullRequestAction + @kotlinx.serialization.Serializable data class PullRequests( - val action: String, + val action: PullRequestAction, val label: Label, val number: Int, val organization: Organization, diff --git a/src/main/kotlin/structures/api/application/PullRequestAction.kt b/src/main/kotlin/structures/api/application/PullRequestAction.kt new file mode 100644 index 0000000..e5ad182 --- /dev/null +++ b/src/main/kotlin/structures/api/application/PullRequestAction.kt @@ -0,0 +1,53 @@ +package structures.api.application + +import kotlinx.serialization.SerialName + +@kotlinx.serialization.Serializable +enum class PullRequestAction { + @SerialName("assigned") + Assigned, + @SerialName("auto_merge_disabled") + AutoMergeDisabled, + /* + if the action is closed and the merged key is false, + the pull request was closed with unmerged commits. If the action is closed and the merged key is true, the pull request was merged. + */ + @SerialName("closed") + Closed, + @SerialName("converted_to_draft") + ConvertedToDraft, + @SerialName("edited") + Edited, + @SerialName("labeled") + Labeled, + @SerialName("locked") + Locked, + @SerialName("opened") + Opened, + @SerialName("ready_for_review") + ReadyForReview, + @SerialName("reopened") + Reopened, + @SerialName("review_request_removed") + ReviewRequestRemoved, + @SerialName("review_requested") + ReviewRequested, + + /** + * Triggered when a pull request's head branch is updated. + * For example, when the head branch is updated from the base branch, + * when new commits are pushed to the head branch, or when the base branch is changed. + */ + @SerialName("synchronize") + Sync, + @SerialName("unassigned") + Unassigned, + @SerialName("unlabeled") + Unlabeled, + @SerialName("unlocked") + Unlocked; + + override fun toString(): String { + return name + } +} diff --git a/src/main/kotlin/structures/wrapped/PRManager.kt b/src/main/kotlin/structures/wrapped/PullRequests.kt similarity index 100% rename from src/main/kotlin/structures/wrapped/PRManager.kt rename to src/main/kotlin/structures/wrapped/PullRequests.kt