{-# 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.Pinpoint.Types.EndpointLocation where
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
data EndpointLocation = EndpointLocation'
{
EndpointLocation -> Maybe Text
postalCode :: Prelude.Maybe Prelude.Text,
EndpointLocation -> Maybe Double
latitude :: Prelude.Maybe Prelude.Double,
EndpointLocation -> Maybe Text
country :: Prelude.Maybe Prelude.Text,
EndpointLocation -> Maybe Text
city :: Prelude.Maybe Prelude.Text,
EndpointLocation -> Maybe Text
region :: Prelude.Maybe Prelude.Text,
EndpointLocation -> Maybe Double
longitude :: Prelude.Maybe Prelude.Double
}
deriving (EndpointLocation -> EndpointLocation -> Bool
(EndpointLocation -> EndpointLocation -> Bool)
-> (EndpointLocation -> EndpointLocation -> Bool)
-> Eq EndpointLocation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: EndpointLocation -> EndpointLocation -> Bool
$c/= :: EndpointLocation -> EndpointLocation -> Bool
== :: EndpointLocation -> EndpointLocation -> Bool
$c== :: EndpointLocation -> EndpointLocation -> Bool
Prelude.Eq, ReadPrec [EndpointLocation]
ReadPrec EndpointLocation
Int -> ReadS EndpointLocation
ReadS [EndpointLocation]
(Int -> ReadS EndpointLocation)
-> ReadS [EndpointLocation]
-> ReadPrec EndpointLocation
-> ReadPrec [EndpointLocation]
-> Read EndpointLocation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [EndpointLocation]
$creadListPrec :: ReadPrec [EndpointLocation]
readPrec :: ReadPrec EndpointLocation
$creadPrec :: ReadPrec EndpointLocation
readList :: ReadS [EndpointLocation]
$creadList :: ReadS [EndpointLocation]
readsPrec :: Int -> ReadS EndpointLocation
$creadsPrec :: Int -> ReadS EndpointLocation
Prelude.Read, Int -> EndpointLocation -> ShowS
[EndpointLocation] -> ShowS
EndpointLocation -> String
(Int -> EndpointLocation -> ShowS)
-> (EndpointLocation -> String)
-> ([EndpointLocation] -> ShowS)
-> Show EndpointLocation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [EndpointLocation] -> ShowS
$cshowList :: [EndpointLocation] -> ShowS
show :: EndpointLocation -> String
$cshow :: EndpointLocation -> String
showsPrec :: Int -> EndpointLocation -> ShowS
$cshowsPrec :: Int -> EndpointLocation -> ShowS
Prelude.Show, (forall x. EndpointLocation -> Rep EndpointLocation x)
-> (forall x. Rep EndpointLocation x -> EndpointLocation)
-> Generic EndpointLocation
forall x. Rep EndpointLocation x -> EndpointLocation
forall x. EndpointLocation -> Rep EndpointLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep EndpointLocation x -> EndpointLocation
$cfrom :: forall x. EndpointLocation -> Rep EndpointLocation x
Prelude.Generic)
newEndpointLocation ::
EndpointLocation
newEndpointLocation :: EndpointLocation
newEndpointLocation =
EndpointLocation' :: Maybe Text
-> Maybe Double
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Double
-> EndpointLocation
EndpointLocation'
{ $sel:postalCode:EndpointLocation' :: Maybe Text
postalCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:latitude:EndpointLocation' :: Maybe Double
latitude = Maybe Double
forall a. Maybe a
Prelude.Nothing,
$sel:country:EndpointLocation' :: Maybe Text
country = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:city:EndpointLocation' :: Maybe Text
city = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:region:EndpointLocation' :: Maybe Text
region = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:longitude:EndpointLocation' :: Maybe Double
longitude = Maybe Double
forall a. Maybe a
Prelude.Nothing
}
endpointLocation_postalCode :: Lens.Lens' EndpointLocation (Prelude.Maybe Prelude.Text)
endpointLocation_postalCode :: (Maybe Text -> f (Maybe Text))
-> EndpointLocation -> f EndpointLocation
endpointLocation_postalCode = (EndpointLocation -> Maybe Text)
-> (EndpointLocation -> Maybe Text -> EndpointLocation)
-> Lens EndpointLocation EndpointLocation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointLocation' {Maybe Text
postalCode :: Maybe Text
$sel:postalCode:EndpointLocation' :: EndpointLocation -> Maybe Text
postalCode} -> Maybe Text
postalCode) (\s :: EndpointLocation
s@EndpointLocation' {} Maybe Text
a -> EndpointLocation
s {$sel:postalCode:EndpointLocation' :: Maybe Text
postalCode = Maybe Text
a} :: EndpointLocation)
endpointLocation_latitude :: Lens.Lens' EndpointLocation (Prelude.Maybe Prelude.Double)
endpointLocation_latitude :: (Maybe Double -> f (Maybe Double))
-> EndpointLocation -> f EndpointLocation
endpointLocation_latitude = (EndpointLocation -> Maybe Double)
-> (EndpointLocation -> Maybe Double -> EndpointLocation)
-> Lens
EndpointLocation EndpointLocation (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointLocation' {Maybe Double
latitude :: Maybe Double
$sel:latitude:EndpointLocation' :: EndpointLocation -> Maybe Double
latitude} -> Maybe Double
latitude) (\s :: EndpointLocation
s@EndpointLocation' {} Maybe Double
a -> EndpointLocation
s {$sel:latitude:EndpointLocation' :: Maybe Double
latitude = Maybe Double
a} :: EndpointLocation)
endpointLocation_country :: Lens.Lens' EndpointLocation (Prelude.Maybe Prelude.Text)
endpointLocation_country :: (Maybe Text -> f (Maybe Text))
-> EndpointLocation -> f EndpointLocation
endpointLocation_country = (EndpointLocation -> Maybe Text)
-> (EndpointLocation -> Maybe Text -> EndpointLocation)
-> Lens EndpointLocation EndpointLocation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointLocation' {Maybe Text
country :: Maybe Text
$sel:country:EndpointLocation' :: EndpointLocation -> Maybe Text
country} -> Maybe Text
country) (\s :: EndpointLocation
s@EndpointLocation' {} Maybe Text
a -> EndpointLocation
s {$sel:country:EndpointLocation' :: Maybe Text
country = Maybe Text
a} :: EndpointLocation)
endpointLocation_city :: Lens.Lens' EndpointLocation (Prelude.Maybe Prelude.Text)
endpointLocation_city :: (Maybe Text -> f (Maybe Text))
-> EndpointLocation -> f EndpointLocation
endpointLocation_city = (EndpointLocation -> Maybe Text)
-> (EndpointLocation -> Maybe Text -> EndpointLocation)
-> Lens EndpointLocation EndpointLocation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointLocation' {Maybe Text
city :: Maybe Text
$sel:city:EndpointLocation' :: EndpointLocation -> Maybe Text
city} -> Maybe Text
city) (\s :: EndpointLocation
s@EndpointLocation' {} Maybe Text
a -> EndpointLocation
s {$sel:city:EndpointLocation' :: Maybe Text
city = Maybe Text
a} :: EndpointLocation)
endpointLocation_region :: Lens.Lens' EndpointLocation (Prelude.Maybe Prelude.Text)
endpointLocation_region :: (Maybe Text -> f (Maybe Text))
-> EndpointLocation -> f EndpointLocation
endpointLocation_region = (EndpointLocation -> Maybe Text)
-> (EndpointLocation -> Maybe Text -> EndpointLocation)
-> Lens EndpointLocation EndpointLocation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointLocation' {Maybe Text
region :: Maybe Text
$sel:region:EndpointLocation' :: EndpointLocation -> Maybe Text
region} -> Maybe Text
region) (\s :: EndpointLocation
s@EndpointLocation' {} Maybe Text
a -> EndpointLocation
s {$sel:region:EndpointLocation' :: Maybe Text
region = Maybe Text
a} :: EndpointLocation)
endpointLocation_longitude :: Lens.Lens' EndpointLocation (Prelude.Maybe Prelude.Double)
endpointLocation_longitude :: (Maybe Double -> f (Maybe Double))
-> EndpointLocation -> f EndpointLocation
endpointLocation_longitude = (EndpointLocation -> Maybe Double)
-> (EndpointLocation -> Maybe Double -> EndpointLocation)
-> Lens
EndpointLocation EndpointLocation (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\EndpointLocation' {Maybe Double
longitude :: Maybe Double
$sel:longitude:EndpointLocation' :: EndpointLocation -> Maybe Double
longitude} -> Maybe Double
longitude) (\s :: EndpointLocation
s@EndpointLocation' {} Maybe Double
a -> EndpointLocation
s {$sel:longitude:EndpointLocation' :: Maybe Double
longitude = Maybe Double
a} :: EndpointLocation)
instance Core.FromJSON EndpointLocation where
parseJSON :: Value -> Parser EndpointLocation
parseJSON =
String
-> (Object -> Parser EndpointLocation)
-> Value
-> Parser EndpointLocation
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
String
"EndpointLocation"
( \Object
x ->
Maybe Text
-> Maybe Double
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Double
-> EndpointLocation
EndpointLocation'
(Maybe Text
-> Maybe Double
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Double
-> EndpointLocation)
-> Parser (Maybe Text)
-> Parser
(Maybe Double
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Double
-> EndpointLocation)
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
"PostalCode")
Parser
(Maybe Double
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Double
-> EndpointLocation)
-> Parser (Maybe Double)
-> Parser
(Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Double -> EndpointLocation)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Latitude")
Parser
(Maybe Text
-> Maybe Text -> Maybe Text -> Maybe Double -> EndpointLocation)
-> Parser (Maybe Text)
-> Parser
(Maybe Text -> Maybe Text -> Maybe Double -> EndpointLocation)
forall (f :: * -> *) a b. Applicative f => 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
"Country")
Parser
(Maybe Text -> Maybe Text -> Maybe Double -> EndpointLocation)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Double -> EndpointLocation)
forall (f :: * -> *) a b. Applicative f => 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
"City")
Parser (Maybe Text -> Maybe Double -> EndpointLocation)
-> Parser (Maybe Text) -> Parser (Maybe Double -> EndpointLocation)
forall (f :: * -> *) a b. Applicative f => 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
"Region")
Parser (Maybe Double -> EndpointLocation)
-> Parser (Maybe Double) -> Parser EndpointLocation
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Longitude")
)
instance Prelude.Hashable EndpointLocation
instance Prelude.NFData EndpointLocation
instance Core.ToJSON EndpointLocation where
toJSON :: EndpointLocation -> Value
toJSON EndpointLocation' {Maybe Double
Maybe Text
longitude :: Maybe Double
region :: Maybe Text
city :: Maybe Text
country :: Maybe Text
latitude :: Maybe Double
postalCode :: Maybe Text
$sel:longitude:EndpointLocation' :: EndpointLocation -> Maybe Double
$sel:region:EndpointLocation' :: EndpointLocation -> Maybe Text
$sel:city:EndpointLocation' :: EndpointLocation -> Maybe Text
$sel:country:EndpointLocation' :: EndpointLocation -> Maybe Text
$sel:latitude:EndpointLocation' :: EndpointLocation -> Maybe Double
$sel:postalCode:EndpointLocation' :: EndpointLocation -> Maybe Text
..} =
[Pair] -> Value
Core.object
( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Text
"PostalCode" 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
postalCode,
(Text
"Latitude" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
latitude,
(Text
"Country" 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
country,
(Text
"City" 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
city,
(Text
"Region" 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
region,
(Text
"Longitude" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
longitude
]
)