{-# 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 #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.Pinpoint.Types.GPSPointDimension
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Pinpoint.Types.GPSPointDimension where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.GPSCoordinates
import qualified Amazonka.Prelude as Prelude

-- | Specifies GPS-based criteria for including or excluding endpoints from a
-- segment.
--
-- /See:/ 'newGPSPointDimension' smart constructor.
data GPSPointDimension = GPSPointDimension'
  { -- | The range, in kilometers, from the GPS coordinates.
    GPSPointDimension -> Maybe Double
rangeInKilometers :: Prelude.Maybe Prelude.Double,
    -- | The GPS coordinates to measure distance from.
    GPSPointDimension -> GPSCoordinates
coordinates :: GPSCoordinates
  }
  deriving (GPSPointDimension -> GPSPointDimension -> Bool
(GPSPointDimension -> GPSPointDimension -> Bool)
-> (GPSPointDimension -> GPSPointDimension -> Bool)
-> Eq GPSPointDimension
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GPSPointDimension -> GPSPointDimension -> Bool
$c/= :: GPSPointDimension -> GPSPointDimension -> Bool
== :: GPSPointDimension -> GPSPointDimension -> Bool
$c== :: GPSPointDimension -> GPSPointDimension -> Bool
Prelude.Eq, ReadPrec [GPSPointDimension]
ReadPrec GPSPointDimension
Int -> ReadS GPSPointDimension
ReadS [GPSPointDimension]
(Int -> ReadS GPSPointDimension)
-> ReadS [GPSPointDimension]
-> ReadPrec GPSPointDimension
-> ReadPrec [GPSPointDimension]
-> Read GPSPointDimension
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GPSPointDimension]
$creadListPrec :: ReadPrec [GPSPointDimension]
readPrec :: ReadPrec GPSPointDimension
$creadPrec :: ReadPrec GPSPointDimension
readList :: ReadS [GPSPointDimension]
$creadList :: ReadS [GPSPointDimension]
readsPrec :: Int -> ReadS GPSPointDimension
$creadsPrec :: Int -> ReadS GPSPointDimension
Prelude.Read, Int -> GPSPointDimension -> ShowS
[GPSPointDimension] -> ShowS
GPSPointDimension -> String
(Int -> GPSPointDimension -> ShowS)
-> (GPSPointDimension -> String)
-> ([GPSPointDimension] -> ShowS)
-> Show GPSPointDimension
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GPSPointDimension] -> ShowS
$cshowList :: [GPSPointDimension] -> ShowS
show :: GPSPointDimension -> String
$cshow :: GPSPointDimension -> String
showsPrec :: Int -> GPSPointDimension -> ShowS
$cshowsPrec :: Int -> GPSPointDimension -> ShowS
Prelude.Show, (forall x. GPSPointDimension -> Rep GPSPointDimension x)
-> (forall x. Rep GPSPointDimension x -> GPSPointDimension)
-> Generic GPSPointDimension
forall x. Rep GPSPointDimension x -> GPSPointDimension
forall x. GPSPointDimension -> Rep GPSPointDimension x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GPSPointDimension x -> GPSPointDimension
$cfrom :: forall x. GPSPointDimension -> Rep GPSPointDimension x
Prelude.Generic)

-- |
-- Create a value of 'GPSPointDimension' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'rangeInKilometers', 'gPSPointDimension_rangeInKilometers' - The range, in kilometers, from the GPS coordinates.
--
-- 'coordinates', 'gPSPointDimension_coordinates' - The GPS coordinates to measure distance from.
newGPSPointDimension ::
  -- | 'coordinates'
  GPSCoordinates ->
  GPSPointDimension
newGPSPointDimension :: GPSCoordinates -> GPSPointDimension
newGPSPointDimension GPSCoordinates
pCoordinates_ =
  GPSPointDimension' :: Maybe Double -> GPSCoordinates -> GPSPointDimension
GPSPointDimension'
    { $sel:rangeInKilometers:GPSPointDimension' :: Maybe Double
rangeInKilometers =
        Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:coordinates:GPSPointDimension' :: GPSCoordinates
coordinates = GPSCoordinates
pCoordinates_
    }

-- | The range, in kilometers, from the GPS coordinates.
gPSPointDimension_rangeInKilometers :: Lens.Lens' GPSPointDimension (Prelude.Maybe Prelude.Double)
gPSPointDimension_rangeInKilometers :: (Maybe Double -> f (Maybe Double))
-> GPSPointDimension -> f GPSPointDimension
gPSPointDimension_rangeInKilometers = (GPSPointDimension -> Maybe Double)
-> (GPSPointDimension -> Maybe Double -> GPSPointDimension)
-> Lens
     GPSPointDimension GPSPointDimension (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GPSPointDimension' {Maybe Double
rangeInKilometers :: Maybe Double
$sel:rangeInKilometers:GPSPointDimension' :: GPSPointDimension -> Maybe Double
rangeInKilometers} -> Maybe Double
rangeInKilometers) (\s :: GPSPointDimension
s@GPSPointDimension' {} Maybe Double
a -> GPSPointDimension
s {$sel:rangeInKilometers:GPSPointDimension' :: Maybe Double
rangeInKilometers = Maybe Double
a} :: GPSPointDimension)

-- | The GPS coordinates to measure distance from.
gPSPointDimension_coordinates :: Lens.Lens' GPSPointDimension GPSCoordinates
gPSPointDimension_coordinates :: (GPSCoordinates -> f GPSCoordinates)
-> GPSPointDimension -> f GPSPointDimension
gPSPointDimension_coordinates = (GPSPointDimension -> GPSCoordinates)
-> (GPSPointDimension -> GPSCoordinates -> GPSPointDimension)
-> Lens
     GPSPointDimension GPSPointDimension GPSCoordinates GPSCoordinates
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GPSPointDimension' {GPSCoordinates
coordinates :: GPSCoordinates
$sel:coordinates:GPSPointDimension' :: GPSPointDimension -> GPSCoordinates
coordinates} -> GPSCoordinates
coordinates) (\s :: GPSPointDimension
s@GPSPointDimension' {} GPSCoordinates
a -> GPSPointDimension
s {$sel:coordinates:GPSPointDimension' :: GPSCoordinates
coordinates = GPSCoordinates
a} :: GPSPointDimension)

instance Core.FromJSON GPSPointDimension where
  parseJSON :: Value -> Parser GPSPointDimension
parseJSON =
    String
-> (Object -> Parser GPSPointDimension)
-> Value
-> Parser GPSPointDimension
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"GPSPointDimension"
      ( \Object
x ->
          Maybe Double -> GPSCoordinates -> GPSPointDimension
GPSPointDimension'
            (Maybe Double -> GPSCoordinates -> GPSPointDimension)
-> Parser (Maybe Double)
-> Parser (GPSCoordinates -> GPSPointDimension)
forall (f :: * -> *) a b. Functor 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
"RangeInKilometers")
            Parser (GPSCoordinates -> GPSPointDimension)
-> Parser GPSCoordinates -> Parser GPSPointDimension
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser GPSCoordinates
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Coordinates")
      )

instance Prelude.Hashable GPSPointDimension

instance Prelude.NFData GPSPointDimension

instance Core.ToJSON GPSPointDimension where
  toJSON :: GPSPointDimension -> Value
toJSON GPSPointDimension' {Maybe Double
GPSCoordinates
coordinates :: GPSCoordinates
rangeInKilometers :: Maybe Double
$sel:coordinates:GPSPointDimension' :: GPSPointDimension -> GPSCoordinates
$sel:rangeInKilometers:GPSPointDimension' :: GPSPointDimension -> Maybe Double
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"RangeInKilometers" 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
rangeInKilometers,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"Coordinates" Text -> GPSCoordinates -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= GPSCoordinates
coordinates)
          ]
      )