{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
module Amazonka.MechanicalTurk.Types.Locale where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data Locale = Locale'
{
Locale -> Maybe Text
subdivision :: Prelude.Maybe Prelude.Text,
Locale -> Text
country :: Prelude.Text
}
deriving (Locale -> Locale -> Bool
(Locale -> Locale -> Bool)
-> (Locale -> Locale -> Bool) -> Eq Locale
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Locale -> Locale -> Bool
$c/= :: Locale -> Locale -> Bool
== :: Locale -> Locale -> Bool
$c== :: Locale -> Locale -> Bool
Prelude.Eq, ReadPrec [Locale]
ReadPrec Locale
Int -> ReadS Locale
ReadS [Locale]
(Int -> ReadS Locale)
-> ReadS [Locale]
-> ReadPrec Locale
-> ReadPrec [Locale]
-> Read Locale
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Locale]
$creadListPrec :: ReadPrec [Locale]
readPrec :: ReadPrec Locale
$creadPrec :: ReadPrec Locale
readList :: ReadS [Locale]
$creadList :: ReadS [Locale]
readsPrec :: Int -> ReadS Locale
$creadsPrec :: Int -> ReadS Locale
Prelude.Read, Int -> Locale -> ShowS
[Locale] -> ShowS
Locale -> String
(Int -> Locale -> ShowS)
-> (Locale -> String) -> ([Locale] -> ShowS) -> Show Locale
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Locale] -> ShowS
$cshowList :: [Locale] -> ShowS
show :: Locale -> String
$cshow :: Locale -> String
showsPrec :: Int -> Locale -> ShowS
$cshowsPrec :: Int -> Locale -> ShowS
Prelude.Show, (forall x. Locale -> Rep Locale x)
-> (forall x. Rep Locale x -> Locale) -> Generic Locale
forall x. Rep Locale x -> Locale
forall x. Locale -> Rep Locale x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Locale x -> Locale
$cfrom :: forall x. Locale -> Rep Locale x
Prelude.Generic)
newLocale ::
Prelude.Text ->
Locale
newLocale :: Text -> Locale
newLocale Text
pCountry_ =
Locale' :: Maybe Text -> Text -> Locale
Locale'
{ $sel:subdivision:Locale' :: Maybe Text
subdivision = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:country:Locale' :: Text
country = Text
pCountry_
}
locale_subdivision :: Lens.Lens' Locale (Prelude.Maybe Prelude.Text)
locale_subdivision :: (Maybe Text -> f (Maybe Text)) -> Locale -> f Locale
locale_subdivision = (Locale -> Maybe Text)
-> (Locale -> Maybe Text -> Locale)
-> Lens Locale Locale (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Locale' {Maybe Text
subdivision :: Maybe Text
$sel:subdivision:Locale' :: Locale -> Maybe Text
subdivision} -> Maybe Text
subdivision) (\s :: Locale
s@Locale' {} Maybe Text
a -> Locale
s {$sel:subdivision:Locale' :: Maybe Text
subdivision = Maybe Text
a} :: Locale)
locale_country :: Lens.Lens' Locale Prelude.Text
locale_country :: (Text -> f Text) -> Locale -> f Locale
locale_country = (Locale -> Text)
-> (Locale -> Text -> Locale) -> Lens Locale Locale Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Locale' {Text
country :: Text
$sel:country:Locale' :: Locale -> Text
country} -> Text
country) (\s :: Locale
s@Locale' {} Text
a -> Locale
s {$sel:country:Locale' :: Text
country = Text
a} :: Locale)
instance Core.FromJSON Locale where
parseJSON :: Value -> Parser Locale
parseJSON =
String -> (Object -> Parser Locale) -> Value -> Parser Locale
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"Locale"
( \Object
x ->
Maybe Text -> Text -> Locale
Locale'
(Maybe Text -> Text -> Locale)
-> Parser (Maybe Text) -> Parser (Text -> Locale)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Subdivision")
Parser (Text -> Locale) -> Parser Text -> Parser Locale
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Country")
)
instance Prelude.Hashable Locale
instance Prelude.NFData Locale
instance Core.ToJSON Locale where
toJSON :: Locale -> Value
toJSON Locale' {Maybe Text
Text
country :: Text
subdivision :: Maybe Text
$sel:country:Locale' :: Locale -> Text
$sel:subdivision:Locale' :: Locale -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"Subdivision" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
subdivision,
Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Country" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
country)
]
)