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

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
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 name of the member that cast the vote.
    VoteSummary -> Maybe Text
memberName :: Prelude.Maybe Prelude.Text,
    -- | The unique identifier of the member that cast the vote.
    VoteSummary -> Maybe Text
memberId :: Prelude.Maybe Prelude.Text,
    -- | The vote value, either @YES@ or @NO@.
    VoteSummary -> Maybe VoteValue
vote :: Prelude.Maybe VoteValue
  }
  deriving (VoteSummary -> VoteSummary -> Bool
(VoteSummary -> VoteSummary -> Bool)
-> (VoteSummary -> VoteSummary -> Bool) -> Eq VoteSummary
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]
(Int -> ReadS VoteSummary)
-> ReadS [VoteSummary]
-> ReadPrec VoteSummary
-> ReadPrec [VoteSummary]
-> Read 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
(Int -> VoteSummary -> ShowS)
-> (VoteSummary -> String)
-> ([VoteSummary] -> ShowS)
-> Show VoteSummary
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. VoteSummary -> Rep VoteSummary x)
-> (forall x. Rep VoteSummary x -> VoteSummary)
-> Generic VoteSummary
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:
--
-- 'memberName', 'voteSummary_memberName' - The name of the member that cast the vote.
--
-- 'memberId', 'voteSummary_memberId' - The unique identifier of the member that cast the vote.
--
-- 'vote', 'voteSummary_vote' - The vote value, either @YES@ or @NO@.
newVoteSummary ::
  VoteSummary
newVoteSummary :: VoteSummary
newVoteSummary =
  VoteSummary' :: Maybe Text -> Maybe Text -> Maybe VoteValue -> VoteSummary
VoteSummary'
    { $sel:memberName:VoteSummary' :: Maybe Text
memberName = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:memberId:VoteSummary' :: Maybe Text
memberId = Maybe Text
forall a. Maybe a
Prelude.Nothing,
      $sel:vote:VoteSummary' :: Maybe VoteValue
vote = Maybe VoteValue
forall a. Maybe a
Prelude.Nothing
    }

-- | The name of the member that cast the vote.
voteSummary_memberName :: Lens.Lens' VoteSummary (Prelude.Maybe Prelude.Text)
voteSummary_memberName :: (Maybe Text -> f (Maybe Text)) -> VoteSummary -> f VoteSummary
voteSummary_memberName = (VoteSummary -> Maybe Text)
-> (VoteSummary -> Maybe Text -> VoteSummary)
-> Lens VoteSummary VoteSummary (Maybe Text) (Maybe Text)
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 unique identifier of the member that cast the vote.
voteSummary_memberId :: Lens.Lens' VoteSummary (Prelude.Maybe Prelude.Text)
voteSummary_memberId :: (Maybe Text -> f (Maybe Text)) -> VoteSummary -> f VoteSummary
voteSummary_memberId = (VoteSummary -> Maybe Text)
-> (VoteSummary -> Maybe Text -> VoteSummary)
-> Lens VoteSummary VoteSummary (Maybe Text) (Maybe Text)
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 vote value, either @YES@ or @NO@.
voteSummary_vote :: Lens.Lens' VoteSummary (Prelude.Maybe VoteValue)
voteSummary_vote :: (Maybe VoteValue -> f (Maybe VoteValue))
-> VoteSummary -> f VoteSummary
voteSummary_vote = (VoteSummary -> Maybe VoteValue)
-> (VoteSummary -> Maybe VoteValue -> VoteSummary)
-> Lens VoteSummary VoteSummary (Maybe VoteValue) (Maybe VoteValue)
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 Core.FromJSON VoteSummary where
  parseJSON :: Value -> Parser VoteSummary
parseJSON =
    String
-> (Object -> Parser VoteSummary) -> Value -> Parser VoteSummary
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"VoteSummary"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe VoteValue -> VoteSummary
VoteSummary'
            (Maybe Text -> Maybe Text -> Maybe VoteValue -> VoteSummary)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe VoteValue -> VoteSummary)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MemberName")
            Parser (Maybe Text -> Maybe VoteValue -> VoteSummary)
-> Parser (Maybe Text) -> Parser (Maybe VoteValue -> VoteSummary)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MemberId")
            Parser (Maybe VoteValue -> VoteSummary)
-> Parser (Maybe VoteValue) -> Parser VoteSummary
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe VoteValue)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Vote")
      )

instance Prelude.Hashable VoteSummary

instance Prelude.NFData VoteSummary