{-# 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.Location.Types.Place
-- 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.Location.Types.Place where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Location.Types.PlaceGeometry
import qualified Amazonka.Prelude as Prelude

-- | Contains details about addresses or points of interest that match the
-- search criteria.
--
-- /See:/ 'newPlace' smart constructor.
data Place = Place'
  { -- | A name for a local area, such as a city or town name. For example,
    -- @Toronto@.
    Place -> Maybe Text
municipality :: Prelude.Maybe Prelude.Text,
    -- | The numerical portion of an address, such as a building number.
    Place -> Maybe Text
addressNumber :: Prelude.Maybe Prelude.Text,
    -- | A group of numbers and letters in a country-specific format, which
    -- accompanies the address for the purpose of identifying a location.
    Place -> Maybe Text
postalCode :: Prelude.Maybe Prelude.Text,
    -- | A country\/region specified using
    -- <https://www.iso.org/iso-3166-country-codes.html ISO 3166> 3-digit
    -- country\/region code. For example, @CAN@.
    Place -> Maybe Text
country :: Prelude.Maybe Prelude.Text,
    -- | The name for a street or a road to identify a location. For example,
    -- @Main Street@.
    Place -> Maybe Text
street :: Prelude.Maybe Prelude.Text,
    -- | A country, or an area that\'s part of a larger region . For example,
    -- @Metro Vancouver@.
    Place -> Maybe Text
subRegion :: Prelude.Maybe Prelude.Text,
    -- | A name for an area or geographical division, such as a province or state
    -- name. For example, @British Columbia@.
    Place -> Maybe Text
region :: Prelude.Maybe Prelude.Text,
    -- | The full name and address of the point of interest such as a city,
    -- region, or country. For example, @123 Any Street, Any Town, USA@.
    Place -> Maybe Text
label :: Prelude.Maybe Prelude.Text,
    -- | The name of a community district. For example, @Downtown@.
    Place -> Maybe Text
neighborhood :: Prelude.Maybe Prelude.Text,
    Place -> PlaceGeometry
geometry :: PlaceGeometry
  }
  deriving (Place -> Place -> Bool
(Place -> Place -> Bool) -> (Place -> Place -> Bool) -> Eq Place
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Place -> Place -> Bool
$c/= :: Place -> Place -> Bool
== :: Place -> Place -> Bool
$c== :: Place -> Place -> Bool
Prelude.Eq, Int -> Place -> ShowS
[Place] -> ShowS
Place -> String
(Int -> Place -> ShowS)
-> (Place -> String) -> ([Place] -> ShowS) -> Show Place
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Place] -> ShowS
$cshowList :: [Place] -> ShowS
show :: Place -> String
$cshow :: Place -> String
showsPrec :: Int -> Place -> ShowS
$cshowsPrec :: Int -> Place -> ShowS
Prelude.Show, (forall x. Place -> Rep Place x)
-> (forall x. Rep Place x -> Place) -> Generic Place
forall x. Rep Place x -> Place
forall x. Place -> Rep Place x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Place x -> Place
$cfrom :: forall x. Place -> Rep Place x
Prelude.Generic)

-- |
-- Create a value of 'Place' 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:
--
-- 'municipality', 'place_municipality' - A name for a local area, such as a city or town name. For example,
-- @Toronto@.
--
-- 'addressNumber', 'place_addressNumber' - The numerical portion of an address, such as a building number.
--
-- 'postalCode', 'place_postalCode' - A group of numbers and letters in a country-specific format, which
-- accompanies the address for the purpose of identifying a location.
--
-- 'country', 'place_country' - A country\/region specified using
-- <https://www.iso.org/iso-3166-country-codes.html ISO 3166> 3-digit
-- country\/region code. For example, @CAN@.
--
-- 'street', 'place_street' - The name for a street or a road to identify a location. For example,
-- @Main Street@.
--
-- 'subRegion', 'place_subRegion' - A country, or an area that\'s part of a larger region . For example,
-- @Metro Vancouver@.
--
-- 'region', 'place_region' - A name for an area or geographical division, such as a province or state
-- name. For example, @British Columbia@.
--
-- 'label', 'place_label' - The full name and address of the point of interest such as a city,
-- region, or country. For example, @123 Any Street, Any Town, USA@.
--
-- 'neighborhood', 'place_neighborhood' - The name of a community district. For example, @Downtown@.
--
-- 'geometry', 'place_geometry' - Undocumented member.
newPlace ::
  -- | 'geometry'
  PlaceGeometry ->
  Place
newPlace :: PlaceGeometry -> Place
newPlace PlaceGeometry
pGeometry_ =
  Place' :: Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> PlaceGeometry
-> Place
Place'
    { $sel:municipality:Place' :: Maybe Text
municipality = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:addressNumber:Place' :: Maybe Text
addressNumber = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:postalCode:Place' :: Maybe Text
postalCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:country:Place' :: Maybe Text
country = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:street:Place' :: Maybe Text
street = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:subRegion:Place' :: Maybe Text
subRegion = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:region:Place' :: Maybe Text
region = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:label:Place' :: Maybe Text
label = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:neighborhood:Place' :: Maybe Text
neighborhood = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:geometry:Place' :: PlaceGeometry
geometry = PlaceGeometry
pGeometry_
    }

-- | A name for a local area, such as a city or town name. For example,
-- @Toronto@.
place_municipality :: Lens.Lens' Place (Prelude.Maybe Prelude.Text)
place_municipality :: (Maybe Text -> f (Maybe Text)) -> Place -> f Place
place_municipality = (Place -> Maybe Text)
-> (Place -> Maybe Text -> Place)
-> Lens Place Place (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Place' {Maybe Text
municipality :: Maybe Text
$sel:municipality:Place' :: Place -> Maybe Text
municipality} -> Maybe Text
municipality) (\s :: Place
s@Place' {} Maybe Text
a -> Place
s {$sel:municipality:Place' :: Maybe Text
municipality = Maybe Text
a} :: Place)

-- | The numerical portion of an address, such as a building number.
place_addressNumber :: Lens.Lens' Place (Prelude.Maybe Prelude.Text)
place_addressNumber :: (Maybe Text -> f (Maybe Text)) -> Place -> f Place
place_addressNumber = (Place -> Maybe Text)
-> (Place -> Maybe Text -> Place)
-> Lens Place Place (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Place' {Maybe Text
addressNumber :: Maybe Text
$sel:addressNumber:Place' :: Place -> Maybe Text
addressNumber} -> Maybe Text
addressNumber) (\s :: Place
s@Place' {} Maybe Text
a -> Place
s {$sel:addressNumber:Place' :: Maybe Text
addressNumber = Maybe Text
a} :: Place)

-- | A group of numbers and letters in a country-specific format, which
-- accompanies the address for the purpose of identifying a location.
place_postalCode :: Lens.Lens' Place (Prelude.Maybe Prelude.Text)
place_postalCode :: (Maybe Text -> f (Maybe Text)) -> Place -> f Place
place_postalCode = (Place -> Maybe Text)
-> (Place -> Maybe Text -> Place)
-> Lens Place Place (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Place' {Maybe Text
postalCode :: Maybe Text
$sel:postalCode:Place' :: Place -> Maybe Text
postalCode} -> Maybe Text
postalCode) (\s :: Place
s@Place' {} Maybe Text
a -> Place
s {$sel:postalCode:Place' :: Maybe Text
postalCode = Maybe Text
a} :: Place)

-- | A country\/region specified using
-- <https://www.iso.org/iso-3166-country-codes.html ISO 3166> 3-digit
-- country\/region code. For example, @CAN@.
place_country :: Lens.Lens' Place (Prelude.Maybe Prelude.Text)
place_country :: (Maybe Text -> f (Maybe Text)) -> Place -> f Place
place_country = (Place -> Maybe Text)
-> (Place -> Maybe Text -> Place)
-> Lens Place Place (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Place' {Maybe Text
country :: Maybe Text
$sel:country:Place' :: Place -> Maybe Text
country} -> Maybe Text
country) (\s :: Place
s@Place' {} Maybe Text
a -> Place
s {$sel:country:Place' :: Maybe Text
country = Maybe Text
a} :: Place)

-- | The name for a street or a road to identify a location. For example,
-- @Main Street@.
place_street :: Lens.Lens' Place (Prelude.Maybe Prelude.Text)
place_street :: (Maybe Text -> f (Maybe Text)) -> Place -> f Place
place_street = (Place -> Maybe Text)
-> (Place -> Maybe Text -> Place)
-> Lens Place Place (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Place' {Maybe Text
street :: Maybe Text
$sel:street:Place' :: Place -> Maybe Text
street} -> Maybe Text
street) (\s :: Place
s@Place' {} Maybe Text
a -> Place
s {$sel:street:Place' :: Maybe Text
street = Maybe Text
a} :: Place)

-- | A country, or an area that\'s part of a larger region . For example,
-- @Metro Vancouver@.
place_subRegion :: Lens.Lens' Place (Prelude.Maybe Prelude.Text)
place_subRegion :: (Maybe Text -> f (Maybe Text)) -> Place -> f Place
place_subRegion = (Place -> Maybe Text)
-> (Place -> Maybe Text -> Place)
-> Lens Place Place (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Place' {Maybe Text
subRegion :: Maybe Text
$sel:subRegion:Place' :: Place -> Maybe Text
subRegion} -> Maybe Text
subRegion) (\s :: Place
s@Place' {} Maybe Text
a -> Place
s {$sel:subRegion:Place' :: Maybe Text
subRegion = Maybe Text
a} :: Place)

-- | A name for an area or geographical division, such as a province or state
-- name. For example, @British Columbia@.
place_region :: Lens.Lens' Place (Prelude.Maybe Prelude.Text)
place_region :: (Maybe Text -> f (Maybe Text)) -> Place -> f Place
place_region = (Place -> Maybe Text)
-> (Place -> Maybe Text -> Place)
-> Lens Place Place (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Place' {Maybe Text
region :: Maybe Text
$sel:region:Place' :: Place -> Maybe Text
region} -> Maybe Text
region) (\s :: Place
s@Place' {} Maybe Text
a -> Place
s {$sel:region:Place' :: Maybe Text
region = Maybe Text
a} :: Place)

-- | The full name and address of the point of interest such as a city,
-- region, or country. For example, @123 Any Street, Any Town, USA@.
place_label :: Lens.Lens' Place (Prelude.Maybe Prelude.Text)
place_label :: (Maybe Text -> f (Maybe Text)) -> Place -> f Place
place_label = (Place -> Maybe Text)
-> (Place -> Maybe Text -> Place)
-> Lens Place Place (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Place' {Maybe Text
label :: Maybe Text
$sel:label:Place' :: Place -> Maybe Text
label} -> Maybe Text
label) (\s :: Place
s@Place' {} Maybe Text
a -> Place
s {$sel:label:Place' :: Maybe Text
label = Maybe Text
a} :: Place)

-- | The name of a community district. For example, @Downtown@.
place_neighborhood :: Lens.Lens' Place (Prelude.Maybe Prelude.Text)
place_neighborhood :: (Maybe Text -> f (Maybe Text)) -> Place -> f Place
place_neighborhood = (Place -> Maybe Text)
-> (Place -> Maybe Text -> Place)
-> Lens Place Place (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Place' {Maybe Text
neighborhood :: Maybe Text
$sel:neighborhood:Place' :: Place -> Maybe Text
neighborhood} -> Maybe Text
neighborhood) (\s :: Place
s@Place' {} Maybe Text
a -> Place
s {$sel:neighborhood:Place' :: Maybe Text
neighborhood = Maybe Text
a} :: Place)

-- | Undocumented member.
place_geometry :: Lens.Lens' Place PlaceGeometry
place_geometry :: (PlaceGeometry -> f PlaceGeometry) -> Place -> f Place
place_geometry = (Place -> PlaceGeometry)
-> (Place -> PlaceGeometry -> Place)
-> Lens Place Place PlaceGeometry PlaceGeometry
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Place' {PlaceGeometry
geometry :: PlaceGeometry
$sel:geometry:Place' :: Place -> PlaceGeometry
geometry} -> PlaceGeometry
geometry) (\s :: Place
s@Place' {} PlaceGeometry
a -> Place
s {$sel:geometry:Place' :: PlaceGeometry
geometry = PlaceGeometry
a} :: Place)

instance Core.FromJSON Place where
  parseJSON :: Value -> Parser Place
parseJSON =
    String -> (Object -> Parser Place) -> Value -> Parser Place
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"Place"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> PlaceGeometry
-> Place
Place'
            (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> PlaceGeometry
 -> Place)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> PlaceGeometry
      -> Place)
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
"Municipality")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> PlaceGeometry
   -> Place)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> PlaceGeometry
      -> Place)
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
"AddressNumber")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> PlaceGeometry
   -> Place)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> PlaceGeometry
      -> Place)
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
"PostalCode")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> PlaceGeometry
   -> Place)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> PlaceGeometry
      -> Place)
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 Text
   -> Maybe Text
   -> Maybe Text
   -> PlaceGeometry
   -> Place)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> PlaceGeometry
      -> Place)
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
"Street")
            Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> PlaceGeometry
   -> Place)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Text -> Maybe Text -> PlaceGeometry -> Place)
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
"SubRegion")
            Parser
  (Maybe Text -> Maybe Text -> Maybe Text -> PlaceGeometry -> Place)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> PlaceGeometry -> Place)
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 Text -> Maybe Text -> PlaceGeometry -> Place)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> PlaceGeometry -> Place)
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
"Label")
            Parser (Maybe Text -> PlaceGeometry -> Place)
-> Parser (Maybe Text) -> Parser (PlaceGeometry -> Place)
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
"Neighborhood")
            Parser (PlaceGeometry -> Place)
-> Parser PlaceGeometry -> Parser Place
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser PlaceGeometry
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"Geometry")
      )

instance Prelude.Hashable Place

instance Prelude.NFData Place