{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-binds #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

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

-- |
-- Module      : Amazonka.SNS.OptInPhoneNumber
-- 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)
--
-- Use this request to opt in a phone number that is opted out, which
-- enables you to resume sending SMS messages to the number.
--
-- You can opt in a phone number only once every 30 days.
module Amazonka.SNS.OptInPhoneNumber
  ( -- * Creating a Request
    OptInPhoneNumber (..),
    newOptInPhoneNumber,

    -- * Request Lenses
    optInPhoneNumber_phoneNumber,

    -- * Destructuring the Response
    OptInPhoneNumberResponse (..),
    newOptInPhoneNumberResponse,

    -- * Response Lenses
    optInPhoneNumberResponse_httpStatus,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response
import Amazonka.SNS.Types

-- | Input for the OptInPhoneNumber action.
--
-- /See:/ 'newOptInPhoneNumber' smart constructor.
data OptInPhoneNumber = OptInPhoneNumber'
  { -- | The phone number to opt in. Use E.164 format.
    OptInPhoneNumber -> Text
phoneNumber :: Prelude.Text
  }
  deriving (OptInPhoneNumber -> OptInPhoneNumber -> Bool
(OptInPhoneNumber -> OptInPhoneNumber -> Bool)
-> (OptInPhoneNumber -> OptInPhoneNumber -> Bool)
-> Eq OptInPhoneNumber
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OptInPhoneNumber -> OptInPhoneNumber -> Bool
$c/= :: OptInPhoneNumber -> OptInPhoneNumber -> Bool
== :: OptInPhoneNumber -> OptInPhoneNumber -> Bool
$c== :: OptInPhoneNumber -> OptInPhoneNumber -> Bool
Prelude.Eq, ReadPrec [OptInPhoneNumber]
ReadPrec OptInPhoneNumber
Int -> ReadS OptInPhoneNumber
ReadS [OptInPhoneNumber]
(Int -> ReadS OptInPhoneNumber)
-> ReadS [OptInPhoneNumber]
-> ReadPrec OptInPhoneNumber
-> ReadPrec [OptInPhoneNumber]
-> Read OptInPhoneNumber
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OptInPhoneNumber]
$creadListPrec :: ReadPrec [OptInPhoneNumber]
readPrec :: ReadPrec OptInPhoneNumber
$creadPrec :: ReadPrec OptInPhoneNumber
readList :: ReadS [OptInPhoneNumber]
$creadList :: ReadS [OptInPhoneNumber]
readsPrec :: Int -> ReadS OptInPhoneNumber
$creadsPrec :: Int -> ReadS OptInPhoneNumber
Prelude.Read, Int -> OptInPhoneNumber -> ShowS
[OptInPhoneNumber] -> ShowS
OptInPhoneNumber -> String
(Int -> OptInPhoneNumber -> ShowS)
-> (OptInPhoneNumber -> String)
-> ([OptInPhoneNumber] -> ShowS)
-> Show OptInPhoneNumber
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OptInPhoneNumber] -> ShowS
$cshowList :: [OptInPhoneNumber] -> ShowS
show :: OptInPhoneNumber -> String
$cshow :: OptInPhoneNumber -> String
showsPrec :: Int -> OptInPhoneNumber -> ShowS
$cshowsPrec :: Int -> OptInPhoneNumber -> ShowS
Prelude.Show, (forall x. OptInPhoneNumber -> Rep OptInPhoneNumber x)
-> (forall x. Rep OptInPhoneNumber x -> OptInPhoneNumber)
-> Generic OptInPhoneNumber
forall x. Rep OptInPhoneNumber x -> OptInPhoneNumber
forall x. OptInPhoneNumber -> Rep OptInPhoneNumber x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OptInPhoneNumber x -> OptInPhoneNumber
$cfrom :: forall x. OptInPhoneNumber -> Rep OptInPhoneNumber x
Prelude.Generic)

-- |
-- Create a value of 'OptInPhoneNumber' 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:
--
-- 'phoneNumber', 'optInPhoneNumber_phoneNumber' - The phone number to opt in. Use E.164 format.
newOptInPhoneNumber ::
  -- | 'phoneNumber'
  Prelude.Text ->
  OptInPhoneNumber
newOptInPhoneNumber :: Text -> OptInPhoneNumber
newOptInPhoneNumber Text
pPhoneNumber_ =
  OptInPhoneNumber' :: Text -> OptInPhoneNumber
OptInPhoneNumber' {$sel:phoneNumber:OptInPhoneNumber' :: Text
phoneNumber = Text
pPhoneNumber_}

-- | The phone number to opt in. Use E.164 format.
optInPhoneNumber_phoneNumber :: Lens.Lens' OptInPhoneNumber Prelude.Text
optInPhoneNumber_phoneNumber :: (Text -> f Text) -> OptInPhoneNumber -> f OptInPhoneNumber
optInPhoneNumber_phoneNumber = (OptInPhoneNumber -> Text)
-> (OptInPhoneNumber -> Text -> OptInPhoneNumber)
-> Lens OptInPhoneNumber OptInPhoneNumber Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OptInPhoneNumber' {Text
phoneNumber :: Text
$sel:phoneNumber:OptInPhoneNumber' :: OptInPhoneNumber -> Text
phoneNumber} -> Text
phoneNumber) (\s :: OptInPhoneNumber
s@OptInPhoneNumber' {} Text
a -> OptInPhoneNumber
s {$sel:phoneNumber:OptInPhoneNumber' :: Text
phoneNumber = Text
a} :: OptInPhoneNumber)

instance Core.AWSRequest OptInPhoneNumber where
  type
    AWSResponse OptInPhoneNumber =
      OptInPhoneNumberResponse
  request :: OptInPhoneNumber -> Request OptInPhoneNumber
request = Service -> OptInPhoneNumber -> Request OptInPhoneNumber
forall a. ToRequest a => Service -> a -> Request a
Request.postQuery Service
defaultService
  response :: Logger
-> Service
-> Proxy OptInPhoneNumber
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse OptInPhoneNumber)))
response =
    Text
-> (Int
    -> ResponseHeaders
    -> [Node]
    -> Either String (AWSResponse OptInPhoneNumber))
-> Logger
-> Service
-> Proxy OptInPhoneNumber
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse OptInPhoneNumber)))
forall (m :: * -> *) a.
MonadResource m =>
Text
-> (Int
    -> ResponseHeaders -> [Node] -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveXMLWrapper
      Text
"OptInPhoneNumberResult"
      ( \Int
s ResponseHeaders
h [Node]
x ->
          Int -> OptInPhoneNumberResponse
OptInPhoneNumberResponse'
            (Int -> OptInPhoneNumberResponse)
-> Either String Int -> Either String OptInPhoneNumberResponse
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Int -> Either String Int
forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (Int -> Int
forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
      )

instance Prelude.Hashable OptInPhoneNumber

instance Prelude.NFData OptInPhoneNumber

instance Core.ToHeaders OptInPhoneNumber where
  toHeaders :: OptInPhoneNumber -> ResponseHeaders
toHeaders = ResponseHeaders -> OptInPhoneNumber -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const ResponseHeaders
forall a. Monoid a => a
Prelude.mempty

instance Core.ToPath OptInPhoneNumber where
  toPath :: OptInPhoneNumber -> ByteString
toPath = ByteString -> OptInPhoneNumber -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

instance Core.ToQuery OptInPhoneNumber where
  toQuery :: OptInPhoneNumber -> QueryString
toQuery OptInPhoneNumber' {Text
phoneNumber :: Text
$sel:phoneNumber:OptInPhoneNumber' :: OptInPhoneNumber -> Text
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"Action"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"OptInPhoneNumber" :: Prelude.ByteString),
        ByteString
"Version"
          ByteString -> ByteString -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: (ByteString
"2010-03-31" :: Prelude.ByteString),
        ByteString
"phoneNumber" ByteString -> Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Text
phoneNumber
      ]

-- | The response for the OptInPhoneNumber action.
--
-- /See:/ 'newOptInPhoneNumberResponse' smart constructor.
data OptInPhoneNumberResponse = OptInPhoneNumberResponse'
  { -- | The response's http status code.
    OptInPhoneNumberResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (OptInPhoneNumberResponse -> OptInPhoneNumberResponse -> Bool
(OptInPhoneNumberResponse -> OptInPhoneNumberResponse -> Bool)
-> (OptInPhoneNumberResponse -> OptInPhoneNumberResponse -> Bool)
-> Eq OptInPhoneNumberResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OptInPhoneNumberResponse -> OptInPhoneNumberResponse -> Bool
$c/= :: OptInPhoneNumberResponse -> OptInPhoneNumberResponse -> Bool
== :: OptInPhoneNumberResponse -> OptInPhoneNumberResponse -> Bool
$c== :: OptInPhoneNumberResponse -> OptInPhoneNumberResponse -> Bool
Prelude.Eq, ReadPrec [OptInPhoneNumberResponse]
ReadPrec OptInPhoneNumberResponse
Int -> ReadS OptInPhoneNumberResponse
ReadS [OptInPhoneNumberResponse]
(Int -> ReadS OptInPhoneNumberResponse)
-> ReadS [OptInPhoneNumberResponse]
-> ReadPrec OptInPhoneNumberResponse
-> ReadPrec [OptInPhoneNumberResponse]
-> Read OptInPhoneNumberResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OptInPhoneNumberResponse]
$creadListPrec :: ReadPrec [OptInPhoneNumberResponse]
readPrec :: ReadPrec OptInPhoneNumberResponse
$creadPrec :: ReadPrec OptInPhoneNumberResponse
readList :: ReadS [OptInPhoneNumberResponse]
$creadList :: ReadS [OptInPhoneNumberResponse]
readsPrec :: Int -> ReadS OptInPhoneNumberResponse
$creadsPrec :: Int -> ReadS OptInPhoneNumberResponse
Prelude.Read, Int -> OptInPhoneNumberResponse -> ShowS
[OptInPhoneNumberResponse] -> ShowS
OptInPhoneNumberResponse -> String
(Int -> OptInPhoneNumberResponse -> ShowS)
-> (OptInPhoneNumberResponse -> String)
-> ([OptInPhoneNumberResponse] -> ShowS)
-> Show OptInPhoneNumberResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OptInPhoneNumberResponse] -> ShowS
$cshowList :: [OptInPhoneNumberResponse] -> ShowS
show :: OptInPhoneNumberResponse -> String
$cshow :: OptInPhoneNumberResponse -> String
showsPrec :: Int -> OptInPhoneNumberResponse -> ShowS
$cshowsPrec :: Int -> OptInPhoneNumberResponse -> ShowS
Prelude.Show, (forall x.
 OptInPhoneNumberResponse -> Rep OptInPhoneNumberResponse x)
-> (forall x.
    Rep OptInPhoneNumberResponse x -> OptInPhoneNumberResponse)
-> Generic OptInPhoneNumberResponse
forall x.
Rep OptInPhoneNumberResponse x -> OptInPhoneNumberResponse
forall x.
OptInPhoneNumberResponse -> Rep OptInPhoneNumberResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep OptInPhoneNumberResponse x -> OptInPhoneNumberResponse
$cfrom :: forall x.
OptInPhoneNumberResponse -> Rep OptInPhoneNumberResponse x
Prelude.Generic)

-- |
-- Create a value of 'OptInPhoneNumberResponse' 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:
--
-- 'httpStatus', 'optInPhoneNumberResponse_httpStatus' - The response's http status code.
newOptInPhoneNumberResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  OptInPhoneNumberResponse
newOptInPhoneNumberResponse :: Int -> OptInPhoneNumberResponse
newOptInPhoneNumberResponse Int
pHttpStatus_ =
  OptInPhoneNumberResponse' :: Int -> OptInPhoneNumberResponse
OptInPhoneNumberResponse'
    { $sel:httpStatus:OptInPhoneNumberResponse' :: Int
httpStatus =
        Int
pHttpStatus_
    }

-- | The response's http status code.
optInPhoneNumberResponse_httpStatus :: Lens.Lens' OptInPhoneNumberResponse Prelude.Int
optInPhoneNumberResponse_httpStatus :: (Int -> f Int)
-> OptInPhoneNumberResponse -> f OptInPhoneNumberResponse
optInPhoneNumberResponse_httpStatus = (OptInPhoneNumberResponse -> Int)
-> (OptInPhoneNumberResponse -> Int -> OptInPhoneNumberResponse)
-> Lens OptInPhoneNumberResponse OptInPhoneNumberResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OptInPhoneNumberResponse' {Int
httpStatus :: Int
$sel:httpStatus:OptInPhoneNumberResponse' :: OptInPhoneNumberResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: OptInPhoneNumberResponse
s@OptInPhoneNumberResponse' {} Int
a -> OptInPhoneNumberResponse
s {$sel:httpStatus:OptInPhoneNumberResponse' :: Int
httpStatus = Int
a} :: OptInPhoneNumberResponse)

instance Prelude.NFData OptInPhoneNumberResponse