module Aws.Ses.Commands.GetIdentityVerificationAttributes
    ( GetIdentityVerificationAttributes(..)
    , GetIdentityVerificationAttributesResponse(..)
    , IdentityVerificationAttributes(..)
    ) where

import Data.Text (Text)
import qualified Data.ByteString.Char8 as BS
import Data.Maybe (listToMaybe)
import Control.Applicative
import Data.Text.Encoding as T (encodeUtf8)
import Data.Typeable
import Text.XML.Cursor (($//), ($/), (&|), laxElement)
import Prelude

import Aws.Core
import Aws.Ses.Core

-- | Get verification status for a list of email addresses and/or domains
data GetIdentityVerificationAttributes = GetIdentityVerificationAttributes [Text]
    deriving (GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes -> Bool
$c/= :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes -> Bool
== :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes -> Bool
$c== :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes -> Bool
Eq, Eq GetIdentityVerificationAttributes
GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes -> Bool
GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes -> Ordering
GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes
$cmin :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes
max :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes
$cmax :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes
>= :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes -> Bool
$c>= :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes -> Bool
> :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes -> Bool
$c> :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes -> Bool
<= :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes -> Bool
$c<= :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes -> Bool
< :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes -> Bool
$c< :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes -> Bool
compare :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes -> Ordering
$ccompare :: GetIdentityVerificationAttributes
-> GetIdentityVerificationAttributes -> Ordering
Ord, Int -> GetIdentityVerificationAttributes -> ShowS
[GetIdentityVerificationAttributes] -> ShowS
GetIdentityVerificationAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetIdentityVerificationAttributes] -> ShowS
$cshowList :: [GetIdentityVerificationAttributes] -> ShowS
show :: GetIdentityVerificationAttributes -> String
$cshow :: GetIdentityVerificationAttributes -> String
showsPrec :: Int -> GetIdentityVerificationAttributes -> ShowS
$cshowsPrec :: Int -> GetIdentityVerificationAttributes -> ShowS
Show, Typeable)


-- | ServiceConfiguration: 'SesConfiguration'
instance SignQuery GetIdentityVerificationAttributes where
    type ServiceConfiguration GetIdentityVerificationAttributes = SesConfiguration
    signQuery :: forall queryType.
GetIdentityVerificationAttributes
-> ServiceConfiguration GetIdentityVerificationAttributes queryType
-> SignatureData
-> SignedQuery
signQuery (GetIdentityVerificationAttributes [Text]
identities) =
        forall qt.
[(ByteString, ByteString)]
-> SesConfiguration qt -> SignatureData -> SignedQuery
sesSignQuery forall a b. (a -> b) -> a -> b
$ (ByteString
"Action", ByteString
"GetIdentityVerificationAttributes")
                     forall a. a -> [a] -> [a]
: forall a b. [a] -> [b] -> [(a, b)]
zip (Int -> ByteString
enumMember forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Int
1..]) (Text -> ByteString
T.encodeUtf8 forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Text]
identities)
            where enumMember :: Int -> ByteString
enumMember (Int
n :: Int) = ByteString -> ByteString -> ByteString
BS.append ByteString
"Identities.member." (String -> ByteString
BS.pack forall a b. (a -> b) -> a -> b
$ forall a. Show a => a -> String
show Int
n)

data IdentityVerificationAttributes = IdentityVerificationAttributes
    { IdentityVerificationAttributes -> Text
ivIdentity :: Text
    , IdentityVerificationAttributes -> Text
ivVerificationStatus :: Text
    , IdentityVerificationAttributes -> Maybe Text
ivVerificationToken :: Maybe Text
    }
    deriving (IdentityVerificationAttributes
-> IdentityVerificationAttributes -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> Bool
$c/= :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> Bool
== :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> Bool
$c== :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> Bool
Eq, Eq IdentityVerificationAttributes
IdentityVerificationAttributes
-> IdentityVerificationAttributes -> Bool
IdentityVerificationAttributes
-> IdentityVerificationAttributes -> Ordering
IdentityVerificationAttributes
-> IdentityVerificationAttributes -> IdentityVerificationAttributes
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> IdentityVerificationAttributes
$cmin :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> IdentityVerificationAttributes
max :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> IdentityVerificationAttributes
$cmax :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> IdentityVerificationAttributes
>= :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> Bool
$c>= :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> Bool
> :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> Bool
$c> :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> Bool
<= :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> Bool
$c<= :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> Bool
< :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> Bool
$c< :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> Bool
compare :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> Ordering
$ccompare :: IdentityVerificationAttributes
-> IdentityVerificationAttributes -> Ordering
Ord, Int -> IdentityVerificationAttributes -> ShowS
[IdentityVerificationAttributes] -> ShowS
IdentityVerificationAttributes -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [IdentityVerificationAttributes] -> ShowS
$cshowList :: [IdentityVerificationAttributes] -> ShowS
show :: IdentityVerificationAttributes -> String
$cshow :: IdentityVerificationAttributes -> String
showsPrec :: Int -> IdentityVerificationAttributes -> ShowS
$cshowsPrec :: Int -> IdentityVerificationAttributes -> ShowS
Show, Typeable)


-- | The response sent back by Amazon SES after a
-- 'GetIdentityVerificationAttributes' command.
data GetIdentityVerificationAttributesResponse =
    GetIdentityVerificationAttributesResponse [IdentityVerificationAttributes]
    deriving (GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse -> Bool
$c/= :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse -> Bool
== :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse -> Bool
$c== :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse -> Bool
Eq, Eq GetIdentityVerificationAttributesResponse
GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse -> Bool
GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse -> Ordering
GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse
$cmin :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse
max :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse
$cmax :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse
>= :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse -> Bool
$c>= :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse -> Bool
> :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse -> Bool
$c> :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse -> Bool
<= :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse -> Bool
$c<= :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse -> Bool
< :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse -> Bool
$c< :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse -> Bool
compare :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse -> Ordering
$ccompare :: GetIdentityVerificationAttributesResponse
-> GetIdentityVerificationAttributesResponse -> Ordering
Ord, Int -> GetIdentityVerificationAttributesResponse -> ShowS
[GetIdentityVerificationAttributesResponse] -> ShowS
GetIdentityVerificationAttributesResponse -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GetIdentityVerificationAttributesResponse] -> ShowS
$cshowList :: [GetIdentityVerificationAttributesResponse] -> ShowS
show :: GetIdentityVerificationAttributesResponse -> String
$cshow :: GetIdentityVerificationAttributesResponse -> String
showsPrec :: Int -> GetIdentityVerificationAttributesResponse -> ShowS
$cshowsPrec :: Int -> GetIdentityVerificationAttributesResponse -> ShowS
Show, Typeable)


instance ResponseConsumer GetIdentityVerificationAttributes GetIdentityVerificationAttributesResponse where
    type ResponseMetadata GetIdentityVerificationAttributesResponse = SesMetadata
    responseConsumer :: Request
-> GetIdentityVerificationAttributes
-> IORef
     (ResponseMetadata GetIdentityVerificationAttributesResponse)
-> HTTPResponseConsumer GetIdentityVerificationAttributesResponse
responseConsumer Request
_ GetIdentityVerificationAttributes
_ =
      forall a.
(Cursor -> Response SesMetadata a)
-> IORef SesMetadata -> HTTPResponseConsumer a
sesResponseConsumer forall a b. (a -> b) -> a -> b
$ \Cursor
cursor -> do
         let buildAttr :: Cursor -> m IdentityVerificationAttributes
buildAttr Cursor
e = do
               Text
ivIdentity <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing Key" forall a b. (a -> b) -> a -> b
$ Cursor
e forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$/ Text -> Cursor -> [Text]
elContent Text
"key"
               Text
ivVerificationStatus <- forall (m :: * -> *) a. MonadThrow m => String -> [a] -> m a
force String
"Missing Verification Status" forall a b. (a -> b) -> a -> b
$ Cursor
e
                   forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Cursor -> [Text]
elContent Text
"VerificationStatus"
               let ivVerificationToken :: Maybe Text
ivVerificationToken = forall a. [a] -> Maybe a
listToMaybe forall a b. (a -> b) -> a -> b
$ Cursor
e forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Cursor -> [Text]
elContent Text
"VerificationToken"
               forall (m :: * -> *) a. Monad m => a -> m a
return IdentityVerificationAttributes {Maybe Text
Text
ivVerificationToken :: Maybe Text
ivVerificationStatus :: Text
ivIdentity :: Text
ivVerificationToken :: Maybe Text
ivVerificationStatus :: Text
ivIdentity :: Text
..}
         [IdentityVerificationAttributes]
attributes <- forall (t :: * -> *) (m :: * -> *) a.
(Traversable t, Monad m) =>
t (m a) -> m (t a)
sequence forall a b. (a -> b) -> a -> b
$ Cursor
cursor forall node a. Cursor node -> (Cursor node -> [a]) -> [a]
$// Text -> Axis
laxElement Text
"entry" forall node a b.
(Cursor node -> [a]) -> (a -> b) -> Cursor node -> [b]
&| forall {m :: * -> *}.
MonadThrow m =>
Cursor -> m IdentityVerificationAttributes
buildAttr
         forall (m :: * -> *) a. Monad m => a -> m a
return forall a b. (a -> b) -> a -> b
$ [IdentityVerificationAttributes]
-> GetIdentityVerificationAttributesResponse
GetIdentityVerificationAttributesResponse [IdentityVerificationAttributes]
attributes


instance Transaction GetIdentityVerificationAttributes GetIdentityVerificationAttributesResponse where

instance AsMemoryResponse GetIdentityVerificationAttributesResponse where
    type MemoryResponse GetIdentityVerificationAttributesResponse = GetIdentityVerificationAttributesResponse
    loadToMemory :: GetIdentityVerificationAttributesResponse
-> ResourceT
     IO (MemoryResponse GetIdentityVerificationAttributesResponse)
loadToMemory = forall (m :: * -> *) a. Monad m => a -> m a
return