{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE OverloadedStrings #-}
module RecurlyClient.Types.Settings where
import qualified Control.Monad.Fail
import qualified Data.Aeson
import qualified Data.Aeson as Data.Aeson.Encoding.Internal
import qualified Data.Aeson as Data.Aeson.Types
import qualified Data.Aeson as Data.Aeson.Types.FromJSON
import qualified Data.Aeson as Data.Aeson.Types.Internal
import qualified Data.Aeson as Data.Aeson.Types.ToJSON
import qualified Data.ByteString
import qualified Data.ByteString as Data.ByteString.Internal
import qualified Data.Foldable
import qualified Data.Functor
import qualified Data.Maybe
import qualified Data.Scientific
import qualified Data.Text
import qualified Data.Text as Data.Text.Internal
import qualified Data.Time.Calendar as Data.Time.Calendar.Days
import qualified Data.Time.LocalTime as Data.Time.LocalTime.Internal.ZonedTime
import qualified GHC.Base
import qualified GHC.Classes
import qualified GHC.Int
import qualified GHC.Show
import qualified GHC.Types
import qualified RecurlyClient.Common
import RecurlyClient.TypeAlias
import qualified Prelude as GHC.Integer.Type
import qualified Prelude as GHC.Maybe
data Settings = Settings
{ Settings -> Maybe [Text]
settingsAccepted_currencies :: (GHC.Maybe.Maybe [Data.Text.Internal.Text])
, Settings -> Maybe SettingsBilling_address_requirement
settingsBilling_address_requirement :: (GHC.Maybe.Maybe SettingsBilling_address_requirement)
, Settings -> Maybe Text
settingsDefault_currency :: (GHC.Maybe.Maybe Data.Text.Internal.Text)
}
deriving
( Int -> Settings -> ShowS
[Settings] -> ShowS
Settings -> String
(Int -> Settings -> ShowS)
-> (Settings -> String) -> ([Settings] -> ShowS) -> Show Settings
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Settings -> ShowS
showsPrec :: Int -> Settings -> ShowS
$cshow :: Settings -> String
show :: Settings -> String
$cshowList :: [Settings] -> ShowS
showList :: [Settings] -> ShowS
GHC.Show.Show
, Settings -> Settings -> Bool
(Settings -> Settings -> Bool)
-> (Settings -> Settings -> Bool) -> Eq Settings
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Settings -> Settings -> Bool
== :: Settings -> Settings -> Bool
$c/= :: Settings -> Settings -> Bool
/= :: Settings -> Settings -> Bool
GHC.Classes.Eq
)
instance Data.Aeson.Types.ToJSON.ToJSON Settings where
toJSON :: Settings -> Value
toJSON Settings
obj = [Pair] -> Value
Data.Aeson.Types.Internal.object ([[Pair]] -> [Pair]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Pair] -> ([Text] -> [Pair]) -> Maybe [Text] -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> ([Text] -> Pair) -> [Text] -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"accepted_currencies" Key -> [Text] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (Settings -> Maybe [Text]
settingsAccepted_currencies Settings
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair]
-> (SettingsBilling_address_requirement -> [Pair])
-> Maybe SettingsBilling_address_requirement
-> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair])
-> (SettingsBilling_address_requirement -> Pair)
-> SettingsBilling_address_requirement
-> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"billing_address_requirement" Key -> SettingsBilling_address_requirement -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (Settings -> Maybe SettingsBilling_address_requirement
settingsBilling_address_requirement Settings
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [Pair] -> (Text -> [Pair]) -> Maybe Text -> [Pair]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Pair]
forall a. Monoid a => a
GHC.Base.mempty (Pair -> [Pair]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Pair -> [Pair]) -> (Text -> Pair) -> Text -> [Pair]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"default_currency" Key -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Pair
Data.Aeson.Types.ToJSON..=)) (Settings -> Maybe Text
settingsDefault_currency Settings
obj) [Pair] -> [[Pair]] -> [[Pair]]
forall a. a -> [a] -> [a]
: [[Pair]]
forall a. Monoid a => a
GHC.Base.mempty))
toEncoding :: Settings -> Encoding
toEncoding Settings
obj = Series -> Encoding
Data.Aeson.Encoding.Internal.pairs ([Series] -> Series
forall a. Monoid a => [a] -> a
GHC.Base.mconcat ([[Series]] -> [Series]
forall (t :: * -> *) a. Foldable t => t [a] -> [a]
Data.Foldable.concat ([Series] -> ([Text] -> [Series]) -> Maybe [Text] -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> ([Text] -> Series) -> [Text] -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"accepted_currencies" Key -> [Text] -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (Settings -> Maybe [Text]
settingsAccepted_currencies Settings
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series]
-> (SettingsBilling_address_requirement -> [Series])
-> Maybe SettingsBilling_address_requirement
-> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series])
-> (SettingsBilling_address_requirement -> Series)
-> SettingsBilling_address_requirement
-> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"billing_address_requirement" Key -> SettingsBilling_address_requirement -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (Settings -> Maybe SettingsBilling_address_requirement
settingsBilling_address_requirement Settings
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [Series] -> (Text -> [Series]) -> Maybe Text -> [Series]
forall b a. b -> (a -> b) -> Maybe a -> b
Data.Maybe.maybe [Series]
forall a. Monoid a => a
GHC.Base.mempty (Series -> [Series]
forall a. a -> [a]
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure (Series -> [Series]) -> (Text -> Series) -> Text -> [Series]
forall b c a. (b -> c) -> (a -> b) -> a -> c
GHC.Base.. (Key
"default_currency" Key -> Text -> Series
forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
forall v. ToJSON v => Key -> v -> Series
Data.Aeson.Types.ToJSON..=)) (Settings -> Maybe Text
settingsDefault_currency Settings
obj) [Series] -> [[Series]] -> [[Series]]
forall a. a -> [a] -> [a]
: [[Series]]
forall a. Monoid a => a
GHC.Base.mempty)))
instance Data.Aeson.Types.FromJSON.FromJSON Settings where
parseJSON :: Value -> Parser Settings
parseJSON = String -> (Object -> Parser Settings) -> Value -> Parser Settings
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.Aeson.Types.FromJSON.withObject String
"Settings" (\Object
obj -> (((Maybe [Text]
-> Maybe SettingsBilling_address_requirement
-> Maybe Text
-> Settings)
-> Parser
(Maybe [Text]
-> Maybe SettingsBilling_address_requirement
-> Maybe Text
-> Settings)
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure Maybe [Text]
-> Maybe SettingsBilling_address_requirement
-> Maybe Text
-> Settings
Settings Parser
(Maybe [Text]
-> Maybe SettingsBilling_address_requirement
-> Maybe Text
-> Settings)
-> Parser (Maybe [Text])
-> Parser
(Maybe SettingsBilling_address_requirement
-> Maybe Text -> Settings)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe [Text])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"accepted_currencies")) Parser
(Maybe SettingsBilling_address_requirement
-> Maybe Text -> Settings)
-> Parser (Maybe SettingsBilling_address_requirement)
-> Parser (Maybe Text -> Settings)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe SettingsBilling_address_requirement)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"billing_address_requirement")) Parser (Maybe Text -> Settings)
-> Parser (Maybe Text) -> Parser Settings
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
GHC.Base.<*> (Object
obj Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data.Aeson.Types.FromJSON..:? Key
"default_currency"))
mkSettings :: Settings
mkSettings :: Settings
mkSettings =
Settings
{ settingsAccepted_currencies :: Maybe [Text]
settingsAccepted_currencies = Maybe [Text]
forall a. Maybe a
GHC.Maybe.Nothing
, settingsBilling_address_requirement :: Maybe SettingsBilling_address_requirement
settingsBilling_address_requirement = Maybe SettingsBilling_address_requirement
forall a. Maybe a
GHC.Maybe.Nothing
, settingsDefault_currency :: Maybe Text
settingsDefault_currency = Maybe Text
forall a. Maybe a
GHC.Maybe.Nothing
}
data SettingsBilling_address_requirement
=
SettingsBilling_address_requirementOther Data.Aeson.Types.Internal.Value
|
SettingsBilling_address_requirementTyped Data.Text.Internal.Text
|
SettingsBilling_address_requirementEnumFull
|
SettingsBilling_address_requirementEnumNone
|
SettingsBilling_address_requirementEnumStreetzip
|
SettingsBilling_address_requirementEnumZip
deriving (Int -> SettingsBilling_address_requirement -> ShowS
[SettingsBilling_address_requirement] -> ShowS
SettingsBilling_address_requirement -> String
(Int -> SettingsBilling_address_requirement -> ShowS)
-> (SettingsBilling_address_requirement -> String)
-> ([SettingsBilling_address_requirement] -> ShowS)
-> Show SettingsBilling_address_requirement
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> SettingsBilling_address_requirement -> ShowS
showsPrec :: Int -> SettingsBilling_address_requirement -> ShowS
$cshow :: SettingsBilling_address_requirement -> String
show :: SettingsBilling_address_requirement -> String
$cshowList :: [SettingsBilling_address_requirement] -> ShowS
showList :: [SettingsBilling_address_requirement] -> ShowS
GHC.Show.Show, SettingsBilling_address_requirement
-> SettingsBilling_address_requirement -> Bool
(SettingsBilling_address_requirement
-> SettingsBilling_address_requirement -> Bool)
-> (SettingsBilling_address_requirement
-> SettingsBilling_address_requirement -> Bool)
-> Eq SettingsBilling_address_requirement
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: SettingsBilling_address_requirement
-> SettingsBilling_address_requirement -> Bool
== :: SettingsBilling_address_requirement
-> SettingsBilling_address_requirement -> Bool
$c/= :: SettingsBilling_address_requirement
-> SettingsBilling_address_requirement -> Bool
/= :: SettingsBilling_address_requirement
-> SettingsBilling_address_requirement -> Bool
GHC.Classes.Eq)
instance Data.Aeson.Types.ToJSON.ToJSON SettingsBilling_address_requirement where
toJSON :: SettingsBilling_address_requirement -> Value
toJSON (SettingsBilling_address_requirementOther Value
val) = Value
val
toJSON (SettingsBilling_address_requirementTyped Text
val) = Text -> Value
forall a. ToJSON a => a -> Value
Data.Aeson.Types.ToJSON.toJSON Text
val
toJSON (SettingsBilling_address_requirement
SettingsBilling_address_requirementEnumFull) = Value
"full"
toJSON (SettingsBilling_address_requirement
SettingsBilling_address_requirementEnumNone) = Value
"none"
toJSON (SettingsBilling_address_requirement
SettingsBilling_address_requirementEnumStreetzip) = Value
"streetzip"
toJSON (SettingsBilling_address_requirement
SettingsBilling_address_requirementEnumZip) = Value
"zip"
instance Data.Aeson.Types.FromJSON.FromJSON SettingsBilling_address_requirement where
parseJSON :: Value -> Parser SettingsBilling_address_requirement
parseJSON Value
val =
SettingsBilling_address_requirement
-> Parser SettingsBilling_address_requirement
forall a. a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
GHC.Base.pure
( if
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"full" -> SettingsBilling_address_requirement
SettingsBilling_address_requirementEnumFull
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"none" -> SettingsBilling_address_requirement
SettingsBilling_address_requirementEnumNone
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"streetzip" -> SettingsBilling_address_requirement
SettingsBilling_address_requirementEnumStreetzip
| Value
val Value -> Value -> Bool
forall a. Eq a => a -> a -> Bool
GHC.Classes.== Value
"zip" -> SettingsBilling_address_requirement
SettingsBilling_address_requirementEnumZip
| Bool
GHC.Base.otherwise -> Value -> SettingsBilling_address_requirement
SettingsBilling_address_requirementOther Value
val
)