{-# 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.Pinpoint.PhoneNumberValidate
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Retrieves information about a phone number.
module Amazonka.Pinpoint.PhoneNumberValidate
  ( -- * Creating a Request
    PhoneNumberValidate (..),
    newPhoneNumberValidate,

    -- * Request Lenses
    phoneNumberValidate_numberValidateRequest,

    -- * Destructuring the Response
    PhoneNumberValidateResponse (..),
    newPhoneNumberValidateResponse,

    -- * Response Lenses
    phoneNumberValidateResponse_httpStatus,
    phoneNumberValidateResponse_numberValidateResponse,
  )
where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.Pinpoint.Types
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newPhoneNumberValidate' smart constructor.
data PhoneNumberValidate = PhoneNumberValidate'
  { PhoneNumberValidate -> NumberValidateRequest
numberValidateRequest :: NumberValidateRequest
  }
  deriving (PhoneNumberValidate -> PhoneNumberValidate -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: PhoneNumberValidate -> PhoneNumberValidate -> Bool
$c/= :: PhoneNumberValidate -> PhoneNumberValidate -> Bool
== :: PhoneNumberValidate -> PhoneNumberValidate -> Bool
$c== :: PhoneNumberValidate -> PhoneNumberValidate -> Bool
Prelude.Eq, ReadPrec [PhoneNumberValidate]
ReadPrec PhoneNumberValidate
Int -> ReadS PhoneNumberValidate
ReadS [PhoneNumberValidate]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [PhoneNumberValidate]
$creadListPrec :: ReadPrec [PhoneNumberValidate]
readPrec :: ReadPrec PhoneNumberValidate
$creadPrec :: ReadPrec PhoneNumberValidate
readList :: ReadS [PhoneNumberValidate]
$creadList :: ReadS [PhoneNumberValidate]
readsPrec :: Int -> ReadS PhoneNumberValidate
$creadsPrec :: Int -> ReadS PhoneNumberValidate
Prelude.Read, Int -> PhoneNumberValidate -> ShowS
[PhoneNumberValidate] -> ShowS
PhoneNumberValidate -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [PhoneNumberValidate] -> ShowS
$cshowList :: [PhoneNumberValidate] -> ShowS
show :: PhoneNumberValidate -> String
$cshow :: PhoneNumberValidate -> String
showsPrec :: Int -> PhoneNumberValidate -> ShowS
$cshowsPrec :: Int -> PhoneNumberValidate -> ShowS
Prelude.Show, forall x. Rep PhoneNumberValidate x -> PhoneNumberValidate
forall x. PhoneNumberValidate -> Rep PhoneNumberValidate x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep PhoneNumberValidate x -> PhoneNumberValidate
$cfrom :: forall x. PhoneNumberValidate -> Rep PhoneNumberValidate x
Prelude.Generic)

-- |
-- Create a value of 'PhoneNumberValidate' 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:
--
-- 'numberValidateRequest', 'phoneNumberValidate_numberValidateRequest' - Undocumented member.
newPhoneNumberValidate ::
  -- | 'numberValidateRequest'
  NumberValidateRequest ->
  PhoneNumberValidate
newPhoneNumberValidate :: NumberValidateRequest -> PhoneNumberValidate
newPhoneNumberValidate NumberValidateRequest
pNumberValidateRequest_ =
  PhoneNumberValidate'
    { $sel:numberValidateRequest:PhoneNumberValidate' :: NumberValidateRequest
numberValidateRequest =
        NumberValidateRequest
pNumberValidateRequest_
    }

-- | Undocumented member.
phoneNumberValidate_numberValidateRequest :: Lens.Lens' PhoneNumberValidate NumberValidateRequest
phoneNumberValidate_numberValidateRequest :: Lens' PhoneNumberValidate NumberValidateRequest
phoneNumberValidate_numberValidateRequest = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhoneNumberValidate' {NumberValidateRequest
numberValidateRequest :: NumberValidateRequest
$sel:numberValidateRequest:PhoneNumberValidate' :: PhoneNumberValidate -> NumberValidateRequest
numberValidateRequest} -> NumberValidateRequest
numberValidateRequest) (\s :: PhoneNumberValidate
s@PhoneNumberValidate' {} NumberValidateRequest
a -> PhoneNumberValidate
s {$sel:numberValidateRequest:PhoneNumberValidate' :: NumberValidateRequest
numberValidateRequest = NumberValidateRequest
a} :: PhoneNumberValidate)

instance Core.AWSRequest PhoneNumberValidate where
  type
    AWSResponse PhoneNumberValidate =
      PhoneNumberValidateResponse
  request :: (Service -> Service)
-> PhoneNumberValidate -> Request PhoneNumberValidate
request Service -> Service
overrides =
    forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy PhoneNumberValidate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PhoneNumberValidate)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> NumberValidateResponse -> PhoneNumberValidateResponse
PhoneNumberValidateResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (forall (f :: * -> *) a. Applicative f => a -> f a
Prelude.pure (forall a. Enum a => a -> Int
Prelude.fromEnum Int
s))
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (forall a. FromJSON a => Object -> Either String a
Data.eitherParseJSON Object
x)
      )

instance Prelude.Hashable PhoneNumberValidate where
  hashWithSalt :: Int -> PhoneNumberValidate -> Int
hashWithSalt Int
_salt PhoneNumberValidate' {NumberValidateRequest
numberValidateRequest :: NumberValidateRequest
$sel:numberValidateRequest:PhoneNumberValidate' :: PhoneNumberValidate -> NumberValidateRequest
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NumberValidateRequest
numberValidateRequest

instance Prelude.NFData PhoneNumberValidate where
  rnf :: PhoneNumberValidate -> ()
rnf PhoneNumberValidate' {NumberValidateRequest
numberValidateRequest :: NumberValidateRequest
$sel:numberValidateRequest:PhoneNumberValidate' :: PhoneNumberValidate -> NumberValidateRequest
..} =
    forall a. NFData a => a -> ()
Prelude.rnf NumberValidateRequest
numberValidateRequest

instance Data.ToHeaders PhoneNumberValidate where
  toHeaders :: PhoneNumberValidate -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON PhoneNumberValidate where
  toJSON :: PhoneNumberValidate -> Value
toJSON PhoneNumberValidate' {NumberValidateRequest
numberValidateRequest :: NumberValidateRequest
$sel:numberValidateRequest:PhoneNumberValidate' :: PhoneNumberValidate -> NumberValidateRequest
..} =
    forall a. ToJSON a => a -> Value
Data.toJSON NumberValidateRequest
numberValidateRequest

instance Data.ToPath PhoneNumberValidate where
  toPath :: PhoneNumberValidate -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/v1/phone/number/validate"

instance Data.ToQuery PhoneNumberValidate where
  toQuery :: PhoneNumberValidate -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const forall a. Monoid a => a
Prelude.mempty

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

-- |
-- Create a value of 'PhoneNumberValidateResponse' 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', 'phoneNumberValidateResponse_httpStatus' - The response's http status code.
--
-- 'numberValidateResponse', 'phoneNumberValidateResponse_numberValidateResponse' - Undocumented member.
newPhoneNumberValidateResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'numberValidateResponse'
  NumberValidateResponse ->
  PhoneNumberValidateResponse
newPhoneNumberValidateResponse :: Int -> NumberValidateResponse -> PhoneNumberValidateResponse
newPhoneNumberValidateResponse
  Int
pHttpStatus_
  NumberValidateResponse
pNumberValidateResponse_ =
    PhoneNumberValidateResponse'
      { $sel:httpStatus:PhoneNumberValidateResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:numberValidateResponse:PhoneNumberValidateResponse' :: NumberValidateResponse
numberValidateResponse =
          NumberValidateResponse
pNumberValidateResponse_
      }

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

-- | Undocumented member.
phoneNumberValidateResponse_numberValidateResponse :: Lens.Lens' PhoneNumberValidateResponse NumberValidateResponse
phoneNumberValidateResponse_numberValidateResponse :: Lens' PhoneNumberValidateResponse NumberValidateResponse
phoneNumberValidateResponse_numberValidateResponse = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\PhoneNumberValidateResponse' {NumberValidateResponse
numberValidateResponse :: NumberValidateResponse
$sel:numberValidateResponse:PhoneNumberValidateResponse' :: PhoneNumberValidateResponse -> NumberValidateResponse
numberValidateResponse} -> NumberValidateResponse
numberValidateResponse) (\s :: PhoneNumberValidateResponse
s@PhoneNumberValidateResponse' {} NumberValidateResponse
a -> PhoneNumberValidateResponse
s {$sel:numberValidateResponse:PhoneNumberValidateResponse' :: NumberValidateResponse
numberValidateResponse = NumberValidateResponse
a} :: PhoneNumberValidateResponse)

instance Prelude.NFData PhoneNumberValidateResponse where
  rnf :: PhoneNumberValidateResponse -> ()
rnf PhoneNumberValidateResponse' {Int
NumberValidateResponse
numberValidateResponse :: NumberValidateResponse
httpStatus :: Int
$sel:numberValidateResponse:PhoneNumberValidateResponse' :: PhoneNumberValidateResponse -> NumberValidateResponse
$sel:httpStatus:PhoneNumberValidateResponse' :: PhoneNumberValidateResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf NumberValidateResponse
numberValidateResponse