{-# 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-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- 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.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

-- | /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
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]
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
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. 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' {$sel:userArn:SendInvitation' :: Maybe Text
userArn = 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 :: Lens' SendInvitation (Maybe Text)
sendInvitation_userArn = 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 :: (Service -> Service) -> SendInvitation -> Request SendInvitation
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 SendInvitation
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse SendInvitation)))
response =
    forall (m :: * -> *) a.
MonadResource m =>
(Int -> ResponseHeaders -> () -> Either String (AWSResponse a))
-> (ByteStringLazy -> IO ByteStringLazy)
-> Service
-> Proxy a
-> ClientResponse ClientBody
-> m (Either Error (ClientResponse (AWSResponse a)))
Response.receiveEmpty
      ( \Int
s ResponseHeaders
h ()
x ->
          Int -> SendInvitationResponse
SendInvitationResponse'
            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))
      )

instance Prelude.Hashable SendInvitation where
  hashWithSalt :: Int -> SendInvitation -> Int
hashWithSalt Int
_salt SendInvitation' {Maybe Text
userArn :: Maybe Text
$sel:userArn:SendInvitation' :: SendInvitation -> Maybe Text
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
userArn

instance Prelude.NFData SendInvitation where
  rnf :: SendInvitation -> ()
rnf SendInvitation' {Maybe Text
userArn :: Maybe Text
$sel:userArn:SendInvitation' :: SendInvitation -> Maybe Text
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
userArn

instance Data.ToHeaders SendInvitation where
  toHeaders :: SendInvitation -> ResponseHeaders
toHeaders =
    forall a b. a -> b -> a
Prelude.const
      ( forall a. Monoid a => [a] -> a
Prelude.mconcat
          [ HeaderName
"X-Amz-Target"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"AlexaForBusiness.SendInvitation" ::
                          Prelude.ByteString
                      ),
            HeaderName
"Content-Type"
              forall a. ToHeader a => HeaderName -> a -> ResponseHeaders
Data.=# ( ByteString
"application/x-amz-json-1.1" ::
                          Prelude.ByteString
                      )
          ]
      )

instance Data.ToJSON SendInvitation where
  toJSON :: SendInvitation -> Value
toJSON SendInvitation' {Maybe Text
userArn :: Maybe Text
$sel:userArn:SendInvitation' :: SendInvitation -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"UserArn" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
userArn]
      )

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

instance Data.ToQuery SendInvitation where
  toQuery :: SendInvitation -> QueryString
toQuery = forall a b. a -> b -> a
Prelude.const 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
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]
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
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. 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' {$sel:httpStatus:SendInvitationResponse' :: Int
httpStatus = Int
pHttpStatus_}

-- | The response's http status code.
sendInvitationResponse_httpStatus :: Lens.Lens' SendInvitationResponse Prelude.Int
sendInvitationResponse_httpStatus :: Lens' SendInvitationResponse Int
sendInvitationResponse_httpStatus = 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 where
  rnf :: SendInvitationResponse -> ()
rnf SendInvitationResponse' {Int
httpStatus :: Int
$sel:httpStatus:SendInvitationResponse' :: SendInvitationResponse -> Int
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Int
httpStatus