diff --git a/github-tools.cabal b/github-tools.cabal index 04f1f13..89af81c 100644 --- a/github-tools.cabal +++ b/github-tools.cabal @@ -66,6 +66,7 @@ library GitHub.Types.Base.PullRequestLinks GitHub.Types.Base.PullRequestRef GitHub.Types.Base.PushCommit + GitHub.Types.Base.Reactions GitHub.Types.Base.Release GitHub.Types.Base.RepoOwner GitHub.Types.Base.Repository diff --git a/src/GitHub/Types/Base.hs b/src/GitHub/Types/Base.hs index 40a53b8..95c369a 100644 --- a/src/GitHub/Types/Base.hs +++ b/src/GitHub/Types/Base.hs @@ -6,7 +6,10 @@ import GitHub.Types.Base.Change as X import GitHub.Types.Base.Changes as X import GitHub.Types.Base.CheckApp as X import GitHub.Types.Base.CheckCommit as X +import GitHub.Types.Base.CheckCommitRef as X +import GitHub.Types.Base.CheckCommitRepo as X import GitHub.Types.Base.CheckOutput as X +import GitHub.Types.Base.CheckPullRequest as X import GitHub.Types.Base.CheckRun as X import GitHub.Types.Base.CheckSuite as X import GitHub.Types.Base.Commit as X @@ -16,6 +19,7 @@ import GitHub.Types.Base.CommitRef as X import GitHub.Types.Base.CommitRefHtml as X import GitHub.Types.Base.DateTime as X import GitHub.Types.Base.Deployment as X +import GitHub.Types.Base.DeploymentPayload as X import GitHub.Types.Base.DeploymentStatus as X import GitHub.Types.Base.Hook as X import GitHub.Types.Base.HookConfig as X @@ -24,16 +28,19 @@ import GitHub.Types.Base.Invitation as X import GitHub.Types.Base.Issue as X import GitHub.Types.Base.IssueComment as X import GitHub.Types.Base.Label as X +import GitHub.Types.Base.License as X import GitHub.Types.Base.Link as X import GitHub.Types.Base.Membership as X import GitHub.Types.Base.Milestone as X import GitHub.Types.Base.Organization as X import GitHub.Types.Base.PageBuild as X import GitHub.Types.Base.PageBuildError as X +import GitHub.Types.Base.Permissions as X import GitHub.Types.Base.PullRequest as X import GitHub.Types.Base.PullRequestLinks as X import GitHub.Types.Base.PullRequestRef as X import GitHub.Types.Base.PushCommit as X +import GitHub.Types.Base.Reactions as X import GitHub.Types.Base.Release as X import GitHub.Types.Base.RepoOwner as X import GitHub.Types.Base.Repository as X @@ -42,11 +49,14 @@ import GitHub.Types.Base.ReviewComment as X import GitHub.Types.Base.ReviewCommentLinks as X import GitHub.Types.Base.ReviewLinks as X import GitHub.Types.Base.SimplePullRequest as X +import GitHub.Types.Base.SimpleRepository as X import GitHub.Types.Base.StatusCommit as X import GitHub.Types.Base.Team as X import GitHub.Types.Base.User as X import GitHub.Types.Base.UserRef as X import GitHub.Types.Base.UserStamp as X +import GitHub.Types.Base.Verification as X import GitHub.Types.Base.Workflow as X import GitHub.Types.Base.WorkflowJob as X import GitHub.Types.Base.WorkflowRun as X +import GitHub.Types.Base.WorkflowStep as X diff --git a/src/GitHub/Types/Base/Issue.hs b/src/GitHub/Types/Base/Issue.hs index 60e1728..176ee6e 100644 --- a/src/GitHub/Types/Base/Issue.hs +++ b/src/GitHub/Types/Base/Issue.hs @@ -14,42 +14,49 @@ import GitHub.Types.Base.DateTime import GitHub.Types.Base.Label import GitHub.Types.Base.Milestone import GitHub.Types.Base.PullRequestRef +import GitHub.Types.Base.Reactions import GitHub.Types.Base.User ------------------------------------------------------------------------------ -- Issue data Issue = Issue - { issueAssignee :: Maybe User - , issueAssignees :: [User] - , issueAuthorAssociation :: Text - , issueBody :: Text - , issueClosedAt :: Maybe DateTime - , issueComments :: Int - , issueCommentsUrl :: Text - , issueCreatedAt :: DateTime - , issueEventsUrl :: Text - , issueHtmlUrl :: Text - , issueId :: Int - , issueLabels :: [Label] - , issueLabelsUrl :: Text - , issueLocked :: Bool - , issueMilestone :: Maybe Milestone - , issueNodeId :: Text - , issueNumber :: Int - , issuePullRequest :: Maybe PullRequestRef - , issueRepositoryUrl :: Text - , issueState :: Text - , issueTitle :: Text - , issueUpdatedAt :: DateTime - , issueUrl :: Text - , issueUser :: User + { issueActiveLockReason :: Maybe Text + , issueAssignee :: Maybe User + , issueAssignees :: [User] + , issueAuthorAssociation :: Text + , issueBody :: Text + , issueClosedAt :: Maybe DateTime + , issueComments :: Int + , issueCommentsUrl :: Text + , issueCreatedAt :: DateTime + , issueDraft :: Bool + , issueEventsUrl :: Text + , issueHtmlUrl :: Text + , issueId :: Int + , issueLabels :: [Label] + , issueLabelsUrl :: Text + , issueLocked :: Bool + , issueMilestone :: Maybe Milestone + , issueNodeId :: Text + , issueNumber :: Int + , issuePerformedViaGithubApp :: Maybe Text + , issuePullRequest :: Maybe PullRequestRef + , issueReactions :: Reactions + , issueRepositoryUrl :: Text + , issueState :: Text + , issueTimelineUrl :: Text + , issueTitle :: Text + , issueUpdatedAt :: DateTime + , issueUrl :: Text + , issueUser :: User } deriving (Eq, Show, Read) instance FromJSON Issue where parseJSON (Object x) = Issue - <$> x .: "assignee" + <$> x .: "active_lock_reason" + <*> x .: "assignee" <*> x .: "assignees" <*> x .: "author_association" <*> x .: "body" @@ -57,6 +64,7 @@ instance FromJSON Issue where <*> x .: "comments" <*> x .: "comments_url" <*> x .: "created_at" + <*> x .: "draft" <*> x .: "events_url" <*> x .: "html_url" <*> x .: "id" @@ -66,9 +74,12 @@ instance FromJSON Issue where <*> x .: "milestone" <*> x .: "node_id" <*> x .: "number" + <*> x .: "performed_via_github_app" <*> x .:? "pull_request" + <*> x .: "reactions" <*> x .: "repository_url" <*> x .: "state" + <*> x .: "timeline_url" <*> x .: "title" <*> x .: "updated_at" <*> x .: "url" @@ -79,30 +90,35 @@ instance FromJSON Issue where instance ToJSON Issue where toJSON Issue{..} = object - [ "assignee" .= issueAssignee - , "assignees" .= issueAssignees - , "author_association" .= issueAuthorAssociation - , "body" .= issueBody - , "closed_at" .= issueClosedAt - , "comments" .= issueComments - , "comments_url" .= issueCommentsUrl - , "created_at" .= issueCreatedAt - , "events_url" .= issueEventsUrl - , "html_url" .= issueHtmlUrl - , "id" .= issueId - , "labels" .= issueLabels - , "labels_url" .= issueLabelsUrl - , "locked" .= issueLocked - , "milestone" .= issueMilestone - , "node_id" .= issueNodeId - , "number" .= issueNumber - , "pull_request" .= issuePullRequest - , "repository_url" .= issueRepositoryUrl - , "state" .= issueState - , "title" .= issueTitle - , "updated_at" .= issueUpdatedAt - , "url" .= issueUrl - , "user" .= issueUser + [ "active_lock_reason" .= issueActiveLockReason + , "assignee" .= issueAssignee + , "assignees" .= issueAssignees + , "author_association" .= issueAuthorAssociation + , "body" .= issueBody + , "closed_at" .= issueClosedAt + , "comments" .= issueComments + , "comments_url" .= issueCommentsUrl + , "created_at" .= issueCreatedAt + , "draft" .= issueDraft + , "events_url" .= issueEventsUrl + , "html_url" .= issueHtmlUrl + , "id" .= issueId + , "labels" .= issueLabels + , "labels_url" .= issueLabelsUrl + , "locked" .= issueLocked + , "milestone" .= issueMilestone + , "node_id" .= issueNodeId + , "number" .= issueNumber + , "performed_via_github_app" .= issuePerformedViaGithubApp + , "pull_request" .= issuePullRequest + , "reactions" .= issueReactions + , "repository_url" .= issueRepositoryUrl + , "state" .= issueState + , "timeline_url" .= issueTimelineUrl + , "title" .= issueTitle + , "updated_at" .= issueUpdatedAt + , "url" .= issueUrl + , "user" .= issueUser ] @@ -132,3 +148,8 @@ instance Arbitrary Issue where <*> arbitrary <*> arbitrary <*> arbitrary + <*> arbitrary + <*> arbitrary + <*> arbitrary + <*> arbitrary + <*> arbitrary diff --git a/src/GitHub/Types/Base/IssueComment.hs b/src/GitHub/Types/Base/IssueComment.hs index 9688943..9e46513 100644 --- a/src/GitHub/Types/Base/IssueComment.hs +++ b/src/GitHub/Types/Base/IssueComment.hs @@ -3,28 +3,32 @@ {-# LANGUAGE StrictData #-} module GitHub.Types.Base.IssueComment where -import Data.Aeson (FromJSON (..), ToJSON (..), object) -import Data.Aeson.Types (Value (..), (.:), (.=)) -import Data.Text (Text) -import Test.QuickCheck.Arbitrary (Arbitrary (..)) +import Data.Aeson (FromJSON (..), ToJSON (..), + object) +import Data.Aeson.Types (Value (..), (.:), (.=)) +import Data.Text (Text) +import Test.QuickCheck.Arbitrary (Arbitrary (..)) import GitHub.Types.Base.DateTime +import GitHub.Types.Base.Reactions import GitHub.Types.Base.User ------------------------------------------------------------------------------ -- IssueComment data IssueComment = IssueComment - { issueCommentAuthorAssociation :: Text - , issueCommentBody :: Text - , issueCommentCreatedAt :: DateTime - , issueCommentHtmlUrl :: Text - , issueCommentId :: Int - , issueCommentNodeId :: Text - , issueCommentIssueUrl :: Text - , issueCommentUpdatedAt :: DateTime - , issueCommentUrl :: Text - , issueCommentUser :: User + { issueCommentAuthorAssociation :: Text + , issueCommentBody :: Text + , issueCommentCreatedAt :: DateTime + , issueCommentHtmlUrl :: Text + , issueCommentId :: Int + , issueCommentNodeId :: Text + , issueCommentIssueUrl :: Text + , issueCommentPerformedViaGithubApp :: Maybe Bool + , issueCommentReactions :: Reactions + , issueCommentUpdatedAt :: DateTime + , issueCommentUrl :: Text + , issueCommentUser :: User } deriving (Eq, Show, Read) @@ -37,6 +41,8 @@ instance FromJSON IssueComment where <*> x .: "id" <*> x .: "node_id" <*> x .: "issue_url" + <*> x .: "performed_via_github_app" + <*> x .: "reactions" <*> x .: "updated_at" <*> x .: "url" <*> x .: "user" @@ -46,16 +52,18 @@ instance FromJSON IssueComment where instance ToJSON IssueComment where toJSON IssueComment{..} = object - [ "author_association" .= issueCommentAuthorAssociation - , "body" .= issueCommentBody - , "created_at" .= issueCommentCreatedAt - , "html_url" .= issueCommentHtmlUrl - , "id" .= issueCommentId - , "node_id" .= issueCommentNodeId - , "issue_url" .= issueCommentIssueUrl - , "updated_at" .= issueCommentUpdatedAt - , "url" .= issueCommentUrl - , "user" .= issueCommentUser + [ "author_association" .= issueCommentAuthorAssociation + , "body" .= issueCommentBody + , "created_at" .= issueCommentCreatedAt + , "html_url" .= issueCommentHtmlUrl + , "id" .= issueCommentId + , "node_id" .= issueCommentNodeId + , "issue_url" .= issueCommentIssueUrl + , "performed_via_github_app" .= issueCommentPerformedViaGithubApp + , "reactions" .= issueCommentReactions + , "updated_at" .= issueCommentUpdatedAt + , "url" .= issueCommentUrl + , "user" .= issueCommentUser ] @@ -71,3 +79,5 @@ instance Arbitrary IssueComment where <*> arbitrary <*> arbitrary <*> arbitrary + <*> arbitrary + <*> arbitrary diff --git a/src/GitHub/Types/Base/Reactions.hs b/src/GitHub/Types/Base/Reactions.hs new file mode 100644 index 0000000..0cb68ff --- /dev/null +++ b/src/GitHub/Types/Base/Reactions.hs @@ -0,0 +1,71 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE RecordWildCards #-} +{-# LANGUAGE StrictData #-} +module GitHub.Types.Base.Reactions where + +import Data.Aeson (FromJSON (..), ToJSON (..), object) +import Data.Aeson.Types (Value (..), (.:), (.=)) +import Data.Text (Text) +import Data.Text.Arbitrary () +import Test.QuickCheck.Arbitrary (Arbitrary (..)) + +------------------------------------------------------------------------------ +-- Reactions + +data Reactions = Reactions + { reactionsConfused :: Int + , reactionsEyes :: Int + , reactionsHeart :: Int + , reactionsHooray :: Int + , reactionsLaugh :: Int + , reactionsMinus1 :: Int + , reactionsPlus1 :: Int + , reactionsRocket :: Int + , reactionsTotalCount :: Int + , reactionsUrl :: Text + } deriving (Eq, Show, Read) + + +instance FromJSON Reactions where + parseJSON (Object x) = Reactions + <$> x .: "confused" + <*> x .: "eyes" + <*> x .: "heart" + <*> x .: "hooray" + <*> x .: "laugh" + <*> x .: "-1" + <*> x .: "+1" + <*> x .: "rocket" + <*> x .: "total_count" + <*> x .: "url" + + parseJSON _ = fail "Reactions" + + +instance ToJSON Reactions where + toJSON Reactions{..} = object + [ "confused" .= reactionsConfused + , "eyes" .= reactionsEyes + , "heart" .= reactionsHeart + , "hooray" .= reactionsHooray + , "laugh" .= reactionsLaugh + , "-1" .= reactionsMinus1 + , "+1" .= reactionsPlus1 + , "rocket" .= reactionsRocket + , "total_count" .= reactionsTotalCount + , "url" .= reactionsUrl + ] + + +instance Arbitrary Reactions where + arbitrary = Reactions + <$> arbitrary + <*> arbitrary + <*> arbitrary + <*> arbitrary + <*> arbitrary + <*> arbitrary + <*> arbitrary + <*> arbitrary + <*> arbitrary + <*> arbitrary