{-# 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.ManagedBlockChain.Types.VoteSummary
-- 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.ManagedBlockChain.Types.VoteSummary where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import Amazonka.ManagedBlockChain.Types.VoteValue
import qualified Amazonka.Prelude as Prelude

-- | Properties of an individual vote that a member cast for a proposal.
--
-- Applies only to Hyperledger Fabric.
--
-- /See:/ 'newVoteSummary' smart constructor.
data VoteSummary = VoteSummary'
  { -- | The unique identifier of the member that cast the vote.
    VoteSummary -> Maybe Text
memberId :: Prelude.Maybe Prelude.Text,
    -- | The name of the member that cast the vote.
    VoteSummary -> Maybe Text
memberName :: Prelude.Maybe Prelude.Text,
    -- | The vote value, either @YES@ or @NO@.
    VoteSummary -> Maybe VoteValue
vote :: Prelude.Maybe VoteValue
  }
  deriving (VoteSummary -> VoteSummary -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: VoteSummary -> VoteSummary -> Bool
$c/= :: VoteSummary -> VoteSummary -> Bool
== :: VoteSummary -> VoteSummary -> Bool
$c== :: VoteSummary -> VoteSummary -> Bool
Prelude.Eq, ReadPrec [VoteSummary]
ReadPrec VoteSummary
Int -> ReadS VoteSummary
ReadS [VoteSummary]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [VoteSummary]
$creadListPrec :: ReadPrec [VoteSummary]
readPrec :: ReadPrec VoteSummary
$creadPrec :: ReadPrec VoteSummary
readList :: ReadS [VoteSummary]
$creadList :: ReadS [VoteSummary]
readsPrec :: Int -> ReadS VoteSummary
$creadsPrec :: Int -> ReadS VoteSummary
Prelude.Read, Int -> VoteSummary -> ShowS
[VoteSummary] -> ShowS
VoteSummary -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [VoteSummary] -> ShowS
$cshowList :: [VoteSummary] -> ShowS
show :: VoteSummary -> String
$cshow :: VoteSummary -> String
showsPrec :: Int -> VoteSummary -> ShowS
$cshowsPrec :: Int -> VoteSummary -> ShowS
Prelude.Show, forall x. Rep VoteSummary x -> VoteSummary
forall x. VoteSummary -> Rep VoteSummary x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep VoteSummary x -> VoteSummary
$cfrom :: forall x. VoteSummary -> Rep VoteSummary x
Prelude.Generic)

-- |
-- Create a value of 'VoteSummary' 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:
--
-- 'memberId', 'voteSummary_memberId' - The unique identifier of the member that cast the vote.
--
-- 'memberName', 'voteSummary_memberName' - The name of the member that cast the vote.
--
-- 'vote', 'voteSummary_vote' - The vote value, either @YES@ or @NO@.
newVoteSummary ::
  VoteSummary
newVoteSummary :: VoteSummary
newVoteSummary =
  VoteSummary'
    { $sel:memberId:VoteSummary' :: Maybe Text
memberId = forall a. Maybe a
Prelude.Nothing,
      $sel:memberName:VoteSummary' :: Maybe Text
memberName = forall a. Maybe a
Prelude.Nothing,
      $sel:vote:VoteSummary' :: Maybe VoteValue
vote = forall a. Maybe a
Prelude.Nothing
    }

-- | The unique identifier of the member that cast the vote.
voteSummary_memberId :: Lens.Lens' VoteSummary (Prelude.Maybe Prelude.Text)
voteSummary_memberId :: Lens' VoteSummary (Maybe Text)
voteSummary_memberId = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VoteSummary' {Maybe Text
memberId :: Maybe Text
$sel:memberId:VoteSummary' :: VoteSummary -> Maybe Text
memberId} -> Maybe Text
memberId) (\s :: VoteSummary
s@VoteSummary' {} Maybe Text
a -> VoteSummary
s {$sel:memberId:VoteSummary' :: Maybe Text
memberId = Maybe Text
a} :: VoteSummary)

-- | The name of the member that cast the vote.
voteSummary_memberName :: Lens.Lens' VoteSummary (Prelude.Maybe Prelude.Text)
voteSummary_memberName :: Lens' VoteSummary (Maybe Text)
voteSummary_memberName = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VoteSummary' {Maybe Text
memberName :: Maybe Text
$sel:memberName:VoteSummary' :: VoteSummary -> Maybe Text
memberName} -> Maybe Text
memberName) (\s :: VoteSummary
s@VoteSummary' {} Maybe Text
a -> VoteSummary
s {$sel:memberName:VoteSummary' :: Maybe Text
memberName = Maybe Text
a} :: VoteSummary)

-- | The vote value, either @YES@ or @NO@.
voteSummary_vote :: Lens.Lens' VoteSummary (Prelude.Maybe VoteValue)
voteSummary_vote :: Lens' VoteSummary (Maybe VoteValue)
voteSummary_vote = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\VoteSummary' {Maybe VoteValue
vote :: Maybe VoteValue
$sel:vote:VoteSummary' :: VoteSummary -> Maybe VoteValue
vote} -> Maybe VoteValue
vote) (\s :: VoteSummary
s@VoteSummary' {} Maybe VoteValue
a -> VoteSummary
s {$sel:vote:VoteSummary' :: Maybe VoteValue
vote = Maybe VoteValue
a} :: VoteSummary)

instance Data.FromJSON VoteSummary where
  parseJSON :: Value -> Parser VoteSummary
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"VoteSummary"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe VoteValue -> VoteSummary
VoteSummary'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"MemberId")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"MemberName")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Vote")
      )

instance Prelude.Hashable VoteSummary where
  hashWithSalt :: Int -> VoteSummary -> Int
hashWithSalt Int
_salt VoteSummary' {Maybe Text
Maybe VoteValue
vote :: Maybe VoteValue
memberName :: Maybe Text
memberId :: Maybe Text
$sel:vote:VoteSummary' :: VoteSummary -> Maybe VoteValue
$sel:memberName:VoteSummary' :: VoteSummary -> Maybe Text
$sel:memberId:VoteSummary' :: VoteSummary -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
memberId
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
memberName
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe VoteValue
vote

instance Prelude.NFData VoteSummary where
  rnf :: VoteSummary -> ()
rnf VoteSummary' {Maybe Text
Maybe VoteValue
vote :: Maybe VoteValue
memberName :: Maybe Text
memberId :: Maybe Text
$sel:vote:VoteSummary' :: VoteSummary -> Maybe VoteValue
$sel:memberName:VoteSummary' :: VoteSummary -> Maybe Text
$sel:memberId:VoteSummary' :: VoteSummary -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
memberId
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
memberName
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe VoteValue
vote