module Web.Telegram.API.Bot.Data
(
User (..)
, ChatMember (..)
, Chat (..)
, Message (..)
, MessageEntity (..)
, PhotoSize (..)
, Audio (..)
, Document (..)
, Sticker (..)
, Video (..)
, Voice (..)
, Venue (..)
, Contact (..)
, Location (..)
, Update (..)
, File (..)
, UserProfilePhotos (..)
, InlineQuery (..)
, ChosenInlineResult (..)
, InlineQueryResult (..)
, InlineKeyboardMarkup (..)
, InlineKeyboardButton (..)
, CallbackQuery (..)
, ChatType (..)
, ParseMode (..)
, InputMessageContent (..)
, KeyboardButton (..)
, inlineKeyboardButton
, keyboardButton
, inlineQueryResultArticle
, inlineQueryResultAudio
, inlineQueryResultContact
, inlineQueryResultDocument
, inlineQueryResultGif
, inlineQueryResultLocation
, inlineQueryResultMpeg4Gif
, inlineQueryResultPhoto
, inlineQueryResultVenue
, inlineQueryResultVideo
, inlineQueryResultVoice
, inlineQueryResultCachedAudio
, inlineQueryResultCachedDocument
, inlineQueryResultCachedGif
, inlineQueryResultCachedMpeg4Gif
, inlineQueryResultCachedPhoto
, inlineQueryResultCachedSticker
, inlineQueryResultCachedVideo
, inlineQueryResultCachedVoice
) where
import Data.Aeson
import Data.Maybe
import Data.Aeson.Types
import Data.Text (Text)
import qualified Data.Char as Char
import GHC.Generics
import Data.List
import Web.Telegram.API.Bot.JsonExt
data User = User
{
user_id :: Int
, user_first_name :: Text
, user_last_name :: Maybe Text
, user_username :: Maybe Text
} deriving (Show, Generic)
instance ToJSON User where
toJSON = toJsonDrop 5
instance FromJSON User where
parseJSON = parseJsonDrop 5
data Contact = Contact
{
contact_phone_number :: Text
, contact_first_name :: Text
, contact_last_name :: Maybe Text
, contact_user_id :: Maybe Int
} deriving (Show, Generic)
instance ToJSON Contact where
toJSON = toJsonDrop 8
instance FromJSON Contact where
parseJSON = parseJsonDrop 8
data Chat = Chat
{
chat_id :: Int
, chat_type :: ChatType
, chat_title :: Maybe Text
, chat_username :: Maybe Text
, chat_first_name :: Maybe Text
, chat_last_name :: Maybe Text
} deriving (Show, Generic)
instance ToJSON Chat where
toJSON = toJsonDrop 5
instance FromJSON Chat where
parseJSON = parseJsonDrop 5
data ChatType = Private
| Group
| Supergroup
| Channel deriving (Show, Generic)
instance ToJSON ChatType where
toJSON Private = "private"
toJSON Group = "group"
toJSON Supergroup = "supergroup"
toJSON Channel = "channel"
instance FromJSON ChatType where
parseJSON "private" = pure Private
parseJSON "group" = pure Group
parseJSON "supergroup" = pure Supergroup
parseJSON "channel" = pure Channel
parseJSON _ = fail "Failed to parse ChatType"
data ParseMode = Markdown | HTML deriving (Show, Generic)
instance ToJSON ParseMode where
toJSON Markdown = "Markdown"
toJSON HTML = "HTML"
instance FromJSON ParseMode where
parseJSON "Markdown" = pure Markdown
parseJSON "HTML" = pure HTML
parseJSON _ = fail "Failed to parse ParseMode"
data PhotoSize = PhotoSize
{
photo_file_id :: Text
, photo_width :: Int
, photo_height :: Int
, photo_file_size :: Maybe Int
} deriving (Show, Generic)
instance ToJSON PhotoSize where
toJSON = toJsonDrop 6
instance FromJSON PhotoSize where
parseJSON = parseJsonDrop 6
data Audio = Audio
{
audio_file_id :: Text
, audio_duration :: Int
, audio_performer :: Maybe Text
, audio_title :: Maybe Text
, audio_mime_type :: Maybe Text
, audio_file_size :: Maybe Int
} deriving (Show, Generic)
instance ToJSON Audio where
toJSON = toJsonDrop 6
instance FromJSON Audio where
parseJSON = parseJsonDrop 6
data Document = Document
{
doc_file_id :: Text
, doc_thumb :: Maybe PhotoSize
, doc_file_name :: Maybe Text
, doc_mime_type :: Maybe Text
, doc_file_size :: Maybe Int
} deriving (Show, Generic)
instance ToJSON Document where
toJSON = toJsonDrop 4
instance FromJSON Document where
parseJSON = parseJsonDrop 4
data Sticker = Sticker
{
sticker_file_id :: Text
, sticker_width :: Int
, sticker_height :: Int
, sticker_thumb :: Maybe PhotoSize
, sticker_emoji :: Maybe Text
, sticker_file_size :: Maybe Int
} deriving (Show, Generic)
instance ToJSON Sticker where
toJSON = toJsonDrop 8
instance FromJSON Sticker where
parseJSON = parseJsonDrop 8
data Video = Video
{
video_file_id :: Text
, video_width :: Int
, video_height :: Int
, video_duration :: Int
, video_thumb :: Maybe PhotoSize
, video_mime_type :: Maybe Text
, video_file_size :: Maybe Int
} deriving (Show, Generic)
instance ToJSON Video where
toJSON = toJsonDrop 6
instance FromJSON Video where
parseJSON = parseJsonDrop 6
data Voice = Voice
{
voice_file_id :: Text
, voice_duration :: Int
, voice_mime_type :: Maybe Text
, voice_file_size :: Maybe Int
} deriving (Show, Generic)
instance ToJSON Voice where
toJSON = toJsonDrop 6
instance FromJSON Voice where
parseJSON = parseJsonDrop 6
data InlineQuery = InlineQuery
{
query_id :: Text
, query_from :: User
, query_location :: Maybe Location
, query_query :: Text
, query_offset :: Text
} deriving (Show, Generic)
instance ToJSON InlineQuery where
toJSON = toJsonDrop 6
instance FromJSON InlineQuery where
parseJSON = parseJsonDrop 6
data ChosenInlineResult = ChosenInlineResult
{
chosen_result_id :: Text
, chosen_from :: User
, chosen_location :: Maybe Location
, chosen_inline_message_id :: Maybe Text
, chosen_query :: Text
} deriving (Show, Generic)
instance ToJSON ChosenInlineResult where
toJSON = toJsonDrop 7
instance FromJSON ChosenInlineResult where
parseJSON = parseJsonDrop 7
data InputMessageContent =
InputTextMessageContent
{
imc_message_text :: Text
, imc_parse_mode :: Maybe ParseMode
, imc_disable_web_page_preview :: Maybe Bool
}
| InputLocationMessageContent
{
imc_latitude :: Float
, imc_longitude :: Float
}
| InputVenueMessageContent
{
imc_latitude :: Float
, imc_longitude :: Float
, imc_title :: Text
, imc_address :: Text
, imc_foursquare_id :: Maybe Text
}
| InputContactMessageContent
{
imc_phone_number :: Text
, imc_first_name :: Text
, imc_last_name :: Maybe Text
} deriving (Show, Generic)
instance ToJSON InputMessageContent where
toJSON (InputTextMessageContent txt mode preview) = object $
("message_text" .= txt) : catMaybes [
("parse_mode" .=) <$> mode,
("disable_web_page_preview" .=) <$> preview]
toJSON (InputLocationMessageContent lat lon) = object [
"latitude" .= lat,
"longitude" .= lon ]
toJSON (InputVenueMessageContent lat lon title addr fsq_id) = object $ [
"latitude" .= lat,
"longitude" .= lon,
"title" .= title,
"address" .= addr ] ++ maybeToList
(("foursquare_id" .=) <$> fsq_id)
toJSON (InputContactMessageContent phone fName lName) = object $ [
"phone_number" .= phone,
"first_name" .= fName] ++ maybeToList
(("last_name" .=) <$> lName)
instance FromJSON InputMessageContent where
parseJSON = parseJsonDrop 4
data InlineQueryResult =
InlineQueryResultArticle
{
iq_res_id :: Text
, iq_res_title :: Maybe Text
, iq_res_input_message_content :: Maybe InputMessageContent
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_url :: Maybe Text
, iq_res_hide_url :: Maybe Bool
, iq_res_description :: Maybe Text
, iq_res_thumb_url :: Maybe Text
, iq_res_thumb_width :: Maybe Int
, iq_res_thumb_height :: Maybe Int
}
| InlineQueryResultPhoto
{
iq_res_id :: Text
, iq_res_photo_url :: Text
, iq_res_thumb_url :: Maybe Text
, iq_res_photo_width :: Maybe Int
, iq_res_photo_height :: Maybe Int
, iq_res_title :: Maybe Text
, iq_res_description :: Maybe Text
, iq_res_caption :: Maybe Text
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
}
| InlineQueryResultGif
{
iq_res_id :: Text
, iq_res_gif_url :: Text
, iq_res_gif_width :: Maybe Int
, iq_res_gif_height :: Maybe Int
, iq_res_thumb_url :: Maybe Text
, iq_res_title :: Maybe Text
, iq_res_caption :: Maybe Text
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
}
| InlineQueryResultMpeg4Gif
{
iq_res_id :: Text
, iq_res_mpeg4_url :: Text
, iq_res_mpeg4_width :: Maybe Int
, iq_res_mpeg4_height :: Maybe Int
, iq_res_thumb_url :: Maybe Text
, iq_res_title :: Maybe Text
, iq_res_caption :: Maybe Text
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
}
| InlineQueryResultVideo
{
iq_res_id :: Text
, iq_res_video_url :: Text
, iq_res_mime_type :: Text
, iq_res_thumb_url :: Maybe Text
, iq_res_title :: Maybe Text
, iq_res_caption :: Maybe Text
, iq_res_video_width :: Maybe Int
, iq_res_video_height :: Maybe Int
, iq_res_video_duration :: Maybe Int
, iq_res_description :: Maybe Text
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
}
| InlineQueryResultAudio
{
iq_res_id :: Text
, iq_res_audio_url :: Text
, iq_res_title :: Maybe Text
, iq_res_performer :: Maybe Text
, iq_res_audio_duration :: Maybe Int
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
}
| InlineQueryResultVoice
{
iq_res_id :: Text
, iq_res_voice_url :: Text
, iq_res_title :: Maybe Text
, iq_res_voice_duration :: Maybe Int
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
}
| InlineQueryResultDocument
{
iq_res_id :: Text
, iq_res_title :: Maybe Text
, iq_res_caption :: Maybe Text
, iq_res_document_url :: Text
, iq_res_mime_type :: Text
, iq_res_description :: Maybe Text
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
, iq_res_thumb_url :: Maybe Text
, iq_res_thumb_width :: Maybe Int
, iq_res_thumb_height :: Maybe Int
}
| InlineQueryResultLocation
{
iq_res_id :: Text
, iq_res_latitude :: Float
, iq_res_longitude :: Float
, iq_res_title :: Maybe Text
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
, iq_res_thumb_url :: Maybe Text
, iq_res_thumb_width :: Maybe Int
, iq_res_thumb_height :: Maybe Int
}
| InlineQueryResultVenue
{
iq_res_id :: Text
, iq_res_latitude :: Float
, iq_res_longitude :: Float
, iq_res_title :: Maybe Text
, iq_res_address :: Text
, iq_res_foursquare_id :: Maybe Text
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
, iq_res_thumb_url :: Maybe Text
, iq_res_thumb_width :: Maybe Int
, iq_res_thumb_height :: Maybe Int
}
| InlineQueryResultContact
{
iq_res_id :: Text
, iq_res_phone_number :: Text
, iq_res_first_name :: Text
, iq_res_last_name :: Maybe Text
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
, iq_res_thumb_url :: Maybe Text
, iq_res_thumb_width :: Maybe Int
, iq_res_thumb_height :: Maybe Int
}
| InlineQueryResultCachedPhoto
{
iq_res_id :: Text
, iq_res_photo_file_id :: Text
, iq_res_title :: Maybe Text
, iq_res_description :: Maybe Text
, iq_res_caption :: Maybe Text
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
}
| InlineQueryResultCachedGif
{
iq_res_id :: Text
, iq_res_gif_file_id :: Text
, iq_res_title :: Maybe Text
, iq_res_caption :: Maybe Text
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
}
| InlineQueryResultCachedMpeg4Gif
{
iq_res_id :: Text
, iq_res_mpeg4_file_id :: Text
, iq_res_title :: Maybe Text
, iq_res_caption :: Maybe Text
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
}
| InlineQueryResultCachedSticker
{
iq_res_id :: Text
, iq_res_sticker_file_id :: Text
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
}
| InlineQueryResultCachedDocument
{
iq_res_id :: Text
, iq_res_title :: Maybe Text
, iq_res_document_file_id :: Text
, iq_res_description :: Maybe Text
, iq_res_caption :: Maybe Text
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
}
| InlineQueryResultCachedVideo
{
iq_res_id :: Text
, iq_res_video_file_id :: Text
, iq_res_title :: Maybe Text
, iq_res_description :: Maybe Text
, iq_res_caption :: Maybe Text
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
}
| InlineQueryResultCachedVoice
{
iq_res_id :: Text
, iq_res_voice_file_id :: Text
, iq_res_title :: Maybe Text
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
}
| InlineQueryResultCachedAudio
{
iq_res_id :: Text
, iq_res_audio_file_id :: Text
, iq_res_reply_markup :: Maybe InlineKeyboardMarkup
, iq_res_input_message_content :: Maybe InputMessageContent
} deriving (Show, Generic)
dropCached :: String -> String
dropCached name = if "Cached" `isPrefixOf` name then drop 6 name else name
tagModifier :: String -> String
tagModifier "InlineQueryResultMpeg4Gif" = "mpeg4_gif"
tagModifier "InlineQueryResultCachedMpeg4Gif" = "mpeg4_gif"
tagModifier x = (fmap Char.toLower . dropCached . drop 17) x
inlineQueryJSONOptions :: Options
inlineQueryJSONOptions = defaultOptions {
fieldLabelModifier = drop 7
, omitNothingFields = True
, sumEncoding = TaggedObject { tagFieldName = "type", contentsFieldName = undefined }
, constructorTagModifier = tagModifier
}
instance ToJSON InlineQueryResult where
toJSON = genericToJSON inlineQueryJSONOptions
instance FromJSON InlineQueryResult where
parseJSON = genericParseJSON inlineQueryJSONOptions
inlineQueryResultArticle :: Text -> Text -> InputMessageContent -> InlineQueryResult
inlineQueryResultArticle id title content = InlineQueryResultArticle id (Just title) (Just content) Nothing Nothing Nothing Nothing Nothing Nothing Nothing
inlineQueryResultPhoto :: Text -> Text -> Text -> InlineQueryResult
inlineQueryResultPhoto id photoUrl thumbUlr = InlineQueryResultPhoto id photoUrl (Just thumbUlr) Nothing Nothing Nothing Nothing Nothing Nothing Nothing
inlineQueryResultGif :: Text -> Text -> Text -> InlineQueryResult
inlineQueryResultGif id gifUrl thumbUrl = InlineQueryResultGif id gifUrl Nothing Nothing (Just thumbUrl) Nothing Nothing Nothing Nothing
inlineQueryResultMpeg4Gif :: Text -> Text -> Text -> InlineQueryResult
inlineQueryResultMpeg4Gif id mpeg4Url thumbUrl = InlineQueryResultMpeg4Gif id mpeg4Url Nothing Nothing (Just thumbUrl) Nothing Nothing Nothing Nothing
inlineQueryResultVideo :: Text -> Text -> Text -> Text -> Text -> InlineQueryResult
inlineQueryResultVideo id videoUrl mimeType thumbUrl title = InlineQueryResultVideo id videoUrl mimeType (Just thumbUrl) (Just title) Nothing Nothing Nothing Nothing Nothing Nothing Nothing
inlineQueryResultAudio :: Text -> Text -> Text -> InlineQueryResult
inlineQueryResultAudio id audioUrl title = InlineQueryResultAudio id audioUrl (Just title) Nothing Nothing Nothing Nothing
inlineQueryResultVoice :: Text -> Text -> Text -> InlineQueryResult
inlineQueryResultVoice id voiceUrl title = InlineQueryResultVoice id voiceUrl (Just title) Nothing Nothing Nothing
inlineQueryResultDocument :: Text -> Text -> Text -> Text -> InlineQueryResult
inlineQueryResultDocument id title docUrl mimeType = InlineQueryResultDocument id (Just title) Nothing docUrl mimeType Nothing Nothing Nothing Nothing Nothing Nothing
inlineQueryResultLocation :: Text -> Float -> Float -> Text -> InlineQueryResult
inlineQueryResultLocation id lat lon title = InlineQueryResultLocation id lat lon (Just title) Nothing Nothing Nothing Nothing Nothing
inlineQueryResultVenue :: Text -> Float -> Float -> Text -> Text -> InlineQueryResult
inlineQueryResultVenue id lat lon title address = InlineQueryResultVenue id lat lon (Just title) address Nothing Nothing Nothing Nothing Nothing Nothing
inlineQueryResultContact :: Text -> Text -> Text -> InlineQueryResult
inlineQueryResultContact id phoneNumber firstName = InlineQueryResultContact id phoneNumber firstName Nothing Nothing Nothing Nothing Nothing Nothing
inlineQueryResultCachedPhoto :: Text -> Text -> InlineQueryResult
inlineQueryResultCachedPhoto id fileId = InlineQueryResultCachedPhoto id fileId Nothing Nothing Nothing Nothing Nothing
inlineQueryResultCachedGif :: Text -> Text -> InlineQueryResult
inlineQueryResultCachedGif id fileId = InlineQueryResultCachedGif id fileId Nothing Nothing Nothing Nothing
inlineQueryResultCachedMpeg4Gif :: Text -> Text -> InlineQueryResult
inlineQueryResultCachedMpeg4Gif id fileId = InlineQueryResultCachedMpeg4Gif id fileId Nothing Nothing Nothing Nothing
inlineQueryResultCachedSticker :: Text -> Text -> InlineQueryResult
inlineQueryResultCachedSticker id fileId = InlineQueryResultCachedSticker id fileId Nothing Nothing
inlineQueryResultCachedDocument :: Text -> Text -> Text -> InlineQueryResult
inlineQueryResultCachedDocument id fileId title = InlineQueryResultCachedDocument id (Just title) fileId Nothing Nothing Nothing Nothing
inlineQueryResultCachedVideo :: Text -> Text -> Text -> InlineQueryResult
inlineQueryResultCachedVideo id fileId title = InlineQueryResultCachedVideo id fileId (Just title) Nothing Nothing Nothing Nothing
inlineQueryResultCachedVoice :: Text -> Text -> Text -> InlineQueryResult
inlineQueryResultCachedVoice id fileId title = InlineQueryResultCachedVoice id fileId (Just title) Nothing Nothing
inlineQueryResultCachedAudio :: Text -> Text -> InlineQueryResult
inlineQueryResultCachedAudio id fileId = InlineQueryResultCachedAudio id fileId Nothing Nothing
data InlineKeyboardMarkup = InlineKeyboardMarkup
{
inline_keyboard :: [[InlineKeyboardButton]]
} deriving (FromJSON, ToJSON, Show, Generic)
data InlineKeyboardButton = InlineKeyboardButton
{
ikb_text :: Text
, ikb_url :: Maybe Text
, ikb_callback_data :: Maybe Text
, ikb_switch_inline_query :: Maybe Text
} deriving (Show, Generic)
instance ToJSON InlineKeyboardButton where
toJSON = toJsonDrop 4
instance FromJSON InlineKeyboardButton where
parseJSON = parseJsonDrop 4
inlineKeyboardButton :: Text -> InlineKeyboardButton
inlineKeyboardButton text = InlineKeyboardButton text Nothing Nothing Nothing
data CallbackQuery = CallbackQuery
{
cq_id :: Text
, cq_from :: User
, cq_message :: Maybe Message
, cq_inline_message_id :: Maybe Text
, cq_data :: Maybe Text
} deriving (Show, Generic)
instance ToJSON CallbackQuery where
toJSON = toJsonDrop 3
instance FromJSON CallbackQuery where
parseJSON = parseJsonDrop 3
data Update = Update
{
update_id :: Int
, message :: Maybe Message
, edited_message :: Maybe Message
, inline_query :: Maybe InlineQuery
, chosen_inline_result :: Maybe ChosenInlineResult
, callback_query :: Maybe CallbackQuery
} deriving (FromJSON, ToJSON, Show, Generic)
data Location = Location
{
longitude :: Float
, latitude :: Float
} deriving (FromJSON, ToJSON, Show, Generic)
data File = File
{
file_id :: Text
, file_size :: Maybe Int
, file_path :: Maybe Text
} deriving (FromJSON, ToJSON, Show, Generic)
data UserProfilePhotos = UserProfilePhotos
{
total_count :: Int
, photos :: [[PhotoSize]]
} deriving (FromJSON, ToJSON, Show, Generic)
data ChatMember = ChatMember
{
cm_user :: User
, cm_status :: Text
} deriving (Show, Generic)
instance ToJSON ChatMember where
toJSON = toJsonDrop 3
instance FromJSON ChatMember where
parseJSON = parseJsonDrop 3
data Message = Message
{
message_id :: Int
, from :: Maybe User
, date :: Int
, chat :: Chat
, forward_from :: Maybe User
, forward_from_chat :: Maybe Chat
, forward_date :: Maybe Int
, reply_to_message :: Maybe Message
, edit_date :: Maybe Int
, text :: Maybe Text
, entities :: Maybe [MessageEntity]
, audio :: Maybe Audio
, document :: Maybe Document
, photo :: Maybe [PhotoSize]
, sticker :: Maybe Sticker
, video :: Maybe Video
, voice :: Maybe Voice
, caption :: Maybe Text
, contact :: Maybe Contact
, location :: Maybe Location
, venue :: Maybe Venue
, new_chat_member :: Maybe User
, left_chat_member :: Maybe User
, new_chat_title :: Maybe Text
, new_chat_photo :: Maybe [PhotoSize]
, delete_chat_photo :: Maybe Bool
, group_chat_created :: Maybe Bool
, supergroup_chat_created :: Maybe Bool
, channel_chat_created :: Maybe Bool
, migrate_to_chat_id :: Maybe Int
, migrate_from_chat_id :: Maybe Int
, pinned_message :: Maybe Message
} deriving (FromJSON, ToJSON, Show, Generic)
data MessageEntity = MessageEntity
{
me_type :: Text
, me_offset :: Int
, me_length :: Int
, me_url :: Maybe Text
, me_user :: Maybe User
} deriving (Show, Generic)
instance ToJSON MessageEntity where
toJSON = toJsonDrop 3
instance FromJSON MessageEntity where
parseJSON = parseJsonDrop 3
data Venue = Venue
{
venue_location :: Location
, venue_title :: Text
, venue_address :: Text
, venue_foursquare_id :: Maybe Text
} deriving (Show, Generic)
instance ToJSON Venue where
toJSON = toJsonDrop 6
instance FromJSON Venue where
parseJSON = parseJsonDrop 6
data KeyboardButton = KeyboardButton
{
kb_text :: Text
, kb_request_contact :: Maybe Bool
, kb_request_location :: Maybe Bool
} deriving (Show, Generic)
instance ToJSON KeyboardButton where
toJSON = toJsonDrop 3
instance FromJSON KeyboardButton where
parseJSON = parseJsonDrop 3
keyboardButton :: Text -> KeyboardButton
keyboardButton text = KeyboardButton text Nothing Nothing