{-# 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.SegmentLocation where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Pinpoint.Types.GPSPointDimension
import Amazonka.Pinpoint.Types.SetDimension
import qualified Amazonka.Prelude as Prelude
data SegmentLocation = SegmentLocation'
{
SegmentLocation -> Maybe SetDimension
country :: Prelude.Maybe SetDimension,
SegmentLocation -> Maybe GPSPointDimension
gPSPoint :: Prelude.Maybe GPSPointDimension
}
deriving (SegmentLocation -> SegmentLocation -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SegmentLocation -> SegmentLocation -> Bool
$c/= :: SegmentLocation -> SegmentLocation -> Bool
== :: SegmentLocation -> SegmentLocation -> Bool
$c== :: SegmentLocation -> SegmentLocation -> Bool
Prelude.Eq, ReadPrec [SegmentLocation]
ReadPrec SegmentLocation
Int -> ReadS SegmentLocation
ReadS [SegmentLocation]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SegmentLocation]
$creadListPrec :: ReadPrec [SegmentLocation]
readPrec :: ReadPrec SegmentLocation
$creadPrec :: ReadPrec SegmentLocation
readList :: ReadS [SegmentLocation]
$creadList :: ReadS [SegmentLocation]
readsPrec :: Int -> ReadS SegmentLocation
$creadsPrec :: Int -> ReadS SegmentLocation
Prelude.Read, Int -> SegmentLocation -> ShowS
[SegmentLocation] -> ShowS
SegmentLocation -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SegmentLocation] -> ShowS
$cshowList :: [SegmentLocation] -> ShowS
show :: SegmentLocation -> String
$cshow :: SegmentLocation -> String
showsPrec :: Int -> SegmentLocation -> ShowS
$cshowsPrec :: Int -> SegmentLocation -> ShowS
Prelude.Show, forall x. Rep SegmentLocation x -> SegmentLocation
forall x. SegmentLocation -> Rep SegmentLocation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SegmentLocation x -> SegmentLocation
$cfrom :: forall x. SegmentLocation -> Rep SegmentLocation x
Prelude.Generic)
newSegmentLocation ::
SegmentLocation
newSegmentLocation :: SegmentLocation
newSegmentLocation =
SegmentLocation'
{ $sel:country:SegmentLocation' :: Maybe SetDimension
country = forall a. Maybe a
Prelude.Nothing,
$sel:gPSPoint:SegmentLocation' :: Maybe GPSPointDimension
gPSPoint = forall a. Maybe a
Prelude.Nothing
}
segmentLocation_country :: Lens.Lens' SegmentLocation (Prelude.Maybe SetDimension)
segmentLocation_country :: Lens' SegmentLocation (Maybe SetDimension)
segmentLocation_country = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SegmentLocation' {Maybe SetDimension
country :: Maybe SetDimension
$sel:country:SegmentLocation' :: SegmentLocation -> Maybe SetDimension
country} -> Maybe SetDimension
country) (\s :: SegmentLocation
s@SegmentLocation' {} Maybe SetDimension
a -> SegmentLocation
s {$sel:country:SegmentLocation' :: Maybe SetDimension
country = Maybe SetDimension
a} :: SegmentLocation)
segmentLocation_gPSPoint :: Lens.Lens' SegmentLocation (Prelude.Maybe GPSPointDimension)
segmentLocation_gPSPoint :: Lens' SegmentLocation (Maybe GPSPointDimension)
segmentLocation_gPSPoint = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SegmentLocation' {Maybe GPSPointDimension
gPSPoint :: Maybe GPSPointDimension
$sel:gPSPoint:SegmentLocation' :: SegmentLocation -> Maybe GPSPointDimension
gPSPoint} -> Maybe GPSPointDimension
gPSPoint) (\s :: SegmentLocation
s@SegmentLocation' {} Maybe GPSPointDimension
a -> SegmentLocation
s {$sel:gPSPoint:SegmentLocation' :: Maybe GPSPointDimension
gPSPoint = Maybe GPSPointDimension
a} :: SegmentLocation)
instance Data.FromJSON SegmentLocation where
parseJSON :: Value -> Parser SegmentLocation
parseJSON =
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
String
"SegmentLocation"
( \Object
x ->
Maybe SetDimension -> Maybe GPSPointDimension -> SegmentLocation
SegmentLocation'
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Country")
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"GPSPoint")
)
instance Prelude.Hashable SegmentLocation where
hashWithSalt :: Int -> SegmentLocation -> Int
hashWithSalt Int
_salt SegmentLocation' {Maybe GPSPointDimension
Maybe SetDimension
gPSPoint :: Maybe GPSPointDimension
country :: Maybe SetDimension
$sel:gPSPoint:SegmentLocation' :: SegmentLocation -> Maybe GPSPointDimension
$sel:country:SegmentLocation' :: SegmentLocation -> Maybe SetDimension
..} =
Int
_salt
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe SetDimension
country
forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe GPSPointDimension
gPSPoint
instance Prelude.NFData SegmentLocation where
rnf :: SegmentLocation -> ()
rnf SegmentLocation' {Maybe GPSPointDimension
Maybe SetDimension
gPSPoint :: Maybe GPSPointDimension
country :: Maybe SetDimension
$sel:gPSPoint:SegmentLocation' :: SegmentLocation -> Maybe GPSPointDimension
$sel:country:SegmentLocation' :: SegmentLocation -> Maybe SetDimension
..} =
forall a. NFData a => a -> ()
Prelude.rnf Maybe SetDimension
country
seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe GPSPointDimension
gPSPoint
instance Data.ToJSON SegmentLocation where
toJSON :: SegmentLocation -> Value
toJSON SegmentLocation' {Maybe GPSPointDimension
Maybe SetDimension
gPSPoint :: Maybe GPSPointDimension
country :: Maybe SetDimension
$sel:gPSPoint:SegmentLocation' :: SegmentLocation -> Maybe GPSPointDimension
$sel:country:SegmentLocation' :: SegmentLocation -> Maybe SetDimension
..} =
[Pair] -> Value
Data.object
( forall a. [Maybe a] -> [a]
Prelude.catMaybes
[ (Key
"Country" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SetDimension
country,
(Key
"GPSPoint" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe GPSPointDimension
gPSPoint
]
)