<commit_before>module Request.GetStampRally (getStampRally) where

import Control.Monad.Aff (Aff, makeAff)
import Control.Monad.Eff.Exception (error)
import Control.Monad.Except (runExcept)
import Data.Either (either)
import Data.Foreign (F)
import Data.Foreign.Class (readJSON)
import Data.GetStampRallyResponse (GetStampRallyResponse)
import Data.Options ((:=))
import Data.StrMap (fromFoldable) as StrMap
import Data.Tuple (Tuple(..))
import Fetch (HTTP, fetch)
import Fetch.Options (Method(..), headers, method, url) as FetchOptions
import Prelude (($), (<>), (<<<), bind, pure, show)

getStampRally :: forall eff
               . String
               -> String
               -> Aff ( http :: HTTP
                      | eff
                      ) GetStampRallyResponse
getStampRally stampRallyId token = do
  text <- fetch options
  let f = readJSON text :: F GetStampRallyResponse
  makeAff (\ng ok -> either (ng <<< error <<< show) ok $ runExcept f)
  where
    headers = StrMap.fromFoldable [ Tuple "Content-Type" "application/json"<commit_msg>remove unused var<commit_after>module Request.GetStampRally (getStampRally) where

import Control.Monad.Aff (Aff, makeAff)
import Control.Monad.Eff.Exception (error)
import Control.Monad.Except (runExcept)
import Data.Either (either)
import Data.Foreign (F)
import Data.Foreign.Class (readJSON)
import Data.GetStampRallyResponse (GetStampRallyResponse)
import Data.Options ((:=))
import Data.StrMap (fromFoldable) as StrMap
import Data.Tuple (Tuple(..))
import Fetch (HTTP, fetch)
import Fetch.Options (Method(..), headers, method, url) as FetchOptions
import Prelude (($), (<>), (<<<), bind, show)

getStampRally :: forall eff
               . String
               -> String
               -> Aff ( http :: HTTP
                      | eff
                      ) GetStampRallyResponse
getStampRally stampRallyId token = do
  text <- fetch options
  let f = readJSON text :: F GetStampRallyResponse
  makeAff (\ng ok -> either (ng <<< error <<< show) ok $ runExcept f)
  where
    headers = StrMap.fromFoldable [ Tuple "Content-Type" "application/json"
{'fraction_non_alphanumeric': 0.11611374407582939, 'fraction_numerical': 0.0, 'mean_word_length': 3.2732793522267207, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5425322', 'n_tokens_mistral': 659, 'n_tokens_neox': 640, 'n_words': 184}