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

-- | 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
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]
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
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. 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'
    { $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 :: Lens' TwitterParameters Text
twitterParameters_query = 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 :: Lens' TwitterParameters Natural
twitterParameters_maxRows = 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 Data.FromJSON TwitterParameters where
  parseJSON :: Value -> Parser TwitterParameters
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"TwitterParameters"
      ( \Object
x ->
          Text -> Natural -> TwitterParameters
TwitterParameters'
            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
"Query")
            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
"MaxRows")
      )

instance Prelude.Hashable TwitterParameters where
  hashWithSalt :: Int -> TwitterParameters -> Int
hashWithSalt Int
_salt TwitterParameters' {Natural
Text
maxRows :: Natural
query :: Text
$sel:maxRows:TwitterParameters' :: TwitterParameters -> Natural
$sel:query:TwitterParameters' :: TwitterParameters -> Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Text
query
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Natural
maxRows

instance Prelude.NFData TwitterParameters where
  rnf :: TwitterParameters -> ()
rnf TwitterParameters' {Natural
Text
maxRows :: Natural
query :: Text
$sel:maxRows:TwitterParameters' :: TwitterParameters -> Natural
$sel:query:TwitterParameters' :: TwitterParameters -> Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Text
query seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Natural
maxRows

instance Data.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
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ forall a. a -> Maybe a
Prelude.Just (Key
"Query" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Text
query),
            forall a. a -> Maybe a
Prelude.Just (Key
"MaxRows" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..= Natural
maxRows)
          ]
      )