{-# 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.Location.Types.TruckWeight
-- 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.Location.Types.TruckWeight where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Location.Types.VehicleWeightUnit
import qualified Amazonka.Prelude as Prelude

-- | Contains details about the truck\'s weight specifications. Used to avoid
-- roads that can\'t support or allow the total weight for requests that
-- specify @TravelMode@ as @Truck@.
--
-- /See:/ 'newTruckWeight' smart constructor.
data TruckWeight = TruckWeight'
  { -- | The total weight of the truck.
    --
    -- -   For example, @3500@.
    TruckWeight -> Maybe Double
total :: Prelude.Maybe Prelude.Double,
    -- | The unit of measurement to use for the truck weight.
    --
    -- Default Value: @Kilograms@
    TruckWeight -> Maybe VehicleWeightUnit
unit :: Prelude.Maybe VehicleWeightUnit
  }
  deriving (TruckWeight -> TruckWeight -> Bool
(TruckWeight -> TruckWeight -> Bool)
-> (TruckWeight -> TruckWeight -> Bool) -> Eq TruckWeight
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: TruckWeight -> TruckWeight -> Bool
$c/= :: TruckWeight -> TruckWeight -> Bool
== :: TruckWeight -> TruckWeight -> Bool
$c== :: TruckWeight -> TruckWeight -> Bool
Prelude.Eq, ReadPrec [TruckWeight]
ReadPrec TruckWeight
Int -> ReadS TruckWeight
ReadS [TruckWeight]
(Int -> ReadS TruckWeight)
-> ReadS [TruckWeight]
-> ReadPrec TruckWeight
-> ReadPrec [TruckWeight]
-> Read TruckWeight
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [TruckWeight]
$creadListPrec :: ReadPrec [TruckWeight]
readPrec :: ReadPrec TruckWeight
$creadPrec :: ReadPrec TruckWeight
readList :: ReadS [TruckWeight]
$creadList :: ReadS [TruckWeight]
readsPrec :: Int -> ReadS TruckWeight
$creadsPrec :: Int -> ReadS TruckWeight
Prelude.Read, Int -> TruckWeight -> ShowS
[TruckWeight] -> ShowS
TruckWeight -> String
(Int -> TruckWeight -> ShowS)
-> (TruckWeight -> String)
-> ([TruckWeight] -> ShowS)
-> Show TruckWeight
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [TruckWeight] -> ShowS
$cshowList :: [TruckWeight] -> ShowS
show :: TruckWeight -> String
$cshow :: TruckWeight -> String
showsPrec :: Int -> TruckWeight -> ShowS
$cshowsPrec :: Int -> TruckWeight -> ShowS
Prelude.Show, (forall x. TruckWeight -> Rep TruckWeight x)
-> (forall x. Rep TruckWeight x -> TruckWeight)
-> Generic TruckWeight
forall x. Rep TruckWeight x -> TruckWeight
forall x. TruckWeight -> Rep TruckWeight x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep TruckWeight x -> TruckWeight
$cfrom :: forall x. TruckWeight -> Rep TruckWeight x
Prelude.Generic)

-- |
-- Create a value of 'TruckWeight' 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:
--
-- 'total', 'truckWeight_total' - The total weight of the truck.
--
-- -   For example, @3500@.
--
-- 'unit', 'truckWeight_unit' - The unit of measurement to use for the truck weight.
--
-- Default Value: @Kilograms@
newTruckWeight ::
  TruckWeight
newTruckWeight :: TruckWeight
newTruckWeight =
  TruckWeight' :: Maybe Double -> Maybe VehicleWeightUnit -> TruckWeight
TruckWeight'
    { $sel:total:TruckWeight' :: Maybe Double
total = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:unit:TruckWeight' :: Maybe VehicleWeightUnit
unit = Maybe VehicleWeightUnit
forall a. Maybe a
Prelude.Nothing
    }

-- | The total weight of the truck.
--
-- -   For example, @3500@.
truckWeight_total :: Lens.Lens' TruckWeight (Prelude.Maybe Prelude.Double)
truckWeight_total :: (Maybe Double -> f (Maybe Double)) -> TruckWeight -> f TruckWeight
truckWeight_total = (TruckWeight -> Maybe Double)
-> (TruckWeight -> Maybe Double -> TruckWeight)
-> Lens TruckWeight TruckWeight (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TruckWeight' {Maybe Double
total :: Maybe Double
$sel:total:TruckWeight' :: TruckWeight -> Maybe Double
total} -> Maybe Double
total) (\s :: TruckWeight
s@TruckWeight' {} Maybe Double
a -> TruckWeight
s {$sel:total:TruckWeight' :: Maybe Double
total = Maybe Double
a} :: TruckWeight)

-- | The unit of measurement to use for the truck weight.
--
-- Default Value: @Kilograms@
truckWeight_unit :: Lens.Lens' TruckWeight (Prelude.Maybe VehicleWeightUnit)
truckWeight_unit :: (Maybe VehicleWeightUnit -> f (Maybe VehicleWeightUnit))
-> TruckWeight -> f TruckWeight
truckWeight_unit = (TruckWeight -> Maybe VehicleWeightUnit)
-> (TruckWeight -> Maybe VehicleWeightUnit -> TruckWeight)
-> Lens
     TruckWeight
     TruckWeight
     (Maybe VehicleWeightUnit)
     (Maybe VehicleWeightUnit)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\TruckWeight' {Maybe VehicleWeightUnit
unit :: Maybe VehicleWeightUnit
$sel:unit:TruckWeight' :: TruckWeight -> Maybe VehicleWeightUnit
unit} -> Maybe VehicleWeightUnit
unit) (\s :: TruckWeight
s@TruckWeight' {} Maybe VehicleWeightUnit
a -> TruckWeight
s {$sel:unit:TruckWeight' :: Maybe VehicleWeightUnit
unit = Maybe VehicleWeightUnit
a} :: TruckWeight)

instance Prelude.Hashable TruckWeight

instance Prelude.NFData TruckWeight

instance Core.ToJSON TruckWeight where
  toJSON :: TruckWeight -> Value
toJSON TruckWeight' {Maybe Double
Maybe VehicleWeightUnit
unit :: Maybe VehicleWeightUnit
total :: Maybe Double
$sel:unit:TruckWeight' :: TruckWeight -> Maybe VehicleWeightUnit
$sel:total:TruckWeight' :: TruckWeight -> Maybe Double
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Total" Text -> Double -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Double -> Pair) -> Maybe Double -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Double
total,
            (Text
"Unit" Text -> VehicleWeightUnit -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (VehicleWeightUnit -> Pair)
-> Maybe VehicleWeightUnit -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe VehicleWeightUnit
unit
          ]
      )