aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Main.hs5
-rw-r--r--src/Model/Json/Search.hs10
2 files changed, 9 insertions, 6 deletions
diff --git a/src/Main.hs b/src/Main.hs
index d561419..f9054af 100644
--- a/src/Main.hs
+++ b/src/Main.hs
@@ -64,8 +64,9 @@ getHtmlPerfumes material = do
Left error ->
return . Left . T.pack $ error
Right searches ->
- case getMaterialIdentifier searches of
+ case getMaterialSearch searches of
Nothing ->
return . Left $ T.concat [ "No material identifier found for ", material ]
- Just identifier -> do
+ Just (Search identifier _ name) -> do
+ T.putStrLn $ T.concat [ "Found material « ", name, " » for ", material, "." ]
fmap parsePerfumes <$> getPage (getMaterialURL identifier)
diff --git a/src/Model/Json/Search.hs b/src/Model/Json/Search.hs
index b31b548..74f0ec9 100644
--- a/src/Model/Json/Search.hs
+++ b/src/Model/Json/Search.hs
@@ -2,7 +2,7 @@
module Model.Json.Search
( Search(..)
- , getMaterialIdentifier
+ , getMaterialSearch
) where
import Control.Monad (mzero)
@@ -15,14 +15,16 @@ import Data.List (find)
data Search = Search
{ identifier :: Text
, kind :: Text
+ , name :: Text
} deriving (Show)
instance FromJSON Search where
parseJSON (Object v) =
Search <$>
v .: "id" <*>
- v .: "type"
+ v .: "type" <*>
+ v .: "name"
parseJSON _ = mzero
-getMaterialIdentifier :: [Search] -> Maybe Text
-getMaterialIdentifier = fmap identifier . find ((==) "matiere" . kind)
+getMaterialSearch :: [Search] -> Maybe Search
+getMaterialSearch = find ((==) "matiere" . kind)