{-# 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.PinpointSmsVoiceV2.Types.OptedOutFilter
-- 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.PinpointSmsVoiceV2.Types.OptedOutFilter where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.PinpointSmsVoiceV2.Types.OptedOutFilterName
import qualified Amazonka.Prelude as Prelude

-- | The information for opted out numbers that meet a specified criteria.
--
-- /See:/ 'newOptedOutFilter' smart constructor.
data OptedOutFilter = OptedOutFilter'
  { -- | The name of the attribute to filter on.
    OptedOutFilter -> OptedOutFilterName
name :: OptedOutFilterName,
    -- | An array of values to filter for.
    OptedOutFilter -> NonEmpty Text
values :: Prelude.NonEmpty Prelude.Text
  }
  deriving (OptedOutFilter -> OptedOutFilter -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OptedOutFilter -> OptedOutFilter -> Bool
$c/= :: OptedOutFilter -> OptedOutFilter -> Bool
== :: OptedOutFilter -> OptedOutFilter -> Bool
$c== :: OptedOutFilter -> OptedOutFilter -> Bool
Prelude.Eq, ReadPrec [OptedOutFilter]
ReadPrec OptedOutFilter
Int -> ReadS OptedOutFilter
ReadS [OptedOutFilter]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OptedOutFilter]
$creadListPrec :: ReadPrec [OptedOutFilter]
readPrec :: ReadPrec OptedOutFilter
$creadPrec :: ReadPrec OptedOutFilter
readList :: ReadS [OptedOutFilter]
$creadList :: ReadS [OptedOutFilter]
readsPrec :: Int -> ReadS OptedOutFilter
$creadsPrec :: Int -> ReadS OptedOutFilter
Prelude.Read, Int -> OptedOutFilter -> ShowS
[OptedOutFilter] -> ShowS
OptedOutFilter -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OptedOutFilter] -> ShowS
$cshowList :: [OptedOutFilter] -> ShowS
show :: OptedOutFilter -> String
$cshow :: OptedOutFilter -> String
showsPrec :: Int -> OptedOutFilter -> ShowS
$cshowsPrec :: Int -> OptedOutFilter -> ShowS
Prelude.Show, forall x. Rep OptedOutFilter x -> OptedOutFilter
forall x. OptedOutFilter -> Rep OptedOutFilter x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OptedOutFilter x -> OptedOutFilter
$cfrom :: forall x. OptedOutFilter -> Rep OptedOutFilter x
Prelude.Generic)

-- |
-- Create a value of 'OptedOutFilter' 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:
--
-- 'name', 'optedOutFilter_name' - The name of the attribute to filter on.
--
-- 'values', 'optedOutFilter_values' - An array of values to filter for.
newOptedOutFilter ::
  -- | 'name'
  OptedOutFilterName ->
  -- | 'values'
  Prelude.NonEmpty Prelude.Text ->
  OptedOutFilter
newOptedOutFilter :: OptedOutFilterName -> NonEmpty Text -> OptedOutFilter
newOptedOutFilter OptedOutFilterName
pName_ NonEmpty Text
pValues_ =
  OptedOutFilter'
    { $sel:name:OptedOutFilter' :: OptedOutFilterName
name = OptedOutFilterName
pName_,
      $sel:values:OptedOutFilter' :: NonEmpty Text
values = forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pValues_
    }

-- | The name of the attribute to filter on.
optedOutFilter_name :: Lens.Lens' OptedOutFilter OptedOutFilterName
optedOutFilter_name :: Lens' OptedOutFilter OptedOutFilterName
optedOutFilter_name = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OptedOutFilter' {OptedOutFilterName
name :: OptedOutFilterName
$sel:name:OptedOutFilter' :: OptedOutFilter -> OptedOutFilterName
name} -> OptedOutFilterName
name) (\s :: OptedOutFilter
s@OptedOutFilter' {} OptedOutFilterName
a -> OptedOutFilter
s {$sel:name:OptedOutFilter' :: OptedOutFilterName
name = OptedOutFilterName
a} :: OptedOutFilter)

-- | An array of values to filter for.
optedOutFilter_values :: Lens.Lens' OptedOutFilter (Prelude.NonEmpty Prelude.Text)
optedOutFilter_values :: Lens' OptedOutFilter (NonEmpty Text)
optedOutFilter_values = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OptedOutFilter' {NonEmpty Text
values :: NonEmpty Text
$sel:values:OptedOutFilter' :: OptedOutFilter -> NonEmpty Text
values} -> NonEmpty Text
values) (\s :: OptedOutFilter
s@OptedOutFilter' {} NonEmpty Text
a -> OptedOutFilter
s {$sel:values:OptedOutFilter' :: NonEmpty Text
values = NonEmpty Text
a} :: OptedOutFilter) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Prelude.Hashable OptedOutFilter where
  hashWithSalt :: Int -> OptedOutFilter -> Int
hashWithSalt Int
_salt OptedOutFilter' {NonEmpty Text
OptedOutFilterName
values :: NonEmpty Text
name :: OptedOutFilterName
$sel:values:OptedOutFilter' :: OptedOutFilter -> NonEmpty Text
$sel:name:OptedOutFilter' :: OptedOutFilter -> OptedOutFilterName
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` OptedOutFilterName
name
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
values

instance Prelude.NFData OptedOutFilter where
  rnf :: OptedOutFilter -> ()
rnf OptedOutFilter' {NonEmpty Text
OptedOutFilterName
values :: NonEmpty Text
name :: OptedOutFilterName
$sel:values:OptedOutFilter' :: OptedOutFilter -> NonEmpty Text
$sel:name:OptedOutFilter' :: OptedOutFilter -> OptedOutFilterName
..} =
    forall a. NFData a => a -> ()
Prelude.rnf OptedOutFilterName
name seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
values

instance Data.ToJSON OptedOutFilter where
  toJSON :: OptedOutFilter -> Value
toJSON OptedOutFilter' {NonEmpty Text
OptedOutFilterName
values :: NonEmpty Text
name :: OptedOutFilterName
$sel:values:OptedOutFilter' :: OptedOutFilter -> NonEmpty Text
$sel:name:OptedOutFilter' :: OptedOutFilter -> OptedOutFilterName
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Name" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= OptedOutFilterName
name),
            forall a. a -> Maybe a
Prelude.Just (Key
"Values" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
values)
          ]
      )