{-# 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.EndpointLocation
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.Pinpoint.Types.EndpointLocation where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude

-- | Specifies geographic information about an endpoint.
--
-- /See:/ 'newEndpointLocation' smart constructor.
data EndpointLocation = EndpointLocation'
  { -- | The name of the city where the endpoint is located.
    EndpointLocation -> Maybe Text
city :: Prelude.Maybe Prelude.Text,
    -- | The two-character code, in ISO 3166-1 alpha-2 format, for the country or
    -- region where the endpoint is located. For example, US for the United
    -- States.
    EndpointLocation -> Maybe Text
country :: Prelude.Maybe Prelude.Text,
    -- | The latitude coordinate of the endpoint location, rounded to one decimal
    -- place.
    EndpointLocation -> Maybe Double
latitude :: Prelude.Maybe Prelude.Double,
    -- | The longitude coordinate of the endpoint location, rounded to one
    -- decimal place.
    EndpointLocation -> Maybe Double
longitude :: Prelude.Maybe Prelude.Double,
    -- | The postal or ZIP code for the area where the endpoint is located.
    EndpointLocation -> Maybe Text
postalCode :: Prelude.Maybe Prelude.Text,
    -- | The name of the region where the endpoint is located. For locations in
    -- the United States, this value is the name of a state.
    EndpointLocation -> Maybe Text
region :: Prelude.Maybe Prelude.Text
  }
  deriving (EndpointLocation -> EndpointLocation -> Bool
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]
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
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. 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)

-- |
-- Create a value of 'EndpointLocation' 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:
--
-- 'city', 'endpointLocation_city' - The name of the city where the endpoint is located.
--
-- 'country', 'endpointLocation_country' - The two-character code, in ISO 3166-1 alpha-2 format, for the country or
-- region where the endpoint is located. For example, US for the United
-- States.
--
-- 'latitude', 'endpointLocation_latitude' - The latitude coordinate of the endpoint location, rounded to one decimal
-- place.
--
-- 'longitude', 'endpointLocation_longitude' - The longitude coordinate of the endpoint location, rounded to one
-- decimal place.
--
-- 'postalCode', 'endpointLocation_postalCode' - The postal or ZIP code for the area where the endpoint is located.
--
-- 'region', 'endpointLocation_region' - The name of the region where the endpoint is located. For locations in
-- the United States, this value is the name of a state.
newEndpointLocation ::
  EndpointLocation
newEndpointLocation :: EndpointLocation
newEndpointLocation =
  EndpointLocation'
    { $sel:city:EndpointLocation' :: Maybe Text
city = forall a. Maybe a
Prelude.Nothing,
      $sel:country:EndpointLocation' :: Maybe Text
country = forall a. Maybe a
Prelude.Nothing,
      $sel:latitude:EndpointLocation' :: Maybe Double
latitude = forall a. Maybe a
Prelude.Nothing,
      $sel:longitude:EndpointLocation' :: Maybe Double
longitude = forall a. Maybe a
Prelude.Nothing,
      $sel:postalCode:EndpointLocation' :: Maybe Text
postalCode = forall a. Maybe a
Prelude.Nothing,
      $sel:region:EndpointLocation' :: Maybe Text
region = forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the city where the endpoint is located.
endpointLocation_city :: Lens.Lens' EndpointLocation (Prelude.Maybe Prelude.Text)
endpointLocation_city :: Lens' EndpointLocation (Maybe Text)
endpointLocation_city = 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)

-- | The two-character code, in ISO 3166-1 alpha-2 format, for the country or
-- region where the endpoint is located. For example, US for the United
-- States.
endpointLocation_country :: Lens.Lens' EndpointLocation (Prelude.Maybe Prelude.Text)
endpointLocation_country :: Lens' EndpointLocation (Maybe Text)
endpointLocation_country = 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)

-- | The latitude coordinate of the endpoint location, rounded to one decimal
-- place.
endpointLocation_latitude :: Lens.Lens' EndpointLocation (Prelude.Maybe Prelude.Double)
endpointLocation_latitude :: Lens' EndpointLocation (Maybe Double)
endpointLocation_latitude = 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)

-- | The longitude coordinate of the endpoint location, rounded to one
-- decimal place.
endpointLocation_longitude :: Lens.Lens' EndpointLocation (Prelude.Maybe Prelude.Double)
endpointLocation_longitude :: Lens' EndpointLocation (Maybe Double)
endpointLocation_longitude = 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)

-- | The postal or ZIP code for the area where the endpoint is located.
endpointLocation_postalCode :: Lens.Lens' EndpointLocation (Prelude.Maybe Prelude.Text)
endpointLocation_postalCode :: Lens' EndpointLocation (Maybe Text)
endpointLocation_postalCode = 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)

-- | The name of the region where the endpoint is located. For locations in
-- the United States, this value is the name of a state.
endpointLocation_region :: Lens.Lens' EndpointLocation (Prelude.Maybe Prelude.Text)
endpointLocation_region :: Lens' EndpointLocation (Maybe Text)
endpointLocation_region = 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)

instance Data.FromJSON EndpointLocation where
  parseJSON :: Value -> Parser EndpointLocation
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"EndpointLocation"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Double
-> Maybe Double
-> Maybe Text
-> Maybe Text
-> EndpointLocation
EndpointLocation'
            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
"City")
            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
"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
"Latitude")
            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
"Longitude")
            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
"PostalCode")
            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
"Region")
      )

instance Prelude.Hashable EndpointLocation where
  hashWithSalt :: Int -> EndpointLocation -> Int
hashWithSalt Int
_salt EndpointLocation' {Maybe Double
Maybe Text
region :: Maybe Text
postalCode :: Maybe Text
longitude :: Maybe Double
latitude :: Maybe Double
country :: Maybe Text
city :: Maybe Text
$sel:region:EndpointLocation' :: EndpointLocation -> Maybe Text
$sel:postalCode:EndpointLocation' :: EndpointLocation -> Maybe Text
$sel:longitude:EndpointLocation' :: EndpointLocation -> Maybe Double
$sel:latitude:EndpointLocation' :: EndpointLocation -> Maybe Double
$sel:country:EndpointLocation' :: EndpointLocation -> Maybe Text
$sel:city:EndpointLocation' :: EndpointLocation -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
city
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
country
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
latitude
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Double
longitude
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
postalCode
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
region

instance Prelude.NFData EndpointLocation where
  rnf :: EndpointLocation -> ()
rnf EndpointLocation' {Maybe Double
Maybe Text
region :: Maybe Text
postalCode :: Maybe Text
longitude :: Maybe Double
latitude :: Maybe Double
country :: Maybe Text
city :: Maybe Text
$sel:region:EndpointLocation' :: EndpointLocation -> Maybe Text
$sel:postalCode:EndpointLocation' :: EndpointLocation -> Maybe Text
$sel:longitude:EndpointLocation' :: EndpointLocation -> Maybe Double
$sel:latitude:EndpointLocation' :: EndpointLocation -> Maybe Double
$sel:country:EndpointLocation' :: EndpointLocation -> Maybe Text
$sel:city:EndpointLocation' :: EndpointLocation -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
city
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
country
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
latitude
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Double
longitude
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
postalCode
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
region

instance Data.ToJSON EndpointLocation where
  toJSON :: EndpointLocation -> Value
toJSON EndpointLocation' {Maybe Double
Maybe Text
region :: Maybe Text
postalCode :: Maybe Text
longitude :: Maybe Double
latitude :: Maybe Double
country :: Maybe Text
city :: Maybe Text
$sel:region:EndpointLocation' :: EndpointLocation -> Maybe Text
$sel:postalCode:EndpointLocation' :: EndpointLocation -> Maybe Text
$sel:longitude:EndpointLocation' :: EndpointLocation -> Maybe Double
$sel:latitude:EndpointLocation' :: EndpointLocation -> Maybe Double
$sel:country:EndpointLocation' :: EndpointLocation -> Maybe Text
$sel:city:EndpointLocation' :: EndpointLocation -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"City" 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 Text
city,
            (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 Text
country,
            (Key
"Latitude" 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 Double
latitude,
            (Key
"Longitude" 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 Double
longitude,
            (Key
"PostalCode" 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 Text
postalCode,
            (Key
"Region" 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 Text
region
          ]
      )