{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.AppFlow.Types.ConnectorOAuthRequest
-- 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)
module Amazonka.AppFlow.Types.ConnectorOAuthRequest where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | Used by select connectors for which the OAuth workflow is supported,
-- such as Salesforce, Google Analytics, Marketo, Zendesk, and Slack.
--
-- /See:/ 'newConnectorOAuthRequest' smart constructor.
data ConnectorOAuthRequest = ConnectorOAuthRequest'
  { -- | The URL to which the authentication server redirects the browser after
    -- authorization has been granted.
    ConnectorOAuthRequest -> Maybe Text
redirectUri :: Prelude.Maybe Prelude.Text,
    -- | The code provided by the connector when it has been authenticated via
    -- the connected app.
    ConnectorOAuthRequest -> Maybe Text
authCode :: Prelude.Maybe Prelude.Text
  }
  deriving (ConnectorOAuthRequest -> ConnectorOAuthRequest -> Bool
(ConnectorOAuthRequest -> ConnectorOAuthRequest -> Bool)
-> (ConnectorOAuthRequest -> ConnectorOAuthRequest -> Bool)
-> Eq ConnectorOAuthRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ConnectorOAuthRequest -> ConnectorOAuthRequest -> Bool
$c/= :: ConnectorOAuthRequest -> ConnectorOAuthRequest -> Bool
== :: ConnectorOAuthRequest -> ConnectorOAuthRequest -> Bool
$c== :: ConnectorOAuthRequest -> ConnectorOAuthRequest -> Bool
Prelude.Eq, ReadPrec [ConnectorOAuthRequest]
ReadPrec ConnectorOAuthRequest
Int -> ReadS ConnectorOAuthRequest
ReadS [ConnectorOAuthRequest]
(Int -> ReadS ConnectorOAuthRequest)
-> ReadS [ConnectorOAuthRequest]
-> ReadPrec ConnectorOAuthRequest
-> ReadPrec [ConnectorOAuthRequest]
-> Read ConnectorOAuthRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ConnectorOAuthRequest]
$creadListPrec :: ReadPrec [ConnectorOAuthRequest]
readPrec :: ReadPrec ConnectorOAuthRequest
$creadPrec :: ReadPrec ConnectorOAuthRequest
readList :: ReadS [ConnectorOAuthRequest]
$creadList :: ReadS [ConnectorOAuthRequest]
readsPrec :: Int -> ReadS ConnectorOAuthRequest
$creadsPrec :: Int -> ReadS ConnectorOAuthRequest
Prelude.Read, Int -> ConnectorOAuthRequest -> ShowS
[ConnectorOAuthRequest] -> ShowS
ConnectorOAuthRequest -> String
(Int -> ConnectorOAuthRequest -> ShowS)
-> (ConnectorOAuthRequest -> String)
-> ([ConnectorOAuthRequest] -> ShowS)
-> Show ConnectorOAuthRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ConnectorOAuthRequest] -> ShowS
$cshowList :: [ConnectorOAuthRequest] -> ShowS
show :: ConnectorOAuthRequest -> String
$cshow :: ConnectorOAuthRequest -> String
showsPrec :: Int -> ConnectorOAuthRequest -> ShowS
$cshowsPrec :: Int -> ConnectorOAuthRequest -> ShowS
Prelude.Show, (forall x. ConnectorOAuthRequest -> Rep ConnectorOAuthRequest x)
-> (forall x. Rep ConnectorOAuthRequest x -> ConnectorOAuthRequest)
-> Generic ConnectorOAuthRequest
forall x. Rep ConnectorOAuthRequest x -> ConnectorOAuthRequest
forall x. ConnectorOAuthRequest -> Rep ConnectorOAuthRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ConnectorOAuthRequest x -> ConnectorOAuthRequest
$cfrom :: forall x. ConnectorOAuthRequest -> Rep ConnectorOAuthRequest x
Prelude.Generic)

-- |
-- Create a value of 'ConnectorOAuthRequest' 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:
--
-- 'redirectUri', 'connectorOAuthRequest_redirectUri' - The URL to which the authentication server redirects the browser after
-- authorization has been granted.
--
-- 'authCode', 'connectorOAuthRequest_authCode' - The code provided by the connector when it has been authenticated via
-- the connected app.
newConnectorOAuthRequest ::
  ConnectorOAuthRequest
newConnectorOAuthRequest :: ConnectorOAuthRequest
newConnectorOAuthRequest =
  ConnectorOAuthRequest' :: Maybe Text -> Maybe Text -> ConnectorOAuthRequest
ConnectorOAuthRequest'
    { $sel:redirectUri:ConnectorOAuthRequest' :: Maybe Text
redirectUri =
        Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:authCode:ConnectorOAuthRequest' :: Maybe Text
authCode = Maybe Text
forall a. Maybe a
Prelude.Nothing
    }

-- | The URL to which the authentication server redirects the browser after
-- authorization has been granted.
connectorOAuthRequest_redirectUri :: Lens.Lens' ConnectorOAuthRequest (Prelude.Maybe Prelude.Text)
connectorOAuthRequest_redirectUri :: (Maybe Text -> f (Maybe Text))
-> ConnectorOAuthRequest -> f ConnectorOAuthRequest
connectorOAuthRequest_redirectUri = (ConnectorOAuthRequest -> Maybe Text)
-> (ConnectorOAuthRequest -> Maybe Text -> ConnectorOAuthRequest)
-> Lens
     ConnectorOAuthRequest
     ConnectorOAuthRequest
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectorOAuthRequest' {Maybe Text
redirectUri :: Maybe Text
$sel:redirectUri:ConnectorOAuthRequest' :: ConnectorOAuthRequest -> Maybe Text
redirectUri} -> Maybe Text
redirectUri) (\s :: ConnectorOAuthRequest
s@ConnectorOAuthRequest' {} Maybe Text
a -> ConnectorOAuthRequest
s {$sel:redirectUri:ConnectorOAuthRequest' :: Maybe Text
redirectUri = Maybe Text
a} :: ConnectorOAuthRequest)

-- | The code provided by the connector when it has been authenticated via
-- the connected app.
connectorOAuthRequest_authCode :: Lens.Lens' ConnectorOAuthRequest (Prelude.Maybe Prelude.Text)
connectorOAuthRequest_authCode :: (Maybe Text -> f (Maybe Text))
-> ConnectorOAuthRequest -> f ConnectorOAuthRequest
connectorOAuthRequest_authCode = (ConnectorOAuthRequest -> Maybe Text)
-> (ConnectorOAuthRequest -> Maybe Text -> ConnectorOAuthRequest)
-> Lens
     ConnectorOAuthRequest
     ConnectorOAuthRequest
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ConnectorOAuthRequest' {Maybe Text
authCode :: Maybe Text
$sel:authCode:ConnectorOAuthRequest' :: ConnectorOAuthRequest -> Maybe Text
authCode} -> Maybe Text
authCode) (\s :: ConnectorOAuthRequest
s@ConnectorOAuthRequest' {} Maybe Text
a -> ConnectorOAuthRequest
s {$sel:authCode:ConnectorOAuthRequest' :: Maybe Text
authCode = Maybe Text
a} :: ConnectorOAuthRequest)

instance Prelude.Hashable ConnectorOAuthRequest

instance Prelude.NFData ConnectorOAuthRequest

instance Core.ToJSON ConnectorOAuthRequest where
  toJSON :: ConnectorOAuthRequest -> Value
toJSON ConnectorOAuthRequest' {Maybe Text
authCode :: Maybe Text
redirectUri :: Maybe Text
$sel:authCode:ConnectorOAuthRequest' :: ConnectorOAuthRequest -> Maybe Text
$sel:redirectUri:ConnectorOAuthRequest' :: ConnectorOAuthRequest -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"redirectUri" 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
redirectUri,
            (Text
"authCode" 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
authCode
          ]
      )