module Wire.API.Event.Gundeck where import Data.Aeson import Data.Aeson.KeyMap qualified as KeyMap import Data.Json.Util import Imports import Wire.API.Push.V2.Token newtype PushRemove = PushRemove PushToken deriving (PushRemove -> PushRemove -> Bool (PushRemove -> PushRemove -> Bool) -> (PushRemove -> PushRemove -> Bool) -> Eq PushRemove forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a $c== :: PushRemove -> PushRemove -> Bool == :: PushRemove -> PushRemove -> Bool $c/= :: PushRemove -> PushRemove -> Bool /= :: PushRemove -> PushRemove -> Bool Eq, Int -> PushRemove -> ShowS [PushRemove] -> ShowS PushRemove -> String (Int -> PushRemove -> ShowS) -> (PushRemove -> String) -> ([PushRemove] -> ShowS) -> Show PushRemove forall a. (Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a $cshowsPrec :: Int -> PushRemove -> ShowS showsPrec :: Int -> PushRemove -> ShowS $cshow :: PushRemove -> String show :: PushRemove -> String $cshowList :: [PushRemove] -> ShowS showList :: [PushRemove] -> ShowS Show) instance FromJSON PushRemove where parseJSON :: Value -> Parser PushRemove parseJSON = String -> (Object -> Parser PushRemove) -> Value -> Parser PushRemove forall a. String -> (Object -> Parser a) -> Value -> Parser a withObject String "push-removed object" ((Object -> Parser PushRemove) -> Value -> Parser PushRemove) -> (Object -> Parser PushRemove) -> Value -> Parser PushRemove forall a b. (a -> b) -> a -> b $ \Object o -> PushToken -> PushRemove PushRemove (PushToken -> PushRemove) -> Parser PushToken -> Parser PushRemove forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b <$> Object o Object -> Key -> Parser PushToken forall a. FromJSON a => Object -> Key -> Parser a .: Key "token" instance ToJSON PushRemove where toJSON :: PushRemove -> Value toJSON = Object -> Value Object (Object -> Value) -> (PushRemove -> Object) -> PushRemove -> Value forall b c a. (b -> c) -> (a -> b) -> a -> c . PushRemove -> Object forall a. ToJSONObject a => a -> Object toJSONObject instance ToJSONObject PushRemove where toJSONObject :: PushRemove -> Object toJSONObject (PushRemove PushToken t) = [(Key, Value)] -> Object forall v. [(Key, v)] -> KeyMap v KeyMap.fromList [ Key "type" Key -> Text -> (Key, Value) forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv forall v. ToJSON v => Key -> v -> (Key, Value) .= (Text "user.push-remove" :: Text), Key "token" Key -> PushToken -> (Key, Value) forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv forall v. ToJSON v => Key -> v -> (Key, Value) .= PushToken t ]