{-# 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.ConnectCampaigns.GetCampaignStateBatch
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Get state of campaigns for the specified Amazon Connect account.
module Amazonka.ConnectCampaigns.GetCampaignStateBatch
  ( -- * Creating a Request
    GetCampaignStateBatch (..),
    newGetCampaignStateBatch,

    -- * Request Lenses
    getCampaignStateBatch_campaignIds,

    -- * Destructuring the Response
    GetCampaignStateBatchResponse (..),
    newGetCampaignStateBatchResponse,

    -- * Response Lenses
    getCampaignStateBatchResponse_failedRequests,
    getCampaignStateBatchResponse_successfulRequests,
    getCampaignStateBatchResponse_httpStatus,
  )
where

import Amazonka.ConnectCampaigns.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

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

-- |
-- Create a value of 'GetCampaignStateBatch' 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:
--
-- 'campaignIds', 'getCampaignStateBatch_campaignIds' - Undocumented member.
newGetCampaignStateBatch ::
  -- | 'campaignIds'
  Prelude.NonEmpty Prelude.Text ->
  GetCampaignStateBatch
newGetCampaignStateBatch :: NonEmpty Text -> GetCampaignStateBatch
newGetCampaignStateBatch NonEmpty Text
pCampaignIds_ =
  GetCampaignStateBatch'
    { $sel:campaignIds:GetCampaignStateBatch' :: NonEmpty Text
campaignIds =
        forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced forall t b. AReview t b -> b -> t
Lens.# NonEmpty Text
pCampaignIds_
    }

-- | Undocumented member.
getCampaignStateBatch_campaignIds :: Lens.Lens' GetCampaignStateBatch (Prelude.NonEmpty Prelude.Text)
getCampaignStateBatch_campaignIds :: Lens' GetCampaignStateBatch (NonEmpty Text)
getCampaignStateBatch_campaignIds = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCampaignStateBatch' {NonEmpty Text
campaignIds :: NonEmpty Text
$sel:campaignIds:GetCampaignStateBatch' :: GetCampaignStateBatch -> NonEmpty Text
campaignIds} -> NonEmpty Text
campaignIds) (\s :: GetCampaignStateBatch
s@GetCampaignStateBatch' {} NonEmpty Text
a -> GetCampaignStateBatch
s {$sel:campaignIds:GetCampaignStateBatch' :: NonEmpty Text
campaignIds = NonEmpty Text
a} :: GetCampaignStateBatch) 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 GetCampaignStateBatch where
  type
    AWSResponse GetCampaignStateBatch =
      GetCampaignStateBatchResponse
  request :: (Service -> Service)
-> GetCampaignStateBatch -> Request GetCampaignStateBatch
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 GetCampaignStateBatch
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetCampaignStateBatch)))
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 [FailedCampaignStateResponse]
-> Maybe [SuccessfulCampaignStateResponse]
-> Int
-> GetCampaignStateBatchResponse
GetCampaignStateBatchResponse'
            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
"failedRequests" 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.<*> ( Object
x
                            forall a. FromJSON a => Object -> Key -> Either String (Maybe a)
Data..?> Key
"successfulRequests"
                            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 GetCampaignStateBatch where
  hashWithSalt :: Int -> GetCampaignStateBatch -> Int
hashWithSalt Int
_salt GetCampaignStateBatch' {NonEmpty Text
campaignIds :: NonEmpty Text
$sel:campaignIds:GetCampaignStateBatch' :: GetCampaignStateBatch -> NonEmpty Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` NonEmpty Text
campaignIds

instance Prelude.NFData GetCampaignStateBatch where
  rnf :: GetCampaignStateBatch -> ()
rnf GetCampaignStateBatch' {NonEmpty Text
campaignIds :: NonEmpty Text
$sel:campaignIds:GetCampaignStateBatch' :: GetCampaignStateBatch -> NonEmpty Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf NonEmpty Text
campaignIds

instance Data.ToHeaders GetCampaignStateBatch where
  toHeaders :: GetCampaignStateBatch -> 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 GetCampaignStateBatch where
  toJSON :: GetCampaignStateBatch -> Value
toJSON GetCampaignStateBatch' {NonEmpty Text
campaignIds :: NonEmpty Text
$sel:campaignIds:GetCampaignStateBatch' :: GetCampaignStateBatch -> NonEmpty Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [forall a. a -> Maybe a
Prelude.Just (Key
"campaignIds" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= NonEmpty Text
campaignIds)]
      )

instance Data.ToPath GetCampaignStateBatch where
  toPath :: GetCampaignStateBatch -> ByteString
toPath = forall a b. a -> b -> a
Prelude.const ByteString
"/campaigns-state"

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

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

-- |
-- Create a value of 'GetCampaignStateBatchResponse' 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:
--
-- 'failedRequests', 'getCampaignStateBatchResponse_failedRequests' - Undocumented member.
--
-- 'successfulRequests', 'getCampaignStateBatchResponse_successfulRequests' - Undocumented member.
--
-- 'httpStatus', 'getCampaignStateBatchResponse_httpStatus' - The response's http status code.
newGetCampaignStateBatchResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  GetCampaignStateBatchResponse
newGetCampaignStateBatchResponse :: Int -> GetCampaignStateBatchResponse
newGetCampaignStateBatchResponse Int
pHttpStatus_ =
  GetCampaignStateBatchResponse'
    { $sel:failedRequests:GetCampaignStateBatchResponse' :: Maybe [FailedCampaignStateResponse]
failedRequests =
        forall a. Maybe a
Prelude.Nothing,
      $sel:successfulRequests:GetCampaignStateBatchResponse' :: Maybe [SuccessfulCampaignStateResponse]
successfulRequests = forall a. Maybe a
Prelude.Nothing,
      $sel:httpStatus:GetCampaignStateBatchResponse' :: Int
httpStatus = Int
pHttpStatus_
    }

-- | Undocumented member.
getCampaignStateBatchResponse_failedRequests :: Lens.Lens' GetCampaignStateBatchResponse (Prelude.Maybe [FailedCampaignStateResponse])
getCampaignStateBatchResponse_failedRequests :: Lens'
  GetCampaignStateBatchResponse (Maybe [FailedCampaignStateResponse])
getCampaignStateBatchResponse_failedRequests = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCampaignStateBatchResponse' {Maybe [FailedCampaignStateResponse]
failedRequests :: Maybe [FailedCampaignStateResponse]
$sel:failedRequests:GetCampaignStateBatchResponse' :: GetCampaignStateBatchResponse
-> Maybe [FailedCampaignStateResponse]
failedRequests} -> Maybe [FailedCampaignStateResponse]
failedRequests) (\s :: GetCampaignStateBatchResponse
s@GetCampaignStateBatchResponse' {} Maybe [FailedCampaignStateResponse]
a -> GetCampaignStateBatchResponse
s {$sel:failedRequests:GetCampaignStateBatchResponse' :: Maybe [FailedCampaignStateResponse]
failedRequests = Maybe [FailedCampaignStateResponse]
a} :: GetCampaignStateBatchResponse) 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

-- | Undocumented member.
getCampaignStateBatchResponse_successfulRequests :: Lens.Lens' GetCampaignStateBatchResponse (Prelude.Maybe [SuccessfulCampaignStateResponse])
getCampaignStateBatchResponse_successfulRequests :: Lens'
  GetCampaignStateBatchResponse
  (Maybe [SuccessfulCampaignStateResponse])
getCampaignStateBatchResponse_successfulRequests = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCampaignStateBatchResponse' {Maybe [SuccessfulCampaignStateResponse]
successfulRequests :: Maybe [SuccessfulCampaignStateResponse]
$sel:successfulRequests:GetCampaignStateBatchResponse' :: GetCampaignStateBatchResponse
-> Maybe [SuccessfulCampaignStateResponse]
successfulRequests} -> Maybe [SuccessfulCampaignStateResponse]
successfulRequests) (\s :: GetCampaignStateBatchResponse
s@GetCampaignStateBatchResponse' {} Maybe [SuccessfulCampaignStateResponse]
a -> GetCampaignStateBatchResponse
s {$sel:successfulRequests:GetCampaignStateBatchResponse' :: Maybe [SuccessfulCampaignStateResponse]
successfulRequests = Maybe [SuccessfulCampaignStateResponse]
a} :: GetCampaignStateBatchResponse) 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.
getCampaignStateBatchResponse_httpStatus :: Lens.Lens' GetCampaignStateBatchResponse Prelude.Int
getCampaignStateBatchResponse_httpStatus :: Lens' GetCampaignStateBatchResponse Int
getCampaignStateBatchResponse_httpStatus = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCampaignStateBatchResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetCampaignStateBatchResponse' :: GetCampaignStateBatchResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetCampaignStateBatchResponse
s@GetCampaignStateBatchResponse' {} Int
a -> GetCampaignStateBatchResponse
s {$sel:httpStatus:GetCampaignStateBatchResponse' :: Int
httpStatus = Int
a} :: GetCampaignStateBatchResponse)

instance Prelude.NFData GetCampaignStateBatchResponse where
  rnf :: GetCampaignStateBatchResponse -> ()
rnf GetCampaignStateBatchResponse' {Int
Maybe [FailedCampaignStateResponse]
Maybe [SuccessfulCampaignStateResponse]
httpStatus :: Int
successfulRequests :: Maybe [SuccessfulCampaignStateResponse]
failedRequests :: Maybe [FailedCampaignStateResponse]
$sel:httpStatus:GetCampaignStateBatchResponse' :: GetCampaignStateBatchResponse -> Int
$sel:successfulRequests:GetCampaignStateBatchResponse' :: GetCampaignStateBatchResponse
-> Maybe [SuccessfulCampaignStateResponse]
$sel:failedRequests:GetCampaignStateBatchResponse' :: GetCampaignStateBatchResponse
-> Maybe [FailedCampaignStateResponse]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [FailedCampaignStateResponse]
failedRequests
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe [SuccessfulCampaignStateResponse]
successfulRequests
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus