55module GitHub.Data.Statuses where
66
77import GitHub.Data.Definitions
8+ import GitHub.Data.Name (Name )
89import GitHub.Data.Id (Id )
910import GitHub.Data.URL (URL )
1011import GitHub.Internal.Prelude
1112import Prelude ()
1213
14+ import GitHub.Data.GitData (Commit )
15+ import GitHub.Data.Repos (RepoRef )
16+
17+
1318data StatusState
1419 = StatusPending
1520 | StatusSuccess
@@ -33,6 +38,7 @@ instance ToJSON StatusState where
3338 toJSON StatusError = String " error"
3439 toJSON StatusFailure = String " failure"
3540
41+
3642data Status = Status
3743 { statusCreatedAt :: ! UTCTime
3844 , statusUpdatedAt :: ! UTCTime
@@ -42,7 +48,7 @@ data Status = Status
4248 , statusId :: ! (Id Status )
4349 , statusUrl :: ! URL
4450 , statusContext :: ! (Maybe Text )
45- , statusCreator :: ! SimpleUser
51+ , statusCreator :: ! ( Maybe SimpleUser )
4652 }
4753 deriving (Show , Data , Typeable , Eq , Ord , Generic )
4854
@@ -56,7 +62,8 @@ instance FromJSON Status where
5662 <*> o .: " id"
5763 <*> o .: " url"
5864 <*> o .:? " context"
59- <*> o .: " creator"
65+ <*> o .:? " creator"
66+
6067
6168data NewStatus = NewStatus
6269 { newStatusState :: ! StatusState
@@ -79,3 +86,25 @@ instance ToJSON NewStatus where
7986 where
8087 notNull (_, Null ) = False
8188 notNull (_, _) = True
89+
90+
91+ data CombinedStatus = CombinedStatus
92+ { combinedStatusState :: ! StatusState
93+ , combinedStatusSha :: ! (Name Commit )
94+ , combinedStatusTotalCount :: ! Int
95+ , combinedStatusStatuses :: ! (Vector Status )
96+ , combinedStatusRepository :: ! RepoRef
97+ , combinedStatusCommitUrl :: ! URL
98+ , combinedStatusUrl :: ! URL
99+ }
100+ deriving (Show , Data , Typeable , Eq , Ord , Generic )
101+
102+ instance FromJSON CombinedStatus where
103+ parseJSON = withObject " CombinedStatus" $ \ o -> CombinedStatus
104+ <$> o .: " state"
105+ <*> o .: " sha"
106+ <*> o .: " total_count"
107+ <*> o .: " statuses"
108+ <*> o .: " repository"
109+ <*> o .: " commit_url"
110+ <*> o .: " url"
0 commit comments