{-# 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-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.IoT.Types.SalesforceAction where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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
(SalesforceAction -> SalesforceAction -> Bool)
-> (SalesforceAction -> SalesforceAction -> Bool)
-> Eq SalesforceAction
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]
(Int -> ReadS SalesforceAction)
-> ReadS [SalesforceAction]
-> ReadPrec SalesforceAction
-> ReadPrec [SalesforceAction]
-> Read 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
(Int -> SalesforceAction -> ShowS)
-> (SalesforceAction -> String)
-> ([SalesforceAction] -> ShowS)
-> Show SalesforceAction
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. SalesforceAction -> Rep SalesforceAction x)
-> (forall x. Rep SalesforceAction x -> SalesforceAction)
-> Generic SalesforceAction
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' :: Text -> Text -> SalesforceAction
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 :: (Text -> f Text) -> SalesforceAction -> f SalesforceAction
salesforceAction_token = (SalesforceAction -> Text)
-> (SalesforceAction -> Text -> SalesforceAction)
-> Lens SalesforceAction SalesforceAction Text Text
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 :: (Text -> f Text) -> SalesforceAction -> f SalesforceAction
salesforceAction_url = (SalesforceAction -> Text)
-> (SalesforceAction -> Text -> SalesforceAction)
-> Lens SalesforceAction SalesforceAction Text Text
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 Core.FromJSON SalesforceAction where
  parseJSON :: Value -> Parser SalesforceAction
parseJSON =
    String
-> (Object -> Parser SalesforceAction)
-> Value
-> Parser SalesforceAction
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SalesforceAction"
      ( \Object
x ->
          Text -> Text -> SalesforceAction
SalesforceAction'
            (Text -> Text -> SalesforceAction)
-> Parser Text -> Parser (Text -> SalesforceAction)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser Text
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"token") Parser (Text -> SalesforceAction)
-> Parser Text -> Parser SalesforceAction
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
"url")
      )

instance Prelude.Hashable SalesforceAction

instance Prelude.NFData SalesforceAction

instance Core.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
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"token" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
token),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"url" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
url)
          ]
      )