github-types (empty) → 0.1.0.0
raw patch · 7 files changed
+188/−0 lines, 7 filesdep +aesondep +basedep +textsetup-changed
Dependencies added: aeson, base, text
Files
- LICENSE +0/−0
- Setup.hs +2/−0
- github-types.cabal +27/−0
- src/GitHub/Types.hs +10/−0
- src/GitHub/Types/Base.hs +50/−0
- src/GitHub/Types/Events.hs +73/−0
- src/GitHub/Types/Repository.hs +26/−0
+ LICENSE view
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ github-types.cabal view
@@ -0,0 +1,27 @@+name: github-types+version: 0.1.0.0+license: OtherLicense+license-file: LICENSE+author: Tomas Carnecky+maintainer: tomas.carnecky@gmail.com+category: GitHub+build-type: Simple+cabal-version: >= 1.10++synopsis: Type definitions for objects used by the GitHub v3 API+description: This package includes (some) type definitions for objects+ which are consumed or produced by the GitHub v3 API.+++library+ default-language: Haskell2010+ hs-source-dirs: src++ build-depends: aeson+ build-depends: base >= 4 && < 5+ build-depends: text++ exposed-modules: GitHub.Types+ exposed-modules: GitHub.Types.Base+ exposed-modules: GitHub.Types.Repository+ exposed-modules: GitHub.Types.Events
+ src/GitHub/Types.hs view
@@ -0,0 +1,10 @@+module GitHub.Types+ ( module GitHub.Types.Base+ , module GitHub.Types.Repository+ , module GitHub.Types.Events+ ) where+++import GitHub.Types.Base+import GitHub.Types.Repository+import GitHub.Types.Events
+ src/GitHub/Types/Base.hs view
@@ -0,0 +1,50 @@+{-# LANGUAGE OverloadedStrings #-}++module GitHub.Types.Base where+++import Control.Applicative+import Control.Monad++import Data.Aeson hiding (Error, Success)+import Data.Text++++------------------------------------------------------------------------------+-- Repository++data Repository = Repository+ { repositoryOwnerName :: Text+ , repositoryName :: Text+ } deriving (Eq, Show)+++instance FromJSON Repository where+ parseJSON (Object x) = Repository+ <$> (x .: "owner" >>= (.: "login"))+ <*> x .: "name"++ parseJSON _ = mzero++++------------------------------------------------------------------------------+-- State++data State = Pending | Success | Failure | Error+ deriving (Eq, Show)+++instance FromJSON State where+ parseJSON (String "pending") = return Pending+ parseJSON (String "success") = return Success+ parseJSON (String "failure") = return Failure+ parseJSON (String "error") = return Error+ parseJSON _ = mzero++instance ToJSON State where+ toJSON Pending = String "pending"+ toJSON Success = String "success"+ toJSON Failure = String "failure"+ toJSON Error = String "error"
+ src/GitHub/Types/Events.hs view
@@ -0,0 +1,73 @@+{-# LANGUAGE OverloadedStrings #-}++module GitHub.Types.Events where+++import Control.Applicative+import Control.Monad++import Data.Aeson+import Data.Text++import GitHub.Types.Base++++data Event+ = CommitCommentEventType CommitCommentEvent+ | DeploymentEventType DeploymentEvent+ | DeploymentStatusEventType DeploymentStatusEvent+ deriving (Eq, Show)++++------------------------------------------------------------------------------+-- CommitCommentEvent++data CommitCommentEvent = CommitCommentEvent+ { commitCommentEventRepository :: Repository+ } deriving (Eq, Show)+++------------------------------------------------------------------------------+-- DeploymentEvent++data DeploymentEvent = DeploymentEvent+ { deploymentEventId :: Int+ -- ^ The deployment Id (UNDOCUMENTED).+ , deploymentEventSha :: Text+ -- The commit SHA for which this deployment was created.+ , deploymentEventName :: Text+ -- ^ Name of repository for this deployment, formatted as :owner/:repo.+ , deploymentEventPayload :: Value+ -- ^ The optional extra information for this deployment.+ , deploymentEventEnvironment :: Text+ -- ^ The optional environment to deploy to. Default: "production"+ , deploymentEventDescription :: Maybe Text+ -- ^ The optional human-readable description added to the deployment.+ , deploymentEventRepository :: Repository+ -- ^ The repository for which the deployment was created (UNDOCUMENTED).+ } deriving (Eq, Show)++instance FromJSON DeploymentEvent where+ parseJSON (Object x) = DeploymentEvent+ <$> x .: "id"+ <*> x .: "sha"+ <*> x .: "name"+ <*> x .: "payload"+ <*> x .: "environment"+ <*> x .: "description"+ <*> x .: "repository"++ parseJSON _ = mzero+++------------------------------------------------------------------------------+-- DeploymentStatusEvent++data DeploymentStatusEvent = DeploymentStatusEvent+ { deploymentStatusEventState :: State+ , deploymentStatusEventTargetUrl :: Text+ , deploymentStatusEventDeployment :: Text+ , deploymentStatusEventDescription :: Text+ } deriving (Eq, Show)
+ src/GitHub/Types/Repository.hs view
@@ -0,0 +1,26 @@+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE RecordWildCards #-}++module GitHub.Types.Repository where+++import Data.Aeson+import Data.Text++import GitHub.Types.Base++++data CreateDeploymentStatusRequest = CreateDeploymentStatusRequest+ { cdsState :: State+ , cdsTargetUrl :: Maybe Text+ , cdsDescription :: Maybe Text+ } deriving (Eq, Show)+++instance ToJSON CreateDeploymentStatusRequest where+ toJSON CreateDeploymentStatusRequest{..} = object+ [ "state" .= cdsState+ , "target_url" .= cdsTargetUrl+ , "description" .= cdsDescription+ ]