{-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
module Network.Google.FirebaseRemoteConfig.Types.Product where
import Network.Google.FirebaseRemoteConfig.Types.Sum
import Network.Google.Prelude
data RemoteConfigParameterValue = RemoteConfigParameterValue'
{ _rcpvValue :: !(Maybe Text)
, _rcpvUseInAppDefault :: !(Maybe Bool)
} deriving (Eq,Show,Data,Typeable,Generic)
remoteConfigParameterValue
:: RemoteConfigParameterValue
remoteConfigParameterValue =
RemoteConfigParameterValue'
{ _rcpvValue = Nothing
, _rcpvUseInAppDefault = Nothing
}
rcpvValue :: Lens' RemoteConfigParameterValue (Maybe Text)
rcpvValue
= lens _rcpvValue (\ s a -> s{_rcpvValue = a})
rcpvUseInAppDefault :: Lens' RemoteConfigParameterValue (Maybe Bool)
rcpvUseInAppDefault
= lens _rcpvUseInAppDefault
(\ s a -> s{_rcpvUseInAppDefault = a})
instance FromJSON RemoteConfigParameterValue where
parseJSON
= withObject "RemoteConfigParameterValue"
(\ o ->
RemoteConfigParameterValue' <$>
(o .:? "value") <*> (o .:? "useInAppDefault"))
instance ToJSON RemoteConfigParameterValue where
toJSON RemoteConfigParameterValue'{..}
= object
(catMaybes
[("value" .=) <$> _rcpvValue,
("useInAppDefault" .=) <$> _rcpvUseInAppDefault])
newtype RemoteConfigParameterConditionalValues = RemoteConfigParameterConditionalValues'
{ _rcpcvAddtional :: HashMap Text RemoteConfigParameterValue
} deriving (Eq,Show,Data,Typeable,Generic)
remoteConfigParameterConditionalValues
:: HashMap Text RemoteConfigParameterValue
-> RemoteConfigParameterConditionalValues
remoteConfigParameterConditionalValues pRcpcvAddtional_ =
RemoteConfigParameterConditionalValues'
{ _rcpcvAddtional = _Coerce # pRcpcvAddtional_
}
rcpcvAddtional :: Lens' RemoteConfigParameterConditionalValues (HashMap Text RemoteConfigParameterValue)
rcpcvAddtional
= lens _rcpcvAddtional
(\ s a -> s{_rcpcvAddtional = a})
. _Coerce
instance FromJSON
RemoteConfigParameterConditionalValues where
parseJSON
= withObject "RemoteConfigParameterConditionalValues"
(\ o ->
RemoteConfigParameterConditionalValues' <$>
(parseJSONObject o))
instance ToJSON
RemoteConfigParameterConditionalValues where
toJSON = toJSON . _rcpcvAddtional
newtype RemoteConfigParameters = RemoteConfigParameters'
{ _rcpAddtional :: HashMap Text RemoteConfigParameter
} deriving (Eq,Show,Data,Typeable,Generic)
remoteConfigParameters
:: HashMap Text RemoteConfigParameter
-> RemoteConfigParameters
remoteConfigParameters pRcpAddtional_ =
RemoteConfigParameters'
{ _rcpAddtional = _Coerce # pRcpAddtional_
}
rcpAddtional :: Lens' RemoteConfigParameters (HashMap Text RemoteConfigParameter)
rcpAddtional
= lens _rcpAddtional (\ s a -> s{_rcpAddtional = a})
. _Coerce
instance FromJSON RemoteConfigParameters where
parseJSON
= withObject "RemoteConfigParameters"
(\ o ->
RemoteConfigParameters' <$> (parseJSONObject o))
instance ToJSON RemoteConfigParameters where
toJSON = toJSON . _rcpAddtional
data RemoteConfigParameter = RemoteConfigParameter'
{ _rcpDefaultValue :: !(Maybe RemoteConfigParameterValue)
, _rcpDescription :: !(Maybe Text)
, _rcpConditionalValues :: !(Maybe RemoteConfigParameterConditionalValues)
} deriving (Eq,Show,Data,Typeable,Generic)
remoteConfigParameter
:: RemoteConfigParameter
remoteConfigParameter =
RemoteConfigParameter'
{ _rcpDefaultValue = Nothing
, _rcpDescription = Nothing
, _rcpConditionalValues = Nothing
}
rcpDefaultValue :: Lens' RemoteConfigParameter (Maybe RemoteConfigParameterValue)
rcpDefaultValue
= lens _rcpDefaultValue
(\ s a -> s{_rcpDefaultValue = a})
rcpDescription :: Lens' RemoteConfigParameter (Maybe Text)
rcpDescription
= lens _rcpDescription
(\ s a -> s{_rcpDescription = a})
rcpConditionalValues :: Lens' RemoteConfigParameter (Maybe RemoteConfigParameterConditionalValues)
rcpConditionalValues
= lens _rcpConditionalValues
(\ s a -> s{_rcpConditionalValues = a})
instance FromJSON RemoteConfigParameter where
parseJSON
= withObject "RemoteConfigParameter"
(\ o ->
RemoteConfigParameter' <$>
(o .:? "defaultValue") <*> (o .:? "description") <*>
(o .:? "conditionalValues"))
instance ToJSON RemoteConfigParameter where
toJSON RemoteConfigParameter'{..}
= object
(catMaybes
[("defaultValue" .=) <$> _rcpDefaultValue,
("description" .=) <$> _rcpDescription,
("conditionalValues" .=) <$> _rcpConditionalValues])
data RemoteConfigCondition = RemoteConfigCondition'
{ _rccTagColor :: !(Maybe RemoteConfigConditionTagColor)
, _rccName :: !(Maybe Text)
, _rccExpression :: !(Maybe Text)
, _rccDescription :: !(Maybe Text)
} deriving (Eq,Show,Data,Typeable,Generic)
remoteConfigCondition
:: RemoteConfigCondition
remoteConfigCondition =
RemoteConfigCondition'
{ _rccTagColor = Nothing
, _rccName = Nothing
, _rccExpression = Nothing
, _rccDescription = Nothing
}
rccTagColor :: Lens' RemoteConfigCondition (Maybe RemoteConfigConditionTagColor)
rccTagColor
= lens _rccTagColor (\ s a -> s{_rccTagColor = a})
rccName :: Lens' RemoteConfigCondition (Maybe Text)
rccName = lens _rccName (\ s a -> s{_rccName = a})
rccExpression :: Lens' RemoteConfigCondition (Maybe Text)
rccExpression
= lens _rccExpression
(\ s a -> s{_rccExpression = a})
rccDescription :: Lens' RemoteConfigCondition (Maybe Text)
rccDescription
= lens _rccDescription
(\ s a -> s{_rccDescription = a})
instance FromJSON RemoteConfigCondition where
parseJSON
= withObject "RemoteConfigCondition"
(\ o ->
RemoteConfigCondition' <$>
(o .:? "tagColor") <*> (o .:? "name") <*>
(o .:? "expression")
<*> (o .:? "description"))
instance ToJSON RemoteConfigCondition where
toJSON RemoteConfigCondition'{..}
= object
(catMaybes
[("tagColor" .=) <$> _rccTagColor,
("name" .=) <$> _rccName,
("expression" .=) <$> _rccExpression,
("description" .=) <$> _rccDescription])
data RemoteConfig = RemoteConfig'
{ _rcParameters :: !(Maybe RemoteConfigParameters)
, _rcConditions :: !(Maybe [RemoteConfigCondition])
} deriving (Eq,Show,Data,Typeable,Generic)
remoteConfig
:: RemoteConfig
remoteConfig =
RemoteConfig'
{ _rcParameters = Nothing
, _rcConditions = Nothing
}
rcParameters :: Lens' RemoteConfig (Maybe RemoteConfigParameters)
rcParameters
= lens _rcParameters (\ s a -> s{_rcParameters = a})
rcConditions :: Lens' RemoteConfig [RemoteConfigCondition]
rcConditions
= lens _rcConditions (\ s a -> s{_rcConditions = a})
. _Default
. _Coerce
instance FromJSON RemoteConfig where
parseJSON
= withObject "RemoteConfig"
(\ o ->
RemoteConfig' <$>
(o .:? "parameters") <*>
(o .:? "conditions" .!= mempty))
instance ToJSON RemoteConfig where
toJSON RemoteConfig'{..}
= object
(catMaybes
[("parameters" .=) <$> _rcParameters,
("conditions" .=) <$> _rcConditions])