From 8bb19193fd4ec92684651a2ff454593ddcafee86 Mon Sep 17 00:00:00 2001 From: Haskell-mouse Date: Thu, 31 Oct 2019 11:08:48 +0300 Subject: [PATCH] Added forkRepo function --- src/GitHub/Endpoints/Repos/Forks.hs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/GitHub/Endpoints/Repos/Forks.hs b/src/GitHub/Endpoints/Repos/Forks.hs index 5ca6ac14..7999c576 100644 --- a/src/GitHub/Endpoints/Repos/Forks.hs +++ b/src/GitHub/Endpoints/Repos/Forks.hs @@ -9,10 +9,13 @@ module GitHub.Endpoints.Repos.Forks ( forksFor, forksFor', forksForR, + forkRepo, + forkRepo', module GitHub.Data, ) where import GitHub.Data +import GitHub.Data.Name import GitHub.Internal.Prelude import GitHub.Request import Prelude () @@ -36,3 +39,15 @@ forksFor' auth user repo = forksForR :: Name Owner -> Name Repo -> FetchCount -> Request k (Vector Repo) forksForR user repo = pagedQuery ["repos", toPathPart user, toPathPart repo, "forks"] [] + +forkRepo :: Auth -> Name Owner -> Name Repo -> Maybe (Name Organization) -> IO (Either Error Repo) +forkRepo auth user repo mOrg = + executeRequest auth $ forkRepo' user repo mOrg + +forkRepo' :: Name Owner -> Name Repo -> Maybe (Name Organization) -> Request 'RW Repo +forkRepo' user repo mOrg = + let + makeOrg :: Maybe (Name Organization) -> Value + makeOrg Nothing = object [] + makeOrg (Just (N org)) = object ["organization" .= org ] + in command Post ["repos", toPathPart user, toPathPart repo, "forks"] (encode $ makeOrg mOrg)