{-# 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 #-}
module Amazonka.Pinpoint.GetCampaigns
(
GetCampaigns (..),
newGetCampaigns,
getCampaigns_token,
getCampaigns_pageSize,
getCampaigns_applicationId,
GetCampaignsResponse (..),
newGetCampaignsResponse,
getCampaignsResponse_httpStatus,
getCampaignsResponse_campaignsResponse,
)
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
data GetCampaigns = GetCampaigns'
{
GetCampaigns -> Maybe Text
token :: Prelude.Maybe Prelude.Text,
GetCampaigns -> Maybe Text
pageSize :: Prelude.Maybe Prelude.Text,
GetCampaigns -> Text
applicationId :: Prelude.Text
}
deriving (GetCampaigns -> GetCampaigns -> Bool
(GetCampaigns -> GetCampaigns -> Bool)
-> (GetCampaigns -> GetCampaigns -> Bool) -> Eq GetCampaigns
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCampaigns -> GetCampaigns -> Bool
$c/= :: GetCampaigns -> GetCampaigns -> Bool
== :: GetCampaigns -> GetCampaigns -> Bool
$c== :: GetCampaigns -> GetCampaigns -> Bool
Prelude.Eq, ReadPrec [GetCampaigns]
ReadPrec GetCampaigns
Int -> ReadS GetCampaigns
ReadS [GetCampaigns]
(Int -> ReadS GetCampaigns)
-> ReadS [GetCampaigns]
-> ReadPrec GetCampaigns
-> ReadPrec [GetCampaigns]
-> Read GetCampaigns
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCampaigns]
$creadListPrec :: ReadPrec [GetCampaigns]
readPrec :: ReadPrec GetCampaigns
$creadPrec :: ReadPrec GetCampaigns
readList :: ReadS [GetCampaigns]
$creadList :: ReadS [GetCampaigns]
readsPrec :: Int -> ReadS GetCampaigns
$creadsPrec :: Int -> ReadS GetCampaigns
Prelude.Read, Int -> GetCampaigns -> ShowS
[GetCampaigns] -> ShowS
GetCampaigns -> String
(Int -> GetCampaigns -> ShowS)
-> (GetCampaigns -> String)
-> ([GetCampaigns] -> ShowS)
-> Show GetCampaigns
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCampaigns] -> ShowS
$cshowList :: [GetCampaigns] -> ShowS
show :: GetCampaigns -> String
$cshow :: GetCampaigns -> String
showsPrec :: Int -> GetCampaigns -> ShowS
$cshowsPrec :: Int -> GetCampaigns -> ShowS
Prelude.Show, (forall x. GetCampaigns -> Rep GetCampaigns x)
-> (forall x. Rep GetCampaigns x -> GetCampaigns)
-> Generic GetCampaigns
forall x. Rep GetCampaigns x -> GetCampaigns
forall x. GetCampaigns -> Rep GetCampaigns x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetCampaigns x -> GetCampaigns
$cfrom :: forall x. GetCampaigns -> Rep GetCampaigns x
Prelude.Generic)
newGetCampaigns ::
Prelude.Text ->
GetCampaigns
newGetCampaigns :: Text -> GetCampaigns
newGetCampaigns Text
pApplicationId_ =
GetCampaigns' :: Maybe Text -> Maybe Text -> Text -> GetCampaigns
GetCampaigns'
{ $sel:token:GetCampaigns' :: Maybe Text
token = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:pageSize:GetCampaigns' :: Maybe Text
pageSize = Maybe Text
forall a. Maybe a
Prelude.Nothing,
$sel:applicationId:GetCampaigns' :: Text
applicationId = Text
pApplicationId_
}
getCampaigns_token :: Lens.Lens' GetCampaigns (Prelude.Maybe Prelude.Text)
getCampaigns_token :: (Maybe Text -> f (Maybe Text)) -> GetCampaigns -> f GetCampaigns
getCampaigns_token = (GetCampaigns -> Maybe Text)
-> (GetCampaigns -> Maybe Text -> GetCampaigns)
-> Lens GetCampaigns GetCampaigns (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCampaigns' {Maybe Text
token :: Maybe Text
$sel:token:GetCampaigns' :: GetCampaigns -> Maybe Text
token} -> Maybe Text
token) (\s :: GetCampaigns
s@GetCampaigns' {} Maybe Text
a -> GetCampaigns
s {$sel:token:GetCampaigns' :: Maybe Text
token = Maybe Text
a} :: GetCampaigns)
getCampaigns_pageSize :: Lens.Lens' GetCampaigns (Prelude.Maybe Prelude.Text)
getCampaigns_pageSize :: (Maybe Text -> f (Maybe Text)) -> GetCampaigns -> f GetCampaigns
getCampaigns_pageSize = (GetCampaigns -> Maybe Text)
-> (GetCampaigns -> Maybe Text -> GetCampaigns)
-> Lens GetCampaigns GetCampaigns (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCampaigns' {Maybe Text
pageSize :: Maybe Text
$sel:pageSize:GetCampaigns' :: GetCampaigns -> Maybe Text
pageSize} -> Maybe Text
pageSize) (\s :: GetCampaigns
s@GetCampaigns' {} Maybe Text
a -> GetCampaigns
s {$sel:pageSize:GetCampaigns' :: Maybe Text
pageSize = Maybe Text
a} :: GetCampaigns)
getCampaigns_applicationId :: Lens.Lens' GetCampaigns Prelude.Text
getCampaigns_applicationId :: (Text -> f Text) -> GetCampaigns -> f GetCampaigns
getCampaigns_applicationId = (GetCampaigns -> Text)
-> (GetCampaigns -> Text -> GetCampaigns)
-> Lens GetCampaigns GetCampaigns Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCampaigns' {Text
applicationId :: Text
$sel:applicationId:GetCampaigns' :: GetCampaigns -> Text
applicationId} -> Text
applicationId) (\s :: GetCampaigns
s@GetCampaigns' {} Text
a -> GetCampaigns
s {$sel:applicationId:GetCampaigns' :: Text
applicationId = Text
a} :: GetCampaigns)
instance Core.AWSRequest GetCampaigns where
type AWSResponse GetCampaigns = GetCampaignsResponse
request :: GetCampaigns -> Request GetCampaigns
request = Service -> GetCampaigns -> Request GetCampaigns
forall a. ToRequest a => Service -> a -> Request a
Request.get Service
defaultService
response :: Logger
-> Service
-> Proxy GetCampaigns
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetCampaigns)))
response =
(Int
-> ResponseHeaders
-> Object
-> Either String (AWSResponse GetCampaigns))
-> Logger
-> Service
-> Proxy GetCampaigns
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse GetCampaigns)))
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 -> CampaignsResponse -> GetCampaignsResponse
GetCampaignsResponse'
(Int -> CampaignsResponse -> GetCampaignsResponse)
-> Either String Int
-> Either String (CampaignsResponse -> GetCampaignsResponse)
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 (CampaignsResponse -> GetCampaignsResponse)
-> Either String CampaignsResponse
-> Either String GetCampaignsResponse
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object -> Either String CampaignsResponse
forall a. FromJSON a => Object -> Either String a
Core.eitherParseJSON Object
x)
)
instance Prelude.Hashable GetCampaigns
instance Prelude.NFData GetCampaigns
instance Core.ToHeaders GetCampaigns where
toHeaders :: GetCampaigns -> ResponseHeaders
toHeaders =
ResponseHeaders -> GetCampaigns -> 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.ToPath GetCampaigns where
toPath :: GetCampaigns -> ByteString
toPath GetCampaigns' {Maybe Text
Text
applicationId :: Text
pageSize :: Maybe Text
token :: Maybe Text
$sel:applicationId:GetCampaigns' :: GetCampaigns -> Text
$sel:pageSize:GetCampaigns' :: GetCampaigns -> Maybe Text
$sel:token:GetCampaigns' :: GetCampaigns -> Maybe Text
..} =
[ByteString] -> ByteString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"/v1/apps/", Text -> ByteString
forall a. ToByteString a => a -> ByteString
Core.toBS Text
applicationId, ByteString
"/campaigns"]
instance Core.ToQuery GetCampaigns where
toQuery :: GetCampaigns -> QueryString
toQuery GetCampaigns' {Maybe Text
Text
applicationId :: Text
pageSize :: Maybe Text
token :: Maybe Text
$sel:applicationId:GetCampaigns' :: GetCampaigns -> Text
$sel:pageSize:GetCampaigns' :: GetCampaigns -> Maybe Text
$sel:token:GetCampaigns' :: GetCampaigns -> Maybe Text
..} =
[QueryString] -> QueryString
forall a. Monoid a => [a] -> a
Prelude.mconcat
[ByteString
"token" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
token, ByteString
"page-size" ByteString -> Maybe Text -> QueryString
forall a. ToQuery a => ByteString -> a -> QueryString
Core.=: Maybe Text
pageSize]
data GetCampaignsResponse = GetCampaignsResponse'
{
GetCampaignsResponse -> Int
httpStatus :: Prelude.Int,
GetCampaignsResponse -> CampaignsResponse
campaignsResponse :: CampaignsResponse
}
deriving (GetCampaignsResponse -> GetCampaignsResponse -> Bool
(GetCampaignsResponse -> GetCampaignsResponse -> Bool)
-> (GetCampaignsResponse -> GetCampaignsResponse -> Bool)
-> Eq GetCampaignsResponse
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetCampaignsResponse -> GetCampaignsResponse -> Bool
$c/= :: GetCampaignsResponse -> GetCampaignsResponse -> Bool
== :: GetCampaignsResponse -> GetCampaignsResponse -> Bool
$c== :: GetCampaignsResponse -> GetCampaignsResponse -> Bool
Prelude.Eq, ReadPrec [GetCampaignsResponse]
ReadPrec GetCampaignsResponse
Int -> ReadS GetCampaignsResponse
ReadS [GetCampaignsResponse]
(Int -> ReadS GetCampaignsResponse)
-> ReadS [GetCampaignsResponse]
-> ReadPrec GetCampaignsResponse
-> ReadPrec [GetCampaignsResponse]
-> Read GetCampaignsResponse
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GetCampaignsResponse]
$creadListPrec :: ReadPrec [GetCampaignsResponse]
readPrec :: ReadPrec GetCampaignsResponse
$creadPrec :: ReadPrec GetCampaignsResponse
readList :: ReadS [GetCampaignsResponse]
$creadList :: ReadS [GetCampaignsResponse]
readsPrec :: Int -> ReadS GetCampaignsResponse
$creadsPrec :: Int -> ReadS GetCampaignsResponse
Prelude.Read, Int -> GetCampaignsResponse -> ShowS
[GetCampaignsResponse] -> ShowS
GetCampaignsResponse -> String
(Int -> GetCampaignsResponse -> ShowS)
-> (GetCampaignsResponse -> String)
-> ([GetCampaignsResponse] -> ShowS)
-> Show GetCampaignsResponse
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetCampaignsResponse] -> ShowS
$cshowList :: [GetCampaignsResponse] -> ShowS
show :: GetCampaignsResponse -> String
$cshow :: GetCampaignsResponse -> String
showsPrec :: Int -> GetCampaignsResponse -> ShowS
$cshowsPrec :: Int -> GetCampaignsResponse -> ShowS
Prelude.Show, (forall x. GetCampaignsResponse -> Rep GetCampaignsResponse x)
-> (forall x. Rep GetCampaignsResponse x -> GetCampaignsResponse)
-> Generic GetCampaignsResponse
forall x. Rep GetCampaignsResponse x -> GetCampaignsResponse
forall x. GetCampaignsResponse -> Rep GetCampaignsResponse x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GetCampaignsResponse x -> GetCampaignsResponse
$cfrom :: forall x. GetCampaignsResponse -> Rep GetCampaignsResponse x
Prelude.Generic)
newGetCampaignsResponse ::
Prelude.Int ->
CampaignsResponse ->
GetCampaignsResponse
newGetCampaignsResponse :: Int -> CampaignsResponse -> GetCampaignsResponse
newGetCampaignsResponse
Int
pHttpStatus_
CampaignsResponse
pCampaignsResponse_ =
GetCampaignsResponse' :: Int -> CampaignsResponse -> GetCampaignsResponse
GetCampaignsResponse'
{ $sel:httpStatus:GetCampaignsResponse' :: Int
httpStatus = Int
pHttpStatus_,
$sel:campaignsResponse:GetCampaignsResponse' :: CampaignsResponse
campaignsResponse = CampaignsResponse
pCampaignsResponse_
}
getCampaignsResponse_httpStatus :: Lens.Lens' GetCampaignsResponse Prelude.Int
getCampaignsResponse_httpStatus :: (Int -> f Int) -> GetCampaignsResponse -> f GetCampaignsResponse
getCampaignsResponse_httpStatus = (GetCampaignsResponse -> Int)
-> (GetCampaignsResponse -> Int -> GetCampaignsResponse)
-> Lens GetCampaignsResponse GetCampaignsResponse Int Int
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCampaignsResponse' {Int
httpStatus :: Int
$sel:httpStatus:GetCampaignsResponse' :: GetCampaignsResponse -> Int
httpStatus} -> Int
httpStatus) (\s :: GetCampaignsResponse
s@GetCampaignsResponse' {} Int
a -> GetCampaignsResponse
s {$sel:httpStatus:GetCampaignsResponse' :: Int
httpStatus = Int
a} :: GetCampaignsResponse)
getCampaignsResponse_campaignsResponse :: Lens.Lens' GetCampaignsResponse CampaignsResponse
getCampaignsResponse_campaignsResponse :: (CampaignsResponse -> f CampaignsResponse)
-> GetCampaignsResponse -> f GetCampaignsResponse
getCampaignsResponse_campaignsResponse = (GetCampaignsResponse -> CampaignsResponse)
-> (GetCampaignsResponse
-> CampaignsResponse -> GetCampaignsResponse)
-> Lens
GetCampaignsResponse
GetCampaignsResponse
CampaignsResponse
CampaignsResponse
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GetCampaignsResponse' {CampaignsResponse
campaignsResponse :: CampaignsResponse
$sel:campaignsResponse:GetCampaignsResponse' :: GetCampaignsResponse -> CampaignsResponse
campaignsResponse} -> CampaignsResponse
campaignsResponse) (\s :: GetCampaignsResponse
s@GetCampaignsResponse' {} CampaignsResponse
a -> GetCampaignsResponse
s {$sel:campaignsResponse:GetCampaignsResponse' :: CampaignsResponse
campaignsResponse = CampaignsResponse
a} :: GetCampaignsResponse)
instance Prelude.NFData GetCampaignsResponse