{-# 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.ZendeskDestinationProperties
-- 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.ZendeskDestinationProperties where

import Amazonka.AppFlow.Types.ErrorHandlingConfig
import Amazonka.AppFlow.Types.WriteOperationType
import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The properties that are applied when Zendesk is used as a destination.
--
-- /See:/ 'newZendeskDestinationProperties' smart constructor.
data ZendeskDestinationProperties = ZendeskDestinationProperties'
  { ZendeskDestinationProperties -> Maybe WriteOperationType
writeOperationType :: Prelude.Maybe WriteOperationType,
    ZendeskDestinationProperties -> Maybe [Text]
idFieldNames :: Prelude.Maybe [Prelude.Text],
    ZendeskDestinationProperties -> Maybe ErrorHandlingConfig
errorHandlingConfig :: Prelude.Maybe ErrorHandlingConfig,
    -- | The object specified in the Zendesk flow destination.
    ZendeskDestinationProperties -> Text
object' :: Prelude.Text
  }
  deriving (ZendeskDestinationProperties
-> ZendeskDestinationProperties -> Bool
(ZendeskDestinationProperties
 -> ZendeskDestinationProperties -> Bool)
-> (ZendeskDestinationProperties
    -> ZendeskDestinationProperties -> Bool)
-> Eq ZendeskDestinationProperties
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ZendeskDestinationProperties
-> ZendeskDestinationProperties -> Bool
$c/= :: ZendeskDestinationProperties
-> ZendeskDestinationProperties -> Bool
== :: ZendeskDestinationProperties
-> ZendeskDestinationProperties -> Bool
$c== :: ZendeskDestinationProperties
-> ZendeskDestinationProperties -> Bool
Prelude.Eq, ReadPrec [ZendeskDestinationProperties]
ReadPrec ZendeskDestinationProperties
Int -> ReadS ZendeskDestinationProperties
ReadS [ZendeskDestinationProperties]
(Int -> ReadS ZendeskDestinationProperties)
-> ReadS [ZendeskDestinationProperties]
-> ReadPrec ZendeskDestinationProperties
-> ReadPrec [ZendeskDestinationProperties]
-> Read ZendeskDestinationProperties
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ZendeskDestinationProperties]
$creadListPrec :: ReadPrec [ZendeskDestinationProperties]
readPrec :: ReadPrec ZendeskDestinationProperties
$creadPrec :: ReadPrec ZendeskDestinationProperties
readList :: ReadS [ZendeskDestinationProperties]
$creadList :: ReadS [ZendeskDestinationProperties]
readsPrec :: Int -> ReadS ZendeskDestinationProperties
$creadsPrec :: Int -> ReadS ZendeskDestinationProperties
Prelude.Read, Int -> ZendeskDestinationProperties -> ShowS
[ZendeskDestinationProperties] -> ShowS
ZendeskDestinationProperties -> String
(Int -> ZendeskDestinationProperties -> ShowS)
-> (ZendeskDestinationProperties -> String)
-> ([ZendeskDestinationProperties] -> ShowS)
-> Show ZendeskDestinationProperties
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ZendeskDestinationProperties] -> ShowS
$cshowList :: [ZendeskDestinationProperties] -> ShowS
show :: ZendeskDestinationProperties -> String
$cshow :: ZendeskDestinationProperties -> String
showsPrec :: Int -> ZendeskDestinationProperties -> ShowS
$cshowsPrec :: Int -> ZendeskDestinationProperties -> ShowS
Prelude.Show, (forall x.
 ZendeskDestinationProperties -> Rep ZendeskDestinationProperties x)
-> (forall x.
    Rep ZendeskDestinationProperties x -> ZendeskDestinationProperties)
-> Generic ZendeskDestinationProperties
forall x.
Rep ZendeskDestinationProperties x -> ZendeskDestinationProperties
forall x.
ZendeskDestinationProperties -> Rep ZendeskDestinationProperties x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep ZendeskDestinationProperties x -> ZendeskDestinationProperties
$cfrom :: forall x.
ZendeskDestinationProperties -> Rep ZendeskDestinationProperties x
Prelude.Generic)

-- |
-- Create a value of 'ZendeskDestinationProperties' 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:
--
-- 'writeOperationType', 'zendeskDestinationProperties_writeOperationType' - Undocumented member.
--
-- 'idFieldNames', 'zendeskDestinationProperties_idFieldNames' - Undocumented member.
--
-- 'errorHandlingConfig', 'zendeskDestinationProperties_errorHandlingConfig' - Undocumented member.
--
-- 'object'', 'zendeskDestinationProperties_object' - The object specified in the Zendesk flow destination.
newZendeskDestinationProperties ::
  -- | 'object''
  Prelude.Text ->
  ZendeskDestinationProperties
newZendeskDestinationProperties :: Text -> ZendeskDestinationProperties
newZendeskDestinationProperties Text
pObject_ =
  ZendeskDestinationProperties' :: Maybe WriteOperationType
-> Maybe [Text]
-> Maybe ErrorHandlingConfig
-> Text
-> ZendeskDestinationProperties
ZendeskDestinationProperties'
    { $sel:writeOperationType:ZendeskDestinationProperties' :: Maybe WriteOperationType
writeOperationType =
        Maybe WriteOperationType
forall a. Maybe a
Prelude.Nothing,
      $sel:idFieldNames:ZendeskDestinationProperties' :: Maybe [Text]
idFieldNames = Maybe [Text]
forall a. Maybe a
Prelude.Nothing,
      $sel:errorHandlingConfig:ZendeskDestinationProperties' :: Maybe ErrorHandlingConfig
errorHandlingConfig = Maybe ErrorHandlingConfig
forall a. Maybe a
Prelude.Nothing,
      $sel:object':ZendeskDestinationProperties' :: Text
object' = Text
pObject_
    }

-- | Undocumented member.
zendeskDestinationProperties_writeOperationType :: Lens.Lens' ZendeskDestinationProperties (Prelude.Maybe WriteOperationType)
zendeskDestinationProperties_writeOperationType :: (Maybe WriteOperationType -> f (Maybe WriteOperationType))
-> ZendeskDestinationProperties -> f ZendeskDestinationProperties
zendeskDestinationProperties_writeOperationType = (ZendeskDestinationProperties -> Maybe WriteOperationType)
-> (ZendeskDestinationProperties
    -> Maybe WriteOperationType -> ZendeskDestinationProperties)
-> Lens
     ZendeskDestinationProperties
     ZendeskDestinationProperties
     (Maybe WriteOperationType)
     (Maybe WriteOperationType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ZendeskDestinationProperties' {Maybe WriteOperationType
writeOperationType :: Maybe WriteOperationType
$sel:writeOperationType:ZendeskDestinationProperties' :: ZendeskDestinationProperties -> Maybe WriteOperationType
writeOperationType} -> Maybe WriteOperationType
writeOperationType) (\s :: ZendeskDestinationProperties
s@ZendeskDestinationProperties' {} Maybe WriteOperationType
a -> ZendeskDestinationProperties
s {$sel:writeOperationType:ZendeskDestinationProperties' :: Maybe WriteOperationType
writeOperationType = Maybe WriteOperationType
a} :: ZendeskDestinationProperties)

-- | Undocumented member.
zendeskDestinationProperties_idFieldNames :: Lens.Lens' ZendeskDestinationProperties (Prelude.Maybe [Prelude.Text])
zendeskDestinationProperties_idFieldNames :: (Maybe [Text] -> f (Maybe [Text]))
-> ZendeskDestinationProperties -> f ZendeskDestinationProperties
zendeskDestinationProperties_idFieldNames = (ZendeskDestinationProperties -> Maybe [Text])
-> (ZendeskDestinationProperties
    -> Maybe [Text] -> ZendeskDestinationProperties)
-> Lens
     ZendeskDestinationProperties
     ZendeskDestinationProperties
     (Maybe [Text])
     (Maybe [Text])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ZendeskDestinationProperties' {Maybe [Text]
idFieldNames :: Maybe [Text]
$sel:idFieldNames:ZendeskDestinationProperties' :: ZendeskDestinationProperties -> Maybe [Text]
idFieldNames} -> Maybe [Text]
idFieldNames) (\s :: ZendeskDestinationProperties
s@ZendeskDestinationProperties' {} Maybe [Text]
a -> ZendeskDestinationProperties
s {$sel:idFieldNames:ZendeskDestinationProperties' :: Maybe [Text]
idFieldNames = Maybe [Text]
a} :: ZendeskDestinationProperties) ((Maybe [Text] -> f (Maybe [Text]))
 -> ZendeskDestinationProperties -> f ZendeskDestinationProperties)
-> ((Maybe [Text] -> f (Maybe [Text]))
    -> Maybe [Text] -> f (Maybe [Text]))
-> (Maybe [Text] -> f (Maybe [Text]))
-> ZendeskDestinationProperties
-> f ZendeskDestinationProperties
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso [Text] [Text] [Text] [Text]
-> Iso (Maybe [Text]) (Maybe [Text]) (Maybe [Text]) (Maybe [Text])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso [Text] [Text] [Text] [Text]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Undocumented member.
zendeskDestinationProperties_errorHandlingConfig :: Lens.Lens' ZendeskDestinationProperties (Prelude.Maybe ErrorHandlingConfig)
zendeskDestinationProperties_errorHandlingConfig :: (Maybe ErrorHandlingConfig -> f (Maybe ErrorHandlingConfig))
-> ZendeskDestinationProperties -> f ZendeskDestinationProperties
zendeskDestinationProperties_errorHandlingConfig = (ZendeskDestinationProperties -> Maybe ErrorHandlingConfig)
-> (ZendeskDestinationProperties
    -> Maybe ErrorHandlingConfig -> ZendeskDestinationProperties)
-> Lens
     ZendeskDestinationProperties
     ZendeskDestinationProperties
     (Maybe ErrorHandlingConfig)
     (Maybe ErrorHandlingConfig)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ZendeskDestinationProperties' {Maybe ErrorHandlingConfig
errorHandlingConfig :: Maybe ErrorHandlingConfig
$sel:errorHandlingConfig:ZendeskDestinationProperties' :: ZendeskDestinationProperties -> Maybe ErrorHandlingConfig
errorHandlingConfig} -> Maybe ErrorHandlingConfig
errorHandlingConfig) (\s :: ZendeskDestinationProperties
s@ZendeskDestinationProperties' {} Maybe ErrorHandlingConfig
a -> ZendeskDestinationProperties
s {$sel:errorHandlingConfig:ZendeskDestinationProperties' :: Maybe ErrorHandlingConfig
errorHandlingConfig = Maybe ErrorHandlingConfig
a} :: ZendeskDestinationProperties)

-- | The object specified in the Zendesk flow destination.
zendeskDestinationProperties_object :: Lens.Lens' ZendeskDestinationProperties Prelude.Text
zendeskDestinationProperties_object :: (Text -> f Text)
-> ZendeskDestinationProperties -> f ZendeskDestinationProperties
zendeskDestinationProperties_object = (ZendeskDestinationProperties -> Text)
-> (ZendeskDestinationProperties
    -> Text -> ZendeskDestinationProperties)
-> Lens
     ZendeskDestinationProperties ZendeskDestinationProperties Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ZendeskDestinationProperties' {Text
object' :: Text
$sel:object':ZendeskDestinationProperties' :: ZendeskDestinationProperties -> Text
object'} -> Text
object') (\s :: ZendeskDestinationProperties
s@ZendeskDestinationProperties' {} Text
a -> ZendeskDestinationProperties
s {$sel:object':ZendeskDestinationProperties' :: Text
object' = Text
a} :: ZendeskDestinationProperties)

instance Core.FromJSON ZendeskDestinationProperties where
  parseJSON :: Value -> Parser ZendeskDestinationProperties
parseJSON =
    String
-> (Object -> Parser ZendeskDestinationProperties)
-> Value
-> Parser ZendeskDestinationProperties
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"ZendeskDestinationProperties"
      ( \Object
x ->
          Maybe WriteOperationType
-> Maybe [Text]
-> Maybe ErrorHandlingConfig
-> Text
-> ZendeskDestinationProperties
ZendeskDestinationProperties'
            (Maybe WriteOperationType
 -> Maybe [Text]
 -> Maybe ErrorHandlingConfig
 -> Text
 -> ZendeskDestinationProperties)
-> Parser (Maybe WriteOperationType)
-> Parser
     (Maybe [Text]
      -> Maybe ErrorHandlingConfig
      -> Text
      -> ZendeskDestinationProperties)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe WriteOperationType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"writeOperationType")
            Parser
  (Maybe [Text]
   -> Maybe ErrorHandlingConfig
   -> Text
   -> ZendeskDestinationProperties)
-> Parser (Maybe [Text])
-> Parser
     (Maybe ErrorHandlingConfig -> Text -> ZendeskDestinationProperties)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe (Maybe [Text]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"idFieldNames" Parser (Maybe (Maybe [Text]))
-> Maybe [Text] -> Parser (Maybe [Text])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [Text]
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe ErrorHandlingConfig -> Text -> ZendeskDestinationProperties)
-> Parser (Maybe ErrorHandlingConfig)
-> Parser (Text -> ZendeskDestinationProperties)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe ErrorHandlingConfig)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"errorHandlingConfig")
            Parser (Text -> ZendeskDestinationProperties)
-> Parser Text -> Parser ZendeskDestinationProperties
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"object")
      )

instance
  Prelude.Hashable
    ZendeskDestinationProperties

instance Prelude.NFData ZendeskDestinationProperties

instance Core.ToJSON ZendeskDestinationProperties where
  toJSON :: ZendeskDestinationProperties -> Value
toJSON ZendeskDestinationProperties' {Maybe [Text]
Maybe ErrorHandlingConfig
Maybe WriteOperationType
Text
object' :: Text
errorHandlingConfig :: Maybe ErrorHandlingConfig
idFieldNames :: Maybe [Text]
writeOperationType :: Maybe WriteOperationType
$sel:object':ZendeskDestinationProperties' :: ZendeskDestinationProperties -> Text
$sel:errorHandlingConfig:ZendeskDestinationProperties' :: ZendeskDestinationProperties -> Maybe ErrorHandlingConfig
$sel:idFieldNames:ZendeskDestinationProperties' :: ZendeskDestinationProperties -> Maybe [Text]
$sel:writeOperationType:ZendeskDestinationProperties' :: ZendeskDestinationProperties -> Maybe WriteOperationType
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"writeOperationType" Text -> WriteOperationType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (WriteOperationType -> Pair)
-> Maybe WriteOperationType -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe WriteOperationType
writeOperationType,
            (Text
"idFieldNames" 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]
idFieldNames,
            (Text
"errorHandlingConfig" Text -> ErrorHandlingConfig -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (ErrorHandlingConfig -> Pair)
-> Maybe ErrorHandlingConfig -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe ErrorHandlingConfig
errorHandlingConfig,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"object" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
object')
          ]
      )