summaryrefslogtreecommitdiff
path: root/lib/Badges.hs
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Badges.hs')
-rw-r--r--lib/Badges.hs11
1 files changed, 4 insertions, 7 deletions
diff --git a/lib/Badges.hs b/lib/Badges.hs
index 65433a1..5da2643 100644
--- a/lib/Badges.hs
+++ b/lib/Badges.hs
@@ -48,20 +48,17 @@ parseToken text = if text =~ ("^[a-zA-Z0-9]{50}$" :: Text)
data Badge = Badge BadgeToken BadgeArea
deriving (Ord, Eq, Generic, Show)
-badgeJsonArray :: A.KeyValue a => Badge -> [a]
-badgeJsonArray (Badge token area) =
- [ "token" .= token ] <> areaObject
- where areaObject = case area of
+instance ToJSON Badge where
+ toJSON (Badge token area) = A.object $ case area of
BadgePoint x y -> [ "x" .= x
, "y" .= y
+ , "token" .= token
, "type" .= A.String "point"
]
BadgeRect {..} -> [ "x" .= areaX
, "y" .= areaY
+ , "token" .= token
, "width" .= areaWidth
, "height" .= areaHeight
, "type" .= A.String "rectangle"
]
-
-badgeJson :: FilePath -> Badge -> A.Value
-badgeJson mappath badge = A.object (badgeJsonArray badge <> [ "map" .= mappath ])