{-# 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.IoT.Types.SalesforceAction
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.IoT.Types.SalesforceAction where

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

-- | Describes an action to write a message to a Salesforce IoT Cloud Input
-- Stream.
--
-- /See:/ 'newSalesforceAction' smart constructor.
data SalesforceAction = SalesforceAction'
  { -- | The token used to authenticate access to the Salesforce IoT Cloud Input
    -- Stream. The token is available from the Salesforce IoT Cloud platform
    -- after creation of the Input Stream.
    SalesforceAction -> Text
token :: Prelude.Text,
    -- | The URL exposed by the Salesforce IoT Cloud Input Stream. The URL is
    -- available from the Salesforce IoT Cloud platform after creation of the
    -- Input Stream.
    SalesforceAction -> Text
url :: Prelude.Text
  }
  deriving (SalesforceAction -> SalesforceAction -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SalesforceAction -> SalesforceAction -> Bool
$c/= :: SalesforceAction -> SalesforceAction -> Bool
== :: SalesforceAction -> SalesforceAction -> Bool
$c== :: SalesforceAction -> SalesforceAction -> Bool
Prelude.Eq, ReadPrec [SalesforceAction]
ReadPrec SalesforceAction
Int -> ReadS SalesforceAction
ReadS [SalesforceAction]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SalesforceAction]
$creadListPrec :: ReadPrec [SalesforceAction]
readPrec :: ReadPrec SalesforceAction
$creadPrec :: ReadPrec SalesforceAction
readList :: ReadS [SalesforceAction]
$creadList :: ReadS [SalesforceAction]
readsPrec :: Int -> ReadS SalesforceAction
$creadsPrec :: Int -> ReadS SalesforceAction
Prelude.Read, Int -> SalesforceAction -> ShowS
[SalesforceAction] -> ShowS
SalesforceAction -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SalesforceAction] -> ShowS
$cshowList :: [SalesforceAction] -> ShowS
show :: SalesforceAction -> String
$cshow :: SalesforceAction -> String
showsPrec :: Int -> SalesforceAction -> ShowS
$cshowsPrec :: Int -> SalesforceAction -> ShowS
Prelude.Show, forall x. Rep SalesforceAction x -> SalesforceAction
forall x. SalesforceAction -> Rep SalesforceAction x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SalesforceAction x -> SalesforceAction
$cfrom :: forall x. SalesforceAction -> Rep SalesforceAction x
Prelude.Generic)

-- |
-- Create a value of 'SalesforceAction' 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:
--
-- 'token', 'salesforceAction_token' - The token used to authenticate access to the Salesforce IoT Cloud Input
-- Stream. The token is available from the Salesforce IoT Cloud platform
-- after creation of the Input Stream.
--
-- 'url', 'salesforceAction_url' - The URL exposed by the Salesforce IoT Cloud Input Stream. The URL is
-- available from the Salesforce IoT Cloud platform after creation of the
-- Input Stream.
newSalesforceAction ::
  -- | 'token'
  Prelude.Text ->
  -- | 'url'
  Prelude.Text ->
  SalesforceAction
newSalesforceAction :: Text -> Text -> SalesforceAction
newSalesforceAction Text
pToken_ Text
pUrl_ =
  SalesforceAction' {$sel:token:SalesforceAction' :: Text
token = Text
pToken_, $sel:url:SalesforceAction' :: Text
url = Text
pUrl_}

-- | The token used to authenticate access to the Salesforce IoT Cloud Input
-- Stream. The token is available from the Salesforce IoT Cloud platform
-- after creation of the Input Stream.
salesforceAction_token :: Lens.Lens' SalesforceAction Prelude.Text
salesforceAction_token :: Lens' SalesforceAction Text
salesforceAction_token = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SalesforceAction' {Text
token :: Text
$sel:token:SalesforceAction' :: SalesforceAction -> Text
token} -> Text
token) (\s :: SalesforceAction
s@SalesforceAction' {} Text
a -> SalesforceAction
s {$sel:token:SalesforceAction' :: Text
token = Text
a} :: SalesforceAction)

-- | The URL exposed by the Salesforce IoT Cloud Input Stream. The URL is
-- available from the Salesforce IoT Cloud platform after creation of the
-- Input Stream.
salesforceAction_url :: Lens.Lens' SalesforceAction Prelude.Text
salesforceAction_url :: Lens' SalesforceAction Text
salesforceAction_url = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SalesforceAction' {Text
url :: Text
$sel:url:SalesforceAction' :: SalesforceAction -> Text
url} -> Text
url) (\s :: SalesforceAction
s@SalesforceAction' {} Text
a -> SalesforceAction
s {$sel:url:SalesforceAction' :: Text
url = Text
a} :: SalesforceAction)

instance Data.FromJSON SalesforceAction where
  parseJSON :: Value -> Parser SalesforceAction
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SalesforceAction"
      ( \Object
x ->
          Text -> Text -> SalesforceAction
SalesforceAction'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"token")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser a
Data..: Key
"url")
      )

instance Prelude.Hashable SalesforceAction where
  hashWithSalt :: Int -> SalesforceAction -> Int
hashWithSalt Int
_salt SalesforceAction' {Text
url :: Text
token :: Text
$sel:url:SalesforceAction' :: SalesforceAction -> Text
$sel:token:SalesforceAction' :: SalesforceAction -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
token
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
url

instance Prelude.NFData SalesforceAction where
  rnf :: SalesforceAction -> ()
rnf SalesforceAction' {Text
url :: Text
token :: Text
$sel:url:SalesforceAction' :: SalesforceAction -> Text
$sel:token:SalesforceAction' :: SalesforceAction -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
token seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Text
url

instance Data.ToJSON SalesforceAction where
  toJSON :: SalesforceAction -> Value
toJSON SalesforceAction' {Text
url :: Text
token :: Text
$sel:url:SalesforceAction' :: SalesforceAction -> Text
$sel:token:SalesforceAction' :: SalesforceAction -> Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"token" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
token),
            forall a. a -> Maybe a
Prelude.Just (Key
"url" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
url)
          ]
      )