{-# 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.QuickSight.Types.TwitterParameters
-- 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.QuickSight.Types.TwitterParameters where

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

-- | The parameters for Twitter.
--
-- /See:/ 'newTwitterParameters' smart constructor.
data TwitterParameters = TwitterParameters'
  { -- | Twitter query string.
    TwitterParameters -> Text
query :: Prelude.Text,
    -- | Maximum number of rows to query Twitter.
    TwitterParameters -> Natural
maxRows :: Prelude.Natural
  }
  deriving (TwitterParameters -> TwitterParameters -> Bool
(TwitterParameters -> TwitterParameters -> Bool)
-> (TwitterParameters -> TwitterParameters -> Bool)
-> Eq TwitterParameters
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TwitterParameters -> TwitterParameters -> Bool
$c/= :: TwitterParameters -> TwitterParameters -> Bool
== :: TwitterParameters -> TwitterParameters -> Bool
$c== :: TwitterParameters -> TwitterParameters -> Bool
Prelude.Eq, ReadPrec [TwitterParameters]
ReadPrec TwitterParameters
Int -> ReadS TwitterParameters
ReadS [TwitterParameters]
(Int -> ReadS TwitterParameters)
-> ReadS [TwitterParameters]
-> ReadPrec TwitterParameters
-> ReadPrec [TwitterParameters]
-> Read TwitterParameters
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TwitterParameters]
$creadListPrec :: ReadPrec [TwitterParameters]
readPrec :: ReadPrec TwitterParameters
$creadPrec :: ReadPrec TwitterParameters
readList :: ReadS [TwitterParameters]
$creadList :: ReadS [TwitterParameters]
readsPrec :: Int -> ReadS TwitterParameters
$creadsPrec :: Int -> ReadS TwitterParameters
Prelude.Read, Int -> TwitterParameters -> ShowS
[TwitterParameters] -> ShowS
TwitterParameters -> String
(Int -> TwitterParameters -> ShowS)
-> (TwitterParameters -> String)
-> ([TwitterParameters] -> ShowS)
-> Show TwitterParameters
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TwitterParameters] -> ShowS
$cshowList :: [TwitterParameters] -> ShowS
show :: TwitterParameters -> String
$cshow :: TwitterParameters -> String
showsPrec :: Int -> TwitterParameters -> ShowS
$cshowsPrec :: Int -> TwitterParameters -> ShowS
Prelude.Show, (forall x. TwitterParameters -> Rep TwitterParameters x)
-> (forall x. Rep TwitterParameters x -> TwitterParameters)
-> Generic TwitterParameters
forall x. Rep TwitterParameters x -> TwitterParameters
forall x. TwitterParameters -> Rep TwitterParameters x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TwitterParameters x -> TwitterParameters
$cfrom :: forall x. TwitterParameters -> Rep TwitterParameters x
Prelude.Generic)

-- |
-- Create a value of 'TwitterParameters' 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:
--
-- 'query', 'twitterParameters_query' - Twitter query string.
--
-- 'maxRows', 'twitterParameters_maxRows' - Maximum number of rows to query Twitter.
newTwitterParameters ::
  -- | 'query'
  Prelude.Text ->
  -- | 'maxRows'
  Prelude.Natural ->
  TwitterParameters
newTwitterParameters :: Text -> Natural -> TwitterParameters
newTwitterParameters Text
pQuery_ Natural
pMaxRows_ =
  TwitterParameters' :: Text -> Natural -> TwitterParameters
TwitterParameters'
    { $sel:query:TwitterParameters' :: Text
query = Text
pQuery_,
      $sel:maxRows:TwitterParameters' :: Natural
maxRows = Natural
pMaxRows_
    }

-- | Twitter query string.
twitterParameters_query :: Lens.Lens' TwitterParameters Prelude.Text
twitterParameters_query :: (Text -> f Text) -> TwitterParameters -> f TwitterParameters
twitterParameters_query = (TwitterParameters -> Text)
-> (TwitterParameters -> Text -> TwitterParameters)
-> Lens TwitterParameters TwitterParameters Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TwitterParameters' {Text
query :: Text
$sel:query:TwitterParameters' :: TwitterParameters -> Text
query} -> Text
query) (\s :: TwitterParameters
s@TwitterParameters' {} Text
a -> TwitterParameters
s {$sel:query:TwitterParameters' :: Text
query = Text
a} :: TwitterParameters)

-- | Maximum number of rows to query Twitter.
twitterParameters_maxRows :: Lens.Lens' TwitterParameters Prelude.Natural
twitterParameters_maxRows :: (Natural -> f Natural) -> TwitterParameters -> f TwitterParameters
twitterParameters_maxRows = (TwitterParameters -> Natural)
-> (TwitterParameters -> Natural -> TwitterParameters)
-> Lens TwitterParameters TwitterParameters Natural Natural
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TwitterParameters' {Natural
maxRows :: Natural
$sel:maxRows:TwitterParameters' :: TwitterParameters -> Natural
maxRows} -> Natural
maxRows) (\s :: TwitterParameters
s@TwitterParameters' {} Natural
a -> TwitterParameters
s {$sel:maxRows:TwitterParameters' :: Natural
maxRows = Natural
a} :: TwitterParameters)

instance Core.FromJSON TwitterParameters where
  parseJSON :: Value -> Parser TwitterParameters
parseJSON =
    String
-> (Object -> Parser TwitterParameters)
-> Value
-> Parser TwitterParameters
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TwitterParameters"
      ( \Object
x ->
          Text -> Natural -> TwitterParameters
TwitterParameters'
            (Text -> Natural -> TwitterParameters)
-> Parser Text -> Parser (Natural -> TwitterParameters)
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
"Query")
            Parser (Natural -> TwitterParameters)
-> Parser Natural -> Parser TwitterParameters
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser Natural
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"MaxRows")
      )

instance Prelude.Hashable TwitterParameters

instance Prelude.NFData TwitterParameters

instance Core.ToJSON TwitterParameters where
  toJSON :: TwitterParameters -> Value
toJSON TwitterParameters' {Natural
Text
maxRows :: Natural
query :: Text
$sel:maxRows:TwitterParameters' :: TwitterParameters -> Natural
$sel:query:TwitterParameters' :: TwitterParameters -> 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
"Query" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
query),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"MaxRows" Text -> Natural -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Natural
maxRows)
          ]
      )