diff --git a/src/NCDeck.hs b/src/NCDeck.hs index 55750a9..276e6a8 100644 --- a/src/NCDeck.hs +++ b/src/NCDeck.hs @@ -166,22 +166,22 @@ listCards hostname username password boardId stackId = in runReq defaultHttpConfig $ do response <- req GET url NoReqBody jsonResponse headers - let - stack :: Stack = responseBody response + let stack :: Stack = responseBody response return $ fromMaybe [] stack.cards createCard :: Text -> Text -> Text -> Word -> Word -> Text -> Text -> LocalTime -> Word -> IO () createCard hostname username password boardId stackId title description date weeklyRepeats = do 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 - 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 = T.replace "%YY" (T.pack $ show year) $ T.replace "%MM" (T.pack $ show month) $ T.replace "%DD" (T.pack $ show day) title + let body = object [ "title" .= expandedTitle @@ -193,8 +193,7 @@ createCard hostname username password boardId stackId title description date wee runReq defaultHttpConfig $ do _ <- req POST url (ReqBodyJson body) ignoreResponse headers when (weeklyRepeats > 0) $ do - let - repeats = weeklyRepeats - 1 - oneWeek = 604800 - nextDate = addLocalTime oneWeek date + let repeats = weeklyRepeats - 1 + let oneWeek = 604800 + let nextDate = addLocalTime oneWeek date liftIO $ createCard hostname username password boardId stackId title description nextDate repeats