module TD.Data.AutoDownloadSettings
( AutoDownloadSettings(..)
, defaultAutoDownloadSettings
) where
import qualified Data.Aeson as A
import qualified Data.Aeson.Types as AT
import qualified TD.Lib.Internal as I
data AutoDownloadSettings
= AutoDownloadSettings
{ AutoDownloadSettings -> Maybe Bool
is_auto_download_enabled :: Maybe Bool
, AutoDownloadSettings -> Maybe Int
max_photo_file_size :: Maybe Int
, AutoDownloadSettings -> Maybe Int
max_video_file_size :: Maybe Int
, AutoDownloadSettings -> Maybe Int
max_other_file_size :: Maybe Int
, AutoDownloadSettings -> Maybe Int
video_upload_bitrate :: Maybe Int
, AutoDownloadSettings -> Maybe Bool
preload_large_videos :: Maybe Bool
, AutoDownloadSettings -> Maybe Bool
preload_next_audio :: Maybe Bool
, AutoDownloadSettings -> Maybe Bool
preload_stories :: Maybe Bool
, AutoDownloadSettings -> Maybe Bool
use_less_data_for_calls :: Maybe Bool
}
deriving (AutoDownloadSettings -> AutoDownloadSettings -> Bool
(AutoDownloadSettings -> AutoDownloadSettings -> Bool)
-> (AutoDownloadSettings -> AutoDownloadSettings -> Bool)
-> Eq AutoDownloadSettings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: AutoDownloadSettings -> AutoDownloadSettings -> Bool
== :: AutoDownloadSettings -> AutoDownloadSettings -> Bool
$c/= :: AutoDownloadSettings -> AutoDownloadSettings -> Bool
/= :: AutoDownloadSettings -> AutoDownloadSettings -> Bool
Eq, Int -> AutoDownloadSettings -> ShowS
[AutoDownloadSettings] -> ShowS
AutoDownloadSettings -> String
(Int -> AutoDownloadSettings -> ShowS)
-> (AutoDownloadSettings -> String)
-> ([AutoDownloadSettings] -> ShowS)
-> Show AutoDownloadSettings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AutoDownloadSettings -> ShowS
showsPrec :: Int -> AutoDownloadSettings -> ShowS
$cshow :: AutoDownloadSettings -> String
show :: AutoDownloadSettings -> String
$cshowList :: [AutoDownloadSettings] -> ShowS
showList :: [AutoDownloadSettings] -> ShowS
Show)
instance I.ShortShow AutoDownloadSettings where
shortShow :: AutoDownloadSettings -> String
shortShow AutoDownloadSettings
{ is_auto_download_enabled :: AutoDownloadSettings -> Maybe Bool
is_auto_download_enabled = Maybe Bool
is_auto_download_enabled_
, max_photo_file_size :: AutoDownloadSettings -> Maybe Int
max_photo_file_size = Maybe Int
max_photo_file_size_
, max_video_file_size :: AutoDownloadSettings -> Maybe Int
max_video_file_size = Maybe Int
max_video_file_size_
, max_other_file_size :: AutoDownloadSettings -> Maybe Int
max_other_file_size = Maybe Int
max_other_file_size_
, video_upload_bitrate :: AutoDownloadSettings -> Maybe Int
video_upload_bitrate = Maybe Int
video_upload_bitrate_
, preload_large_videos :: AutoDownloadSettings -> Maybe Bool
preload_large_videos = Maybe Bool
preload_large_videos_
, preload_next_audio :: AutoDownloadSettings -> Maybe Bool
preload_next_audio = Maybe Bool
preload_next_audio_
, preload_stories :: AutoDownloadSettings -> Maybe Bool
preload_stories = Maybe Bool
preload_stories_
, use_less_data_for_calls :: AutoDownloadSettings -> Maybe Bool
use_less_data_for_calls = Maybe Bool
use_less_data_for_calls_
}
= String
"AutoDownloadSettings"
String -> ShowS
forall a. [a] -> [a] -> [a]
++ [String] -> String
I.cc
[ String
"is_auto_download_enabled" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
is_auto_download_enabled_
, String
"max_photo_file_size" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
max_photo_file_size_
, String
"max_video_file_size" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
max_video_file_size_
, String
"max_other_file_size" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
max_other_file_size_
, String
"video_upload_bitrate" String -> Maybe Int -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Int
video_upload_bitrate_
, String
"preload_large_videos" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
preload_large_videos_
, String
"preload_next_audio" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
preload_next_audio_
, String
"preload_stories" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
preload_stories_
, String
"use_less_data_for_calls" String -> Maybe Bool -> String
forall a. ShortShow a => String -> Maybe a -> String
`I.p` Maybe Bool
use_less_data_for_calls_
]
instance AT.FromJSON AutoDownloadSettings where
parseJSON :: Value -> Parser AutoDownloadSettings
parseJSON v :: Value
v@(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
"autoDownloadSettings" -> Value -> Parser AutoDownloadSettings
parseAutoDownloadSettings Value
v
String
_ -> Parser AutoDownloadSettings
forall a. Monoid a => a
mempty
where
parseAutoDownloadSettings :: A.Value -> AT.Parser AutoDownloadSettings
parseAutoDownloadSettings :: Value -> Parser AutoDownloadSettings
parseAutoDownloadSettings = String
-> (Object -> Parser AutoDownloadSettings)
-> Value
-> Parser AutoDownloadSettings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
A.withObject String
"AutoDownloadSettings" ((Object -> Parser AutoDownloadSettings)
-> Value -> Parser AutoDownloadSettings)
-> (Object -> Parser AutoDownloadSettings)
-> Value
-> Parser AutoDownloadSettings
forall a b. (a -> b) -> a -> b
$ \Object
o -> do
Maybe Bool
is_auto_download_enabled_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"is_auto_download_enabled"
Maybe Int
max_photo_file_size_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"max_photo_file_size"
Maybe Int
max_video_file_size_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"max_video_file_size"
Maybe Int
max_other_file_size_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"max_other_file_size"
Maybe Int
video_upload_bitrate_ <- Object
o Object -> Key -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"video_upload_bitrate"
Maybe Bool
preload_large_videos_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"preload_large_videos"
Maybe Bool
preload_next_audio_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"preload_next_audio"
Maybe Bool
preload_stories_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"preload_stories"
Maybe Bool
use_less_data_for_calls_ <- Object
o Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
A..:? Key
"use_less_data_for_calls"
AutoDownloadSettings -> Parser AutoDownloadSettings
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AutoDownloadSettings -> Parser AutoDownloadSettings)
-> AutoDownloadSettings -> Parser AutoDownloadSettings
forall a b. (a -> b) -> a -> b
$ AutoDownloadSettings
{ is_auto_download_enabled :: Maybe Bool
is_auto_download_enabled = Maybe Bool
is_auto_download_enabled_
, max_photo_file_size :: Maybe Int
max_photo_file_size = Maybe Int
max_photo_file_size_
, max_video_file_size :: Maybe Int
max_video_file_size = Maybe Int
max_video_file_size_
, max_other_file_size :: Maybe Int
max_other_file_size = Maybe Int
max_other_file_size_
, video_upload_bitrate :: Maybe Int
video_upload_bitrate = Maybe Int
video_upload_bitrate_
, preload_large_videos :: Maybe Bool
preload_large_videos = Maybe Bool
preload_large_videos_
, preload_next_audio :: Maybe Bool
preload_next_audio = Maybe Bool
preload_next_audio_
, preload_stories :: Maybe Bool
preload_stories = Maybe Bool
preload_stories_
, use_less_data_for_calls :: Maybe Bool
use_less_data_for_calls = Maybe Bool
use_less_data_for_calls_
}
parseJSON Value
_ = Parser AutoDownloadSettings
forall a. Monoid a => a
mempty
instance AT.ToJSON AutoDownloadSettings where
toJSON :: AutoDownloadSettings -> Value
toJSON AutoDownloadSettings
{ is_auto_download_enabled :: AutoDownloadSettings -> Maybe Bool
is_auto_download_enabled = Maybe Bool
is_auto_download_enabled_
, max_photo_file_size :: AutoDownloadSettings -> Maybe Int
max_photo_file_size = Maybe Int
max_photo_file_size_
, max_video_file_size :: AutoDownloadSettings -> Maybe Int
max_video_file_size = Maybe Int
max_video_file_size_
, max_other_file_size :: AutoDownloadSettings -> Maybe Int
max_other_file_size = Maybe Int
max_other_file_size_
, video_upload_bitrate :: AutoDownloadSettings -> Maybe Int
video_upload_bitrate = Maybe Int
video_upload_bitrate_
, preload_large_videos :: AutoDownloadSettings -> Maybe Bool
preload_large_videos = Maybe Bool
preload_large_videos_
, preload_next_audio :: AutoDownloadSettings -> Maybe Bool
preload_next_audio = Maybe Bool
preload_next_audio_
, preload_stories :: AutoDownloadSettings -> Maybe Bool
preload_stories = Maybe Bool
preload_stories_
, use_less_data_for_calls :: AutoDownloadSettings -> Maybe Bool
use_less_data_for_calls = Maybe Bool
use_less_data_for_calls_
}
= [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
"autoDownloadSettings"
, Key
"is_auto_download_enabled" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
is_auto_download_enabled_
, Key
"max_photo_file_size" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
max_photo_file_size_
, Key
"max_video_file_size" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
max_video_file_size_
, Key
"max_other_file_size" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
max_other_file_size_
, Key
"video_upload_bitrate" Key -> Maybe Int -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Int
video_upload_bitrate_
, Key
"preload_large_videos" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
preload_large_videos_
, Key
"preload_next_audio" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
preload_next_audio_
, Key
"preload_stories" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
preload_stories_
, Key
"use_less_data_for_calls" Key -> Maybe Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
A..= Maybe Bool
use_less_data_for_calls_
]
defaultAutoDownloadSettings :: AutoDownloadSettings
defaultAutoDownloadSettings :: AutoDownloadSettings
defaultAutoDownloadSettings =
AutoDownloadSettings
{ is_auto_download_enabled :: Maybe Bool
is_auto_download_enabled = Maybe Bool
forall a. Maybe a
Nothing
, max_photo_file_size :: Maybe Int
max_photo_file_size = Maybe Int
forall a. Maybe a
Nothing
, max_video_file_size :: Maybe Int
max_video_file_size = Maybe Int
forall a. Maybe a
Nothing
, max_other_file_size :: Maybe Int
max_other_file_size = Maybe Int
forall a. Maybe a
Nothing
, video_upload_bitrate :: Maybe Int
video_upload_bitrate = Maybe Int
forall a. Maybe a
Nothing
, preload_large_videos :: Maybe Bool
preload_large_videos = Maybe Bool
forall a. Maybe a
Nothing
, preload_next_audio :: Maybe Bool
preload_next_audio = Maybe Bool
forall a. Maybe a
Nothing
, preload_stories :: Maybe Bool
preload_stories = Maybe Bool
forall a. Maybe a
Nothing
, use_less_data_for_calls :: Maybe Bool
use_less_data_for_calls = Maybe Bool
forall a. Maybe a
Nothing
}