{-# 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.ChimeSdkVoice.BatchUpdatePhoneNumber
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- -- | Undocumented operation.
module Amazonka.ChimeSdkVoice.BatchUpdatePhoneNumber
  ( -- * Creating a Request
    BatchUpdatePhoneNumber (..),
    newBatchUpdatePhoneNumber,

    -- * Request Lenses
    batchUpdatePhoneNumber_updatePhoneNumberRequestItems,

    -- * Destructuring the Response
    BatchUpdatePhoneNumberResponse (..),
    newBatchUpdatePhoneNumberResponse,

    -- * Response Lenses
    batchUpdatePhoneNumberResponse_phoneNumberErrors,
    batchUpdatePhoneNumberResponse_httpStatus,
  )
where

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

-- | /See:/ 'newBatchUpdatePhoneNumber' smart constructor.
data BatchUpdatePhoneNumber = BatchUpdatePhoneNumber'
  { BatchUpdatePhoneNumber -> [UpdatePhoneNumberRequestItem]
updatePhoneNumberRequestItems :: [UpdatePhoneNumberRequestItem]
  }
  deriving (BatchUpdatePhoneNumber -> BatchUpdatePhoneNumber -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchUpdatePhoneNumber -> BatchUpdatePhoneNumber -> Bool
$c/= :: BatchUpdatePhoneNumber -> BatchUpdatePhoneNumber -> Bool
== :: BatchUpdatePhoneNumber -> BatchUpdatePhoneNumber -> Bool
$c== :: BatchUpdatePhoneNumber -> BatchUpdatePhoneNumber -> Bool
Prelude.Eq, Int -> BatchUpdatePhoneNumber -> ShowS
[BatchUpdatePhoneNumber] -> ShowS
BatchUpdatePhoneNumber -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchUpdatePhoneNumber] -> ShowS
$cshowList :: [BatchUpdatePhoneNumber] -> ShowS
show :: BatchUpdatePhoneNumber -> String
$cshow :: BatchUpdatePhoneNumber -> String
showsPrec :: Int -> BatchUpdatePhoneNumber -> ShowS
$cshowsPrec :: Int -> BatchUpdatePhoneNumber -> ShowS
Prelude.Show, forall x. Rep BatchUpdatePhoneNumber x -> BatchUpdatePhoneNumber
forall x. BatchUpdatePhoneNumber -> Rep BatchUpdatePhoneNumber x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep BatchUpdatePhoneNumber x -> BatchUpdatePhoneNumber
$cfrom :: forall x. BatchUpdatePhoneNumber -> Rep BatchUpdatePhoneNumber x
Prelude.Generic)

-- |
-- Create a value of 'BatchUpdatePhoneNumber' 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:
--
-- 'updatePhoneNumberRequestItems', 'batchUpdatePhoneNumber_updatePhoneNumberRequestItems' - Undocumented member.
newBatchUpdatePhoneNumber ::
  BatchUpdatePhoneNumber
newBatchUpdatePhoneNumber :: BatchUpdatePhoneNumber
newBatchUpdatePhoneNumber =
  BatchUpdatePhoneNumber'
    { $sel:updatePhoneNumberRequestItems:BatchUpdatePhoneNumber' :: [UpdatePhoneNumberRequestItem]
updatePhoneNumberRequestItems =
        forall a. Monoid a => a
Prelude.mempty
    }

-- | Undocumented member.
batchUpdatePhoneNumber_updatePhoneNumberRequestItems :: Lens.Lens' BatchUpdatePhoneNumber [UpdatePhoneNumberRequestItem]
batchUpdatePhoneNumber_updatePhoneNumberRequestItems :: Lens' BatchUpdatePhoneNumber [UpdatePhoneNumberRequestItem]
batchUpdatePhoneNumber_updatePhoneNumberRequestItems = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpdatePhoneNumber' {[UpdatePhoneNumberRequestItem]
updatePhoneNumberRequestItems :: [UpdatePhoneNumberRequestItem]
$sel:updatePhoneNumberRequestItems:BatchUpdatePhoneNumber' :: BatchUpdatePhoneNumber -> [UpdatePhoneNumberRequestItem]
updatePhoneNumberRequestItems} -> [UpdatePhoneNumberRequestItem]
updatePhoneNumberRequestItems) (\s :: BatchUpdatePhoneNumber
s@BatchUpdatePhoneNumber' {} [UpdatePhoneNumberRequestItem]
a -> BatchUpdatePhoneNumber
s {$sel:updatePhoneNumberRequestItems:BatchUpdatePhoneNumber' :: [UpdatePhoneNumberRequestItem]
updatePhoneNumberRequestItems = [UpdatePhoneNumberRequestItem]
a} :: BatchUpdatePhoneNumber) 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 Core.AWSRequest BatchUpdatePhoneNumber where
  type
    AWSResponse BatchUpdatePhoneNumber =
      BatchUpdatePhoneNumberResponse
  request :: (Service -> Service)
-> BatchUpdatePhoneNumber -> Request BatchUpdatePhoneNumber
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 BatchUpdatePhoneNumber
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse BatchUpdatePhoneNumber)))
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 ->
          Maybe [PhoneNumberError] -> Int -> BatchUpdatePhoneNumberResponse
BatchUpdatePhoneNumberResponse'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"PhoneNumberErrors"
                            forall (f :: * -> *) a. Functor f => f (Maybe a) -> a -> f a
Core..!@ forall a. Monoid a => a
Prelude.mempty
                        )
            forall (f :: * -> *) a b. Applicative f => 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))
      )

instance Prelude.Hashable BatchUpdatePhoneNumber where
  hashWithSalt :: Int -> BatchUpdatePhoneNumber -> Int
hashWithSalt Int
_salt BatchUpdatePhoneNumber' {[UpdatePhoneNumberRequestItem]
updatePhoneNumberRequestItems :: [UpdatePhoneNumberRequestItem]
$sel:updatePhoneNumberRequestItems:BatchUpdatePhoneNumber' :: BatchUpdatePhoneNumber -> [UpdatePhoneNumberRequestItem]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` [UpdatePhoneNumberRequestItem]
updatePhoneNumberRequestItems

instance Prelude.NFData BatchUpdatePhoneNumber where
  rnf :: BatchUpdatePhoneNumber -> ()
rnf BatchUpdatePhoneNumber' {[UpdatePhoneNumberRequestItem]
updatePhoneNumberRequestItems :: [UpdatePhoneNumberRequestItem]
$sel:updatePhoneNumberRequestItems:BatchUpdatePhoneNumber' :: BatchUpdatePhoneNumber -> [UpdatePhoneNumberRequestItem]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf [UpdatePhoneNumberRequestItem]
updatePhoneNumberRequestItems

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

instance Data.ToJSON BatchUpdatePhoneNumber where
  toJSON :: BatchUpdatePhoneNumber -> Value
toJSON BatchUpdatePhoneNumber' {[UpdatePhoneNumberRequestItem]
updatePhoneNumberRequestItems :: [UpdatePhoneNumberRequestItem]
$sel:updatePhoneNumberRequestItems:BatchUpdatePhoneNumber' :: BatchUpdatePhoneNumber -> [UpdatePhoneNumberRequestItem]
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just
              ( Key
"UpdatePhoneNumberRequestItems"
                  forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= [UpdatePhoneNumberRequestItem]
updatePhoneNumberRequestItems
              )
          ]
      )

instance Data.ToPath BatchUpdatePhoneNumber where
  toPath :: BatchUpdatePhoneNumber -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/phone-numbers"

instance Data.ToQuery BatchUpdatePhoneNumber where
  toQuery :: BatchUpdatePhoneNumber -> QueryString
toQuery =
    forall a b. a -> b -> a
Prelude.const
      (forall a. Monoid a => [a] -> a
Prelude.mconcat [QueryString
"operation=batch-update"])

-- | /See:/ 'newBatchUpdatePhoneNumberResponse' smart constructor.
data BatchUpdatePhoneNumberResponse = BatchUpdatePhoneNumberResponse'
  { BatchUpdatePhoneNumberResponse -> Maybe [PhoneNumberError]
phoneNumberErrors :: Prelude.Maybe [PhoneNumberError],
    -- | The response's http status code.
    BatchUpdatePhoneNumberResponse -> Int
httpStatus :: Prelude.Int
  }
  deriving (BatchUpdatePhoneNumberResponse
-> BatchUpdatePhoneNumberResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: BatchUpdatePhoneNumberResponse
-> BatchUpdatePhoneNumberResponse -> Bool
$c/= :: BatchUpdatePhoneNumberResponse
-> BatchUpdatePhoneNumberResponse -> Bool
== :: BatchUpdatePhoneNumberResponse
-> BatchUpdatePhoneNumberResponse -> Bool
$c== :: BatchUpdatePhoneNumberResponse
-> BatchUpdatePhoneNumberResponse -> Bool
Prelude.Eq, Int -> BatchUpdatePhoneNumberResponse -> ShowS
[BatchUpdatePhoneNumberResponse] -> ShowS
BatchUpdatePhoneNumberResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [BatchUpdatePhoneNumberResponse] -> ShowS
$cshowList :: [BatchUpdatePhoneNumberResponse] -> ShowS
show :: BatchUpdatePhoneNumberResponse -> String
$cshow :: BatchUpdatePhoneNumberResponse -> String
showsPrec :: Int -> BatchUpdatePhoneNumberResponse -> ShowS
$cshowsPrec :: Int -> BatchUpdatePhoneNumberResponse -> ShowS
Prelude.Show, forall x.
Rep BatchUpdatePhoneNumberResponse x
-> BatchUpdatePhoneNumberResponse
forall x.
BatchUpdatePhoneNumberResponse
-> Rep BatchUpdatePhoneNumberResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep BatchUpdatePhoneNumberResponse x
-> BatchUpdatePhoneNumberResponse
$cfrom :: forall x.
BatchUpdatePhoneNumberResponse
-> Rep BatchUpdatePhoneNumberResponse x
Prelude.Generic)

-- |
-- Create a value of 'BatchUpdatePhoneNumberResponse' 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:
--
-- 'phoneNumberErrors', 'batchUpdatePhoneNumberResponse_phoneNumberErrors' - Undocumented member.
--
-- 'httpStatus', 'batchUpdatePhoneNumberResponse_httpStatus' - The response's http status code.
newBatchUpdatePhoneNumberResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  BatchUpdatePhoneNumberResponse
newBatchUpdatePhoneNumberResponse :: Int -> BatchUpdatePhoneNumberResponse
newBatchUpdatePhoneNumberResponse Int
pHttpStatus_ =
  BatchUpdatePhoneNumberResponse'
    { $sel:phoneNumberErrors:BatchUpdatePhoneNumberResponse' :: Maybe [PhoneNumberError]
phoneNumberErrors =
        forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:BatchUpdatePhoneNumberResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
batchUpdatePhoneNumberResponse_phoneNumberErrors :: Lens.Lens' BatchUpdatePhoneNumberResponse (Prelude.Maybe [PhoneNumberError])
batchUpdatePhoneNumberResponse_phoneNumberErrors :: Lens' BatchUpdatePhoneNumberResponse (Maybe [PhoneNumberError])
batchUpdatePhoneNumberResponse_phoneNumberErrors = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\BatchUpdatePhoneNumberResponse' {Maybe [PhoneNumberError]
phoneNumberErrors :: Maybe [PhoneNumberError]
$sel:phoneNumberErrors:BatchUpdatePhoneNumberResponse' :: BatchUpdatePhoneNumberResponse -> Maybe [PhoneNumberError]
phoneNumberErrors} -> Maybe [PhoneNumberError]
phoneNumberErrors) (\s :: BatchUpdatePhoneNumberResponse
s@BatchUpdatePhoneNumberResponse' {} Maybe [PhoneNumberError]
a -> BatchUpdatePhoneNumberResponse
s {$sel:phoneNumberErrors:BatchUpdatePhoneNumberResponse' :: Maybe [PhoneNumberError]
phoneNumberErrors = Maybe [PhoneNumberError]
a} :: BatchUpdatePhoneNumberResponse) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. 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 forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

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

instance
  Prelude.NFData
    BatchUpdatePhoneNumberResponse
  where
  rnf :: BatchUpdatePhoneNumberResponse -> ()
rnf BatchUpdatePhoneNumberResponse' {Int
Maybe [PhoneNumberError]
httpStatus :: Int
phoneNumberErrors :: Maybe [PhoneNumberError]
$sel:httpStatus:BatchUpdatePhoneNumberResponse' :: BatchUpdatePhoneNumberResponse -> Int
$sel:phoneNumberErrors:BatchUpdatePhoneNumberResponse' :: BatchUpdatePhoneNumberResponse -> Maybe [PhoneNumberError]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [PhoneNumberError]
phoneNumberErrors
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus