{-# 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-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)
--
-- 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.Lens as Lens
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
(PhoneNumberValidate -> PhoneNumberValidate -> Bool)
-> (PhoneNumberValidate -> PhoneNumberValidate -> Bool)
-> Eq PhoneNumberValidate
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]
(Int -> ReadS PhoneNumberValidate)
-> ReadS [PhoneNumberValidate]
-> ReadPrec PhoneNumberValidate
-> ReadPrec [PhoneNumberValidate]
-> Read 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
(Int -> PhoneNumberValidate -> ShowS)
-> (PhoneNumberValidate -> String)
-> ([PhoneNumberValidate] -> ShowS)
-> Show PhoneNumberValidate
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. PhoneNumberValidate -> Rep PhoneNumberValidate x)
-> (forall x. Rep PhoneNumberValidate x -> PhoneNumberValidate)
-> Generic PhoneNumberValidate
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' :: NumberValidateRequest -> PhoneNumberValidate
PhoneNumberValidate'
    { $sel:numberValidateRequest:PhoneNumberValidate' :: NumberValidateRequest
numberValidateRequest =
        NumberValidateRequest
pNumberValidateRequest_
    }

-- | Undocumented member.
phoneNumberValidate_numberValidateRequest :: Lens.Lens' PhoneNumberValidate NumberValidateRequest
phoneNumberValidate_numberValidateRequest :: (NumberValidateRequest -> f NumberValidateRequest)
-> PhoneNumberValidate -> f PhoneNumberValidate
phoneNumberValidate_numberValidateRequest = (PhoneNumberValidate -> NumberValidateRequest)
-> (PhoneNumberValidate
    -> NumberValidateRequest -> PhoneNumberValidate)
-> Lens
     PhoneNumberValidate
     PhoneNumberValidate
     NumberValidateRequest
     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 :: PhoneNumberValidate -> Request PhoneNumberValidate
request = Service -> PhoneNumberValidate -> Request PhoneNumberValidate
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy PhoneNumberValidate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PhoneNumberValidate)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse PhoneNumberValidate))
-> Logger
-> Service
-> Proxy PhoneNumberValidate
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse PhoneNumberValidate)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> Object -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveJSON
      ( \Int
s ResponseHeaders
h Object
x ->
          Int -> NumberValidateResponse -> PhoneNumberValidateResponse
PhoneNumberValidateResponse'
            (Int -> NumberValidateResponse -> PhoneNumberValidateResponse)
-> Either String Int
-> Either
     String (NumberValidateResponse -> PhoneNumberValidateResponse)
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))
            Either
  String (NumberValidateResponse -> PhoneNumberValidateResponse)
-> Either String NumberValidateResponse
-> Either String PhoneNumberValidateResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String NumberValidateResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
      )

instance Prelude.Hashable PhoneNumberValidate

instance Prelude.NFData PhoneNumberValidate

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

instance Core.ToJSON PhoneNumberValidate where
  toJSON :: PhoneNumberValidate -> Value
toJSON PhoneNumberValidate' {NumberValidateRequest
numberValidateRequest :: NumberValidateRequest
$sel:numberValidateRequest:PhoneNumberValidate' :: PhoneNumberValidate -> NumberValidateRequest
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"NumberValidateRequest"
                  Text -> NumberValidateRequest -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NumberValidateRequest
numberValidateRequest
              )
          ]
      )

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

instance Core.ToQuery PhoneNumberValidate where
  toQuery :: PhoneNumberValidate -> QueryString
toQuery = QueryString -> PhoneNumberValidate -> QueryString
forall a b. a -> b -> a
Prelude.const QueryString
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
(PhoneNumberValidateResponse
 -> PhoneNumberValidateResponse -> Bool)
-> (PhoneNumberValidateResponse
    -> PhoneNumberValidateResponse -> Bool)
-> Eq PhoneNumberValidateResponse
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]
(Int -> ReadS PhoneNumberValidateResponse)
-> ReadS [PhoneNumberValidateResponse]
-> ReadPrec PhoneNumberValidateResponse
-> ReadPrec [PhoneNumberValidateResponse]
-> Read 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
(Int -> PhoneNumberValidateResponse -> ShowS)
-> (PhoneNumberValidateResponse -> String)
-> ([PhoneNumberValidateResponse] -> ShowS)
-> Show PhoneNumberValidateResponse
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.
 PhoneNumberValidateResponse -> Rep PhoneNumberValidateResponse x)
-> (forall x.
    Rep PhoneNumberValidateResponse x -> PhoneNumberValidateResponse)
-> Generic PhoneNumberValidateResponse
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' :: Int -> NumberValidateResponse -> PhoneNumberValidateResponse
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 :: (Int -> f Int)
-> PhoneNumberValidateResponse -> f PhoneNumberValidateResponse
phoneNumberValidateResponse_httpStatus = (PhoneNumberValidateResponse -> Int)
-> (PhoneNumberValidateResponse
    -> Int -> PhoneNumberValidateResponse)
-> Lens
     PhoneNumberValidateResponse PhoneNumberValidateResponse Int Int
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 :: (NumberValidateResponse -> f NumberValidateResponse)
-> PhoneNumberValidateResponse -> f PhoneNumberValidateResponse
phoneNumberValidateResponse_numberValidateResponse = (PhoneNumberValidateResponse -> NumberValidateResponse)
-> (PhoneNumberValidateResponse
    -> NumberValidateResponse -> PhoneNumberValidateResponse)
-> Lens
     PhoneNumberValidateResponse
     PhoneNumberValidateResponse
     NumberValidateResponse
     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