{-# 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.Chime.SearchAvailablePhoneNumbers
-- 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)
--
-- Searches for phone numbers that can be ordered. For US numbers, provide
-- at least one of the following search filters: @AreaCode@, @City@,
-- @State@, or @TollFreePrefix@. If you provide @City@, you must also
-- provide @State@. Numbers outside the US only support the
-- @PhoneNumberType@ filter, which you must use.
module Amazonka.Chime.SearchAvailablePhoneNumbers
  ( -- * Creating a Request
    SearchAvailablePhoneNumbers (..),
    newSearchAvailablePhoneNumbers,

    -- * Request Lenses
    searchAvailablePhoneNumbers_phoneNumberType,
    searchAvailablePhoneNumbers_state,
    searchAvailablePhoneNumbers_tollFreePrefix,
    searchAvailablePhoneNumbers_country,
    searchAvailablePhoneNumbers_nextToken,
    searchAvailablePhoneNumbers_city,
    searchAvailablePhoneNumbers_areaCode,
    searchAvailablePhoneNumbers_maxResults,

    -- * Destructuring the Response
    SearchAvailablePhoneNumbersResponse (..),
    newSearchAvailablePhoneNumbersResponse,

    -- * Response Lenses
    searchAvailablePhoneNumbersResponse_e164PhoneNumbers,
    searchAvailablePhoneNumbersResponse_nextToken,
    searchAvailablePhoneNumbersResponse_httpStatus,
  )
where

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

-- | /See:/ 'newSearchAvailablePhoneNumbers' smart constructor.
data SearchAvailablePhoneNumbers = SearchAvailablePhoneNumbers'
  { -- | The phone number type used to filter results. Required for non-US
    -- numbers.
    SearchAvailablePhoneNumbers -> Maybe PhoneNumberType
phoneNumberType :: Prelude.Maybe PhoneNumberType,
    -- | The state used to filter results. Required only if you provide @City@.
    -- Only applies to the US.
    SearchAvailablePhoneNumbers -> Maybe Text
state :: Prelude.Maybe Prelude.Text,
    -- | The toll-free prefix that you use to filter results. Only applies to the
    -- US.
    SearchAvailablePhoneNumbers -> Maybe Text
tollFreePrefix :: Prelude.Maybe Prelude.Text,
    -- | The country used to filter results. Defaults to the US Format: ISO
    -- 3166-1 alpha-2.
    SearchAvailablePhoneNumbers -> Maybe Text
country :: Prelude.Maybe Prelude.Text,
    -- | The token used to retrieve the next page of results.
    SearchAvailablePhoneNumbers -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The city used to filter results. Only applies to the US.
    SearchAvailablePhoneNumbers -> Maybe Text
city :: Prelude.Maybe Prelude.Text,
    -- | The area code used to filter results. Only applies to the US.
    SearchAvailablePhoneNumbers -> Maybe Text
areaCode :: Prelude.Maybe Prelude.Text,
    -- | The maximum number of results to return in a single call.
    SearchAvailablePhoneNumbers -> Maybe Natural
maxResults :: Prelude.Maybe Prelude.Natural
  }
  deriving (SearchAvailablePhoneNumbers -> SearchAvailablePhoneNumbers -> Bool
(SearchAvailablePhoneNumbers
 -> SearchAvailablePhoneNumbers -> Bool)
-> (SearchAvailablePhoneNumbers
    -> SearchAvailablePhoneNumbers -> Bool)
-> Eq SearchAvailablePhoneNumbers
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchAvailablePhoneNumbers -> SearchAvailablePhoneNumbers -> Bool
$c/= :: SearchAvailablePhoneNumbers -> SearchAvailablePhoneNumbers -> Bool
== :: SearchAvailablePhoneNumbers -> SearchAvailablePhoneNumbers -> Bool
$c== :: SearchAvailablePhoneNumbers -> SearchAvailablePhoneNumbers -> Bool
Prelude.Eq, ReadPrec [SearchAvailablePhoneNumbers]
ReadPrec SearchAvailablePhoneNumbers
Int -> ReadS SearchAvailablePhoneNumbers
ReadS [SearchAvailablePhoneNumbers]
(Int -> ReadS SearchAvailablePhoneNumbers)
-> ReadS [SearchAvailablePhoneNumbers]
-> ReadPrec SearchAvailablePhoneNumbers
-> ReadPrec [SearchAvailablePhoneNumbers]
-> Read SearchAvailablePhoneNumbers
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SearchAvailablePhoneNumbers]
$creadListPrec :: ReadPrec [SearchAvailablePhoneNumbers]
readPrec :: ReadPrec SearchAvailablePhoneNumbers
$creadPrec :: ReadPrec SearchAvailablePhoneNumbers
readList :: ReadS [SearchAvailablePhoneNumbers]
$creadList :: ReadS [SearchAvailablePhoneNumbers]
readsPrec :: Int -> ReadS SearchAvailablePhoneNumbers
$creadsPrec :: Int -> ReadS SearchAvailablePhoneNumbers
Prelude.Read, Int -> SearchAvailablePhoneNumbers -> ShowS
[SearchAvailablePhoneNumbers] -> ShowS
SearchAvailablePhoneNumbers -> String
(Int -> SearchAvailablePhoneNumbers -> ShowS)
-> (SearchAvailablePhoneNumbers -> String)
-> ([SearchAvailablePhoneNumbers] -> ShowS)
-> Show SearchAvailablePhoneNumbers
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchAvailablePhoneNumbers] -> ShowS
$cshowList :: [SearchAvailablePhoneNumbers] -> ShowS
show :: SearchAvailablePhoneNumbers -> String
$cshow :: SearchAvailablePhoneNumbers -> String
showsPrec :: Int -> SearchAvailablePhoneNumbers -> ShowS
$cshowsPrec :: Int -> SearchAvailablePhoneNumbers -> ShowS
Prelude.Show, (forall x.
 SearchAvailablePhoneNumbers -> Rep SearchAvailablePhoneNumbers x)
-> (forall x.
    Rep SearchAvailablePhoneNumbers x -> SearchAvailablePhoneNumbers)
-> Generic SearchAvailablePhoneNumbers
forall x.
Rep SearchAvailablePhoneNumbers x -> SearchAvailablePhoneNumbers
forall x.
SearchAvailablePhoneNumbers -> Rep SearchAvailablePhoneNumbers x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SearchAvailablePhoneNumbers x -> SearchAvailablePhoneNumbers
$cfrom :: forall x.
SearchAvailablePhoneNumbers -> Rep SearchAvailablePhoneNumbers x
Prelude.Generic)

-- |
-- Create a value of 'SearchAvailablePhoneNumbers' 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:
--
-- 'phoneNumberType', 'searchAvailablePhoneNumbers_phoneNumberType' - The phone number type used to filter results. Required for non-US
-- numbers.
--
-- 'state', 'searchAvailablePhoneNumbers_state' - The state used to filter results. Required only if you provide @City@.
-- Only applies to the US.
--
-- 'tollFreePrefix', 'searchAvailablePhoneNumbers_tollFreePrefix' - The toll-free prefix that you use to filter results. Only applies to the
-- US.
--
-- 'country', 'searchAvailablePhoneNumbers_country' - The country used to filter results. Defaults to the US Format: ISO
-- 3166-1 alpha-2.
--
-- 'nextToken', 'searchAvailablePhoneNumbers_nextToken' - The token used to retrieve the next page of results.
--
-- 'city', 'searchAvailablePhoneNumbers_city' - The city used to filter results. Only applies to the US.
--
-- 'areaCode', 'searchAvailablePhoneNumbers_areaCode' - The area code used to filter results. Only applies to the US.
--
-- 'maxResults', 'searchAvailablePhoneNumbers_maxResults' - The maximum number of results to return in a single call.
newSearchAvailablePhoneNumbers ::
  SearchAvailablePhoneNumbers
newSearchAvailablePhoneNumbers :: SearchAvailablePhoneNumbers
newSearchAvailablePhoneNumbers =
  SearchAvailablePhoneNumbers' :: Maybe PhoneNumberType
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Natural
-> SearchAvailablePhoneNumbers
SearchAvailablePhoneNumbers'
    { $sel:phoneNumberType:SearchAvailablePhoneNumbers' :: Maybe PhoneNumberType
phoneNumberType =
        Maybe PhoneNumberType
forall a. Maybe a
Prelude.Nothing,
      $sel:state:SearchAvailablePhoneNumbers' :: Maybe Text
state = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:tollFreePrefix:SearchAvailablePhoneNumbers' :: Maybe Text
tollFreePrefix = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:country:SearchAvailablePhoneNumbers' :: Maybe Text
country = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:SearchAvailablePhoneNumbers' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:city:SearchAvailablePhoneNumbers' :: Maybe Text
city = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:areaCode:SearchAvailablePhoneNumbers' :: Maybe Text
areaCode = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:maxResults:SearchAvailablePhoneNumbers' :: Maybe Natural
maxResults = Maybe Natural
forall a. Maybe a
Prelude.Nothing
    }

-- | The phone number type used to filter results. Required for non-US
-- numbers.
searchAvailablePhoneNumbers_phoneNumberType :: Lens.Lens' SearchAvailablePhoneNumbers (Prelude.Maybe PhoneNumberType)
searchAvailablePhoneNumbers_phoneNumberType :: (Maybe PhoneNumberType -> f (Maybe PhoneNumberType))
-> SearchAvailablePhoneNumbers -> f SearchAvailablePhoneNumbers
searchAvailablePhoneNumbers_phoneNumberType = (SearchAvailablePhoneNumbers -> Maybe PhoneNumberType)
-> (SearchAvailablePhoneNumbers
    -> Maybe PhoneNumberType -> SearchAvailablePhoneNumbers)
-> Lens
     SearchAvailablePhoneNumbers
     SearchAvailablePhoneNumbers
     (Maybe PhoneNumberType)
     (Maybe PhoneNumberType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAvailablePhoneNumbers' {Maybe PhoneNumberType
phoneNumberType :: Maybe PhoneNumberType
$sel:phoneNumberType:SearchAvailablePhoneNumbers' :: SearchAvailablePhoneNumbers -> Maybe PhoneNumberType
phoneNumberType} -> Maybe PhoneNumberType
phoneNumberType) (\s :: SearchAvailablePhoneNumbers
s@SearchAvailablePhoneNumbers' {} Maybe PhoneNumberType
a -> SearchAvailablePhoneNumbers
s {$sel:phoneNumberType:SearchAvailablePhoneNumbers' :: Maybe PhoneNumberType
phoneNumberType = Maybe PhoneNumberType
a} :: SearchAvailablePhoneNumbers)

-- | The state used to filter results. Required only if you provide @City@.
-- Only applies to the US.
searchAvailablePhoneNumbers_state :: Lens.Lens' SearchAvailablePhoneNumbers (Prelude.Maybe Prelude.Text)
searchAvailablePhoneNumbers_state :: (Maybe Text -> f (Maybe Text))
-> SearchAvailablePhoneNumbers -> f SearchAvailablePhoneNumbers
searchAvailablePhoneNumbers_state = (SearchAvailablePhoneNumbers -> Maybe Text)
-> (SearchAvailablePhoneNumbers
    -> Maybe Text -> SearchAvailablePhoneNumbers)
-> Lens
     SearchAvailablePhoneNumbers
     SearchAvailablePhoneNumbers
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAvailablePhoneNumbers' {Maybe Text
state :: Maybe Text
$sel:state:SearchAvailablePhoneNumbers' :: SearchAvailablePhoneNumbers -> Maybe Text
state} -> Maybe Text
state) (\s :: SearchAvailablePhoneNumbers
s@SearchAvailablePhoneNumbers' {} Maybe Text
a -> SearchAvailablePhoneNumbers
s {$sel:state:SearchAvailablePhoneNumbers' :: Maybe Text
state = Maybe Text
a} :: SearchAvailablePhoneNumbers)

-- | The toll-free prefix that you use to filter results. Only applies to the
-- US.
searchAvailablePhoneNumbers_tollFreePrefix :: Lens.Lens' SearchAvailablePhoneNumbers (Prelude.Maybe Prelude.Text)
searchAvailablePhoneNumbers_tollFreePrefix :: (Maybe Text -> f (Maybe Text))
-> SearchAvailablePhoneNumbers -> f SearchAvailablePhoneNumbers
searchAvailablePhoneNumbers_tollFreePrefix = (SearchAvailablePhoneNumbers -> Maybe Text)
-> (SearchAvailablePhoneNumbers
    -> Maybe Text -> SearchAvailablePhoneNumbers)
-> Lens
     SearchAvailablePhoneNumbers
     SearchAvailablePhoneNumbers
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAvailablePhoneNumbers' {Maybe Text
tollFreePrefix :: Maybe Text
$sel:tollFreePrefix:SearchAvailablePhoneNumbers' :: SearchAvailablePhoneNumbers -> Maybe Text
tollFreePrefix} -> Maybe Text
tollFreePrefix) (\s :: SearchAvailablePhoneNumbers
s@SearchAvailablePhoneNumbers' {} Maybe Text
a -> SearchAvailablePhoneNumbers
s {$sel:tollFreePrefix:SearchAvailablePhoneNumbers' :: Maybe Text
tollFreePrefix = Maybe Text
a} :: SearchAvailablePhoneNumbers)

-- | The country used to filter results. Defaults to the US Format: ISO
-- 3166-1 alpha-2.
searchAvailablePhoneNumbers_country :: Lens.Lens' SearchAvailablePhoneNumbers (Prelude.Maybe Prelude.Text)
searchAvailablePhoneNumbers_country :: (Maybe Text -> f (Maybe Text))
-> SearchAvailablePhoneNumbers -> f SearchAvailablePhoneNumbers
searchAvailablePhoneNumbers_country = (SearchAvailablePhoneNumbers -> Maybe Text)
-> (SearchAvailablePhoneNumbers
    -> Maybe Text -> SearchAvailablePhoneNumbers)
-> Lens
     SearchAvailablePhoneNumbers
     SearchAvailablePhoneNumbers
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAvailablePhoneNumbers' {Maybe Text
country :: Maybe Text
$sel:country:SearchAvailablePhoneNumbers' :: SearchAvailablePhoneNumbers -> Maybe Text
country} -> Maybe Text
country) (\s :: SearchAvailablePhoneNumbers
s@SearchAvailablePhoneNumbers' {} Maybe Text
a -> SearchAvailablePhoneNumbers
s {$sel:country:SearchAvailablePhoneNumbers' :: Maybe Text
country = Maybe Text
a} :: SearchAvailablePhoneNumbers)

-- | The token used to retrieve the next page of results.
searchAvailablePhoneNumbers_nextToken :: Lens.Lens' SearchAvailablePhoneNumbers (Prelude.Maybe Prelude.Text)
searchAvailablePhoneNumbers_nextToken :: (Maybe Text -> f (Maybe Text))
-> SearchAvailablePhoneNumbers -> f SearchAvailablePhoneNumbers
searchAvailablePhoneNumbers_nextToken = (SearchAvailablePhoneNumbers -> Maybe Text)
-> (SearchAvailablePhoneNumbers
    -> Maybe Text -> SearchAvailablePhoneNumbers)
-> Lens
     SearchAvailablePhoneNumbers
     SearchAvailablePhoneNumbers
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAvailablePhoneNumbers' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SearchAvailablePhoneNumbers' :: SearchAvailablePhoneNumbers -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SearchAvailablePhoneNumbers
s@SearchAvailablePhoneNumbers' {} Maybe Text
a -> SearchAvailablePhoneNumbers
s {$sel:nextToken:SearchAvailablePhoneNumbers' :: Maybe Text
nextToken = Maybe Text
a} :: SearchAvailablePhoneNumbers)

-- | The city used to filter results. Only applies to the US.
searchAvailablePhoneNumbers_city :: Lens.Lens' SearchAvailablePhoneNumbers (Prelude.Maybe Prelude.Text)
searchAvailablePhoneNumbers_city :: (Maybe Text -> f (Maybe Text))
-> SearchAvailablePhoneNumbers -> f SearchAvailablePhoneNumbers
searchAvailablePhoneNumbers_city = (SearchAvailablePhoneNumbers -> Maybe Text)
-> (SearchAvailablePhoneNumbers
    -> Maybe Text -> SearchAvailablePhoneNumbers)
-> Lens
     SearchAvailablePhoneNumbers
     SearchAvailablePhoneNumbers
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAvailablePhoneNumbers' {Maybe Text
city :: Maybe Text
$sel:city:SearchAvailablePhoneNumbers' :: SearchAvailablePhoneNumbers -> Maybe Text
city} -> Maybe Text
city) (\s :: SearchAvailablePhoneNumbers
s@SearchAvailablePhoneNumbers' {} Maybe Text
a -> SearchAvailablePhoneNumbers
s {$sel:city:SearchAvailablePhoneNumbers' :: Maybe Text
city = Maybe Text
a} :: SearchAvailablePhoneNumbers)

-- | The area code used to filter results. Only applies to the US.
searchAvailablePhoneNumbers_areaCode :: Lens.Lens' SearchAvailablePhoneNumbers (Prelude.Maybe Prelude.Text)
searchAvailablePhoneNumbers_areaCode :: (Maybe Text -> f (Maybe Text))
-> SearchAvailablePhoneNumbers -> f SearchAvailablePhoneNumbers
searchAvailablePhoneNumbers_areaCode = (SearchAvailablePhoneNumbers -> Maybe Text)
-> (SearchAvailablePhoneNumbers
    -> Maybe Text -> SearchAvailablePhoneNumbers)
-> Lens
     SearchAvailablePhoneNumbers
     SearchAvailablePhoneNumbers
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAvailablePhoneNumbers' {Maybe Text
areaCode :: Maybe Text
$sel:areaCode:SearchAvailablePhoneNumbers' :: SearchAvailablePhoneNumbers -> Maybe Text
areaCode} -> Maybe Text
areaCode) (\s :: SearchAvailablePhoneNumbers
s@SearchAvailablePhoneNumbers' {} Maybe Text
a -> SearchAvailablePhoneNumbers
s {$sel:areaCode:SearchAvailablePhoneNumbers' :: Maybe Text
areaCode = Maybe Text
a} :: SearchAvailablePhoneNumbers)

-- | The maximum number of results to return in a single call.
searchAvailablePhoneNumbers_maxResults :: Lens.Lens' SearchAvailablePhoneNumbers (Prelude.Maybe Prelude.Natural)
searchAvailablePhoneNumbers_maxResults :: (Maybe Natural -> f (Maybe Natural))
-> SearchAvailablePhoneNumbers -> f SearchAvailablePhoneNumbers
searchAvailablePhoneNumbers_maxResults = (SearchAvailablePhoneNumbers -> Maybe Natural)
-> (SearchAvailablePhoneNumbers
    -> Maybe Natural -> SearchAvailablePhoneNumbers)
-> Lens
     SearchAvailablePhoneNumbers
     SearchAvailablePhoneNumbers
     (Maybe Natural)
     (Maybe Natural)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAvailablePhoneNumbers' {Maybe Natural
maxResults :: Maybe Natural
$sel:maxResults:SearchAvailablePhoneNumbers' :: SearchAvailablePhoneNumbers -> Maybe Natural
maxResults} -> Maybe Natural
maxResults) (\s :: SearchAvailablePhoneNumbers
s@SearchAvailablePhoneNumbers' {} Maybe Natural
a -> SearchAvailablePhoneNumbers
s {$sel:maxResults:SearchAvailablePhoneNumbers' :: Maybe Natural
maxResults = Maybe Natural
a} :: SearchAvailablePhoneNumbers)

instance Core.AWSRequest SearchAvailablePhoneNumbers where
  type
    AWSResponse SearchAvailablePhoneNumbers =
      SearchAvailablePhoneNumbersResponse
  request :: SearchAvailablePhoneNumbers -> Request SearchAvailablePhoneNumbers
request = Service
-> SearchAvailablePhoneNumbers
-> Request SearchAvailablePhoneNumbers
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
  response :: Logger
-> Service
-> Proxy SearchAvailablePhoneNumbers
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SearchAvailablePhoneNumbers)))
response =
    (Int
 -> ResponseHeaders
 -> Object
 -> Either String (AWSResponse SearchAvailablePhoneNumbers))
-> Logger
-> Service
-> Proxy SearchAvailablePhoneNumbers
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse SearchAvailablePhoneNumbers)))
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 ->
          Maybe [Sensitive Text]
-> Maybe Text -> Int -> SearchAvailablePhoneNumbersResponse
SearchAvailablePhoneNumbersResponse'
            (Maybe [Sensitive Text]
 -> Maybe Text -> Int -> SearchAvailablePhoneNumbersResponse)
-> Either String (Maybe [Sensitive Text])
-> Either
     String (Maybe Text -> Int -> SearchAvailablePhoneNumbersResponse)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x Object -> Text -> Either String (Maybe (Maybe [Sensitive Text]))
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"E164PhoneNumbers"
                            Either String (Maybe (Maybe [Sensitive Text]))
-> Maybe [Sensitive Text] -> Either String (Maybe [Sensitive Text])
forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ Maybe [Sensitive Text]
forall a. Monoid a => a
Prelude.mempty
                        )
            Either
  String (Maybe Text -> Int -> SearchAvailablePhoneNumbersResponse)
-> Either String (Maybe Text)
-> Either String (Int -> SearchAvailablePhoneNumbersResponse)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Either String (Maybe Text)
forall a. FromJSON a => Object -> Text -> Either String (Maybe a)
Core..?> Text
"NextToken")
            Either String (Int -> SearchAvailablePhoneNumbersResponse)
-> Either String Int
-> Either String SearchAvailablePhoneNumbersResponse
forall (f :: * -> *) a b. Applicative f => 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 SearchAvailablePhoneNumbers

instance Prelude.NFData SearchAvailablePhoneNumbers

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

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

instance Core.ToQuery SearchAvailablePhoneNumbers where
  toQuery :: SearchAvailablePhoneNumbers -> QueryString
toQuery SearchAvailablePhoneNumbers' {Maybe Natural
Maybe Text
Maybe PhoneNumberType
maxResults :: Maybe Natural
areaCode :: Maybe Text
city :: Maybe Text
nextToken :: Maybe Text
country :: Maybe Text
tollFreePrefix :: Maybe Text
state :: Maybe Text
phoneNumberType :: Maybe PhoneNumberType
$sel:maxResults:SearchAvailablePhoneNumbers' :: SearchAvailablePhoneNumbers -> Maybe Natural
$sel:areaCode:SearchAvailablePhoneNumbers' :: SearchAvailablePhoneNumbers -> Maybe Text
$sel:city:SearchAvailablePhoneNumbers' :: SearchAvailablePhoneNumbers -> Maybe Text
$sel:nextToken:SearchAvailablePhoneNumbers' :: SearchAvailablePhoneNumbers -> Maybe Text
$sel:country:SearchAvailablePhoneNumbers' :: SearchAvailablePhoneNumbers -> Maybe Text
$sel:tollFreePrefix:SearchAvailablePhoneNumbers' :: SearchAvailablePhoneNumbers -> Maybe Text
$sel:state:SearchAvailablePhoneNumbers' :: SearchAvailablePhoneNumbers -> Maybe Text
$sel:phoneNumberType:SearchAvailablePhoneNumbers' :: SearchAvailablePhoneNumbers -> Maybe PhoneNumberType
..} =
    [QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"phone-number-type" ByteString -> Maybe PhoneNumberType -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe PhoneNumberType
phoneNumberType,
        ByteString
"state" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
state,
        ByteString
"toll-free-prefix" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
tollFreePrefix,
        ByteString
"country" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
country,
        ByteString
"next-token" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
nextToken,
        ByteString
"city" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
city,
        ByteString
"area-code" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
areaCode,
        ByteString
"max-results" ByteString -> Maybe Natural -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Natural
maxResults,
        QueryString
"type=phone-numbers"
      ]

-- | /See:/ 'newSearchAvailablePhoneNumbersResponse' smart constructor.
data SearchAvailablePhoneNumbersResponse = SearchAvailablePhoneNumbersResponse'
  { -- | List of phone numbers, in E.164 format.
    SearchAvailablePhoneNumbersResponse -> Maybe [Sensitive Text]
e164PhoneNumbers :: Prelude.Maybe [Core.Sensitive Prelude.Text],
    -- | The token used to retrieve the next page of search results.
    SearchAvailablePhoneNumbersResponse -> Maybe Text
nextToken :: Prelude.Maybe Prelude.Text,
    -- | The response's http status code.
    SearchAvailablePhoneNumbersResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (SearchAvailablePhoneNumbersResponse
-> SearchAvailablePhoneNumbersResponse -> Bool
(SearchAvailablePhoneNumbersResponse
 -> SearchAvailablePhoneNumbersResponse -> Bool)
-> (SearchAvailablePhoneNumbersResponse
    -> SearchAvailablePhoneNumbersResponse -> Bool)
-> Eq SearchAvailablePhoneNumbersResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SearchAvailablePhoneNumbersResponse
-> SearchAvailablePhoneNumbersResponse -> Bool
$c/= :: SearchAvailablePhoneNumbersResponse
-> SearchAvailablePhoneNumbersResponse -> Bool
== :: SearchAvailablePhoneNumbersResponse
-> SearchAvailablePhoneNumbersResponse -> Bool
$c== :: SearchAvailablePhoneNumbersResponse
-> SearchAvailablePhoneNumbersResponse -> Bool
Prelude.Eq, Int -> SearchAvailablePhoneNumbersResponse -> ShowS
[SearchAvailablePhoneNumbersResponse] -> ShowS
SearchAvailablePhoneNumbersResponse -> String
(Int -> SearchAvailablePhoneNumbersResponse -> ShowS)
-> (SearchAvailablePhoneNumbersResponse -> String)
-> ([SearchAvailablePhoneNumbersResponse] -> ShowS)
-> Show SearchAvailablePhoneNumbersResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SearchAvailablePhoneNumbersResponse] -> ShowS
$cshowList :: [SearchAvailablePhoneNumbersResponse] -> ShowS
show :: SearchAvailablePhoneNumbersResponse -> String
$cshow :: SearchAvailablePhoneNumbersResponse -> String
showsPrec :: Int -> SearchAvailablePhoneNumbersResponse -> ShowS
$cshowsPrec :: Int -> SearchAvailablePhoneNumbersResponse -> ShowS
Prelude.Show, (forall x.
 SearchAvailablePhoneNumbersResponse
 -> Rep SearchAvailablePhoneNumbersResponse x)
-> (forall x.
    Rep SearchAvailablePhoneNumbersResponse x
    -> SearchAvailablePhoneNumbersResponse)
-> Generic SearchAvailablePhoneNumbersResponse
forall x.
Rep SearchAvailablePhoneNumbersResponse x
-> SearchAvailablePhoneNumbersResponse
forall x.
SearchAvailablePhoneNumbersResponse
-> Rep SearchAvailablePhoneNumbersResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep SearchAvailablePhoneNumbersResponse x
-> SearchAvailablePhoneNumbersResponse
$cfrom :: forall x.
SearchAvailablePhoneNumbersResponse
-> Rep SearchAvailablePhoneNumbersResponse x
Prelude.Generic)

-- |
-- Create a value of 'SearchAvailablePhoneNumbersResponse' 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:
--
-- 'e164PhoneNumbers', 'searchAvailablePhoneNumbersResponse_e164PhoneNumbers' - List of phone numbers, in E.164 format.
--
-- 'nextToken', 'searchAvailablePhoneNumbersResponse_nextToken' - The token used to retrieve the next page of search results.
--
-- 'httpStatus', 'searchAvailablePhoneNumbersResponse_httpStatus' - The response's http status code.
newSearchAvailablePhoneNumbersResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SearchAvailablePhoneNumbersResponse
newSearchAvailablePhoneNumbersResponse :: Int -> SearchAvailablePhoneNumbersResponse
newSearchAvailablePhoneNumbersResponse Int
pHttpStatus_ =
  SearchAvailablePhoneNumbersResponse' :: Maybe [Sensitive Text]
-> Maybe Text -> Int -> SearchAvailablePhoneNumbersResponse
SearchAvailablePhoneNumbersResponse'
    { $sel:e164PhoneNumbers:SearchAvailablePhoneNumbersResponse' :: Maybe [Sensitive Text]
e164PhoneNumbers =
        Maybe [Sensitive Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:nextToken:SearchAvailablePhoneNumbersResponse' :: Maybe Text
nextToken = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:SearchAvailablePhoneNumbersResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | List of phone numbers, in E.164 format.
searchAvailablePhoneNumbersResponse_e164PhoneNumbers :: Lens.Lens' SearchAvailablePhoneNumbersResponse (Prelude.Maybe [Prelude.Text])
searchAvailablePhoneNumbersResponse_e164PhoneNumbers :: (Maybe [Text] -> f (Maybe [Text]))
-> SearchAvailablePhoneNumbersResponse
-> f SearchAvailablePhoneNumbersResponse
searchAvailablePhoneNumbersResponse_e164PhoneNumbers = (SearchAvailablePhoneNumbersResponse -> Maybe [Sensitive Text])
-> (SearchAvailablePhoneNumbersResponse
    -> Maybe [Sensitive Text] -> SearchAvailablePhoneNumbersResponse)
-> Lens
     SearchAvailablePhoneNumbersResponse
     SearchAvailablePhoneNumbersResponse
     (Maybe [Sensitive Text])
     (Maybe [Sensitive Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAvailablePhoneNumbersResponse' {Maybe [Sensitive Text]
e164PhoneNumbers :: Maybe [Sensitive Text]
$sel:e164PhoneNumbers:SearchAvailablePhoneNumbersResponse' :: SearchAvailablePhoneNumbersResponse -> Maybe [Sensitive Text]
e164PhoneNumbers} -> Maybe [Sensitive Text]
e164PhoneNumbers) (\s :: SearchAvailablePhoneNumbersResponse
s@SearchAvailablePhoneNumbersResponse' {} Maybe [Sensitive Text]
a -> SearchAvailablePhoneNumbersResponse
s {$sel:e164PhoneNumbers:SearchAvailablePhoneNumbersResponse' :: Maybe [Sensitive Text]
e164PhoneNumbers = Maybe [Sensitive Text]
a} :: SearchAvailablePhoneNumbersResponse) ((Maybe [Sensitive Text] -> f (Maybe [Sensitive Text]))
 -> SearchAvailablePhoneNumbersResponse
 -> f SearchAvailablePhoneNumbersResponse)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Sensitive Text] -> f (Maybe [Sensitive Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> SearchAvailablePhoneNumbersResponse
-> f SearchAvailablePhoneNumbersResponse
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Sensitive Text] [Sensitive Text] [Text] [Text]
-> Iso
     (Maybe [Sensitive Text])
     (Maybe [Sensitive Text])
     (Maybe [Text])
     (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Sensitive Text] [Sensitive Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The token used to retrieve the next page of search results.
searchAvailablePhoneNumbersResponse_nextToken :: Lens.Lens' SearchAvailablePhoneNumbersResponse (Prelude.Maybe Prelude.Text)
searchAvailablePhoneNumbersResponse_nextToken :: (Maybe Text -> f (Maybe Text))
-> SearchAvailablePhoneNumbersResponse
-> f SearchAvailablePhoneNumbersResponse
searchAvailablePhoneNumbersResponse_nextToken = (SearchAvailablePhoneNumbersResponse -> Maybe Text)
-> (SearchAvailablePhoneNumbersResponse
    -> Maybe Text -> SearchAvailablePhoneNumbersResponse)
-> Lens
     SearchAvailablePhoneNumbersResponse
     SearchAvailablePhoneNumbersResponse
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SearchAvailablePhoneNumbersResponse' {Maybe Text
nextToken :: Maybe Text
$sel:nextToken:SearchAvailablePhoneNumbersResponse' :: SearchAvailablePhoneNumbersResponse -> Maybe Text
nextToken} -> Maybe Text
nextToken) (\s :: SearchAvailablePhoneNumbersResponse
s@SearchAvailablePhoneNumbersResponse' {} Maybe Text
a -> SearchAvailablePhoneNumbersResponse
s {$sel:nextToken:SearchAvailablePhoneNumbersResponse' :: Maybe Text
nextToken = Maybe Text
a} :: SearchAvailablePhoneNumbersResponse)

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

instance
  Prelude.NFData
    SearchAvailablePhoneNumbersResponse