{-# 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.AlexaBusiness.Types.SipAddress
-- 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.AlexaBusiness.Types.SipAddress where

import Amazonka.AlexaBusiness.Types.SipType
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

-- | The SIP address for the contact containing the URI and SIP address type.
--
-- /See:/ 'newSipAddress' smart constructor.
data SipAddress = SipAddress'
  { -- | The URI for the SIP address.
    SipAddress -> Sensitive Text
uri :: Data.Sensitive Prelude.Text,
    -- | The type of the SIP address.
    SipAddress -> Sensitive SipType
type' :: Data.Sensitive SipType
  }
  deriving (SipAddress -> SipAddress -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SipAddress -> SipAddress -> Bool
$c/= :: SipAddress -> SipAddress -> Bool
== :: SipAddress -> SipAddress -> Bool
$c== :: SipAddress -> SipAddress -> Bool
Prelude.Eq, Int -> SipAddress -> ShowS
[SipAddress] -> ShowS
SipAddress -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SipAddress] -> ShowS
$cshowList :: [SipAddress] -> ShowS
show :: SipAddress -> String
$cshow :: SipAddress -> String
showsPrec :: Int -> SipAddress -> ShowS
$cshowsPrec :: Int -> SipAddress -> ShowS
Prelude.Show, forall x. Rep SipAddress x -> SipAddress
forall x. SipAddress -> Rep SipAddress x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SipAddress x -> SipAddress
$cfrom :: forall x. SipAddress -> Rep SipAddress x
Prelude.Generic)

-- |
-- Create a value of 'SipAddress' 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:
--
-- 'uri', 'sipAddress_uri' - The URI for the SIP address.
--
-- 'type'', 'sipAddress_type' - The type of the SIP address.
newSipAddress ::
  -- | 'uri'
  Prelude.Text ->
  -- | 'type''
  SipType ->
  SipAddress
newSipAddress :: Text -> SipType -> SipAddress
newSipAddress Text
pUri_ SipType
pType_ =
  SipAddress'
    { $sel:uri:SipAddress' :: Sensitive Text
uri = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# Text
pUri_,
      $sel:type':SipAddress' :: Sensitive SipType
type' = forall a. Iso' (Sensitive a) a
Data._Sensitive forall t b. AReview t b -> b -> t
Lens.# SipType
pType_
    }

-- | The URI for the SIP address.
sipAddress_uri :: Lens.Lens' SipAddress Prelude.Text
sipAddress_uri :: Lens' SipAddress Text
sipAddress_uri = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SipAddress' {Sensitive Text
uri :: Sensitive Text
$sel:uri:SipAddress' :: SipAddress -> Sensitive Text
uri} -> Sensitive Text
uri) (\s :: SipAddress
s@SipAddress' {} Sensitive Text
a -> SipAddress
s {$sel:uri:SipAddress' :: Sensitive Text
uri = Sensitive Text
a} :: SipAddress) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

-- | The type of the SIP address.
sipAddress_type :: Lens.Lens' SipAddress SipType
sipAddress_type :: Lens' SipAddress SipType
sipAddress_type = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SipAddress' {Sensitive SipType
type' :: Sensitive SipType
$sel:type':SipAddress' :: SipAddress -> Sensitive SipType
type'} -> Sensitive SipType
type') (\s :: SipAddress
s@SipAddress' {} Sensitive SipType
a -> SipAddress
s {$sel:type':SipAddress' :: Sensitive SipType
type' = Sensitive SipType
a} :: SipAddress) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall a. Iso' (Sensitive a) a
Data._Sensitive

instance Data.FromJSON SipAddress where
  parseJSON :: Value -> Parser SipAddress
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SipAddress"
      ( \Object
x ->
          Sensitive Text -> Sensitive SipType -> SipAddress
SipAddress'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Uri")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"Type")
      )

instance Prelude.Hashable SipAddress where
  hashWithSalt :: Int -> SipAddress -> Int
hashWithSalt Int
_salt SipAddress' {Sensitive Text
Sensitive SipType
type' :: Sensitive SipType
uri :: Sensitive Text
$sel:type':SipAddress' :: SipAddress -> Sensitive SipType
$sel:uri:SipAddress' :: SipAddress -> Sensitive Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive Text
uri
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Sensitive SipType
type'

instance Prelude.NFData SipAddress where
  rnf :: SipAddress -> ()
rnf SipAddress' {Sensitive Text
Sensitive SipType
type' :: Sensitive SipType
uri :: Sensitive Text
$sel:type':SipAddress' :: SipAddress -> Sensitive SipType
$sel:uri:SipAddress' :: SipAddress -> Sensitive Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Sensitive Text
uri seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Sensitive SipType
type'

instance Data.ToJSON SipAddress where
  toJSON :: SipAddress -> Value
toJSON SipAddress' {Sensitive Text
Sensitive SipType
type' :: Sensitive SipType
uri :: Sensitive Text
$sel:type':SipAddress' :: SipAddress -> Sensitive SipType
$sel:uri:SipAddress' :: SipAddress -> Sensitive Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Uri" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive Text
uri),
            forall a. a -> Maybe a
Prelude.Just (Key
"Type" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Sensitive SipType
type')
          ]
      )