{-# 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.DeviceFarm.Types.TrialMinutes
-- 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.DeviceFarm.Types.TrialMinutes where

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

-- | Represents information about free trial device minutes for an AWS
-- account.
--
-- /See:/ 'newTrialMinutes' smart constructor.
data TrialMinutes = TrialMinutes'
  { -- | The number of free trial minutes remaining in the account.
    TrialMinutes -> Maybe Double
remaining :: Prelude.Maybe Prelude.Double,
    -- | The total number of free trial minutes that the account started with.
    TrialMinutes -> Maybe Double
total :: Prelude.Maybe Prelude.Double
  }
  deriving (TrialMinutes -> TrialMinutes -> Bool
(TrialMinutes -> TrialMinutes -> Bool)
-> (TrialMinutes -> TrialMinutes -> Bool) -> Eq TrialMinutes
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TrialMinutes -> TrialMinutes -> Bool
$c/= :: TrialMinutes -> TrialMinutes -> Bool
== :: TrialMinutes -> TrialMinutes -> Bool
$c== :: TrialMinutes -> TrialMinutes -> Bool
Prelude.Eq, ReadPrec [TrialMinutes]
ReadPrec TrialMinutes
Int -> ReadS TrialMinutes
ReadS [TrialMinutes]
(Int -> ReadS TrialMinutes)
-> ReadS [TrialMinutes]
-> ReadPrec TrialMinutes
-> ReadPrec [TrialMinutes]
-> Read TrialMinutes
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TrialMinutes]
$creadListPrec :: ReadPrec [TrialMinutes]
readPrec :: ReadPrec TrialMinutes
$creadPrec :: ReadPrec TrialMinutes
readList :: ReadS [TrialMinutes]
$creadList :: ReadS [TrialMinutes]
readsPrec :: Int -> ReadS TrialMinutes
$creadsPrec :: Int -> ReadS TrialMinutes
Prelude.Read, Int -> TrialMinutes -> ShowS
[TrialMinutes] -> ShowS
TrialMinutes -> String
(Int -> TrialMinutes -> ShowS)
-> (TrialMinutes -> String)
-> ([TrialMinutes] -> ShowS)
-> Show TrialMinutes
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TrialMinutes] -> ShowS
$cshowList :: [TrialMinutes] -> ShowS
show :: TrialMinutes -> String
$cshow :: TrialMinutes -> String
showsPrec :: Int -> TrialMinutes -> ShowS
$cshowsPrec :: Int -> TrialMinutes -> ShowS
Prelude.Show, (forall x. TrialMinutes -> Rep TrialMinutes x)
-> (forall x. Rep TrialMinutes x -> TrialMinutes)
-> Generic TrialMinutes
forall x. Rep TrialMinutes x -> TrialMinutes
forall x. TrialMinutes -> Rep TrialMinutes x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TrialMinutes x -> TrialMinutes
$cfrom :: forall x. TrialMinutes -> Rep TrialMinutes x
Prelude.Generic)

-- |
-- Create a value of 'TrialMinutes' 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:
--
-- 'remaining', 'trialMinutes_remaining' - The number of free trial minutes remaining in the account.
--
-- 'total', 'trialMinutes_total' - The total number of free trial minutes that the account started with.
newTrialMinutes ::
  TrialMinutes
newTrialMinutes :: TrialMinutes
newTrialMinutes =
  TrialMinutes' :: Maybe Double -> Maybe Double -> TrialMinutes
TrialMinutes'
    { $sel:remaining:TrialMinutes' :: Maybe Double
remaining = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:total:TrialMinutes' :: Maybe Double
total = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | The number of free trial minutes remaining in the account.
trialMinutes_remaining :: Lens.Lens' TrialMinutes (Prelude.Maybe Prelude.Double)
trialMinutes_remaining :: (Maybe Double -> f (Maybe Double))
-> TrialMinutes -> f TrialMinutes
trialMinutes_remaining = (TrialMinutes -> Maybe Double)
-> (TrialMinutes -> Maybe Double -> TrialMinutes)
-> Lens TrialMinutes TrialMinutes (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrialMinutes' {Maybe Double
remaining :: Maybe Double
$sel:remaining:TrialMinutes' :: TrialMinutes -> Maybe Double
remaining} -> Maybe Double
remaining) (\s :: TrialMinutes
s@TrialMinutes' {} Maybe Double
a -> TrialMinutes
s {$sel:remaining:TrialMinutes' :: Maybe Double
remaining = Maybe Double
a} :: TrialMinutes)

-- | The total number of free trial minutes that the account started with.
trialMinutes_total :: Lens.Lens' TrialMinutes (Prelude.Maybe Prelude.Double)
trialMinutes_total :: (Maybe Double -> f (Maybe Double))
-> TrialMinutes -> f TrialMinutes
trialMinutes_total = (TrialMinutes -> Maybe Double)
-> (TrialMinutes -> Maybe Double -> TrialMinutes)
-> Lens TrialMinutes TrialMinutes (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TrialMinutes' {Maybe Double
total :: Maybe Double
$sel:total:TrialMinutes' :: TrialMinutes -> Maybe Double
total} -> Maybe Double
total) (\s :: TrialMinutes
s@TrialMinutes' {} Maybe Double
a -> TrialMinutes
s {$sel:total:TrialMinutes' :: Maybe Double
total = Maybe Double
a} :: TrialMinutes)

instance Core.FromJSON TrialMinutes where
  parseJSON :: Value -> Parser TrialMinutes
parseJSON =
    String
-> (Object -> Parser TrialMinutes) -> Value -> Parser TrialMinutes
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"TrialMinutes"
      ( \Object
x ->
          Maybe Double -> Maybe Double -> TrialMinutes
TrialMinutes'
            (Maybe Double -> Maybe Double -> TrialMinutes)
-> Parser (Maybe Double) -> Parser (Maybe Double -> TrialMinutes)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"remaining")
            Parser (Maybe Double -> TrialMinutes)
-> Parser (Maybe Double) -> Parser TrialMinutes
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Double)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"total")
      )

instance Prelude.Hashable TrialMinutes

instance Prelude.NFData TrialMinutes