{-# 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.GetCampaignVersion
-- 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 the status, configuration, and other
-- settings for a specific version of a campaign.
module Amazonka.Pinpoint.GetCampaignVersion
  ( -- * Creating a Request
    GetCampaignVersion (..),
    newGetCampaignVersion,

    -- * Request Lenses
    getCampaignVersion_version,
    getCampaignVersion_applicationId,
    getCampaignVersion_campaignId,

    -- * Destructuring the Response
    GetCampaignVersionResponse (..),
    newGetCampaignVersionResponse,

    -- * Response Lenses
    getCampaignVersionResponse_httpStatus,
    getCampaignVersionResponse_campaignResponse,
  )
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:/ 'newGetCampaignVersion' smart constructor.
data GetCampaignVersion = GetCampaignVersion'
  { -- | The unique version number (Version property) for the campaign version.
    GetCampaignVersion -> Text
version :: Prelude.Text,
    -- | The unique identifier for the application. This identifier is displayed
    -- as the __Project ID__ on the Amazon Pinpoint console.
    GetCampaignVersion -> Text
applicationId :: Prelude.Text,
    -- | The unique identifier for the campaign.
    GetCampaignVersion -> Text
campaignId :: Prelude.Text
  }
  deriving (GetCampaignVersion -> GetCampaignVersion -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCampaignVersion -> GetCampaignVersion -> Bool
$c/= :: GetCampaignVersion -> GetCampaignVersion -> Bool
== :: GetCampaignVersion -> GetCampaignVersion -> Bool
$c== :: GetCampaignVersion -> GetCampaignVersion -> Bool
Prelude.Eq, ReadPrec [GetCampaignVersion]
ReadPrec GetCampaignVersion
Int -> ReadS GetCampaignVersion
ReadS [GetCampaignVersion]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCampaignVersion]
$creadListPrec :: ReadPrec [GetCampaignVersion]
readPrec :: ReadPrec GetCampaignVersion
$creadPrec :: ReadPrec GetCampaignVersion
readList :: ReadS [GetCampaignVersion]
$creadList :: ReadS [GetCampaignVersion]
readsPrec :: Int -> ReadS GetCampaignVersion
$creadsPrec :: Int -> ReadS GetCampaignVersion
Prelude.Read, Int -> GetCampaignVersion -> ShowS
[GetCampaignVersion] -> ShowS
GetCampaignVersion -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCampaignVersion] -> ShowS
$cshowList :: [GetCampaignVersion] -> ShowS
show :: GetCampaignVersion -> String
$cshow :: GetCampaignVersion -> String
showsPrec :: Int -> GetCampaignVersion -> ShowS
$cshowsPrec :: Int -> GetCampaignVersion -> ShowS
Prelude.Show, forall x. Rep GetCampaignVersion x -> GetCampaignVersion
forall x. GetCampaignVersion -> Rep GetCampaignVersion x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetCampaignVersion x -> GetCampaignVersion
$cfrom :: forall x. GetCampaignVersion -> Rep GetCampaignVersion x
Prelude.Generic)

-- |
-- Create a value of 'GetCampaignVersion' 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:
--
-- 'version', 'getCampaignVersion_version' - The unique version number (Version property) for the campaign version.
--
-- 'applicationId', 'getCampaignVersion_applicationId' - The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
--
-- 'campaignId', 'getCampaignVersion_campaignId' - The unique identifier for the campaign.
newGetCampaignVersion ::
  -- | 'version'
  Prelude.Text ->
  -- | 'applicationId'
  Prelude.Text ->
  -- | 'campaignId'
  Prelude.Text ->
  GetCampaignVersion
newGetCampaignVersion :: Text -> Text -> Text -> GetCampaignVersion
newGetCampaignVersion
  Text
pVersion_
  Text
pApplicationId_
  Text
pCampaignId_ =
    GetCampaignVersion'
      { $sel:version:GetCampaignVersion' :: Text
version = Text
pVersion_,
        $sel:applicationId:GetCampaignVersion' :: Text
applicationId = Text
pApplicationId_,
        $sel:campaignId:GetCampaignVersion' :: Text
campaignId = Text
pCampaignId_
      }

-- | The unique version number (Version property) for the campaign version.
getCampaignVersion_version :: Lens.Lens' GetCampaignVersion Prelude.Text
getCampaignVersion_version :: Lens' GetCampaignVersion Text
getCampaignVersion_version = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCampaignVersion' {Text
version :: Text
$sel:version:GetCampaignVersion' :: GetCampaignVersion -> Text
version} -> Text
version) (\s :: GetCampaignVersion
s@GetCampaignVersion' {} Text
a -> GetCampaignVersion
s {$sel:version:GetCampaignVersion' :: Text
version = Text
a} :: GetCampaignVersion)

-- | The unique identifier for the application. This identifier is displayed
-- as the __Project ID__ on the Amazon Pinpoint console.
getCampaignVersion_applicationId :: Lens.Lens' GetCampaignVersion Prelude.Text
getCampaignVersion_applicationId :: Lens' GetCampaignVersion Text
getCampaignVersion_applicationId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCampaignVersion' {Text
applicationId :: Text
$sel:applicationId:GetCampaignVersion' :: GetCampaignVersion -> Text
applicationId} -> Text
applicationId) (\s :: GetCampaignVersion
s@GetCampaignVersion' {} Text
a -> GetCampaignVersion
s {$sel:applicationId:GetCampaignVersion' :: Text
applicationId = Text
a} :: GetCampaignVersion)

-- | The unique identifier for the campaign.
getCampaignVersion_campaignId :: Lens.Lens' GetCampaignVersion Prelude.Text
getCampaignVersion_campaignId :: Lens' GetCampaignVersion Text
getCampaignVersion_campaignId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCampaignVersion' {Text
campaignId :: Text
$sel:campaignId:GetCampaignVersion' :: GetCampaignVersion -> Text
campaignId} -> Text
campaignId) (\s :: GetCampaignVersion
s@GetCampaignVersion' {} Text
a -> GetCampaignVersion
s {$sel:campaignId:GetCampaignVersion' :: Text
campaignId = Text
a} :: GetCampaignVersion)

instance Core.AWSRequest GetCampaignVersion where
  type
    AWSResponse GetCampaignVersion =
      GetCampaignVersionResponse
  request :: (Service -> Service)
-> GetCampaignVersion -> Request GetCampaignVersion
request Service -> Service
overrides =
    forall a. ToRequest a => Service -> a -> Request a
Request.get (Service -> Service
overrides Service
defaultService)
  response :: forall (m :: * -> *).
MonadResource m =>
(ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy GetCampaignVersion
-> ClientResponse ClientBody
-> m (Either
        Error (ClientResponse (AWSResponse GetCampaignVersion)))
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 -> CampaignResponse -> GetCampaignVersionResponse
GetCampaignVersionResponse'
            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 GetCampaignVersion where
  hashWithSalt :: Int -> GetCampaignVersion -> Int
hashWithSalt Int
_salt GetCampaignVersion' {Text
campaignId :: Text
applicationId :: Text
version :: Text
$sel:campaignId:GetCampaignVersion' :: GetCampaignVersion -> Text
$sel:applicationId:GetCampaignVersion' :: GetCampaignVersion -> Text
$sel:version:GetCampaignVersion' :: GetCampaignVersion -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
version
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
applicationId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
campaignId

instance Prelude.NFData GetCampaignVersion where
  rnf :: GetCampaignVersion -> ()
rnf GetCampaignVersion' {Text
campaignId :: Text
applicationId :: Text
version :: Text
$sel:campaignId:GetCampaignVersion' :: GetCampaignVersion -> Text
$sel:applicationId:GetCampaignVersion' :: GetCampaignVersion -> Text
$sel:version:GetCampaignVersion' :: GetCampaignVersion -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
version
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
applicationId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
campaignId

instance Data.ToHeaders GetCampaignVersion where
  toHeaders :: GetCampaignVersion -> 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.ToPath GetCampaignVersion where
  toPath :: GetCampaignVersion -> ByteString
toPath GetCampaignVersion' {Text
campaignId :: Text
applicationId :: Text
version :: Text
$sel:campaignId:GetCampaignVersion' :: GetCampaignVersion -> Text
$sel:applicationId:GetCampaignVersion' :: GetCampaignVersion -> Text
$sel:version:GetCampaignVersion' :: GetCampaignVersion -> Text
..} =
    forall a. Monoid a => [a] -> a
Prelude.mconcat
      [ ByteString
"/v1/apps/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
applicationId,
        ByteString
"/campaigns/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
campaignId,
        ByteString
"/versions/",
        forall a. ToByteString a => a -> ByteString
Data.toBS Text
version
      ]

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

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

-- |
-- Create a value of 'GetCampaignVersionResponse' 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', 'getCampaignVersionResponse_httpStatus' - The response's http status code.
--
-- 'campaignResponse', 'getCampaignVersionResponse_campaignResponse' - Undocumented member.
newGetCampaignVersionResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  -- | 'campaignResponse'
  CampaignResponse ->
  GetCampaignVersionResponse
newGetCampaignVersionResponse :: Int -> CampaignResponse -> GetCampaignVersionResponse
newGetCampaignVersionResponse
  Int
pHttpStatus_
  CampaignResponse
pCampaignResponse_ =
    GetCampaignVersionResponse'
      { $sel:httpStatus:GetCampaignVersionResponse' :: Int
httpStatus =
          Int
pHttpStatus_,
        $sel:campaignResponse:GetCampaignVersionResponse' :: CampaignResponse
campaignResponse = CampaignResponse
pCampaignResponse_
      }

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

-- | Undocumented member.
getCampaignVersionResponse_campaignResponse :: Lens.Lens' GetCampaignVersionResponse CampaignResponse
getCampaignVersionResponse_campaignResponse :: Lens' GetCampaignVersionResponse CampaignResponse
getCampaignVersionResponse_campaignResponse = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCampaignVersionResponse' {CampaignResponse
campaignResponse :: CampaignResponse
$sel:campaignResponse:GetCampaignVersionResponse' :: GetCampaignVersionResponse -> CampaignResponse
campaignResponse} -> CampaignResponse
campaignResponse) (\s :: GetCampaignVersionResponse
s@GetCampaignVersionResponse' {} CampaignResponse
a -> GetCampaignVersionResponse
s {$sel:campaignResponse:GetCampaignVersionResponse' :: CampaignResponse
campaignResponse = CampaignResponse
a} :: GetCampaignVersionResponse)

instance Prelude.NFData GetCampaignVersionResponse where
  rnf :: GetCampaignVersionResponse -> ()
rnf GetCampaignVersionResponse' {Int
CampaignResponse
campaignResponse :: CampaignResponse
httpStatus :: Int
$sel:campaignResponse:GetCampaignVersionResponse' :: GetCampaignVersionResponse -> CampaignResponse
$sel:httpStatus:GetCampaignVersionResponse' :: GetCampaignVersionResponse -> 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 CampaignResponse
campaignResponse