{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NoMonomorphismRestriction #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PolyKinds #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE StandaloneDeriving #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE UnicodeSyntax #-}
{-# LANGUAGE ViewPatterns #-}
{-# LANGUAGE TypeAbstractions #-}
{-# OPTIONS_GHC -Wno-unrecognised-pragmas #-}
{-# HLINT ignore "Use <&>" #-}
module MatrixBot.MatrixApi where
import GHC.Generics
import Data.Aeson
import Data.Aeson.Types
import Data.Functor.Identity
import Data.Kind
import Data.List (find)
import Data.Proxy
import Data.String
import Data.Text (Text)
import Data.Typeable
import qualified Data.Aeson.KeyMap as KM
import Servant.API
import MatrixBot.AesonUtils (myGenericToJSON, myGenericParseJSON)
import MatrixBot.MatrixApi.Types.MEventTypes
import MatrixBot.SharedTypes
type ClientV3 a = "_matrix" :> "client" :> "v3" :> a
type Authenticated a = AuthProtect "access-token" :> a
type LoginApi
= ClientV3
( "login"
:> ReqBody '[JSON] LoginRequest
:> Post '[JSON] LoginResponse
)
data LoginRequest = LoginRequest
{ LoginRequest -> MEventTypeOneOf '[ 'MLoginPasswordType]
loginRequestType ∷ MEventTypeOneOf '[ 'MLoginPasswordType ]
, LoginRequest -> Username
loginRequestUser ∷ Username
, LoginRequest -> Password
loginRequestPassword ∷ Password
}
deriving stock ((forall x. LoginRequest -> Rep LoginRequest x)
-> (forall x. Rep LoginRequest x -> LoginRequest)
-> Generic LoginRequest
forall x. Rep LoginRequest x -> LoginRequest
forall x. LoginRequest -> Rep LoginRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. LoginRequest -> Rep LoginRequest x
from :: forall x. LoginRequest -> Rep LoginRequest x
$cto :: forall x. Rep LoginRequest x -> LoginRequest
to :: forall x. Rep LoginRequest x -> LoginRequest
Generic, Int -> LoginRequest -> ShowS
[LoginRequest] -> ShowS
LoginRequest -> String
(Int -> LoginRequest -> ShowS)
-> (LoginRequest -> String)
-> ([LoginRequest] -> ShowS)
-> Show LoginRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LoginRequest -> ShowS
showsPrec :: Int -> LoginRequest -> ShowS
$cshow :: LoginRequest -> String
show :: LoginRequest -> String
$cshowList :: [LoginRequest] -> ShowS
showList :: [LoginRequest] -> ShowS
Show, LoginRequest -> LoginRequest -> Bool
(LoginRequest -> LoginRequest -> Bool)
-> (LoginRequest -> LoginRequest -> Bool) -> Eq LoginRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LoginRequest -> LoginRequest -> Bool
== :: LoginRequest -> LoginRequest -> Bool
$c/= :: LoginRequest -> LoginRequest -> Bool
/= :: LoginRequest -> LoginRequest -> Bool
Eq)
instance ToJSON LoginRequest where toJSON :: LoginRequest -> Value
toJSON = LoginRequest -> Value
forall a.
(Generic a, Typeable a, GToJSON' Value Zero (Rep a)) =>
a -> Value
myGenericToJSON
instance FromJSON LoginRequest where parseJSON :: Value -> Parser LoginRequest
parseJSON = Value -> Parser LoginRequest
forall a.
(Generic a, Typeable a, GFromJSON Zero (Rep a)) =>
Value -> Parser a
myGenericParseJSON
data LoginResponse = LoginResponse
{ LoginResponse -> AccessToken
loginResponseAccessToken ∷ AccessToken
, LoginResponse -> HomeServer
loginResponseHomeServer ∷ HomeServer
, LoginResponse -> Mxid
loginResponseUserId ∷ Mxid
}
deriving stock ((forall x. LoginResponse -> Rep LoginResponse x)
-> (forall x. Rep LoginResponse x -> LoginResponse)
-> Generic LoginResponse
forall x. Rep LoginResponse x -> LoginResponse
forall x. LoginResponse -> Rep LoginResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. LoginResponse -> Rep LoginResponse x
from :: forall x. LoginResponse -> Rep LoginResponse x
$cto :: forall x. Rep LoginResponse x -> LoginResponse
to :: forall x. Rep LoginResponse x -> LoginResponse
Generic, Int -> LoginResponse -> ShowS
[LoginResponse] -> ShowS
LoginResponse -> String
(Int -> LoginResponse -> ShowS)
-> (LoginResponse -> String)
-> ([LoginResponse] -> ShowS)
-> Show LoginResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> LoginResponse -> ShowS
showsPrec :: Int -> LoginResponse -> ShowS
$cshow :: LoginResponse -> String
show :: LoginResponse -> String
$cshowList :: [LoginResponse] -> ShowS
showList :: [LoginResponse] -> ShowS
Show, LoginResponse -> LoginResponse -> Bool
(LoginResponse -> LoginResponse -> Bool)
-> (LoginResponse -> LoginResponse -> Bool) -> Eq LoginResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: LoginResponse -> LoginResponse -> Bool
== :: LoginResponse -> LoginResponse -> Bool
$c/= :: LoginResponse -> LoginResponse -> Bool
/= :: LoginResponse -> LoginResponse -> Bool
Eq)
instance ToJSON LoginResponse where toJSON :: LoginResponse -> Value
toJSON = LoginResponse -> Value
forall a.
(Generic a, Typeable a, GToJSON' Value Zero (Rep a)) =>
a -> Value
myGenericToJSON
instance FromJSON LoginResponse where parseJSON :: Value -> Parser LoginResponse
parseJSON = Value -> Parser LoginResponse
forall a.
(Generic a, Typeable a, GFromJSON Zero (Rep a)) =>
Value -> Parser a
myGenericParseJSON
type ListRoomApi
= ClientV3
( Authenticated
( "directory"
:> "list"
:> "room"
:> Capture "roomId" RoomId
:> Get '[JSON] ListRoomResponse
))
newtype ListRoomResponse = ListRoomResponse
{ ListRoomResponse -> RoomVisibility
listRoomResponseVisibility ∷ RoomVisibility
}
deriving stock ((forall x. ListRoomResponse -> Rep ListRoomResponse x)
-> (forall x. Rep ListRoomResponse x -> ListRoomResponse)
-> Generic ListRoomResponse
forall x. Rep ListRoomResponse x -> ListRoomResponse
forall x. ListRoomResponse -> Rep ListRoomResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ListRoomResponse -> Rep ListRoomResponse x
from :: forall x. ListRoomResponse -> Rep ListRoomResponse x
$cto :: forall x. Rep ListRoomResponse x -> ListRoomResponse
to :: forall x. Rep ListRoomResponse x -> ListRoomResponse
Generic, Int -> ListRoomResponse -> ShowS
[ListRoomResponse] -> ShowS
ListRoomResponse -> String
(Int -> ListRoomResponse -> ShowS)
-> (ListRoomResponse -> String)
-> ([ListRoomResponse] -> ShowS)
-> Show ListRoomResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ListRoomResponse -> ShowS
showsPrec :: Int -> ListRoomResponse -> ShowS
$cshow :: ListRoomResponse -> String
show :: ListRoomResponse -> String
$cshowList :: [ListRoomResponse] -> ShowS
showList :: [ListRoomResponse] -> ShowS
Show, ListRoomResponse -> ListRoomResponse -> Bool
(ListRoomResponse -> ListRoomResponse -> Bool)
-> (ListRoomResponse -> ListRoomResponse -> Bool)
-> Eq ListRoomResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ListRoomResponse -> ListRoomResponse -> Bool
== :: ListRoomResponse -> ListRoomResponse -> Bool
$c/= :: ListRoomResponse -> ListRoomResponse -> Bool
/= :: ListRoomResponse -> ListRoomResponse -> Bool
Eq)
instance ToJSON ListRoomResponse where toJSON :: ListRoomResponse -> Value
toJSON = ListRoomResponse -> Value
forall a.
(Generic a, Typeable a, GToJSON' Value Zero (Rep a)) =>
a -> Value
myGenericToJSON
instance FromJSON ListRoomResponse where parseJSON :: Value -> Parser ListRoomResponse
parseJSON = Value -> Parser ListRoomResponse
forall a.
(Generic a, Typeable a, GFromJSON Zero (Rep a)) =>
Value -> Parser a
myGenericParseJSON
data RoomVisibility = RoomVisibilityPrivate | RoomVisibilityPublic
deriving stock (Int -> RoomVisibility -> ShowS
[RoomVisibility] -> ShowS
RoomVisibility -> String
(Int -> RoomVisibility -> ShowS)
-> (RoomVisibility -> String)
-> ([RoomVisibility] -> ShowS)
-> Show RoomVisibility
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RoomVisibility -> ShowS
showsPrec :: Int -> RoomVisibility -> ShowS
$cshow :: RoomVisibility -> String
show :: RoomVisibility -> String
$cshowList :: [RoomVisibility] -> ShowS
showList :: [RoomVisibility] -> ShowS
Show, RoomVisibility -> RoomVisibility -> Bool
(RoomVisibility -> RoomVisibility -> Bool)
-> (RoomVisibility -> RoomVisibility -> Bool) -> Eq RoomVisibility
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RoomVisibility -> RoomVisibility -> Bool
== :: RoomVisibility -> RoomVisibility -> Bool
$c/= :: RoomVisibility -> RoomVisibility -> Bool
/= :: RoomVisibility -> RoomVisibility -> Bool
Eq, Int -> RoomVisibility
RoomVisibility -> Int
RoomVisibility -> [RoomVisibility]
RoomVisibility -> RoomVisibility
RoomVisibility -> RoomVisibility -> [RoomVisibility]
RoomVisibility
-> RoomVisibility -> RoomVisibility -> [RoomVisibility]
(RoomVisibility -> RoomVisibility)
-> (RoomVisibility -> RoomVisibility)
-> (Int -> RoomVisibility)
-> (RoomVisibility -> Int)
-> (RoomVisibility -> [RoomVisibility])
-> (RoomVisibility -> RoomVisibility -> [RoomVisibility])
-> (RoomVisibility -> RoomVisibility -> [RoomVisibility])
-> (RoomVisibility
-> RoomVisibility -> RoomVisibility -> [RoomVisibility])
-> Enum RoomVisibility
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: RoomVisibility -> RoomVisibility
succ :: RoomVisibility -> RoomVisibility
$cpred :: RoomVisibility -> RoomVisibility
pred :: RoomVisibility -> RoomVisibility
$ctoEnum :: Int -> RoomVisibility
toEnum :: Int -> RoomVisibility
$cfromEnum :: RoomVisibility -> Int
fromEnum :: RoomVisibility -> Int
$cenumFrom :: RoomVisibility -> [RoomVisibility]
enumFrom :: RoomVisibility -> [RoomVisibility]
$cenumFromThen :: RoomVisibility -> RoomVisibility -> [RoomVisibility]
enumFromThen :: RoomVisibility -> RoomVisibility -> [RoomVisibility]
$cenumFromTo :: RoomVisibility -> RoomVisibility -> [RoomVisibility]
enumFromTo :: RoomVisibility -> RoomVisibility -> [RoomVisibility]
$cenumFromThenTo :: RoomVisibility
-> RoomVisibility -> RoomVisibility -> [RoomVisibility]
enumFromThenTo :: RoomVisibility
-> RoomVisibility -> RoomVisibility -> [RoomVisibility]
Enum, RoomVisibility
RoomVisibility -> RoomVisibility -> Bounded RoomVisibility
forall a. a -> a -> Bounded a
$cminBound :: RoomVisibility
minBound :: RoomVisibility
$cmaxBound :: RoomVisibility
maxBound :: RoomVisibility
Bounded)
instance ToJSON RoomVisibility where
toJSON :: RoomVisibility -> Value
toJSON RoomVisibility
RoomVisibilityPublic = Text -> Value
String Text
"public"
toJSON RoomVisibility
RoomVisibilityPrivate = Text -> Value
String Text
"private"
instance FromJSON RoomVisibility where
parseJSON ∷ ∀a. a ~ RoomVisibility ⇒ Value → Parser a
parseJSON :: forall a. (a ~ RoomVisibility) => Value -> Parser a
parseJSON Value
jsonInput
= Parser a -> (a -> Parser a) -> Maybe a -> Parser a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> Value -> Parser a
forall a. String -> Value -> Parser a
typeMismatch (TypeRep -> String
forall a. Show a => a -> String
show (TypeRep -> String) -> (Proxy a -> TypeRep) -> Proxy a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy a -> TypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> TypeRep
typeRep (Proxy a -> String) -> Proxy a -> String
forall a b. (a -> b) -> a -> b
$ forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @a) Value
jsonInput) a -> Parser a
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
(Maybe a -> Parser a) -> Maybe a -> Parser a
forall a b. (a -> b) -> a -> b
$ (a -> Bool) -> [a] -> Maybe a
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
find ((Value
jsonInput Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
==) (Value -> Bool) -> (a -> Value) -> a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Value
forall a. ToJSON a => a -> Value
toJSON) [a
forall a. Bounded a => a
minBound .. a
forall a. Bounded a => a
maxBound ∷ a]
type EventsApi
= ClientV3
( Authenticated
( "events"
:> QueryParam "from" EventToken
:> QueryParam "room_id" RoomId
:> QueryParam "timeout" Milliseconds
:> Get '[JSON] EventsResponse
))
data EventsResponse = EventsResponse
{ EventsResponse -> [ClientEvent]
eventsResponseChunk ∷ [ClientEvent]
, EventsResponse -> EventToken
eventsResponseEnd ∷ EventToken
, EventsResponse -> EventToken
eventsResponseStart ∷ EventToken
}
deriving stock ((forall x. EventsResponse -> Rep EventsResponse x)
-> (forall x. Rep EventsResponse x -> EventsResponse)
-> Generic EventsResponse
forall x. Rep EventsResponse x -> EventsResponse
forall x. EventsResponse -> Rep EventsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. EventsResponse -> Rep EventsResponse x
from :: forall x. EventsResponse -> Rep EventsResponse x
$cto :: forall x. Rep EventsResponse x -> EventsResponse
to :: forall x. Rep EventsResponse x -> EventsResponse
Generic, Int -> EventsResponse -> ShowS
[EventsResponse] -> ShowS
EventsResponse -> String
(Int -> EventsResponse -> ShowS)
-> (EventsResponse -> String)
-> ([EventsResponse] -> ShowS)
-> Show EventsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EventsResponse -> ShowS
showsPrec :: Int -> EventsResponse -> ShowS
$cshow :: EventsResponse -> String
show :: EventsResponse -> String
$cshowList :: [EventsResponse] -> ShowS
showList :: [EventsResponse] -> ShowS
Show, EventsResponse -> EventsResponse -> Bool
(EventsResponse -> EventsResponse -> Bool)
-> (EventsResponse -> EventsResponse -> Bool) -> Eq EventsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EventsResponse -> EventsResponse -> Bool
== :: EventsResponse -> EventsResponse -> Bool
$c/= :: EventsResponse -> EventsResponse -> Bool
/= :: EventsResponse -> EventsResponse -> Bool
Eq)
instance ToJSON EventsResponse where toJSON :: EventsResponse -> Value
toJSON = EventsResponse -> Value
forall a.
(Generic a, Typeable a, GToJSON' Value Zero (Rep a)) =>
a -> Value
myGenericToJSON
instance FromJSON EventsResponse where parseJSON :: Value -> Parser EventsResponse
parseJSON = Value -> Parser EventsResponse
forall a.
(Generic a, Typeable a, GFromJSON Zero (Rep a)) =>
Value -> Parser a
myGenericParseJSON
data ClientEvent
= ClientEventMRoomMessage (ClientEventGeneric Identity) MRoomMessageClientEvent
| ClientEventOther (ClientEventGeneric Maybe) Object
deriving stock ((forall x. ClientEvent -> Rep ClientEvent x)
-> (forall x. Rep ClientEvent x -> ClientEvent)
-> Generic ClientEvent
forall x. Rep ClientEvent x -> ClientEvent
forall x. ClientEvent -> Rep ClientEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. ClientEvent -> Rep ClientEvent x
from :: forall x. ClientEvent -> Rep ClientEvent x
$cto :: forall x. Rep ClientEvent x -> ClientEvent
to :: forall x. Rep ClientEvent x -> ClientEvent
Generic, Int -> ClientEvent -> ShowS
[ClientEvent] -> ShowS
ClientEvent -> String
(Int -> ClientEvent -> ShowS)
-> (ClientEvent -> String)
-> ([ClientEvent] -> ShowS)
-> Show ClientEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ClientEvent -> ShowS
showsPrec :: Int -> ClientEvent -> ShowS
$cshow :: ClientEvent -> String
show :: ClientEvent -> String
$cshowList :: [ClientEvent] -> ShowS
showList :: [ClientEvent] -> ShowS
Show, ClientEvent -> ClientEvent -> Bool
(ClientEvent -> ClientEvent -> Bool)
-> (ClientEvent -> ClientEvent -> Bool) -> Eq ClientEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ClientEvent -> ClientEvent -> Bool
== :: ClientEvent -> ClientEvent -> Bool
$c/= :: ClientEvent -> ClientEvent -> Bool
/= :: ClientEvent -> ClientEvent -> Bool
Eq)
instance ToJSON ClientEvent where
toJSON :: ClientEvent -> Value
toJSON (ClientEventMRoomMessage ClientEventGeneric Identity
g MRoomMessageClientEvent
_) = ClientEventGeneric Identity -> Value
forall a. ToJSON a => a -> Value
toJSON ClientEventGeneric Identity
g
toJSON (ClientEventOther ClientEventGeneric Maybe
_ Object
obj) = Object -> Value
Object Object
obj
instance FromJSON ClientEvent where
parseJSON ∷ ∀a. a ~ ClientEvent ⇒ Value → Parser a
parseJSON :: forall a. (a ~ ClientEvent) => Value -> Parser a
parseJSON Value
jsonInput = case Value
jsonInput of
Object (Key -> Object -> Maybe Value
forall v. Key -> KeyMap v -> Maybe v
KM.lookup Key
"type" → (Value -> Bool) -> Maybe Value -> Maybe Bool
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
== MEventType -> Value
forall a. ToJSON a => a -> Value
toJSON MEventType
MRoomMessageType) → Just Bool
True) →
ClientEventGeneric Identity -> MRoomMessageClientEvent -> a
ClientEventGeneric Identity
-> MRoomMessageClientEvent -> ClientEvent
ClientEventMRoomMessage
(ClientEventGeneric Identity -> MRoomMessageClientEvent -> a)
-> Parser (ClientEventGeneric Identity)
-> Parser (MRoomMessageClientEvent -> a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (ClientEventGeneric Identity)
forall a. FromJSON a => Value -> Parser a
parseJSON Value
jsonInput
Parser (MRoomMessageClientEvent -> a)
-> Parser MRoomMessageClientEvent -> Parser a
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Value -> Parser MRoomMessageClientEvent
forall a. FromJSON a => Value -> Parser a
parseJSON Value
jsonInput
Object Object
obj → ClientEventGeneric Maybe -> Object -> a
ClientEventGeneric Maybe -> Object -> ClientEvent
ClientEventOther (ClientEventGeneric Maybe -> Object -> a)
-> Parser (ClientEventGeneric Maybe) -> Parser (Object -> a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser (ClientEventGeneric Maybe)
forall a. FromJSON a => Value -> Parser a
parseJSON Value
jsonInput Parser (Object -> a) -> Parser Object -> Parser a
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object -> Parser Object
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Object
obj
Value
_ → String -> Value -> Parser a
forall a. String -> Value -> Parser a
typeMismatch (TypeRep -> String
forall a. Show a => a -> String
show (TypeRep -> String) -> (Proxy a -> TypeRep) -> Proxy a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy a -> TypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> TypeRep
typeRep (Proxy a -> String) -> Proxy a -> String
forall a b. (a -> b) -> a -> b
$ forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @a) Value
jsonInput
data ClientEventGeneric f = ClientEventGeneric
{ forall (f :: * -> *). ClientEventGeneric f -> Text
clientEventGenericType ∷ Text
, forall (f :: * -> *). ClientEventGeneric f -> Object
clientEventGenericContent ∷ Object
, forall (f :: * -> *). ClientEventGeneric f -> f EventId
clientEventGenericEventId ∷ f EventId
, forall (f :: * -> *). ClientEventGeneric f -> f Integer
clientEventGenericOriginServerTs ∷ f Integer
, forall (f :: * -> *). ClientEventGeneric f -> f RoomId
clientEventGenericRoomId ∷ f RoomId
, forall (f :: * -> *). ClientEventGeneric f -> f Mxid
clientEventGenericSender ∷ f Mxid
, forall (f :: * -> *). ClientEventGeneric f -> Maybe Text
clientEventGenericStateKey ∷ Maybe Text
, forall (f :: * -> *). ClientEventGeneric f -> Maybe Value
clientEventGenericUnsigned ∷ Maybe Value
}
deriving stock ((forall x. ClientEventGeneric f -> Rep (ClientEventGeneric f) x)
-> (forall x. Rep (ClientEventGeneric f) x -> ClientEventGeneric f)
-> Generic (ClientEventGeneric f)
forall x. Rep (ClientEventGeneric f) x -> ClientEventGeneric f
forall x. ClientEventGeneric f -> Rep (ClientEventGeneric f) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall (f :: * -> *) x.
Rep (ClientEventGeneric f) x -> ClientEventGeneric f
forall (f :: * -> *) x.
ClientEventGeneric f -> Rep (ClientEventGeneric f) x
$cfrom :: forall (f :: * -> *) x.
ClientEventGeneric f -> Rep (ClientEventGeneric f) x
from :: forall x. ClientEventGeneric f -> Rep (ClientEventGeneric f) x
$cto :: forall (f :: * -> *) x.
Rep (ClientEventGeneric f) x -> ClientEventGeneric f
to :: forall x. Rep (ClientEventGeneric f) x -> ClientEventGeneric f
Generic)
deriving instance Show (ClientEventGeneric Identity)
deriving instance Show (ClientEventGeneric Maybe)
deriving instance Eq (ClientEventGeneric Identity)
deriving instance Eq (ClientEventGeneric Maybe)
instance ToJSON (ClientEventGeneric Identity) where toJSON :: ClientEventGeneric Identity -> Value
toJSON = ClientEventGeneric Identity -> Value
forall a.
(Generic a, Typeable a, GToJSON' Value Zero (Rep a)) =>
a -> Value
myGenericToJSON
instance ToJSON (ClientEventGeneric Maybe) where toJSON :: ClientEventGeneric Maybe -> Value
toJSON = ClientEventGeneric Maybe -> Value
forall a.
(Generic a, Typeable a, GToJSON' Value Zero (Rep a)) =>
a -> Value
myGenericToJSON
instance FromJSON (ClientEventGeneric Identity) where parseJSON :: Value -> Parser (ClientEventGeneric Identity)
parseJSON = Value -> Parser (ClientEventGeneric Identity)
forall a.
(Generic a, Typeable a, GFromJSON Zero (Rep a)) =>
Value -> Parser a
myGenericParseJSON
instance FromJSON (ClientEventGeneric Maybe) where parseJSON :: Value -> Parser (ClientEventGeneric Maybe)
parseJSON = Value -> Parser (ClientEventGeneric Maybe)
forall a.
(Generic a, Typeable a, GFromJSON Zero (Rep a)) =>
Value -> Parser a
myGenericParseJSON
data MRoomMessageClientEvent = MRoomMessageClientEvent
{ MRoomMessageClientEvent -> MEventTypeOneOf '[ 'MRoomMessageType]
mRoomMessageClientEventType ∷ MEventTypeOneOf '[ 'MRoomMessageType ]
, MRoomMessageClientEvent -> MRoomMessageClientEventContent
mRoomMessageClientEventContent ∷ MRoomMessageClientEventContent
}
deriving stock ((forall x.
MRoomMessageClientEvent -> Rep MRoomMessageClientEvent x)
-> (forall x.
Rep MRoomMessageClientEvent x -> MRoomMessageClientEvent)
-> Generic MRoomMessageClientEvent
forall x. Rep MRoomMessageClientEvent x -> MRoomMessageClientEvent
forall x. MRoomMessageClientEvent -> Rep MRoomMessageClientEvent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MRoomMessageClientEvent -> Rep MRoomMessageClientEvent x
from :: forall x. MRoomMessageClientEvent -> Rep MRoomMessageClientEvent x
$cto :: forall x. Rep MRoomMessageClientEvent x -> MRoomMessageClientEvent
to :: forall x. Rep MRoomMessageClientEvent x -> MRoomMessageClientEvent
Generic, Int -> MRoomMessageClientEvent -> ShowS
[MRoomMessageClientEvent] -> ShowS
MRoomMessageClientEvent -> String
(Int -> MRoomMessageClientEvent -> ShowS)
-> (MRoomMessageClientEvent -> String)
-> ([MRoomMessageClientEvent] -> ShowS)
-> Show MRoomMessageClientEvent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MRoomMessageClientEvent -> ShowS
showsPrec :: Int -> MRoomMessageClientEvent -> ShowS
$cshow :: MRoomMessageClientEvent -> String
show :: MRoomMessageClientEvent -> String
$cshowList :: [MRoomMessageClientEvent] -> ShowS
showList :: [MRoomMessageClientEvent] -> ShowS
Show, MRoomMessageClientEvent -> MRoomMessageClientEvent -> Bool
(MRoomMessageClientEvent -> MRoomMessageClientEvent -> Bool)
-> (MRoomMessageClientEvent -> MRoomMessageClientEvent -> Bool)
-> Eq MRoomMessageClientEvent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MRoomMessageClientEvent -> MRoomMessageClientEvent -> Bool
== :: MRoomMessageClientEvent -> MRoomMessageClientEvent -> Bool
$c/= :: MRoomMessageClientEvent -> MRoomMessageClientEvent -> Bool
/= :: MRoomMessageClientEvent -> MRoomMessageClientEvent -> Bool
Eq)
instance ToJSON MRoomMessageClientEvent where toJSON :: MRoomMessageClientEvent -> Value
toJSON = MRoomMessageClientEvent -> Value
forall a.
(Generic a, Typeable a, GToJSON' Value Zero (Rep a)) =>
a -> Value
myGenericToJSON
instance FromJSON MRoomMessageClientEvent where parseJSON :: Value -> Parser MRoomMessageClientEvent
parseJSON = Value -> Parser MRoomMessageClientEvent
forall a.
(Generic a, Typeable a, GFromJSON Zero (Rep a)) =>
Value -> Parser a
myGenericParseJSON
data MRoomMessageClientEventContent
= MRoomMessageClientEventContentMText MRoomMessageMTextMsgtypeClientEventContent
| MRoomMessageClientEventContentMImage MRoomMessageMImageMsgtypeClientEventContent
| MRoomMessageClientEventContentMVideo MRoomMessageMVideoMsgtypeClientEventContent
| MRoomMessageClientEventContentMAudio MRoomMessageMAudioMsgtypeClientEventContent
| MRoomMessageClientEventContentMFile MRoomMessageMFileMsgtypeClientEventContent
| MRoomMessageClientEventContentOther Object
deriving stock ((forall x.
MRoomMessageClientEventContent
-> Rep MRoomMessageClientEventContent x)
-> (forall x.
Rep MRoomMessageClientEventContent x
-> MRoomMessageClientEventContent)
-> Generic MRoomMessageClientEventContent
forall x.
Rep MRoomMessageClientEventContent x
-> MRoomMessageClientEventContent
forall x.
MRoomMessageClientEventContent
-> Rep MRoomMessageClientEventContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
MRoomMessageClientEventContent
-> Rep MRoomMessageClientEventContent x
from :: forall x.
MRoomMessageClientEventContent
-> Rep MRoomMessageClientEventContent x
$cto :: forall x.
Rep MRoomMessageClientEventContent x
-> MRoomMessageClientEventContent
to :: forall x.
Rep MRoomMessageClientEventContent x
-> MRoomMessageClientEventContent
Generic, Int -> MRoomMessageClientEventContent -> ShowS
[MRoomMessageClientEventContent] -> ShowS
MRoomMessageClientEventContent -> String
(Int -> MRoomMessageClientEventContent -> ShowS)
-> (MRoomMessageClientEventContent -> String)
-> ([MRoomMessageClientEventContent] -> ShowS)
-> Show MRoomMessageClientEventContent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MRoomMessageClientEventContent -> ShowS
showsPrec :: Int -> MRoomMessageClientEventContent -> ShowS
$cshow :: MRoomMessageClientEventContent -> String
show :: MRoomMessageClientEventContent -> String
$cshowList :: [MRoomMessageClientEventContent] -> ShowS
showList :: [MRoomMessageClientEventContent] -> ShowS
Show, MRoomMessageClientEventContent
-> MRoomMessageClientEventContent -> Bool
(MRoomMessageClientEventContent
-> MRoomMessageClientEventContent -> Bool)
-> (MRoomMessageClientEventContent
-> MRoomMessageClientEventContent -> Bool)
-> Eq MRoomMessageClientEventContent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MRoomMessageClientEventContent
-> MRoomMessageClientEventContent -> Bool
== :: MRoomMessageClientEventContent
-> MRoomMessageClientEventContent -> Bool
$c/= :: MRoomMessageClientEventContent
-> MRoomMessageClientEventContent -> Bool
/= :: MRoomMessageClientEventContent
-> MRoomMessageClientEventContent -> Bool
Eq)
instance ToJSON MRoomMessageClientEventContent where
toJSON :: MRoomMessageClientEventContent -> Value
toJSON = \case
MRoomMessageClientEventContentMText MRoomMessageMTextMsgtypeClientEventContent
x → MRoomMessageMTextMsgtypeClientEventContent -> Value
forall a. ToJSON a => a -> Value
toJSON MRoomMessageMTextMsgtypeClientEventContent
x
MRoomMessageClientEventContentMImage MRoomMessageMImageMsgtypeClientEventContent
x → MRoomMessageMImageMsgtypeClientEventContent -> Value
forall a. ToJSON a => a -> Value
toJSON MRoomMessageMImageMsgtypeClientEventContent
x
MRoomMessageClientEventContentMVideo MRoomMessageMVideoMsgtypeClientEventContent
x → MRoomMessageMVideoMsgtypeClientEventContent -> Value
forall a. ToJSON a => a -> Value
toJSON MRoomMessageMVideoMsgtypeClientEventContent
x
MRoomMessageClientEventContentMAudio MRoomMessageMAudioMsgtypeClientEventContent
x → MRoomMessageMAudioMsgtypeClientEventContent -> Value
forall a. ToJSON a => a -> Value
toJSON MRoomMessageMAudioMsgtypeClientEventContent
x
MRoomMessageClientEventContentMFile MRoomMessageMFileMsgtypeClientEventContent
x → MRoomMessageMFileMsgtypeClientEventContent -> Value
forall a. ToJSON a => a -> Value
toJSON MRoomMessageMFileMsgtypeClientEventContent
x
MRoomMessageClientEventContentOther Object
x → Object -> Value
forall a. ToJSON a => a -> Value
toJSON Object
x
instance FromJSON MRoomMessageClientEventContent where
parseJSON ∷ ∀a. a ~ MRoomMessageClientEventContent ⇒ Value → Parser a
parseJSON :: forall a. (a ~ MRoomMessageClientEventContent) => Value -> Parser a
parseJSON Value
jsonInput = case Value
jsonInput of
Object (Key -> Object -> Maybe Value
forall v. Key -> KeyMap v -> Maybe v
KM.lookup Key
"msgtype" → (Value -> Bool) -> Maybe Value -> Maybe Bool
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
== MTextType -> Value
forall a. ToJSON a => a -> Value
toJSON MTextType
MTextType) → Just Bool
True) →
MRoomMessageMTextMsgtypeClientEventContent -> a
MRoomMessageMTextMsgtypeClientEventContent
-> MRoomMessageClientEventContent
MRoomMessageClientEventContentMText (MRoomMessageMTextMsgtypeClientEventContent -> a)
-> Parser MRoomMessageMTextMsgtypeClientEventContent -> Parser a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser MRoomMessageMTextMsgtypeClientEventContent
forall a. FromJSON a => Value -> Parser a
parseJSON Value
jsonInput
Object (Key -> Object -> Maybe Value
forall v. Key -> KeyMap v -> Maybe v
KM.lookup Key
"msgtype" → (Value -> Bool) -> Maybe Value -> Maybe Bool
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
== MImageType -> Value
forall a. ToJSON a => a -> Value
toJSON MImageType
MImageType) → Just Bool
True) →
MRoomMessageMImageMsgtypeClientEventContent -> a
MRoomMessageMImageMsgtypeClientEventContent
-> MRoomMessageClientEventContent
MRoomMessageClientEventContentMImage (MRoomMessageMImageMsgtypeClientEventContent -> a)
-> Parser MRoomMessageMImageMsgtypeClientEventContent -> Parser a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser MRoomMessageMImageMsgtypeClientEventContent
forall a. FromJSON a => Value -> Parser a
parseJSON Value
jsonInput
Object (Key -> Object -> Maybe Value
forall v. Key -> KeyMap v -> Maybe v
KM.lookup Key
"msgtype" → (Value -> Bool) -> Maybe Value -> Maybe Bool
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
== MVideoType -> Value
forall a. ToJSON a => a -> Value
toJSON MVideoType
MVideoType) → Just Bool
True) →
MRoomMessageMVideoMsgtypeClientEventContent -> a
MRoomMessageMVideoMsgtypeClientEventContent
-> MRoomMessageClientEventContent
MRoomMessageClientEventContentMVideo (MRoomMessageMVideoMsgtypeClientEventContent -> a)
-> Parser MRoomMessageMVideoMsgtypeClientEventContent -> Parser a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser MRoomMessageMVideoMsgtypeClientEventContent
forall a. FromJSON a => Value -> Parser a
parseJSON Value
jsonInput
Object (Key -> Object -> Maybe Value
forall v. Key -> KeyMap v -> Maybe v
KM.lookup Key
"msgtype" → (Value -> Bool) -> Maybe Value -> Maybe Bool
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
== MAudioType -> Value
forall a. ToJSON a => a -> Value
toJSON MAudioType
MAudioType) → Just Bool
True) →
MRoomMessageMAudioMsgtypeClientEventContent -> a
MRoomMessageMAudioMsgtypeClientEventContent
-> MRoomMessageClientEventContent
MRoomMessageClientEventContentMAudio (MRoomMessageMAudioMsgtypeClientEventContent -> a)
-> Parser MRoomMessageMAudioMsgtypeClientEventContent -> Parser a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser MRoomMessageMAudioMsgtypeClientEventContent
forall a. FromJSON a => Value -> Parser a
parseJSON Value
jsonInput
Object (Key -> Object -> Maybe Value
forall v. Key -> KeyMap v -> Maybe v
KM.lookup Key
"msgtype" → (Value -> Bool) -> Maybe Value -> Maybe Bool
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
== MFileType -> Value
forall a. ToJSON a => a -> Value
toJSON MFileType
MFileType) → Just Bool
True) →
MRoomMessageMFileMsgtypeClientEventContent -> a
MRoomMessageMFileMsgtypeClientEventContent
-> MRoomMessageClientEventContent
MRoomMessageClientEventContentMFile (MRoomMessageMFileMsgtypeClientEventContent -> a)
-> Parser MRoomMessageMFileMsgtypeClientEventContent -> Parser a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser MRoomMessageMFileMsgtypeClientEventContent
forall a. FromJSON a => Value -> Parser a
parseJSON Value
jsonInput
Object Object
_ → Object -> a
Object -> MRoomMessageClientEventContent
MRoomMessageClientEventContentOther (Object -> a) -> Parser Object -> Parser a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Value -> Parser Object
forall a. FromJSON a => Value -> Parser a
parseJSON Value
jsonInput
Value
_ → String -> Value -> Parser a
forall a. String -> Value -> Parser a
typeMismatch (TypeRep -> String
forall a. Show a => a -> String
show (TypeRep -> String) -> (Proxy a -> TypeRep) -> Proxy a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy a -> TypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> TypeRep
typeRep (Proxy a -> String) -> Proxy a -> String
forall a b. (a -> b) -> a -> b
$ forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @a) Value
jsonInput
data MRoomMessageMTextMsgtypeClientEventContent = MRoomMessageMTextMsgtypeClientEventContent
{ MRoomMessageMTextMsgtypeClientEventContent -> MTextType
mRoomMessageMTextMsgtypeClientEventContentMsgtype ∷ MTextType
, MRoomMessageMTextMsgtypeClientEventContent -> Text
mRoomMessageMTextMsgtypeClientEventContentBody ∷ Text
}
deriving stock ((forall x.
MRoomMessageMTextMsgtypeClientEventContent
-> Rep MRoomMessageMTextMsgtypeClientEventContent x)
-> (forall x.
Rep MRoomMessageMTextMsgtypeClientEventContent x
-> MRoomMessageMTextMsgtypeClientEventContent)
-> Generic MRoomMessageMTextMsgtypeClientEventContent
forall x.
Rep MRoomMessageMTextMsgtypeClientEventContent x
-> MRoomMessageMTextMsgtypeClientEventContent
forall x.
MRoomMessageMTextMsgtypeClientEventContent
-> Rep MRoomMessageMTextMsgtypeClientEventContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
MRoomMessageMTextMsgtypeClientEventContent
-> Rep MRoomMessageMTextMsgtypeClientEventContent x
from :: forall x.
MRoomMessageMTextMsgtypeClientEventContent
-> Rep MRoomMessageMTextMsgtypeClientEventContent x
$cto :: forall x.
Rep MRoomMessageMTextMsgtypeClientEventContent x
-> MRoomMessageMTextMsgtypeClientEventContent
to :: forall x.
Rep MRoomMessageMTextMsgtypeClientEventContent x
-> MRoomMessageMTextMsgtypeClientEventContent
Generic, Int -> MRoomMessageMTextMsgtypeClientEventContent -> ShowS
[MRoomMessageMTextMsgtypeClientEventContent] -> ShowS
MRoomMessageMTextMsgtypeClientEventContent -> String
(Int -> MRoomMessageMTextMsgtypeClientEventContent -> ShowS)
-> (MRoomMessageMTextMsgtypeClientEventContent -> String)
-> ([MRoomMessageMTextMsgtypeClientEventContent] -> ShowS)
-> Show MRoomMessageMTextMsgtypeClientEventContent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MRoomMessageMTextMsgtypeClientEventContent -> ShowS
showsPrec :: Int -> MRoomMessageMTextMsgtypeClientEventContent -> ShowS
$cshow :: MRoomMessageMTextMsgtypeClientEventContent -> String
show :: MRoomMessageMTextMsgtypeClientEventContent -> String
$cshowList :: [MRoomMessageMTextMsgtypeClientEventContent] -> ShowS
showList :: [MRoomMessageMTextMsgtypeClientEventContent] -> ShowS
Show, MRoomMessageMTextMsgtypeClientEventContent
-> MRoomMessageMTextMsgtypeClientEventContent -> Bool
(MRoomMessageMTextMsgtypeClientEventContent
-> MRoomMessageMTextMsgtypeClientEventContent -> Bool)
-> (MRoomMessageMTextMsgtypeClientEventContent
-> MRoomMessageMTextMsgtypeClientEventContent -> Bool)
-> Eq MRoomMessageMTextMsgtypeClientEventContent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MRoomMessageMTextMsgtypeClientEventContent
-> MRoomMessageMTextMsgtypeClientEventContent -> Bool
== :: MRoomMessageMTextMsgtypeClientEventContent
-> MRoomMessageMTextMsgtypeClientEventContent -> Bool
$c/= :: MRoomMessageMTextMsgtypeClientEventContent
-> MRoomMessageMTextMsgtypeClientEventContent -> Bool
/= :: MRoomMessageMTextMsgtypeClientEventContent
-> MRoomMessageMTextMsgtypeClientEventContent -> Bool
Eq)
instance ToJSON MRoomMessageMTextMsgtypeClientEventContent where toJSON :: MRoomMessageMTextMsgtypeClientEventContent -> Value
toJSON = MRoomMessageMTextMsgtypeClientEventContent -> Value
forall a.
(Generic a, Typeable a, GToJSON' Value Zero (Rep a)) =>
a -> Value
myGenericToJSON
instance FromJSON MRoomMessageMTextMsgtypeClientEventContent where parseJSON :: Value -> Parser MRoomMessageMTextMsgtypeClientEventContent
parseJSON = Value -> Parser MRoomMessageMTextMsgtypeClientEventContent
forall a.
(Generic a, Typeable a, GFromJSON Zero (Rep a)) =>
Value -> Parser a
myGenericParseJSON
data MRoomMessageMImageMsgtypeClientEventContent = MRoomMessageMImageMsgtypeClientEventContent
{ MRoomMessageMImageMsgtypeClientEventContent -> MImageType
mRoomMessageMImageMsgtypeClientEventContentMsgtype ∷ MImageType
, MRoomMessageMImageMsgtypeClientEventContent -> Text
mRoomMessageMImageMsgtypeClientEventContentBody ∷ Text
, MRoomMessageMImageMsgtypeClientEventContent -> Text
mRoomMessageMImageMsgtypeClientEventContentUrl ∷ Text
}
deriving stock ((forall x.
MRoomMessageMImageMsgtypeClientEventContent
-> Rep MRoomMessageMImageMsgtypeClientEventContent x)
-> (forall x.
Rep MRoomMessageMImageMsgtypeClientEventContent x
-> MRoomMessageMImageMsgtypeClientEventContent)
-> Generic MRoomMessageMImageMsgtypeClientEventContent
forall x.
Rep MRoomMessageMImageMsgtypeClientEventContent x
-> MRoomMessageMImageMsgtypeClientEventContent
forall x.
MRoomMessageMImageMsgtypeClientEventContent
-> Rep MRoomMessageMImageMsgtypeClientEventContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
MRoomMessageMImageMsgtypeClientEventContent
-> Rep MRoomMessageMImageMsgtypeClientEventContent x
from :: forall x.
MRoomMessageMImageMsgtypeClientEventContent
-> Rep MRoomMessageMImageMsgtypeClientEventContent x
$cto :: forall x.
Rep MRoomMessageMImageMsgtypeClientEventContent x
-> MRoomMessageMImageMsgtypeClientEventContent
to :: forall x.
Rep MRoomMessageMImageMsgtypeClientEventContent x
-> MRoomMessageMImageMsgtypeClientEventContent
Generic, Int -> MRoomMessageMImageMsgtypeClientEventContent -> ShowS
[MRoomMessageMImageMsgtypeClientEventContent] -> ShowS
MRoomMessageMImageMsgtypeClientEventContent -> String
(Int -> MRoomMessageMImageMsgtypeClientEventContent -> ShowS)
-> (MRoomMessageMImageMsgtypeClientEventContent -> String)
-> ([MRoomMessageMImageMsgtypeClientEventContent] -> ShowS)
-> Show MRoomMessageMImageMsgtypeClientEventContent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MRoomMessageMImageMsgtypeClientEventContent -> ShowS
showsPrec :: Int -> MRoomMessageMImageMsgtypeClientEventContent -> ShowS
$cshow :: MRoomMessageMImageMsgtypeClientEventContent -> String
show :: MRoomMessageMImageMsgtypeClientEventContent -> String
$cshowList :: [MRoomMessageMImageMsgtypeClientEventContent] -> ShowS
showList :: [MRoomMessageMImageMsgtypeClientEventContent] -> ShowS
Show, MRoomMessageMImageMsgtypeClientEventContent
-> MRoomMessageMImageMsgtypeClientEventContent -> Bool
(MRoomMessageMImageMsgtypeClientEventContent
-> MRoomMessageMImageMsgtypeClientEventContent -> Bool)
-> (MRoomMessageMImageMsgtypeClientEventContent
-> MRoomMessageMImageMsgtypeClientEventContent -> Bool)
-> Eq MRoomMessageMImageMsgtypeClientEventContent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MRoomMessageMImageMsgtypeClientEventContent
-> MRoomMessageMImageMsgtypeClientEventContent -> Bool
== :: MRoomMessageMImageMsgtypeClientEventContent
-> MRoomMessageMImageMsgtypeClientEventContent -> Bool
$c/= :: MRoomMessageMImageMsgtypeClientEventContent
-> MRoomMessageMImageMsgtypeClientEventContent -> Bool
/= :: MRoomMessageMImageMsgtypeClientEventContent
-> MRoomMessageMImageMsgtypeClientEventContent -> Bool
Eq)
instance ToJSON MRoomMessageMImageMsgtypeClientEventContent where toJSON :: MRoomMessageMImageMsgtypeClientEventContent -> Value
toJSON = MRoomMessageMImageMsgtypeClientEventContent -> Value
forall a.
(Generic a, Typeable a, GToJSON' Value Zero (Rep a)) =>
a -> Value
myGenericToJSON
instance FromJSON MRoomMessageMImageMsgtypeClientEventContent where parseJSON :: Value -> Parser MRoomMessageMImageMsgtypeClientEventContent
parseJSON = Value -> Parser MRoomMessageMImageMsgtypeClientEventContent
forall a.
(Generic a, Typeable a, GFromJSON Zero (Rep a)) =>
Value -> Parser a
myGenericParseJSON
data MRoomMessageMVideoMsgtypeClientEventContent = MRoomMessageMVideoMsgtypeClientEventContent
{ MRoomMessageMVideoMsgtypeClientEventContent -> MVideoType
mRoomMessageMVideoMsgtypeClientEventContentMsgtype ∷ MVideoType
, MRoomMessageMVideoMsgtypeClientEventContent -> Text
mRoomMessageMVideoMsgtypeClientEventContentBody ∷ Text
, MRoomMessageMVideoMsgtypeClientEventContent -> Text
mRoomMessageMVideoMsgtypeClientEventContentUrl ∷ Text
}
deriving stock ((forall x.
MRoomMessageMVideoMsgtypeClientEventContent
-> Rep MRoomMessageMVideoMsgtypeClientEventContent x)
-> (forall x.
Rep MRoomMessageMVideoMsgtypeClientEventContent x
-> MRoomMessageMVideoMsgtypeClientEventContent)
-> Generic MRoomMessageMVideoMsgtypeClientEventContent
forall x.
Rep MRoomMessageMVideoMsgtypeClientEventContent x
-> MRoomMessageMVideoMsgtypeClientEventContent
forall x.
MRoomMessageMVideoMsgtypeClientEventContent
-> Rep MRoomMessageMVideoMsgtypeClientEventContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
MRoomMessageMVideoMsgtypeClientEventContent
-> Rep MRoomMessageMVideoMsgtypeClientEventContent x
from :: forall x.
MRoomMessageMVideoMsgtypeClientEventContent
-> Rep MRoomMessageMVideoMsgtypeClientEventContent x
$cto :: forall x.
Rep MRoomMessageMVideoMsgtypeClientEventContent x
-> MRoomMessageMVideoMsgtypeClientEventContent
to :: forall x.
Rep MRoomMessageMVideoMsgtypeClientEventContent x
-> MRoomMessageMVideoMsgtypeClientEventContent
Generic, Int -> MRoomMessageMVideoMsgtypeClientEventContent -> ShowS
[MRoomMessageMVideoMsgtypeClientEventContent] -> ShowS
MRoomMessageMVideoMsgtypeClientEventContent -> String
(Int -> MRoomMessageMVideoMsgtypeClientEventContent -> ShowS)
-> (MRoomMessageMVideoMsgtypeClientEventContent -> String)
-> ([MRoomMessageMVideoMsgtypeClientEventContent] -> ShowS)
-> Show MRoomMessageMVideoMsgtypeClientEventContent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MRoomMessageMVideoMsgtypeClientEventContent -> ShowS
showsPrec :: Int -> MRoomMessageMVideoMsgtypeClientEventContent -> ShowS
$cshow :: MRoomMessageMVideoMsgtypeClientEventContent -> String
show :: MRoomMessageMVideoMsgtypeClientEventContent -> String
$cshowList :: [MRoomMessageMVideoMsgtypeClientEventContent] -> ShowS
showList :: [MRoomMessageMVideoMsgtypeClientEventContent] -> ShowS
Show, MRoomMessageMVideoMsgtypeClientEventContent
-> MRoomMessageMVideoMsgtypeClientEventContent -> Bool
(MRoomMessageMVideoMsgtypeClientEventContent
-> MRoomMessageMVideoMsgtypeClientEventContent -> Bool)
-> (MRoomMessageMVideoMsgtypeClientEventContent
-> MRoomMessageMVideoMsgtypeClientEventContent -> Bool)
-> Eq MRoomMessageMVideoMsgtypeClientEventContent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MRoomMessageMVideoMsgtypeClientEventContent
-> MRoomMessageMVideoMsgtypeClientEventContent -> Bool
== :: MRoomMessageMVideoMsgtypeClientEventContent
-> MRoomMessageMVideoMsgtypeClientEventContent -> Bool
$c/= :: MRoomMessageMVideoMsgtypeClientEventContent
-> MRoomMessageMVideoMsgtypeClientEventContent -> Bool
/= :: MRoomMessageMVideoMsgtypeClientEventContent
-> MRoomMessageMVideoMsgtypeClientEventContent -> Bool
Eq)
instance ToJSON MRoomMessageMVideoMsgtypeClientEventContent where toJSON :: MRoomMessageMVideoMsgtypeClientEventContent -> Value
toJSON = MRoomMessageMVideoMsgtypeClientEventContent -> Value
forall a.
(Generic a, Typeable a, GToJSON' Value Zero (Rep a)) =>
a -> Value
myGenericToJSON
instance FromJSON MRoomMessageMVideoMsgtypeClientEventContent where parseJSON :: Value -> Parser MRoomMessageMVideoMsgtypeClientEventContent
parseJSON = Value -> Parser MRoomMessageMVideoMsgtypeClientEventContent
forall a.
(Generic a, Typeable a, GFromJSON Zero (Rep a)) =>
Value -> Parser a
myGenericParseJSON
data MRoomMessageMAudioMsgtypeClientEventContent = MRoomMessageMAudioMsgtypeClientEventContent
{ MRoomMessageMAudioMsgtypeClientEventContent -> MAudioType
mRoomMessageMAudioMsgtypeClientEventContentMsgtype ∷ MAudioType
, MRoomMessageMAudioMsgtypeClientEventContent -> Text
mRoomMessageMAudioMsgtypeClientEventContentBody ∷ Text
, MRoomMessageMAudioMsgtypeClientEventContent -> Text
mRoomMessageMAudioMsgtypeClientEventContentUrl ∷ Text
}
deriving stock ((forall x.
MRoomMessageMAudioMsgtypeClientEventContent
-> Rep MRoomMessageMAudioMsgtypeClientEventContent x)
-> (forall x.
Rep MRoomMessageMAudioMsgtypeClientEventContent x
-> MRoomMessageMAudioMsgtypeClientEventContent)
-> Generic MRoomMessageMAudioMsgtypeClientEventContent
forall x.
Rep MRoomMessageMAudioMsgtypeClientEventContent x
-> MRoomMessageMAudioMsgtypeClientEventContent
forall x.
MRoomMessageMAudioMsgtypeClientEventContent
-> Rep MRoomMessageMAudioMsgtypeClientEventContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
MRoomMessageMAudioMsgtypeClientEventContent
-> Rep MRoomMessageMAudioMsgtypeClientEventContent x
from :: forall x.
MRoomMessageMAudioMsgtypeClientEventContent
-> Rep MRoomMessageMAudioMsgtypeClientEventContent x
$cto :: forall x.
Rep MRoomMessageMAudioMsgtypeClientEventContent x
-> MRoomMessageMAudioMsgtypeClientEventContent
to :: forall x.
Rep MRoomMessageMAudioMsgtypeClientEventContent x
-> MRoomMessageMAudioMsgtypeClientEventContent
Generic, Int -> MRoomMessageMAudioMsgtypeClientEventContent -> ShowS
[MRoomMessageMAudioMsgtypeClientEventContent] -> ShowS
MRoomMessageMAudioMsgtypeClientEventContent -> String
(Int -> MRoomMessageMAudioMsgtypeClientEventContent -> ShowS)
-> (MRoomMessageMAudioMsgtypeClientEventContent -> String)
-> ([MRoomMessageMAudioMsgtypeClientEventContent] -> ShowS)
-> Show MRoomMessageMAudioMsgtypeClientEventContent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MRoomMessageMAudioMsgtypeClientEventContent -> ShowS
showsPrec :: Int -> MRoomMessageMAudioMsgtypeClientEventContent -> ShowS
$cshow :: MRoomMessageMAudioMsgtypeClientEventContent -> String
show :: MRoomMessageMAudioMsgtypeClientEventContent -> String
$cshowList :: [MRoomMessageMAudioMsgtypeClientEventContent] -> ShowS
showList :: [MRoomMessageMAudioMsgtypeClientEventContent] -> ShowS
Show, MRoomMessageMAudioMsgtypeClientEventContent
-> MRoomMessageMAudioMsgtypeClientEventContent -> Bool
(MRoomMessageMAudioMsgtypeClientEventContent
-> MRoomMessageMAudioMsgtypeClientEventContent -> Bool)
-> (MRoomMessageMAudioMsgtypeClientEventContent
-> MRoomMessageMAudioMsgtypeClientEventContent -> Bool)
-> Eq MRoomMessageMAudioMsgtypeClientEventContent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MRoomMessageMAudioMsgtypeClientEventContent
-> MRoomMessageMAudioMsgtypeClientEventContent -> Bool
== :: MRoomMessageMAudioMsgtypeClientEventContent
-> MRoomMessageMAudioMsgtypeClientEventContent -> Bool
$c/= :: MRoomMessageMAudioMsgtypeClientEventContent
-> MRoomMessageMAudioMsgtypeClientEventContent -> Bool
/= :: MRoomMessageMAudioMsgtypeClientEventContent
-> MRoomMessageMAudioMsgtypeClientEventContent -> Bool
Eq)
instance ToJSON MRoomMessageMAudioMsgtypeClientEventContent where toJSON :: MRoomMessageMAudioMsgtypeClientEventContent -> Value
toJSON = MRoomMessageMAudioMsgtypeClientEventContent -> Value
forall a.
(Generic a, Typeable a, GToJSON' Value Zero (Rep a)) =>
a -> Value
myGenericToJSON
instance FromJSON MRoomMessageMAudioMsgtypeClientEventContent where parseJSON :: Value -> Parser MRoomMessageMAudioMsgtypeClientEventContent
parseJSON = Value -> Parser MRoomMessageMAudioMsgtypeClientEventContent
forall a.
(Generic a, Typeable a, GFromJSON Zero (Rep a)) =>
Value -> Parser a
myGenericParseJSON
data MRoomMessageMFileMsgtypeClientEventContent = MRoomMessageMFileMsgtypeClientEventContent
{ MRoomMessageMFileMsgtypeClientEventContent -> MFileType
mRoomMessageMFileMsgtypeClientEventContentMsgtype ∷ MFileType
, MRoomMessageMFileMsgtypeClientEventContent -> Text
mRoomMessageMFileMsgtypeClientEventContentBody ∷ Text
, MRoomMessageMFileMsgtypeClientEventContent -> Text
mRoomMessageMFileMsgtypeClientEventContentUrl ∷ Text
}
deriving stock ((forall x.
MRoomMessageMFileMsgtypeClientEventContent
-> Rep MRoomMessageMFileMsgtypeClientEventContent x)
-> (forall x.
Rep MRoomMessageMFileMsgtypeClientEventContent x
-> MRoomMessageMFileMsgtypeClientEventContent)
-> Generic MRoomMessageMFileMsgtypeClientEventContent
forall x.
Rep MRoomMessageMFileMsgtypeClientEventContent x
-> MRoomMessageMFileMsgtypeClientEventContent
forall x.
MRoomMessageMFileMsgtypeClientEventContent
-> Rep MRoomMessageMFileMsgtypeClientEventContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x.
MRoomMessageMFileMsgtypeClientEventContent
-> Rep MRoomMessageMFileMsgtypeClientEventContent x
from :: forall x.
MRoomMessageMFileMsgtypeClientEventContent
-> Rep MRoomMessageMFileMsgtypeClientEventContent x
$cto :: forall x.
Rep MRoomMessageMFileMsgtypeClientEventContent x
-> MRoomMessageMFileMsgtypeClientEventContent
to :: forall x.
Rep MRoomMessageMFileMsgtypeClientEventContent x
-> MRoomMessageMFileMsgtypeClientEventContent
Generic, Int -> MRoomMessageMFileMsgtypeClientEventContent -> ShowS
[MRoomMessageMFileMsgtypeClientEventContent] -> ShowS
MRoomMessageMFileMsgtypeClientEventContent -> String
(Int -> MRoomMessageMFileMsgtypeClientEventContent -> ShowS)
-> (MRoomMessageMFileMsgtypeClientEventContent -> String)
-> ([MRoomMessageMFileMsgtypeClientEventContent] -> ShowS)
-> Show MRoomMessageMFileMsgtypeClientEventContent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MRoomMessageMFileMsgtypeClientEventContent -> ShowS
showsPrec :: Int -> MRoomMessageMFileMsgtypeClientEventContent -> ShowS
$cshow :: MRoomMessageMFileMsgtypeClientEventContent -> String
show :: MRoomMessageMFileMsgtypeClientEventContent -> String
$cshowList :: [MRoomMessageMFileMsgtypeClientEventContent] -> ShowS
showList :: [MRoomMessageMFileMsgtypeClientEventContent] -> ShowS
Show, MRoomMessageMFileMsgtypeClientEventContent
-> MRoomMessageMFileMsgtypeClientEventContent -> Bool
(MRoomMessageMFileMsgtypeClientEventContent
-> MRoomMessageMFileMsgtypeClientEventContent -> Bool)
-> (MRoomMessageMFileMsgtypeClientEventContent
-> MRoomMessageMFileMsgtypeClientEventContent -> Bool)
-> Eq MRoomMessageMFileMsgtypeClientEventContent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MRoomMessageMFileMsgtypeClientEventContent
-> MRoomMessageMFileMsgtypeClientEventContent -> Bool
== :: MRoomMessageMFileMsgtypeClientEventContent
-> MRoomMessageMFileMsgtypeClientEventContent -> Bool
$c/= :: MRoomMessageMFileMsgtypeClientEventContent
-> MRoomMessageMFileMsgtypeClientEventContent -> Bool
/= :: MRoomMessageMFileMsgtypeClientEventContent
-> MRoomMessageMFileMsgtypeClientEventContent -> Bool
Eq)
instance ToJSON MRoomMessageMFileMsgtypeClientEventContent where toJSON :: MRoomMessageMFileMsgtypeClientEventContent -> Value
toJSON = MRoomMessageMFileMsgtypeClientEventContent -> Value
forall a.
(Generic a, Typeable a, GToJSON' Value Zero (Rep a)) =>
a -> Value
myGenericToJSON
instance FromJSON MRoomMessageMFileMsgtypeClientEventContent where parseJSON :: Value -> Parser MRoomMessageMFileMsgtypeClientEventContent
parseJSON = Value -> Parser MRoomMessageMFileMsgtypeClientEventContent
forall a.
(Generic a, Typeable a, GFromJSON Zero (Rep a)) =>
Value -> Parser a
myGenericParseJSON
type SendEventApi t
= ClientV3
( Authenticated
( "rooms"
:> Capture "roomId" RoomId
:> "send"
:> Capture "eventType" t
:> Capture "txnId" TransactionId
:> ReqBody '[JSON] (EventContent t)
:> Put '[JSON] EventResponse
))
type family EventContent eventType ∷ Type
newtype EventResponse = EventResponse
{ EventResponse -> EventId
eventResponseEventId ∷ EventId
}
deriving stock ((forall x. EventResponse -> Rep EventResponse x)
-> (forall x. Rep EventResponse x -> EventResponse)
-> Generic EventResponse
forall x. Rep EventResponse x -> EventResponse
forall x. EventResponse -> Rep EventResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. EventResponse -> Rep EventResponse x
from :: forall x. EventResponse -> Rep EventResponse x
$cto :: forall x. Rep EventResponse x -> EventResponse
to :: forall x. Rep EventResponse x -> EventResponse
Generic, Int -> EventResponse -> ShowS
[EventResponse] -> ShowS
EventResponse -> String
(Int -> EventResponse -> ShowS)
-> (EventResponse -> String)
-> ([EventResponse] -> ShowS)
-> Show EventResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EventResponse -> ShowS
showsPrec :: Int -> EventResponse -> ShowS
$cshow :: EventResponse -> String
show :: EventResponse -> String
$cshowList :: [EventResponse] -> ShowS
showList :: [EventResponse] -> ShowS
Show, EventResponse -> EventResponse -> Bool
(EventResponse -> EventResponse -> Bool)
-> (EventResponse -> EventResponse -> Bool) -> Eq EventResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EventResponse -> EventResponse -> Bool
== :: EventResponse -> EventResponse -> Bool
$c/= :: EventResponse -> EventResponse -> Bool
/= :: EventResponse -> EventResponse -> Bool
Eq)
instance ToJSON EventResponse where toJSON :: EventResponse -> Value
toJSON = EventResponse -> Value
forall a.
(Generic a, Typeable a, GToJSON' Value Zero (Rep a)) =>
a -> Value
myGenericToJSON
instance FromJSON EventResponse where parseJSON :: Value -> Parser EventResponse
parseJSON = Value -> Parser EventResponse
forall a.
(Generic a, Typeable a, GFromJSON Zero (Rep a)) =>
Value -> Parser a
myGenericParseJSON
type CreateUserFilter
= ClientV3
( Authenticated
( "user"
:> Capture "userId" Mxid
:> "filter"
:> ReqBody '[JSON] UserFilter
:> Post '[JSON] UserFilterIdResponse
))
newtype UserFilterIdResponse = UserFilterIdResponse
{ UserFilterIdResponse -> FilterId
userFilterIdResponse ∷ FilterId
}
deriving stock ((forall x. UserFilterIdResponse -> Rep UserFilterIdResponse x)
-> (forall x. Rep UserFilterIdResponse x -> UserFilterIdResponse)
-> Generic UserFilterIdResponse
forall x. Rep UserFilterIdResponse x -> UserFilterIdResponse
forall x. UserFilterIdResponse -> Rep UserFilterIdResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. UserFilterIdResponse -> Rep UserFilterIdResponse x
from :: forall x. UserFilterIdResponse -> Rep UserFilterIdResponse x
$cto :: forall x. Rep UserFilterIdResponse x -> UserFilterIdResponse
to :: forall x. Rep UserFilterIdResponse x -> UserFilterIdResponse
Generic, Int -> UserFilterIdResponse -> ShowS
[UserFilterIdResponse] -> ShowS
UserFilterIdResponse -> String
(Int -> UserFilterIdResponse -> ShowS)
-> (UserFilterIdResponse -> String)
-> ([UserFilterIdResponse] -> ShowS)
-> Show UserFilterIdResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UserFilterIdResponse -> ShowS
showsPrec :: Int -> UserFilterIdResponse -> ShowS
$cshow :: UserFilterIdResponse -> String
show :: UserFilterIdResponse -> String
$cshowList :: [UserFilterIdResponse] -> ShowS
showList :: [UserFilterIdResponse] -> ShowS
Show, UserFilterIdResponse -> UserFilterIdResponse -> Bool
(UserFilterIdResponse -> UserFilterIdResponse -> Bool)
-> (UserFilterIdResponse -> UserFilterIdResponse -> Bool)
-> Eq UserFilterIdResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UserFilterIdResponse -> UserFilterIdResponse -> Bool
== :: UserFilterIdResponse -> UserFilterIdResponse -> Bool
$c/= :: UserFilterIdResponse -> UserFilterIdResponse -> Bool
/= :: UserFilterIdResponse -> UserFilterIdResponse -> Bool
Eq)
instance ToJSON UserFilterIdResponse where toJSON :: UserFilterIdResponse -> Value
toJSON = UserFilterIdResponse -> Value
forall a.
(Generic a, Typeable a, GToJSON' Value Zero (Rep a)) =>
a -> Value
myGenericToJSON
instance FromJSON UserFilterIdResponse where parseJSON :: Value -> Parser UserFilterIdResponse
parseJSON = Value -> Parser UserFilterIdResponse
forall a.
(Generic a, Typeable a, GFromJSON Zero (Rep a)) =>
Value -> Parser a
myGenericParseJSON
type GetUserFilter
= ClientV3
( Authenticated
( "user"
:> Capture "userId" Mxid
:> "filter"
:> Capture "filterId" FilterId
:> Post '[JSON] UserFilter
))
data UserFilter = UserFilter
{ UserFilter -> Maybe ()
userFilterAccountData ∷ Maybe ()
, UserFilter -> Maybe ()
userFilterEventFields ∷ Maybe ()
, UserFilter -> Maybe ()
userFilterEventFormat ∷ Maybe ()
, UserFilter -> Maybe ()
userFilterPresence ∷ Maybe ()
, UserFilter -> Maybe ()
userFilterRoom ∷ Maybe ()
}
deriving stock ((forall x. UserFilter -> Rep UserFilter x)
-> (forall x. Rep UserFilter x -> UserFilter) -> Generic UserFilter
forall x. Rep UserFilter x -> UserFilter
forall x. UserFilter -> Rep UserFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. UserFilter -> Rep UserFilter x
from :: forall x. UserFilter -> Rep UserFilter x
$cto :: forall x. Rep UserFilter x -> UserFilter
to :: forall x. Rep UserFilter x -> UserFilter
Generic, Int -> UserFilter -> ShowS
[UserFilter] -> ShowS
UserFilter -> String
(Int -> UserFilter -> ShowS)
-> (UserFilter -> String)
-> ([UserFilter] -> ShowS)
-> Show UserFilter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> UserFilter -> ShowS
showsPrec :: Int -> UserFilter -> ShowS
$cshow :: UserFilter -> String
show :: UserFilter -> String
$cshowList :: [UserFilter] -> ShowS
showList :: [UserFilter] -> ShowS
Show, UserFilter -> UserFilter -> Bool
(UserFilter -> UserFilter -> Bool)
-> (UserFilter -> UserFilter -> Bool) -> Eq UserFilter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: UserFilter -> UserFilter -> Bool
== :: UserFilter -> UserFilter -> Bool
$c/= :: UserFilter -> UserFilter -> Bool
/= :: UserFilter -> UserFilter -> Bool
Eq)
instance ToJSON UserFilter where toJSON :: UserFilter -> Value
toJSON = UserFilter -> Value
forall a.
(Generic a, Typeable a, GToJSON' Value Zero (Rep a)) =>
a -> Value
myGenericToJSON
instance FromJSON UserFilter where parseJSON :: Value -> Parser UserFilter
parseJSON = Value -> Parser UserFilter
forall a.
(Generic a, Typeable a, GFromJSON Zero (Rep a)) =>
Value -> Parser a
myGenericParseJSON
class MsgtypeString a where
msgtypeString ∷ a → Text
data MTextType = MTextType
deriving stock (Int -> MTextType -> ShowS
[MTextType] -> ShowS
MTextType -> String
(Int -> MTextType -> ShowS)
-> (MTextType -> String)
-> ([MTextType] -> ShowS)
-> Show MTextType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MTextType -> ShowS
showsPrec :: Int -> MTextType -> ShowS
$cshow :: MTextType -> String
show :: MTextType -> String
$cshowList :: [MTextType] -> ShowS
showList :: [MTextType] -> ShowS
Show, MTextType -> MTextType -> Bool
(MTextType -> MTextType -> Bool)
-> (MTextType -> MTextType -> Bool) -> Eq MTextType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MTextType -> MTextType -> Bool
== :: MTextType -> MTextType -> Bool
$c/= :: MTextType -> MTextType -> Bool
/= :: MTextType -> MTextType -> Bool
Eq, Typeable, Int -> MTextType
MTextType -> Int
MTextType -> [MTextType]
MTextType -> MTextType
MTextType -> MTextType -> [MTextType]
MTextType -> MTextType -> MTextType -> [MTextType]
(MTextType -> MTextType)
-> (MTextType -> MTextType)
-> (Int -> MTextType)
-> (MTextType -> Int)
-> (MTextType -> [MTextType])
-> (MTextType -> MTextType -> [MTextType])
-> (MTextType -> MTextType -> [MTextType])
-> (MTextType -> MTextType -> MTextType -> [MTextType])
-> Enum MTextType
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: MTextType -> MTextType
succ :: MTextType -> MTextType
$cpred :: MTextType -> MTextType
pred :: MTextType -> MTextType
$ctoEnum :: Int -> MTextType
toEnum :: Int -> MTextType
$cfromEnum :: MTextType -> Int
fromEnum :: MTextType -> Int
$cenumFrom :: MTextType -> [MTextType]
enumFrom :: MTextType -> [MTextType]
$cenumFromThen :: MTextType -> MTextType -> [MTextType]
enumFromThen :: MTextType -> MTextType -> [MTextType]
$cenumFromTo :: MTextType -> MTextType -> [MTextType]
enumFromTo :: MTextType -> MTextType -> [MTextType]
$cenumFromThenTo :: MTextType -> MTextType -> MTextType -> [MTextType]
enumFromThenTo :: MTextType -> MTextType -> MTextType -> [MTextType]
Enum, MTextType
MTextType -> MTextType -> Bounded MTextType
forall a. a -> a -> Bounded a
$cminBound :: MTextType
minBound :: MTextType
$cmaxBound :: MTextType
maxBound :: MTextType
Bounded)
instance MsgtypeString MTextType where msgtypeString :: MTextType -> Text
msgtypeString MTextType
MTextType = Text
"m.text"
instance ToHttpApiData MTextType where toUrlPiece :: MTextType -> Text
toUrlPiece = MTextType -> Text
forall a. MsgtypeString a => a -> Text
msgtypeString
instance ToJSON MTextType where toJSON :: MTextType -> Value
toJSON = Text -> Value
String (Text -> Value) -> (MTextType -> Text) -> MTextType -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MTextType -> Text
forall a. MsgtypeString a => a -> Text
msgtypeString
instance FromJSON MTextType where parseJSON :: Value -> Parser MTextType
parseJSON = Value -> Parser MTextType
forall a.
(Bounded a, Enum a, Typeable a, ToJSON a) =>
Value -> Parser a
mTypeGenericParseJSON
data MImageType = MImageType
deriving stock (Int -> MImageType -> ShowS
[MImageType] -> ShowS
MImageType -> String
(Int -> MImageType -> ShowS)
-> (MImageType -> String)
-> ([MImageType] -> ShowS)
-> Show MImageType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MImageType -> ShowS
showsPrec :: Int -> MImageType -> ShowS
$cshow :: MImageType -> String
show :: MImageType -> String
$cshowList :: [MImageType] -> ShowS
showList :: [MImageType] -> ShowS
Show, MImageType -> MImageType -> Bool
(MImageType -> MImageType -> Bool)
-> (MImageType -> MImageType -> Bool) -> Eq MImageType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MImageType -> MImageType -> Bool
== :: MImageType -> MImageType -> Bool
$c/= :: MImageType -> MImageType -> Bool
/= :: MImageType -> MImageType -> Bool
Eq, Typeable, Int -> MImageType
MImageType -> Int
MImageType -> [MImageType]
MImageType -> MImageType
MImageType -> MImageType -> [MImageType]
MImageType -> MImageType -> MImageType -> [MImageType]
(MImageType -> MImageType)
-> (MImageType -> MImageType)
-> (Int -> MImageType)
-> (MImageType -> Int)
-> (MImageType -> [MImageType])
-> (MImageType -> MImageType -> [MImageType])
-> (MImageType -> MImageType -> [MImageType])
-> (MImageType -> MImageType -> MImageType -> [MImageType])
-> Enum MImageType
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: MImageType -> MImageType
succ :: MImageType -> MImageType
$cpred :: MImageType -> MImageType
pred :: MImageType -> MImageType
$ctoEnum :: Int -> MImageType
toEnum :: Int -> MImageType
$cfromEnum :: MImageType -> Int
fromEnum :: MImageType -> Int
$cenumFrom :: MImageType -> [MImageType]
enumFrom :: MImageType -> [MImageType]
$cenumFromThen :: MImageType -> MImageType -> [MImageType]
enumFromThen :: MImageType -> MImageType -> [MImageType]
$cenumFromTo :: MImageType -> MImageType -> [MImageType]
enumFromTo :: MImageType -> MImageType -> [MImageType]
$cenumFromThenTo :: MImageType -> MImageType -> MImageType -> [MImageType]
enumFromThenTo :: MImageType -> MImageType -> MImageType -> [MImageType]
Enum, MImageType
MImageType -> MImageType -> Bounded MImageType
forall a. a -> a -> Bounded a
$cminBound :: MImageType
minBound :: MImageType
$cmaxBound :: MImageType
maxBound :: MImageType
Bounded)
instance MsgtypeString MImageType where msgtypeString :: MImageType -> Text
msgtypeString MImageType
MImageType = Text
"m.image"
instance ToHttpApiData MImageType where toUrlPiece :: MImageType -> Text
toUrlPiece = MImageType -> Text
forall a. MsgtypeString a => a -> Text
msgtypeString
instance ToJSON MImageType where toJSON :: MImageType -> Value
toJSON = Text -> Value
String (Text -> Value) -> (MImageType -> Text) -> MImageType -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MImageType -> Text
forall a. MsgtypeString a => a -> Text
msgtypeString
instance FromJSON MImageType where parseJSON :: Value -> Parser MImageType
parseJSON = Value -> Parser MImageType
forall a.
(Bounded a, Enum a, Typeable a, ToJSON a) =>
Value -> Parser a
mTypeGenericParseJSON
data MVideoType = MVideoType
deriving stock (Int -> MVideoType -> ShowS
[MVideoType] -> ShowS
MVideoType -> String
(Int -> MVideoType -> ShowS)
-> (MVideoType -> String)
-> ([MVideoType] -> ShowS)
-> Show MVideoType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MVideoType -> ShowS
showsPrec :: Int -> MVideoType -> ShowS
$cshow :: MVideoType -> String
show :: MVideoType -> String
$cshowList :: [MVideoType] -> ShowS
showList :: [MVideoType] -> ShowS
Show, MVideoType -> MVideoType -> Bool
(MVideoType -> MVideoType -> Bool)
-> (MVideoType -> MVideoType -> Bool) -> Eq MVideoType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MVideoType -> MVideoType -> Bool
== :: MVideoType -> MVideoType -> Bool
$c/= :: MVideoType -> MVideoType -> Bool
/= :: MVideoType -> MVideoType -> Bool
Eq, Typeable, Int -> MVideoType
MVideoType -> Int
MVideoType -> [MVideoType]
MVideoType -> MVideoType
MVideoType -> MVideoType -> [MVideoType]
MVideoType -> MVideoType -> MVideoType -> [MVideoType]
(MVideoType -> MVideoType)
-> (MVideoType -> MVideoType)
-> (Int -> MVideoType)
-> (MVideoType -> Int)
-> (MVideoType -> [MVideoType])
-> (MVideoType -> MVideoType -> [MVideoType])
-> (MVideoType -> MVideoType -> [MVideoType])
-> (MVideoType -> MVideoType -> MVideoType -> [MVideoType])
-> Enum MVideoType
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: MVideoType -> MVideoType
succ :: MVideoType -> MVideoType
$cpred :: MVideoType -> MVideoType
pred :: MVideoType -> MVideoType
$ctoEnum :: Int -> MVideoType
toEnum :: Int -> MVideoType
$cfromEnum :: MVideoType -> Int
fromEnum :: MVideoType -> Int
$cenumFrom :: MVideoType -> [MVideoType]
enumFrom :: MVideoType -> [MVideoType]
$cenumFromThen :: MVideoType -> MVideoType -> [MVideoType]
enumFromThen :: MVideoType -> MVideoType -> [MVideoType]
$cenumFromTo :: MVideoType -> MVideoType -> [MVideoType]
enumFromTo :: MVideoType -> MVideoType -> [MVideoType]
$cenumFromThenTo :: MVideoType -> MVideoType -> MVideoType -> [MVideoType]
enumFromThenTo :: MVideoType -> MVideoType -> MVideoType -> [MVideoType]
Enum, MVideoType
MVideoType -> MVideoType -> Bounded MVideoType
forall a. a -> a -> Bounded a
$cminBound :: MVideoType
minBound :: MVideoType
$cmaxBound :: MVideoType
maxBound :: MVideoType
Bounded)
instance MsgtypeString MVideoType where msgtypeString :: MVideoType -> Text
msgtypeString MVideoType
MVideoType = Text
"m.video"
instance ToHttpApiData MVideoType where toUrlPiece :: MVideoType -> Text
toUrlPiece = MVideoType -> Text
forall a. MsgtypeString a => a -> Text
msgtypeString
instance ToJSON MVideoType where toJSON :: MVideoType -> Value
toJSON = Text -> Value
String (Text -> Value) -> (MVideoType -> Text) -> MVideoType -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MVideoType -> Text
forall a. MsgtypeString a => a -> Text
msgtypeString
instance FromJSON MVideoType where parseJSON :: Value -> Parser MVideoType
parseJSON = Value -> Parser MVideoType
forall a.
(Bounded a, Enum a, Typeable a, ToJSON a) =>
Value -> Parser a
mTypeGenericParseJSON
data MAudioType = MAudioType
deriving stock (Int -> MAudioType -> ShowS
[MAudioType] -> ShowS
MAudioType -> String
(Int -> MAudioType -> ShowS)
-> (MAudioType -> String)
-> ([MAudioType] -> ShowS)
-> Show MAudioType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MAudioType -> ShowS
showsPrec :: Int -> MAudioType -> ShowS
$cshow :: MAudioType -> String
show :: MAudioType -> String
$cshowList :: [MAudioType] -> ShowS
showList :: [MAudioType] -> ShowS
Show, MAudioType -> MAudioType -> Bool
(MAudioType -> MAudioType -> Bool)
-> (MAudioType -> MAudioType -> Bool) -> Eq MAudioType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MAudioType -> MAudioType -> Bool
== :: MAudioType -> MAudioType -> Bool
$c/= :: MAudioType -> MAudioType -> Bool
/= :: MAudioType -> MAudioType -> Bool
Eq, Typeable, Int -> MAudioType
MAudioType -> Int
MAudioType -> [MAudioType]
MAudioType -> MAudioType
MAudioType -> MAudioType -> [MAudioType]
MAudioType -> MAudioType -> MAudioType -> [MAudioType]
(MAudioType -> MAudioType)
-> (MAudioType -> MAudioType)
-> (Int -> MAudioType)
-> (MAudioType -> Int)
-> (MAudioType -> [MAudioType])
-> (MAudioType -> MAudioType -> [MAudioType])
-> (MAudioType -> MAudioType -> [MAudioType])
-> (MAudioType -> MAudioType -> MAudioType -> [MAudioType])
-> Enum MAudioType
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: MAudioType -> MAudioType
succ :: MAudioType -> MAudioType
$cpred :: MAudioType -> MAudioType
pred :: MAudioType -> MAudioType
$ctoEnum :: Int -> MAudioType
toEnum :: Int -> MAudioType
$cfromEnum :: MAudioType -> Int
fromEnum :: MAudioType -> Int
$cenumFrom :: MAudioType -> [MAudioType]
enumFrom :: MAudioType -> [MAudioType]
$cenumFromThen :: MAudioType -> MAudioType -> [MAudioType]
enumFromThen :: MAudioType -> MAudioType -> [MAudioType]
$cenumFromTo :: MAudioType -> MAudioType -> [MAudioType]
enumFromTo :: MAudioType -> MAudioType -> [MAudioType]
$cenumFromThenTo :: MAudioType -> MAudioType -> MAudioType -> [MAudioType]
enumFromThenTo :: MAudioType -> MAudioType -> MAudioType -> [MAudioType]
Enum, MAudioType
MAudioType -> MAudioType -> Bounded MAudioType
forall a. a -> a -> Bounded a
$cminBound :: MAudioType
minBound :: MAudioType
$cmaxBound :: MAudioType
maxBound :: MAudioType
Bounded)
instance MsgtypeString MAudioType where msgtypeString :: MAudioType -> Text
msgtypeString MAudioType
MAudioType = Text
"m.audio"
instance ToHttpApiData MAudioType where toUrlPiece :: MAudioType -> Text
toUrlPiece = MAudioType -> Text
forall a. MsgtypeString a => a -> Text
msgtypeString
instance ToJSON MAudioType where toJSON :: MAudioType -> Value
toJSON = Text -> Value
String (Text -> Value) -> (MAudioType -> Text) -> MAudioType -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MAudioType -> Text
forall a. MsgtypeString a => a -> Text
msgtypeString
instance FromJSON MAudioType where parseJSON :: Value -> Parser MAudioType
parseJSON = Value -> Parser MAudioType
forall a.
(Bounded a, Enum a, Typeable a, ToJSON a) =>
Value -> Parser a
mTypeGenericParseJSON
data MFileType = MFileType
deriving stock (Int -> MFileType -> ShowS
[MFileType] -> ShowS
MFileType -> String
(Int -> MFileType -> ShowS)
-> (MFileType -> String)
-> ([MFileType] -> ShowS)
-> Show MFileType
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MFileType -> ShowS
showsPrec :: Int -> MFileType -> ShowS
$cshow :: MFileType -> String
show :: MFileType -> String
$cshowList :: [MFileType] -> ShowS
showList :: [MFileType] -> ShowS
Show, MFileType -> MFileType -> Bool
(MFileType -> MFileType -> Bool)
-> (MFileType -> MFileType -> Bool) -> Eq MFileType
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MFileType -> MFileType -> Bool
== :: MFileType -> MFileType -> Bool
$c/= :: MFileType -> MFileType -> Bool
/= :: MFileType -> MFileType -> Bool
Eq, Typeable, Int -> MFileType
MFileType -> Int
MFileType -> [MFileType]
MFileType -> MFileType
MFileType -> MFileType -> [MFileType]
MFileType -> MFileType -> MFileType -> [MFileType]
(MFileType -> MFileType)
-> (MFileType -> MFileType)
-> (Int -> MFileType)
-> (MFileType -> Int)
-> (MFileType -> [MFileType])
-> (MFileType -> MFileType -> [MFileType])
-> (MFileType -> MFileType -> [MFileType])
-> (MFileType -> MFileType -> MFileType -> [MFileType])
-> Enum MFileType
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: MFileType -> MFileType
succ :: MFileType -> MFileType
$cpred :: MFileType -> MFileType
pred :: MFileType -> MFileType
$ctoEnum :: Int -> MFileType
toEnum :: Int -> MFileType
$cfromEnum :: MFileType -> Int
fromEnum :: MFileType -> Int
$cenumFrom :: MFileType -> [MFileType]
enumFrom :: MFileType -> [MFileType]
$cenumFromThen :: MFileType -> MFileType -> [MFileType]
enumFromThen :: MFileType -> MFileType -> [MFileType]
$cenumFromTo :: MFileType -> MFileType -> [MFileType]
enumFromTo :: MFileType -> MFileType -> [MFileType]
$cenumFromThenTo :: MFileType -> MFileType -> MFileType -> [MFileType]
enumFromThenTo :: MFileType -> MFileType -> MFileType -> [MFileType]
Enum, MFileType
MFileType -> MFileType -> Bounded MFileType
forall a. a -> a -> Bounded a
$cminBound :: MFileType
minBound :: MFileType
$cmaxBound :: MFileType
maxBound :: MFileType
Bounded)
instance MsgtypeString MFileType where msgtypeString :: MFileType -> Text
msgtypeString MFileType
MFileType = Text
"m.file"
instance ToHttpApiData MFileType where toUrlPiece :: MFileType -> Text
toUrlPiece = MFileType -> Text
forall a. MsgtypeString a => a -> Text
msgtypeString
instance ToJSON MFileType where toJSON :: MFileType -> Value
toJSON = Text -> Value
String (Text -> Value) -> (MFileType -> Text) -> MFileType -> Value
forall b c a. (b -> c) -> (a -> b) -> a -> c
. MFileType -> Text
forall a. MsgtypeString a => a -> Text
msgtypeString
instance FromJSON MFileType where parseJSON :: Value -> Parser MFileType
parseJSON = Value -> Parser MFileType
forall a.
(Bounded a, Enum a, Typeable a, ToJSON a) =>
Value -> Parser a
mTypeGenericParseJSON
data MRoomMessageContent = MRoomMessageContent
{ MRoomMessageContent -> MTextType
mRoomMessageContentMsgtype ∷ MTextType
, MRoomMessageContent -> Text
mRoomMessageContentBody ∷ Text
, MRoomMessageContent -> Maybe Text
mRoomMessageContentHtmlBody ∷ Maybe Text
, MRoomMessageContent -> Maybe InReplyTo
mRoomMessageContentMRelatesTo ∷ Maybe InReplyTo
, MRoomMessageContent -> Maybe MessageEdit
mRoomMessageContentMessageEdit ∷ Maybe MessageEdit
}
deriving stock ((forall x. MRoomMessageContent -> Rep MRoomMessageContent x)
-> (forall x. Rep MRoomMessageContent x -> MRoomMessageContent)
-> Generic MRoomMessageContent
forall x. Rep MRoomMessageContent x -> MRoomMessageContent
forall x. MRoomMessageContent -> Rep MRoomMessageContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MRoomMessageContent -> Rep MRoomMessageContent x
from :: forall x. MRoomMessageContent -> Rep MRoomMessageContent x
$cto :: forall x. Rep MRoomMessageContent x -> MRoomMessageContent
to :: forall x. Rep MRoomMessageContent x -> MRoomMessageContent
Generic, Int -> MRoomMessageContent -> ShowS
[MRoomMessageContent] -> ShowS
MRoomMessageContent -> String
(Int -> MRoomMessageContent -> ShowS)
-> (MRoomMessageContent -> String)
-> ([MRoomMessageContent] -> ShowS)
-> Show MRoomMessageContent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MRoomMessageContent -> ShowS
showsPrec :: Int -> MRoomMessageContent -> ShowS
$cshow :: MRoomMessageContent -> String
show :: MRoomMessageContent -> String
$cshowList :: [MRoomMessageContent] -> ShowS
showList :: [MRoomMessageContent] -> ShowS
Show, MRoomMessageContent -> MRoomMessageContent -> Bool
(MRoomMessageContent -> MRoomMessageContent -> Bool)
-> (MRoomMessageContent -> MRoomMessageContent -> Bool)
-> Eq MRoomMessageContent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MRoomMessageContent -> MRoomMessageContent -> Bool
== :: MRoomMessageContent -> MRoomMessageContent -> Bool
$c/= :: MRoomMessageContent -> MRoomMessageContent -> Bool
/= :: MRoomMessageContent -> MRoomMessageContent -> Bool
Eq)
instance ToJSON MRoomMessageContent where
toJSON :: MRoomMessageContent -> Value
toJSON MRoomMessageContent
x = Value
merge
where
merge :: Value
merge =
case (Value
messageObject, Value
editObject) of
(Object Object
a, Object Object
b) → Object -> Value
Object (Object
a Object -> Object -> Object
forall a. Semigroup a => a -> a -> a
<> Object
b)
(Value, Value)
_ → Value
Null
messageObject :: Value
messageObject = [Pair] -> Value
object ([Pair]
content [Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> [Pair]
htmlContent [Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<> [Pair]
inReplyTo)
editObject :: Value
editObject = Value -> (MessageEdit -> Value) -> Maybe MessageEdit -> Value
forall b a. b -> (a -> b) -> Maybe a -> b
maybe ([Pair] -> Value
object []) MessageEdit -> Value
forall a. ToJSON a => a -> Value
toJSON (MRoomMessageContent -> Maybe MessageEdit
mRoomMessageContentMessageEdit MRoomMessageContent
x)
content :: [Pair]
content =
[ Key
"msgtype" Key -> MTextType -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= MRoomMessageContent -> MTextType
mRoomMessageContentMsgtype MRoomMessageContent
x
, Key
"body" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= MRoomMessageContent -> Text
mRoomMessageContentBody MRoomMessageContent
x
]
htmlContent :: [Pair]
htmlContent =
case MRoomMessageContent -> Maybe Text
mRoomMessageContentHtmlBody MRoomMessageContent
x of
Maybe Text
Nothing → [Pair]
forall a. Monoid a => a
mempty
Just Text
htmlString →
[ Key
"format" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
forall s. IsString s => s
htmlBodyFormatValue
, Key
"formatted_body" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
htmlString
]
inReplyTo :: [Pair]
inReplyTo =
case MRoomMessageContent -> Maybe InReplyTo
mRoomMessageContentMRelatesTo MRoomMessageContent
x of
Maybe InReplyTo
Nothing → [Pair]
forall a. Monoid a => a
mempty
Just InReplyTo
y →
[ Key
forall s. IsString s => s
mRelatedToKey Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= [Pair] -> Value
object
[ Key
forall s. IsString s => s
mInReplyToKey Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= InReplyTo -> Value
forall a. ToJSON a => a -> Value
toJSON InReplyTo
y
]
]
instance FromJSON MRoomMessageContent where
parseJSON :: Value -> Parser MRoomMessageContent
parseJSON jsonValue :: Value
jsonValue@(Object Object
x) = MTextType
-> Text
-> Maybe Text
-> Maybe InReplyTo
-> Maybe MessageEdit
-> MRoomMessageContent
MRoomMessageContent
(MTextType
-> Text
-> Maybe Text
-> Maybe InReplyTo
-> Maybe MessageEdit
-> MRoomMessageContent)
-> Parser MTextType
-> Parser
(Text
-> Maybe Text
-> Maybe InReplyTo
-> Maybe MessageEdit
-> MRoomMessageContent)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
x Object -> Key -> Parser MTextType
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"msgtype"
Parser
(Text
-> Maybe Text
-> Maybe InReplyTo
-> Maybe MessageEdit
-> MRoomMessageContent)
-> Parser Text
-> Parser
(Maybe Text
-> Maybe InReplyTo -> Maybe MessageEdit -> MRoomMessageContent)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"body"
Parser
(Maybe Text
-> Maybe InReplyTo -> Maybe MessageEdit -> MRoomMessageContent)
-> Parser (Maybe Text)
-> Parser
(Maybe InReplyTo -> Maybe MessageEdit -> MRoomMessageContent)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe Text)
htmlBodyParser
Parser
(Maybe InReplyTo -> Maybe MessageEdit -> MRoomMessageContent)
-> Parser (Maybe InReplyTo)
-> Parser (Maybe MessageEdit -> MRoomMessageContent)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Parser (Maybe InReplyTo)
inReplyToParser
Parser (Maybe MessageEdit -> MRoomMessageContent)
-> Parser (Maybe MessageEdit) -> Parser MRoomMessageContent
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Maybe MessageEdit -> Parser (Maybe MessageEdit)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe MessageEdit
forall a. Maybe a
Nothing
where
htmlBodyParser :: Parser (Maybe Text)
htmlBodyParser = do
((,) (Maybe Text -> Maybe Text -> (Maybe Text, Maybe Text))
-> Parser (Maybe Text)
-> Parser (Maybe Text -> (Maybe Text, Maybe Text))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
x Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"format" Parser (Maybe Text -> (Maybe Text, Maybe Text))
-> Parser (Maybe Text) -> Parser (Maybe Text, Maybe Text)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
x Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"formatted_body") Parser (Maybe Text, Maybe Text)
-> ((Maybe Text, Maybe Text) -> Parser (Maybe Text))
-> Parser (Maybe Text)
forall a b. Parser a -> (a -> Parser b) -> Parser b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
(Maybe Text
Nothing, Maybe Text
Nothing) → Maybe Text -> Parser (Maybe Text)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Text
forall a. Maybe a
Nothing
(Just ((Text -> Text -> Bool
forall a. Eq a => a -> a -> Bool
== (Text
forall s. IsString s => s
htmlBodyFormatValue ∷ Text)) → Bool
True), htmlBody :: Maybe Text
htmlBody@(Just @Text Text
_)) → Maybe Text -> Parser (Maybe Text)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe Text
htmlBody
(Maybe Text, Maybe Text)
_ → String -> Parser (Maybe Text)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser (Maybe Text)) -> String -> Parser (Maybe Text)
forall a b. (a -> b) -> a -> b
$ String
"Failed to parse MRoomMessageContent from " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Value -> String
forall a. Show a => a -> String
show Value
jsonValue
inReplyToParser :: Parser (Maybe InReplyTo)
inReplyToParser =
Object
x Object -> Key -> Parser (Maybe Value)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
forall s. IsString s => s
mRelatedToKey Parser (Maybe Value)
-> (Maybe Value -> Parser (Maybe InReplyTo))
-> Parser (Maybe InReplyTo)
forall a b. Parser a -> (a -> Parser b) -> Parser b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \case
Maybe Value
Nothing → Maybe InReplyTo -> Parser (Maybe InReplyTo)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe InReplyTo
forall a. Maybe a
Nothing
Just Value
Null → Maybe InReplyTo -> Parser (Maybe InReplyTo)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe InReplyTo
forall a. Maybe a
Nothing
Just (Object Object
y) → Object
y Object -> Key -> Parser Value
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
forall s. IsString s => s
mInReplyToKey Parser Value
-> (Value -> Parser (Maybe InReplyTo)) -> Parser (Maybe InReplyTo)
forall a b. Parser a -> (a -> Parser b) -> Parser b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (InReplyTo -> Maybe InReplyTo)
-> Parser InReplyTo -> Parser (Maybe InReplyTo)
forall a b. (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap InReplyTo -> Maybe InReplyTo
forall a. a -> Maybe a
Just (Parser InReplyTo -> Parser (Maybe InReplyTo))
-> (Value -> Parser InReplyTo) -> Value -> Parser (Maybe InReplyTo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. forall a. FromJSON a => Value -> Parser a
parseJSON @InReplyTo
Maybe Value
_ → String -> Parser (Maybe InReplyTo)
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser (Maybe InReplyTo))
-> String -> Parser (Maybe InReplyTo)
forall a b. (a -> b) -> a -> b
$ String
"Failed to parse MRoomMessageContent from " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Value -> String
forall a. Show a => a -> String
show Value
jsonValue
parseJSON Value
jsonValue = String -> Parser MRoomMessageContent
forall a. String -> Parser a
forall (m :: * -> *) a. MonadFail m => String -> m a
fail (String -> Parser MRoomMessageContent)
-> String -> Parser MRoomMessageContent
forall a b. (a -> b) -> a -> b
$ String
"Failed to parse MRoomMessageContent from " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Value -> String
forall a. Show a => a -> String
show Value
jsonValue
type instance EventContent (MEventTypeOneOf '[ 'MRoomMessageType ]) = MRoomMessageContent
newtype InReplyTo = InReplyTo
{ InReplyTo -> EventId
inReplyToEventId ∷ EventId
}
deriving stock ((forall x. InReplyTo -> Rep InReplyTo x)
-> (forall x. Rep InReplyTo x -> InReplyTo) -> Generic InReplyTo
forall x. Rep InReplyTo x -> InReplyTo
forall x. InReplyTo -> Rep InReplyTo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. InReplyTo -> Rep InReplyTo x
from :: forall x. InReplyTo -> Rep InReplyTo x
$cto :: forall x. Rep InReplyTo x -> InReplyTo
to :: forall x. Rep InReplyTo x -> InReplyTo
Generic, Int -> InReplyTo -> ShowS
[InReplyTo] -> ShowS
InReplyTo -> String
(Int -> InReplyTo -> ShowS)
-> (InReplyTo -> String)
-> ([InReplyTo] -> ShowS)
-> Show InReplyTo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> InReplyTo -> ShowS
showsPrec :: Int -> InReplyTo -> ShowS
$cshow :: InReplyTo -> String
show :: InReplyTo -> String
$cshowList :: [InReplyTo] -> ShowS
showList :: [InReplyTo] -> ShowS
Show, InReplyTo -> InReplyTo -> Bool
(InReplyTo -> InReplyTo -> Bool)
-> (InReplyTo -> InReplyTo -> Bool) -> Eq InReplyTo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: InReplyTo -> InReplyTo -> Bool
== :: InReplyTo -> InReplyTo -> Bool
$c/= :: InReplyTo -> InReplyTo -> Bool
/= :: InReplyTo -> InReplyTo -> Bool
Eq)
instance ToJSON InReplyTo where toJSON :: InReplyTo -> Value
toJSON = InReplyTo -> Value
forall a.
(Generic a, Typeable a, GToJSON' Value Zero (Rep a)) =>
a -> Value
myGenericToJSON
instance FromJSON InReplyTo where parseJSON :: Value -> Parser InReplyTo
parseJSON = Value -> Parser InReplyTo
forall a.
(Generic a, Typeable a, GFromJSON Zero (Rep a)) =>
Value -> Parser a
myGenericParseJSON
mInReplyToKey ∷ IsString s ⇒ s
mInReplyToKey :: forall s. IsString s => s
mInReplyToKey = s
"m.in_reply_to"
htmlBodyFormatValue ∷ IsString s ⇒ s
htmlBodyFormatValue :: forall s. IsString s => s
htmlBodyFormatValue = s
"org.matrix.custom.html"
data MessageEdit = MessageEdit
{ MessageEdit -> MTextType
messageEditMsgtype ∷ MTextType
, MessageEdit -> Text
messageEditNewContentBody ∷ Text
, MessageEdit -> Maybe Text
messageEditNewContentHtmlBody ∷ Maybe Text
, MessageEdit -> EventId
messageEditRelatedTo ∷ EventId
}
deriving stock ((forall x. MessageEdit -> Rep MessageEdit x)
-> (forall x. Rep MessageEdit x -> MessageEdit)
-> Generic MessageEdit
forall x. Rep MessageEdit x -> MessageEdit
forall x. MessageEdit -> Rep MessageEdit x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MessageEdit -> Rep MessageEdit x
from :: forall x. MessageEdit -> Rep MessageEdit x
$cto :: forall x. Rep MessageEdit x -> MessageEdit
to :: forall x. Rep MessageEdit x -> MessageEdit
Generic, Int -> MessageEdit -> ShowS
[MessageEdit] -> ShowS
MessageEdit -> String
(Int -> MessageEdit -> ShowS)
-> (MessageEdit -> String)
-> ([MessageEdit] -> ShowS)
-> Show MessageEdit
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MessageEdit -> ShowS
showsPrec :: Int -> MessageEdit -> ShowS
$cshow :: MessageEdit -> String
show :: MessageEdit -> String
$cshowList :: [MessageEdit] -> ShowS
showList :: [MessageEdit] -> ShowS
Show, MessageEdit -> MessageEdit -> Bool
(MessageEdit -> MessageEdit -> Bool)
-> (MessageEdit -> MessageEdit -> Bool) -> Eq MessageEdit
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MessageEdit -> MessageEdit -> Bool
== :: MessageEdit -> MessageEdit -> Bool
$c/= :: MessageEdit -> MessageEdit -> Bool
/= :: MessageEdit -> MessageEdit -> Bool
Eq)
instance ToJSON MessageEdit where
toJSON :: MessageEdit -> Value
toJSON MessageEdit
x = [Pair] -> Value
object
[ Key
forall s. IsString s => s
mNewContentKey Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Value
newContent
, Key
forall s. IsString s => s
mRelatedToKey Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Value
relatesTo
]
where
newContent :: Value
newContent = [Pair] -> Value
object ([Pair] -> Value) -> [Pair] -> Value
forall a b. (a -> b) -> a -> b
$
[ Key
"msgtype" Key -> MTextType -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= MessageEdit -> MTextType
messageEditMsgtype MessageEdit
x
, Key
"body" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= MessageEdit -> Text
messageEditNewContentBody MessageEdit
x
]
[Pair] -> [Pair] -> [Pair]
forall a. Semigroup a => a -> a -> a
<>
(
case MessageEdit -> Maybe Text
messageEditNewContentHtmlBody MessageEdit
x of
Maybe Text
Nothing → [Pair]
forall a. Monoid a => a
mempty
Just Text
htmlString →
[ Key
"format" Key -> Value -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text -> Value
String Text
forall s. IsString s => s
htmlBodyFormatValue
, Key
"formatted_body" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= Text
htmlString
]
)
relatesTo :: Value
relatesTo = [Pair] -> Value
object
[ Key
"rel_type" Key -> Text -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= (Text
forall s. IsString s => s
mReplaceType ∷ Text)
, Key
"event_id" Key -> EventId -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= MessageEdit -> EventId
messageEditRelatedTo MessageEdit
x
]
mNewContentKey ∷ IsString s ⇒ s
mNewContentKey :: forall s. IsString s => s
mNewContentKey = s
"m.new_content"
mReplaceType ∷ IsString s ⇒ s
mReplaceType :: forall s. IsString s => s
mReplaceType = s
"m.replace"
newtype MReactionContent = MReactionContent
{ MReactionContent -> RelatesTo
mReactionContentMRelatesTo ∷ RelatesTo
}
deriving stock ((forall x. MReactionContent -> Rep MReactionContent x)
-> (forall x. Rep MReactionContent x -> MReactionContent)
-> Generic MReactionContent
forall x. Rep MReactionContent x -> MReactionContent
forall x. MReactionContent -> Rep MReactionContent x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. MReactionContent -> Rep MReactionContent x
from :: forall x. MReactionContent -> Rep MReactionContent x
$cto :: forall x. Rep MReactionContent x -> MReactionContent
to :: forall x. Rep MReactionContent x -> MReactionContent
Generic, Int -> MReactionContent -> ShowS
[MReactionContent] -> ShowS
MReactionContent -> String
(Int -> MReactionContent -> ShowS)
-> (MReactionContent -> String)
-> ([MReactionContent] -> ShowS)
-> Show MReactionContent
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> MReactionContent -> ShowS
showsPrec :: Int -> MReactionContent -> ShowS
$cshow :: MReactionContent -> String
show :: MReactionContent -> String
$cshowList :: [MReactionContent] -> ShowS
showList :: [MReactionContent] -> ShowS
Show, MReactionContent -> MReactionContent -> Bool
(MReactionContent -> MReactionContent -> Bool)
-> (MReactionContent -> MReactionContent -> Bool)
-> Eq MReactionContent
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: MReactionContent -> MReactionContent -> Bool
== :: MReactionContent -> MReactionContent -> Bool
$c/= :: MReactionContent -> MReactionContent -> Bool
/= :: MReactionContent -> MReactionContent -> Bool
Eq)
instance ToJSON MReactionContent where
toJSON :: MReactionContent -> Value
toJSON MReactionContent
x = [Pair] -> Value
object [Key
forall s. IsString s => s
mRelatedToKey Key -> RelatesTo -> Pair
forall v. ToJSON v => Key -> v -> Pair
forall e kv v. (KeyValue e kv, ToJSON v) => Key -> v -> kv
.= MReactionContent -> RelatesTo
mReactionContentMRelatesTo MReactionContent
x]
instance FromJSON MReactionContent where
parseJSON ∷ ∀a. (a ~ MReactionContent) ⇒ Value → Parser a
parseJSON :: forall a. (a ~ MReactionContent) => Value -> Parser a
parseJSON = String -> (Object -> Parser a) -> Value -> Parser a
forall a. String -> (Object -> Parser a) -> Value -> Parser a
withObject (TypeRep -> String
forall a. Show a => a -> String
show (TypeRep -> String) -> (Proxy a -> TypeRep) -> Proxy a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy a -> TypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> TypeRep
typeRep (Proxy a -> String) -> Proxy a -> String
forall a b. (a -> b) -> a -> b
$ forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @a) ((Object -> Parser a) -> Value -> Parser a)
-> (Object -> Parser a) -> Value -> Parser a
forall a b. (a -> b) -> a -> b
$ \Object
v → RelatesTo -> a
RelatesTo -> MReactionContent
MReactionContent (RelatesTo -> a) -> Parser RelatesTo -> Parser a
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser RelatesTo
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
forall s. IsString s => s
mRelatedToKey
mRelatedToKey ∷ IsString s ⇒ s
mRelatedToKey :: forall s. IsString s => s
mRelatedToKey = s
"m.relates_to"
type instance EventContent (MEventTypeOneOf '[ 'MReactionType ]) = MReactionContent
data RelatesTo = RelatesTo
{ RelatesTo -> EventId
relatesToEventId ∷ EventId
, RelatesTo -> Text
relatesToKey ∷ Text
, RelatesTo -> MEventTypeOneOf '[ 'MAnnotationType]
relatesToRelType ∷ MEventTypeOneOf '[ 'MAnnotationType ]
}
deriving stock ((forall x. RelatesTo -> Rep RelatesTo x)
-> (forall x. Rep RelatesTo x -> RelatesTo) -> Generic RelatesTo
forall x. Rep RelatesTo x -> RelatesTo
forall x. RelatesTo -> Rep RelatesTo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. RelatesTo -> Rep RelatesTo x
from :: forall x. RelatesTo -> Rep RelatesTo x
$cto :: forall x. Rep RelatesTo x -> RelatesTo
to :: forall x. Rep RelatesTo x -> RelatesTo
Generic, Int -> RelatesTo -> ShowS
[RelatesTo] -> ShowS
RelatesTo -> String
(Int -> RelatesTo -> ShowS)
-> (RelatesTo -> String)
-> ([RelatesTo] -> ShowS)
-> Show RelatesTo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> RelatesTo -> ShowS
showsPrec :: Int -> RelatesTo -> ShowS
$cshow :: RelatesTo -> String
show :: RelatesTo -> String
$cshowList :: [RelatesTo] -> ShowS
showList :: [RelatesTo] -> ShowS
Show, RelatesTo -> RelatesTo -> Bool
(RelatesTo -> RelatesTo -> Bool)
-> (RelatesTo -> RelatesTo -> Bool) -> Eq RelatesTo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: RelatesTo -> RelatesTo -> Bool
== :: RelatesTo -> RelatesTo -> Bool
$c/= :: RelatesTo -> RelatesTo -> Bool
/= :: RelatesTo -> RelatesTo -> Bool
Eq)
instance ToJSON RelatesTo where toJSON :: RelatesTo -> Value
toJSON = RelatesTo -> Value
forall a.
(Generic a, Typeable a, GToJSON' Value Zero (Rep a)) =>
a -> Value
myGenericToJSON
instance FromJSON RelatesTo where parseJSON :: Value -> Parser RelatesTo
parseJSON = Value -> Parser RelatesTo
forall a.
(Generic a, Typeable a, GFromJSON Zero (Rep a)) =>
Value -> Parser a
myGenericParseJSON
mTypeGenericParseJSON ∷ ∀a. (Bounded a, Enum a, Typeable a, ToJSON a) ⇒ Value → Parser a
mTypeGenericParseJSON :: forall a.
(Bounded a, Enum a, Typeable a, ToJSON a) =>
Value -> Parser a
mTypeGenericParseJSON Value
jsonInput
= Parser a -> (a -> Parser a) -> Maybe a -> Parser a
forall b a. b -> (a -> b) -> Maybe a -> b
maybe (String -> Value -> Parser a
forall a. String -> Value -> Parser a
typeMismatch (TypeRep -> String
forall a. Show a => a -> String
show (TypeRep -> String) -> (Proxy a -> TypeRep) -> Proxy a -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Proxy a -> TypeRep
forall {k} (proxy :: k -> *) (a :: k).
Typeable a =>
proxy a -> TypeRep
typeRep (Proxy a -> String) -> Proxy a -> String
forall a b. (a -> b) -> a -> b
$ forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @a) Value
jsonInput) a -> Parser a
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
(Maybe a -> Parser a) -> Maybe a -> Parser a
forall a b. (a -> b) -> a -> b
$ (a -> Bool) -> [a] -> Maybe a
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Maybe a
find ((Value
jsonInput Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
==) (Value -> Bool) -> (a -> Value) -> a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> Value
forall a. ToJSON a => a -> Value
toJSON) [a
forall a. Bounded a => a
minBound .. a
forall a. Bounded a => a
maxBound ∷ a]