{-# 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.AlexaBusiness.SendInvitation
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
--
-- Sends an enrollment invitation email with a URL to a user. The URL is
-- valid for 30 days or until you call this operation again, whichever
-- comes first.
module Amazonka.AlexaBusiness.SendInvitation
  ( -- * Creating a Request
    SendInvitation (..),
    newSendInvitation,

    -- * Request Lenses
    sendInvitation_userArn,

    -- * Destructuring the Response
    SendInvitationResponse (..),
    newSendInvitationResponse,

    -- * Response Lenses
    sendInvitationResponse_httpStatus,
  )
where

import Amazonka.AlexaBusiness.Types
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import qualified Amazonka.Request as Request
import qualified Amazonka.Response as Response

-- | /See:/ 'newSendInvitation' smart constructor.
data SendInvitation = SendInvitation'
  { -- | The ARN of the user to whom to send an invitation. Required.
    SendInvitation -> Maybe Text
userArn :: Prelude.Maybe Prelude.Text
  }
  deriving (SendInvitation -> SendInvitation -> Bool
(SendInvitation -> SendInvitation -> Bool)
-> (SendInvitation -> SendInvitation -> Bool) -> Eq SendInvitation
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SendInvitation -> SendInvitation -> Bool
$c/= :: SendInvitation -> SendInvitation -> Bool
== :: SendInvitation -> SendInvitation -> Bool
$c== :: SendInvitation -> SendInvitation -> Bool
Prelude.Eq, ReadPrec [SendInvitation]
ReadPrec SendInvitation
Int -> ReadS SendInvitation
ReadS [SendInvitation]
(Int -> ReadS SendInvitation)
-> ReadS [SendInvitation]
-> ReadPrec SendInvitation
-> ReadPrec [SendInvitation]
-> Read SendInvitation
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SendInvitation]
$creadListPrec :: ReadPrec [SendInvitation]
readPrec :: ReadPrec SendInvitation
$creadPrec :: ReadPrec SendInvitation
readList :: ReadS [SendInvitation]
$creadList :: ReadS [SendInvitation]
readsPrec :: Int -> ReadS SendInvitation
$creadsPrec :: Int -> ReadS SendInvitation
Prelude.Read, Int -> SendInvitation -> ShowS
[SendInvitation] -> ShowS
SendInvitation -> String
(Int -> SendInvitation -> ShowS)
-> (SendInvitation -> String)
-> ([SendInvitation] -> ShowS)
-> Show SendInvitation
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SendInvitation] -> ShowS
$cshowList :: [SendInvitation] -> ShowS
show :: SendInvitation -> String
$cshow :: SendInvitation -> String
showsPrec :: Int -> SendInvitation -> ShowS
$cshowsPrec :: Int -> SendInvitation -> ShowS
Prelude.Show, (forall x. SendInvitation -> Rep SendInvitation x)
-> (forall x. Rep SendInvitation x -> SendInvitation)
-> Generic SendInvitation
forall x. Rep SendInvitation x -> SendInvitation
forall x. SendInvitation -> Rep SendInvitation x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SendInvitation x -> SendInvitation
$cfrom :: forall x. SendInvitation -> Rep SendInvitation x
Prelude.Generic)

-- |
-- Create a value of 'SendInvitation' 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:
--
-- 'userArn', 'sendInvitation_userArn' - The ARN of the user to whom to send an invitation. Required.
newSendInvitation ::
  SendInvitation
newSendInvitation :: SendInvitation
newSendInvitation =
  SendInvitation' :: Maybe Text -> SendInvitation
SendInvitation' {$sel:userArn:SendInvitation' :: Maybe Text
userArn = Maybe Text
forall a. Maybe a
Prelude.Nothing}

-- | The ARN of the user to whom to send an invitation. Required.
sendInvitation_userArn :: Lens.Lens' SendInvitation (Prelude.Maybe Prelude.Text)
sendInvitation_userArn :: (Maybe Text -> f (Maybe Text))
-> SendInvitation -> f SendInvitation
sendInvitation_userArn = (SendInvitation -> Maybe Text)
-> (SendInvitation -> Maybe Text -> SendInvitation)
-> Lens SendInvitation SendInvitation (Maybe Text) (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SendInvitation' {Maybe Text
userArn :: Maybe Text
$sel:userArn:SendInvitation' :: SendInvitation -> Maybe Text
userArn} -> Maybe Text
userArn) (\s :: SendInvitation
s@SendInvitation' {} Maybe Text
a -> SendInvitation
s {$sel:userArn:SendInvitation' :: Maybe Text
userArn = Maybe Text
a} :: SendInvitation)

instance Core.AWSRequest SendInvitation where
  type
    AWSResponse SendInvitation =
      SendInvitationResponse
  request :: SendInvitation -> Request SendInvitation
request = Service -> SendInvitation -> Request SendInvitation
forall a. (ToRequest a, ToJSON a) => Service -> a -> Request a
Request.postJSON Service
defaultService
  response :: Logger
-> Service
-> Proxy SendInvitation
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SendInvitation)))
response =
    (Int
 -> ResponseHeaders
 -> ()
 -> Either String (AWSResponse SendInvitation))
-> Logger
-> Service
-> Proxy SendInvitation
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SendInvitation)))
forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> Logger
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> SendInvitationResponse
SendInvitationResponse'
            (Int -> SendInvitationResponse)
-> Either String Int -> Either String SendInvitationResponse
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))
      )

instance Prelude.Hashable SendInvitation

instance Prelude.NFData SendInvitation

instance Core.ToHeaders SendInvitation where
  toHeaders :: SendInvitation -> ResponseHeaders
toHeaders =
    ResponseHeaders -> SendInvitation -> ResponseHeaders
forall a b. a -> b -> a
Prelude.const
      ( [ResponseHeaders] -> ResponseHeaders
forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              HeaderName -> ByteString -> ResponseHeaders
forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Core.=# ( ByteString
"AlexaForBusiness.SendInvitation" ::
                          Prelude.ByteString
                      ),
            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.ToJSON SendInvitation where
  toJSON :: SendInvitation -> Value
toJSON SendInvitation' {Maybe Text
userArn :: Maybe Text
$sel:userArn:SendInvitation' :: SendInvitation -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Text
"UserArn" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
userArn]
      )

instance Core.ToPath SendInvitation where
  toPath :: SendInvitation -> ByteString
toPath = ByteString -> SendInvitation -> ByteString
forall a b. a -> b -> a
Prelude.const ByteString
"/"

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

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

-- |
-- Create a value of 'SendInvitationResponse' 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', 'sendInvitationResponse_httpStatus' - The response's http status code.
newSendInvitationResponse ::
  -- | 'httpStatus'
  Prelude.Int ->
  SendInvitationResponse
newSendInvitationResponse :: Int -> SendInvitationResponse
newSendInvitationResponse Int
pHttpStatus_ =
  SendInvitationResponse' :: Int -> SendInvitationResponse
SendInvitationResponse' {$sel:httpStatus:SendInvitationResponse' :: Int
httpStatus = Int
pHttpStatus_}

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

instance Prelude.NFData SendInvitationResponse