module TD.Data.ReportReason
  (ReportReason(..)) where

import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I

-- | Describes the reason why a chat is reported
data ReportReason
  = ReportReasonSpam -- ^ The chat contains spam messages
  | ReportReasonViolence -- ^ The chat promotes violence
  | ReportReasonPornography -- ^ The chat contains pornographic messages
  | ReportReasonChildAbuse -- ^ The chat has child abuse related content
  | ReportReasonCopyright -- ^ The chat contains copyrighted content
  | ReportReasonUnrelatedLocation -- ^ The location-based chat is unrelated to its stated location
  | ReportReasonFake -- ^ The chat represents a fake account
  | ReportReasonIllegalDrugs -- ^ The chat has illegal drugs related content
  | ReportReasonPersonalDetails -- ^ The chat contains messages with personal details
  | ReportReasonCustom -- ^ A custom reason provided by the user
  deriving (ReportReason -> ReportReason -> Bool
(ReportReason -> ReportReason -> Bool)
-> (ReportReason -> ReportReason -> Bool) -> Eq ReportReason
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: ReportReason -> ReportReason -> Bool
== :: ReportReason -> ReportReason -> Bool
$c/= :: ReportReason -> ReportReason -> Bool
/= :: ReportReason -> ReportReason -> Bool
Eq, Int -> ReportReason -> ShowS
[ReportReason] -> ShowS
ReportReason -> String
(Int -> ReportReason -> ShowS)
-> (ReportReason -> String)
-> ([ReportReason] -> ShowS)
-> Show ReportReason
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> ReportReason -> ShowS
showsPrec :: Int -> ReportReason -> ShowS
$cshow :: ReportReason -> String
show :: ReportReason -> String
$cshowList :: [ReportReason] -> ShowS
showList :: [ReportReason] -> ShowS
Show)

instance I.ShortShow ReportReason where
  shortShow :: ReportReason -> String
shortShow ReportReason
ReportReasonSpam
      = String
"ReportReasonSpam"
  shortShow ReportReason
ReportReasonViolence
      = String
"ReportReasonViolence"
  shortShow ReportReason
ReportReasonPornography
      = String
"ReportReasonPornography"
  shortShow ReportReason
ReportReasonChildAbuse
      = String
"ReportReasonChildAbuse"
  shortShow ReportReason
ReportReasonCopyright
      = String
"ReportReasonCopyright"
  shortShow ReportReason
ReportReasonUnrelatedLocation
      = String
"ReportReasonUnrelatedLocation"
  shortShow ReportReason
ReportReasonFake
      = String
"ReportReasonFake"
  shortShow ReportReason
ReportReasonIllegalDrugs
      = String
"ReportReasonIllegalDrugs"
  shortShow ReportReason
ReportReasonPersonalDetails
      = String
"ReportReasonPersonalDetails"
  shortShow ReportReason
ReportReasonCustom
      = String
"ReportReasonCustom"

instance AT.FromJSON ReportReason where
  parseJSON :: Value -> Parser ReportReason
parseJSON (AT.Object Object
obj) = do
    String
t <- Object
obj Object -> Key -> Parser String
forall a. FromJSON a => Object -> Key -> Parser a
A..: Key
"@type" :: AT.Parser String

    case String
t of
      String
"reportReasonSpam"              -> ReportReason -> Parser ReportReason
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReportReason
ReportReasonSpam
      String
"reportReasonViolence"          -> ReportReason -> Parser ReportReason
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReportReason
ReportReasonViolence
      String
"reportReasonPornography"       -> ReportReason -> Parser ReportReason
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReportReason
ReportReasonPornography
      String
"reportReasonChildAbuse"        -> ReportReason -> Parser ReportReason
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReportReason
ReportReasonChildAbuse
      String
"reportReasonCopyright"         -> ReportReason -> Parser ReportReason
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReportReason
ReportReasonCopyright
      String
"reportReasonUnrelatedLocation" -> ReportReason -> Parser ReportReason
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReportReason
ReportReasonUnrelatedLocation
      String
"reportReasonFake"              -> ReportReason -> Parser ReportReason
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReportReason
ReportReasonFake
      String
"reportReasonIllegalDrugs"      -> ReportReason -> Parser ReportReason
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReportReason
ReportReasonIllegalDrugs
      String
"reportReasonPersonalDetails"   -> ReportReason -> Parser ReportReason
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReportReason
ReportReasonPersonalDetails
      String
"reportReasonCustom"            -> ReportReason -> Parser ReportReason
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ReportReason
ReportReasonCustom
      String
_                               -> Parser ReportReason
forall a. Monoid a => a
mempty
    
  parseJSON Value
_ = Parser ReportReason
forall a. Monoid a => a
mempty

instance AT.ToJSON ReportReason where
  toJSON :: ReportReason -> Value
toJSON ReportReason
ReportReasonSpam
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"reportReasonSpam"
        ]
  toJSON ReportReason
ReportReasonViolence
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"reportReasonViolence"
        ]
  toJSON ReportReason
ReportReasonPornography
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"reportReasonPornography"
        ]
  toJSON ReportReason
ReportReasonChildAbuse
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"reportReasonChildAbuse"
        ]
  toJSON ReportReason
ReportReasonCopyright
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"reportReasonCopyright"
        ]
  toJSON ReportReason
ReportReasonUnrelatedLocation
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"reportReasonUnrelatedLocation"
        ]
  toJSON ReportReason
ReportReasonFake
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"reportReasonFake"
        ]
  toJSON ReportReason
ReportReasonIllegalDrugs
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"reportReasonIllegalDrugs"
        ]
  toJSON ReportReason
ReportReasonPersonalDetails
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"reportReasonPersonalDetails"
        ]
  toJSON ReportReason
ReportReasonCustom
      = [Pair] -> Value
A.object
        [ Key
"@type" Key -> Value -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Text -> Value
AT.String Text
"reportReasonCustom"
        ]