-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathButton.hs
50 lines (42 loc) · 1.62 KB
/
Button.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE OverloadedStrings #-}
module Aitu.Bot.Forms.Content.Button
( Button(..)
, ButtonType(..)
)
where
import Data.Text
import Data.Aeson hiding ( Options
, defaultOptions
)
import Aitu.Bot.Forms.Options ( Options
, backgroundColor
, defaultOptions
)
import Aitu.Bot.Forms.FormAction ( FormAction(..) )
import qualified Aitu.Bot.Forms.Content.Content
as Content
data ButtonType = DefaultButton | DefaultByContent | Alternative deriving (Show)
instance ToJSON ButtonType where
toJSON DefaultButton = String "default"
toJSON DefaultByContent = String "default_by_content"
toJSON Alternative = String "alternative"
type Id = Text
type Title = Text
data Button = Button {
contentId :: Content.ContentID
, title :: Title
, buttonType :: ButtonType
, formAction :: FormAction
, options :: Maybe Options
} deriving (Show)
instance ToJSON Button where
toJSON Button {..} = object
[ "id" .= contentId
, "type" .= Content.Button
, "button_type" .= buttonType
, "title" .= title
, "options" .= options
, "form_action" .= formAction
]