Permalink
Browse files

user API completed, repo API started

  • Loading branch information...
1 parent 44b504b commit 42f41271a989b947d9ca81395863606d2ffaa2f1 @dmnpignaud committed Oct 9, 2011
Showing with 91 additions and 0 deletions.
  1. +80 −0 GitHub/Data.hs
  2. +11 −0 GitHubRepos.hs
View
@@ -0,0 +1,80 @@
+module GitHub.Data
+ (
+ GitHubUser(..)
+ , GitHubRepo(..)
+ , GitHubKey(..)
+ ) where
+
+
+
+import Data.Time
+import System.Locale
+
+type Url = String
+type UserName = String
+
+data GitHubUser = GHUser {
+ login :: UserName,
+ user_name :: String,
+ user_id ::Int,
+ avatarUrl :: Url,
+ user_url :: Url,
+ company :: String,
+ blog :: Url,
+ location :: String,
+ email :: String,
+ hireable :: Bool,
+ bio :: String,
+ publicRepos :: Int,
+ publicGists :: Int,
+ followers :: Int,
+ following :: Int,
+ user_htmlUrl :: Url,
+ user_createdAt :: UTCTime,
+ user_type :: String -- TODO : maybe it should be an enum
+} deriving (Show)
+
+data GitHubPrivUser = GHPrivUser{
+ totalPrivateRepos :: Int,
+ ownedPrivateRepos :: Int,
+ privateGists :: Int,
+ diskUsage :: Int,
+ collaborators :: Int,
+ planName :: String,
+ planSpace :: Int,
+ planCollaborators :: Int,
+ planPrivateRepos :: Int
+ }
+data GitHubRepo = GHRepo {
+ updatedAt :: UTCTime,
+ pushedAt :: UTCTime,
+ forks :: Int,
+ cloneUrl :: Url,
+ repo_createdAt ::UTCTime,
+ description :: String,
+ svnUrl :: Url,
+ htmlUrl :: Url,
+ masterBranch :: String, -- coming soon : GitHubBranch
+ fork :: Bool,
+ sshUrl :: Url,
+ openIssues :: Int,
+ language :: String,
+ private :: Bool,
+ size :: Int,
+ owner :: GitHubUser,
+ homepage :: String,
+ repo_name :: String,
+ repoGitUrl :: Url,
+ watchers :: Int,
+ repo_id :: Int,
+ repo_url :: Url
+ } deriving (Show)
+
+data GitHubKey = GHKey {
+ key :: String,
+ title :: String,
+ key_id :: Int
+ } deriving (Show)
+
+
+
View
@@ -0,0 +1,11 @@
+module GitHubRepos where
+
+import Control.Monad (liftM)
+import GitHubGeneral
+import GitHub.Data(GitHubRepo)
+import JsonParsing
+
+-- List repositories for the authenticated user
+getMyRepos :: AuthTuple -> IO (ParsEither [GitHubRepo])--[String]
+getMyRepos auth = liftM jsonToRepos
+ (request "user/repos" [auth])

0 comments on commit 42f4127

Please sign in to comment.