module Network.GitHub.Types
( Organisation(..)
, OrgLogin
, Team(..)
, TeamId
, Member(..)
, MemberId
, Repository(..)
, RepositoryName
)
where
import Control.Monad
import Data.Aeson
import Data.Text
data Organisation = Organisation
{ orgLogin :: OrgLogin
, orgId :: Int
, orgDescription :: Maybe Text
} deriving (Eq, Show)
type OrgLogin = Text
instance FromJSON Organisation where
parseJSON (Object o) =
Organisation <$> o .: "login"
<*> o .: "id"
<*> o .: "description"
parseJSON _ = mzero
data Team = Team
{ teamId :: TeamId
, teamName :: Text
, teamDescription :: Maybe Text
, teamPermission :: Maybe Text
} deriving (Eq, Show)
type TeamId = Integer
instance FromJSON Team where
parseJSON (Object o) =
Team <$> o .: "id"
<*> o .: "name"
<*> o .: "description"
<*> o .: "permission"
parseJSON _ = mzero
data Member = Member
{ memberId :: MemberId
, memberLogin :: Text
} deriving (Eq, Show)
type MemberId = Integer
instance FromJSON Member where
parseJSON (Object o) =
Member <$> o .: "id"
<*> o .: "login"
parseJSON _ = mzero
data Repository = Repository
{ repositoryName :: RepositoryName
, repositoryDescription :: Maybe Text
, repositoryPrivate :: Bool
} deriving (Eq, Show)
type RepositoryName = Text
instance FromJSON Repository where
parseJSON (Object o) =
Repository <$> o .: "name"
<*> o .: "description"
<*> o .: "private"
parseJSON _ = mzero