tchIssue :: IssueResponseType -> OutputResponse -> Text -> IO ()
fetchIssue respType resp issueName = do
  domain <- T.pack <$> envDefault "jira.atlassian.net" "JIRA_DOMAIN"
  let uri = T.concat ["https://", domain, "/rest/api/2/issue/", issueName]
  username <- fmap T.pack <$> envMaybe "JIRA_USERNAME"
  password <- fmap T.pack <$> envMaybe "JIRA_PASSWORD"
  response <- safeGetUrl uri username password

  -- TODO thread those guys
  case response of
    Left err -> print $ T.concat ["[JIRA] Error: ", err, " :: issue ", issueName]
    Right success -> do
      print $ T.concat ["[JIRA] Fetched issue ", issueName]
      -- print $ toStrict $ decodeUtf8 $ success ^. responseBody
      let status = success ^. responseStatus
      let body = decode (success ^. responseBody) :: Maybe Issue
      case body of
        Just issue -> slackWriter resp $ handle respType issueName (withUrl domain issue) status
        Nothing    -> pure ()


fetchIssue :: IssueResponseType -> OutputResponse -> Text -> IO ()
fetchIssue respType resp issueName = do
  domain <- T.pack <$> envDefault "jira.atlassian.net" "JIRA_DOMAIN"
  let uri = T.concat ["https://", domain, "/rest/api/2/issue/", issueName]
  username <- fmap T.pack <$> envMaybe "JIRA_USERNAME"
  password <- fmap T.pack <$> envMaybe "JIRA_PASSWORD"
  response <- safeGetUrl uri username password

  -- TODO thread those guys
  case response of
    Left err -> print $ T.concat ["[JIRA] Error: ", err, " :: issue ", issueName]
    Right success -> do
      print $ T.concat ["[JIRA] Fetched issue ", issueName]
      -- print $ toStrict $ decodeUtf8 $ success ^. responseBody
      let status = success ^. responseStatus
      let body = decode (success ^. responseBody) :: Maybe Issue
      case body of
        Just issue -> slackWriter resp $ handle respType issueName (withUrl domain issue) status
        Nothing    -> pure ()
fetchIssue respType resp issueName = do
  domain <- T.pack <$> envDefault "jira.atlassian.net" "JIRA_DOMAIN"
  let uri = T.concat ["https://", domain, "/rest/api/2/issue/", issueName]
  username <- fmap T.pack <$> envMaybe "JIRA_USERNAME"
  password <- fmap T.pack <$> envMaybe "JIRA_PASSWORD"
  response <- safeGetUrl uri username password

  -- TODO thread those guys
  case response of
    Left err -> print $ T.concat ["[JIRA] Error: ", err, " :: issue ", issueName]
    Right success -> do
      print $ T.concat ["[JIRA] Fetched issue ", issueName]
      -- print $ toStrict $ decodeUtf8 $ success ^. responseBody
      let status = success ^. responseStatus
      let body = decode (success ^. responseBody) :: Maybe Issue
      case body of
        Just issue -> slackWriter resp $ handle respType issueName (withUrl domain issue) status
        Nothing    -> pure ()