{-# 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.OfferingStatus
-- 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.OfferingStatus where

import qualified Amazonka.Core as Core
import Amazonka.DeviceFarm.Types.Offering
import Amazonka.DeviceFarm.Types.OfferingTransactionType
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | The status of the offering.
--
-- /See:/ 'newOfferingStatus' smart constructor.
data OfferingStatus = OfferingStatus'
  { -- | The date on which the offering is effective.
    OfferingStatus -> Maybe POSIX
effectiveOn :: Prelude.Maybe Core.POSIX,
    -- | Represents the metadata of an offering status.
    OfferingStatus -> Maybe Offering
offering :: Prelude.Maybe Offering,
    -- | The number of available devices in the offering.
    OfferingStatus -> Maybe Int
quantity :: Prelude.Maybe Prelude.Int,
    -- | The type specified for the offering status.
    OfferingStatus -> Maybe OfferingTransactionType
type' :: Prelude.Maybe OfferingTransactionType
  }
  deriving (OfferingStatus -> OfferingStatus -> Bool
(OfferingStatus -> OfferingStatus -> Bool)
-> (OfferingStatus -> OfferingStatus -> Bool) -> Eq OfferingStatus
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: OfferingStatus -> OfferingStatus -> Bool
$c/= :: OfferingStatus -> OfferingStatus -> Bool
== :: OfferingStatus -> OfferingStatus -> Bool
$c== :: OfferingStatus -> OfferingStatus -> Bool
Prelude.Eq, ReadPrec [OfferingStatus]
ReadPrec OfferingStatus
Int -> ReadS OfferingStatus
ReadS [OfferingStatus]
(Int -> ReadS OfferingStatus)
-> ReadS [OfferingStatus]
-> ReadPrec OfferingStatus
-> ReadPrec [OfferingStatus]
-> Read OfferingStatus
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [OfferingStatus]
$creadListPrec :: ReadPrec [OfferingStatus]
readPrec :: ReadPrec OfferingStatus
$creadPrec :: ReadPrec OfferingStatus
readList :: ReadS [OfferingStatus]
$creadList :: ReadS [OfferingStatus]
readsPrec :: Int -> ReadS OfferingStatus
$creadsPrec :: Int -> ReadS OfferingStatus
Prelude.Read, Int -> OfferingStatus -> ShowS
[OfferingStatus] -> ShowS
OfferingStatus -> String
(Int -> OfferingStatus -> ShowS)
-> (OfferingStatus -> String)
-> ([OfferingStatus] -> ShowS)
-> Show OfferingStatus
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [OfferingStatus] -> ShowS
$cshowList :: [OfferingStatus] -> ShowS
show :: OfferingStatus -> String
$cshow :: OfferingStatus -> String
showsPrec :: Int -> OfferingStatus -> ShowS
$cshowsPrec :: Int -> OfferingStatus -> ShowS
Prelude.Show, (forall x. OfferingStatus -> Rep OfferingStatus x)
-> (forall x. Rep OfferingStatus x -> OfferingStatus)
-> Generic OfferingStatus
forall x. Rep OfferingStatus x -> OfferingStatus
forall x. OfferingStatus -> Rep OfferingStatus x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep OfferingStatus x -> OfferingStatus
$cfrom :: forall x. OfferingStatus -> Rep OfferingStatus x
Prelude.Generic)

-- |
-- Create a value of 'OfferingStatus' 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:
--
-- 'effectiveOn', 'offeringStatus_effectiveOn' - The date on which the offering is effective.
--
-- 'offering', 'offeringStatus_offering' - Represents the metadata of an offering status.
--
-- 'quantity', 'offeringStatus_quantity' - The number of available devices in the offering.
--
-- 'type'', 'offeringStatus_type' - The type specified for the offering status.
newOfferingStatus ::
  OfferingStatus
newOfferingStatus :: OfferingStatus
newOfferingStatus =
  OfferingStatus' :: Maybe POSIX
-> Maybe Offering
-> Maybe Int
-> Maybe OfferingTransactionType
-> OfferingStatus
OfferingStatus'
    { $sel:effectiveOn:OfferingStatus' :: Maybe POSIX
effectiveOn = Maybe POSIX
forall a. Maybe a
Prelude.Nothing,
      $sel:offering:OfferingStatus' :: Maybe Offering
offering = Maybe Offering
forall a. Maybe a
Prelude.Nothing,
      $sel:quantity:OfferingStatus' :: Maybe Int
quantity = Maybe Int
forall a. Maybe a
Prelude.Nothing,
      $sel:type':OfferingStatus' :: Maybe OfferingTransactionType
type' = Maybe OfferingTransactionType
forall a. Maybe a
Prelude.Nothing
    }

-- | The date on which the offering is effective.
offeringStatus_effectiveOn :: Lens.Lens' OfferingStatus (Prelude.Maybe Prelude.UTCTime)
offeringStatus_effectiveOn :: (Maybe UTCTime -> f (Maybe UTCTime))
-> OfferingStatus -> f OfferingStatus
offeringStatus_effectiveOn = (OfferingStatus -> Maybe POSIX)
-> (OfferingStatus -> Maybe POSIX -> OfferingStatus)
-> Lens OfferingStatus OfferingStatus (Maybe POSIX) (Maybe POSIX)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OfferingStatus' {Maybe POSIX
effectiveOn :: Maybe POSIX
$sel:effectiveOn:OfferingStatus' :: OfferingStatus -> Maybe POSIX
effectiveOn} -> Maybe POSIX
effectiveOn) (\s :: OfferingStatus
s@OfferingStatus' {} Maybe POSIX
a -> OfferingStatus
s {$sel:effectiveOn:OfferingStatus' :: Maybe POSIX
effectiveOn = Maybe POSIX
a} :: OfferingStatus) ((Maybe POSIX -> f (Maybe POSIX))
 -> OfferingStatus -> f OfferingStatus)
-> ((Maybe UTCTime -> f (Maybe UTCTime))
    -> Maybe POSIX -> f (Maybe POSIX))
-> (Maybe UTCTime -> f (Maybe UTCTime))
-> OfferingStatus
-> f OfferingStatus
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso POSIX POSIX UTCTime UTCTime
-> Iso (Maybe POSIX) (Maybe POSIX) (Maybe UTCTime) (Maybe UTCTime)
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso POSIX POSIX UTCTime UTCTime
forall (a :: Format). Iso' (Time a) UTCTime
Core._Time

-- | Represents the metadata of an offering status.
offeringStatus_offering :: Lens.Lens' OfferingStatus (Prelude.Maybe Offering)
offeringStatus_offering :: (Maybe Offering -> f (Maybe Offering))
-> OfferingStatus -> f OfferingStatus
offeringStatus_offering = (OfferingStatus -> Maybe Offering)
-> (OfferingStatus -> Maybe Offering -> OfferingStatus)
-> Lens
     OfferingStatus OfferingStatus (Maybe Offering) (Maybe Offering)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OfferingStatus' {Maybe Offering
offering :: Maybe Offering
$sel:offering:OfferingStatus' :: OfferingStatus -> Maybe Offering
offering} -> Maybe Offering
offering) (\s :: OfferingStatus
s@OfferingStatus' {} Maybe Offering
a -> OfferingStatus
s {$sel:offering:OfferingStatus' :: Maybe Offering
offering = Maybe Offering
a} :: OfferingStatus)

-- | The number of available devices in the offering.
offeringStatus_quantity :: Lens.Lens' OfferingStatus (Prelude.Maybe Prelude.Int)
offeringStatus_quantity :: (Maybe Int -> f (Maybe Int)) -> OfferingStatus -> f OfferingStatus
offeringStatus_quantity = (OfferingStatus -> Maybe Int)
-> (OfferingStatus -> Maybe Int -> OfferingStatus)
-> Lens OfferingStatus OfferingStatus (Maybe Int) (Maybe Int)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OfferingStatus' {Maybe Int
quantity :: Maybe Int
$sel:quantity:OfferingStatus' :: OfferingStatus -> Maybe Int
quantity} -> Maybe Int
quantity) (\s :: OfferingStatus
s@OfferingStatus' {} Maybe Int
a -> OfferingStatus
s {$sel:quantity:OfferingStatus' :: Maybe Int
quantity = Maybe Int
a} :: OfferingStatus)

-- | The type specified for the offering status.
offeringStatus_type :: Lens.Lens' OfferingStatus (Prelude.Maybe OfferingTransactionType)
offeringStatus_type :: (Maybe OfferingTransactionType
 -> f (Maybe OfferingTransactionType))
-> OfferingStatus -> f OfferingStatus
offeringStatus_type = (OfferingStatus -> Maybe OfferingTransactionType)
-> (OfferingStatus
    -> Maybe OfferingTransactionType -> OfferingStatus)
-> Lens
     OfferingStatus
     OfferingStatus
     (Maybe OfferingTransactionType)
     (Maybe OfferingTransactionType)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\OfferingStatus' {Maybe OfferingTransactionType
type' :: Maybe OfferingTransactionType
$sel:type':OfferingStatus' :: OfferingStatus -> Maybe OfferingTransactionType
type'} -> Maybe OfferingTransactionType
type') (\s :: OfferingStatus
s@OfferingStatus' {} Maybe OfferingTransactionType
a -> OfferingStatus
s {$sel:type':OfferingStatus' :: Maybe OfferingTransactionType
type' = Maybe OfferingTransactionType
a} :: OfferingStatus)

instance Core.FromJSON OfferingStatus where
  parseJSON :: Value -> Parser OfferingStatus
parseJSON =
    String
-> (Object -> Parser OfferingStatus)
-> Value
-> Parser OfferingStatus
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"OfferingStatus"
      ( \Object
x ->
          Maybe POSIX
-> Maybe Offering
-> Maybe Int
-> Maybe OfferingTransactionType
-> OfferingStatus
OfferingStatus'
            (Maybe POSIX
 -> Maybe Offering
 -> Maybe Int
 -> Maybe OfferingTransactionType
 -> OfferingStatus)
-> Parser (Maybe POSIX)
-> Parser
     (Maybe Offering
      -> Maybe Int -> Maybe OfferingTransactionType -> OfferingStatus)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe POSIX)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"effectiveOn")
            Parser
  (Maybe Offering
   -> Maybe Int -> Maybe OfferingTransactionType -> OfferingStatus)
-> Parser (Maybe Offering)
-> Parser
     (Maybe Int -> Maybe OfferingTransactionType -> OfferingStatus)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Offering)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"offering")
            Parser
  (Maybe Int -> Maybe OfferingTransactionType -> OfferingStatus)
-> Parser (Maybe Int)
-> Parser (Maybe OfferingTransactionType -> OfferingStatus)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Int)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"quantity")
            Parser (Maybe OfferingTransactionType -> OfferingStatus)
-> Parser (Maybe OfferingTransactionType) -> Parser OfferingStatus
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe OfferingTransactionType)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"type")
      )

instance Prelude.Hashable OfferingStatus

instance Prelude.NFData OfferingStatus