{-# LANGUAGE OverloadedStrings #-}
module GitLab.API.Notes where
import qualified Data.ByteString.Lazy as BSL
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.Text.Encoding as T
import GitLab.Types
import GitLab.WebRequests.GitLabWebCalls
import Network.HTTP.Client
createMergeRequestNote ::
Project ->
Int ->
Text ->
GitLab (Either (Response BSL.ByteString) (Maybe ()))
createMergeRequestNote :: Project
-> Int -> Text -> GitLab (Either (Response ByteString) (Maybe ()))
createMergeRequestNote Project
project =
Int
-> Int -> Text -> GitLab (Either (Response ByteString) (Maybe ()))
createMergeRequestNote' (Project -> Int
project_id Project
project)
createMergeRequestNote' ::
Int ->
Int ->
Text ->
GitLab (Either (Response BSL.ByteString) (Maybe ()))
createMergeRequestNote' :: Int
-> Int -> Text -> GitLab (Either (Response ByteString) (Maybe ()))
createMergeRequestNote' Int
projectId Int
mergeRequestIID Text
comment =
Text
-> [GitLabParam]
-> GitLab (Either (Response ByteString) (Maybe ()))
forall a.
FromJSON a =>
Text
-> [GitLabParam] -> GitLab (Either (Response ByteString) (Maybe a))
gitlabPost Text
addr [GitLabParam]
params
where
params :: [GitLabParam]
params :: [GitLabParam]
params =
[ (ByteString
"id", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 (String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
projectId)))),
(ByteString
"merge_request_iid", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 (String -> Text
T.pack (Int -> String
forall a. Show a => a -> String
show Int
mergeRequestIID)))),
(ByteString
"body", ByteString -> Maybe ByteString
forall a. a -> Maybe a
Just (Text -> ByteString
T.encodeUtf8 Text
comment))
]
addr :: Text
addr =
String -> Text
T.pack (String -> Text) -> String -> Text
forall a b. (a -> b) -> a -> b
$
String
"/projects/" String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
projectId String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/merge_requests/"
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> Int -> String
forall a. Show a => a -> String
show Int
mergeRequestIID
String -> String -> String
forall a. Semigroup a => a -> a -> a
<> String
"/notes"