This commit is contained in:
Christian Ulrich 2024-05-29 00:33:13 +02:00
parent c814c1a800
commit 49ba6d5976
No known key found for this signature in database
GPG Key ID: 8241BE099775A097
1 changed files with 9 additions and 10 deletions

View File

@ -166,22 +166,22 @@ listCards hostname username password boardId stackId =
in in
runReq defaultHttpConfig $ do runReq defaultHttpConfig $ do
response <- req GET url NoReqBody jsonResponse headers response <- req GET url NoReqBody jsonResponse headers
let let stack :: Stack = responseBody response
stack :: Stack = responseBody response
return $ fromMaybe [] stack.cards return $ fromMaybe [] stack.cards
createCard :: Text -> Text -> Text -> Word -> Word -> Text -> Text -> LocalTime -> Word -> IO () createCard :: Text -> Text -> Text -> Word -> Word -> Text -> Text -> LocalTime -> Word -> IO ()
createCard hostname username password boardId stackId title description date weeklyRepeats = do createCard hostname username password boardId stackId title description date weeklyRepeats = do
timezone <- getCurrentTimeZone timezone <- getCurrentTimeZone
let headers = authHeaders username password
let url = baseUrl hostname /: "boards" /: T.pack (show boardId) /: "stacks" /: T.pack (show stackId) /: "cards"
let (_, dayOfYear) = toOrdinalDate date.localDay
let (year, month, day) = toGregorian date.localDay
let let
headers = authHeaders username password
url = baseUrl hostname /: "boards" /: T.pack (show boardId) /: "stacks" /: T.pack (show stackId) /: "cards"
(_, dayOfYear) = toOrdinalDate date.localDay
(year, month, day) = toGregorian date.localDay
expandedTitle = expandedTitle =
T.replace "%YY" (T.pack $ show year) T.replace "%YY" (T.pack $ show year)
$ T.replace "%MM" (T.pack $ show month) $ T.replace "%MM" (T.pack $ show month)
$ T.replace "%DD" (T.pack $ show day) title $ T.replace "%DD" (T.pack $ show day) title
let
body = body =
object object
[ "title" .= expandedTitle [ "title" .= expandedTitle
@ -193,8 +193,7 @@ createCard hostname username password boardId stackId title description date wee
runReq defaultHttpConfig $ do runReq defaultHttpConfig $ do
_ <- req POST url (ReqBodyJson body) ignoreResponse headers _ <- req POST url (ReqBodyJson body) ignoreResponse headers
when (weeklyRepeats > 0) $ do when (weeklyRepeats > 0) $ do
let let repeats = weeklyRepeats - 1
repeats = weeklyRepeats - 1 let oneWeek = 604800
oneWeek = 604800 let nextDate = addLocalTime oneWeek date
nextDate = addLocalTime oneWeek date
liftIO $ createCard hostname username password boardId stackId title description nextDate repeats liftIO $ createCard hostname username password boardId stackId title description nextDate repeats