module TD.Data.BusinessFeature
  (BusinessFeature(..)) where

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

-- | Describes a feature available to Business user accounts
data BusinessFeature
  = BusinessFeatureLocation -- ^ The ability to set location
  | BusinessFeatureOpeningHours -- ^ The ability to set opening hours
  | BusinessFeatureQuickReplies -- ^ The ability to use quick replies
  | BusinessFeatureGreetingMessage -- ^ The ability to set up a greeting message
  | BusinessFeatureAwayMessage -- ^ The ability to set up an away message
  | BusinessFeatureAccountLinks -- ^ The ability to create links to the business account with predefined message text
  | BusinessFeatureStartPage -- ^ The ability to customize start page
  | BusinessFeatureBots -- ^ The ability to connect a bot to the account
  | BusinessFeatureEmojiStatus -- ^ The ability to show an emoji status along with the business name
  | BusinessFeatureChatFolderTags -- ^ The ability to display folder names for each chat in the chat list
  | BusinessFeatureUpgradedStories -- ^ Allowed to use many additional features for stories
  deriving (BusinessFeature -> BusinessFeature -> Bool
(BusinessFeature -> BusinessFeature -> Bool)
-> (BusinessFeature -> BusinessFeature -> Bool)
-> Eq BusinessFeature
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: BusinessFeature -> BusinessFeature -> Bool
== :: BusinessFeature -> BusinessFeature -> Bool
$c/= :: BusinessFeature -> BusinessFeature -> Bool
/= :: BusinessFeature -> BusinessFeature -> Bool
Eq, Int -> BusinessFeature -> ShowS
[BusinessFeature] -> ShowS
BusinessFeature -> String
(Int -> BusinessFeature -> ShowS)
-> (BusinessFeature -> String)
-> ([BusinessFeature] -> ShowS)
-> Show BusinessFeature
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> BusinessFeature -> ShowS
showsPrec :: Int -> BusinessFeature -> ShowS
$cshow :: BusinessFeature -> String
show :: BusinessFeature -> String
$cshowList :: [BusinessFeature] -> ShowS
showList :: [BusinessFeature] -> ShowS
Show)

instance I.ShortShow BusinessFeature where
  shortShow :: BusinessFeature -> String
shortShow BusinessFeature
BusinessFeatureLocation
      = String
"BusinessFeatureLocation"
  shortShow BusinessFeature
BusinessFeatureOpeningHours
      = String
"BusinessFeatureOpeningHours"
  shortShow BusinessFeature
BusinessFeatureQuickReplies
      = String
"BusinessFeatureQuickReplies"
  shortShow BusinessFeature
BusinessFeatureGreetingMessage
      = String
"BusinessFeatureGreetingMessage"
  shortShow BusinessFeature
BusinessFeatureAwayMessage
      = String
"BusinessFeatureAwayMessage"
  shortShow BusinessFeature
BusinessFeatureAccountLinks
      = String
"BusinessFeatureAccountLinks"
  shortShow BusinessFeature
BusinessFeatureStartPage
      = String
"BusinessFeatureStartPage"
  shortShow BusinessFeature
BusinessFeatureBots
      = String
"BusinessFeatureBots"
  shortShow BusinessFeature
BusinessFeatureEmojiStatus
      = String
"BusinessFeatureEmojiStatus"
  shortShow BusinessFeature
BusinessFeatureChatFolderTags
      = String
"BusinessFeatureChatFolderTags"
  shortShow BusinessFeature
BusinessFeatureUpgradedStories
      = String
"BusinessFeatureUpgradedStories"

instance AT.FromJSON BusinessFeature where
  parseJSON :: Value -> Parser BusinessFeature
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
"businessFeatureLocation"        -> BusinessFeature -> Parser BusinessFeature
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BusinessFeature
BusinessFeatureLocation
      String
"businessFeatureOpeningHours"    -> BusinessFeature -> Parser BusinessFeature
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BusinessFeature
BusinessFeatureOpeningHours
      String
"businessFeatureQuickReplies"    -> BusinessFeature -> Parser BusinessFeature
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BusinessFeature
BusinessFeatureQuickReplies
      String
"businessFeatureGreetingMessage" -> BusinessFeature -> Parser BusinessFeature
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BusinessFeature
BusinessFeatureGreetingMessage
      String
"businessFeatureAwayMessage"     -> BusinessFeature -> Parser BusinessFeature
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BusinessFeature
BusinessFeatureAwayMessage
      String
"businessFeatureAccountLinks"    -> BusinessFeature -> Parser BusinessFeature
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BusinessFeature
BusinessFeatureAccountLinks
      String
"businessFeatureStartPage"       -> BusinessFeature -> Parser BusinessFeature
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BusinessFeature
BusinessFeatureStartPage
      String
"businessFeatureBots"            -> BusinessFeature -> Parser BusinessFeature
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BusinessFeature
BusinessFeatureBots
      String
"businessFeatureEmojiStatus"     -> BusinessFeature -> Parser BusinessFeature
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BusinessFeature
BusinessFeatureEmojiStatus
      String
"businessFeatureChatFolderTags"  -> BusinessFeature -> Parser BusinessFeature
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BusinessFeature
BusinessFeatureChatFolderTags
      String
"businessFeatureUpgradedStories" -> BusinessFeature -> Parser BusinessFeature
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure BusinessFeature
BusinessFeatureUpgradedStories
      String
_                                -> Parser BusinessFeature
forall a. Monoid a => a
mempty
    
  parseJSON Value
_ = Parser BusinessFeature
forall a. Monoid a => a
mempty

instance AT.ToJSON BusinessFeature where
  toJSON :: BusinessFeature -> Value
toJSON BusinessFeature
BusinessFeatureLocation
      = [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
"businessFeatureLocation"
        ]
  toJSON BusinessFeature
BusinessFeatureOpeningHours
      = [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
"businessFeatureOpeningHours"
        ]
  toJSON BusinessFeature
BusinessFeatureQuickReplies
      = [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
"businessFeatureQuickReplies"
        ]
  toJSON BusinessFeature
BusinessFeatureGreetingMessage
      = [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
"businessFeatureGreetingMessage"
        ]
  toJSON BusinessFeature
BusinessFeatureAwayMessage
      = [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
"businessFeatureAwayMessage"
        ]
  toJSON BusinessFeature
BusinessFeatureAccountLinks
      = [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
"businessFeatureAccountLinks"
        ]
  toJSON BusinessFeature
BusinessFeatureStartPage
      = [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
"businessFeatureStartPage"
        ]
  toJSON BusinessFeature
BusinessFeatureBots
      = [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
"businessFeatureBots"
        ]
  toJSON BusinessFeature
BusinessFeatureEmojiStatus
      = [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
"businessFeatureEmojiStatus"
        ]
  toJSON BusinessFeature
BusinessFeatureChatFolderTags
      = [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
"businessFeatureChatFolderTags"
        ]
  toJSON BusinessFeature
BusinessFeatureUpgradedStories
      = [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
"businessFeatureUpgradedStories"
        ]