{-# 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.Pinpoint.Types.SegmentDimensions
-- 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.Pinpoint.Types.SegmentDimensions where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import Amazonka.Pinpoint.Types.AttributeDimension
import Amazonka.Pinpoint.Types.MetricDimension
import Amazonka.Pinpoint.Types.SegmentBehaviors
import Amazonka.Pinpoint.Types.SegmentDemographics
import Amazonka.Pinpoint.Types.SegmentLocation
import qualified Amazonka.Prelude as Prelude

-- | Specifies the dimension settings for a segment.
--
-- /See:/ 'newSegmentDimensions' smart constructor.
data SegmentDimensions = SegmentDimensions'
  { -- | One or more custom metrics to use as criteria for the segment.
    SegmentDimensions -> Maybe (HashMap Text MetricDimension)
metrics :: Prelude.Maybe (Prelude.HashMap Prelude.Text MetricDimension),
    -- | The location-based criteria, such as region or GPS coordinates, for the
    -- segment.
    SegmentDimensions -> Maybe SegmentLocation
location :: Prelude.Maybe SegmentLocation,
    -- | The demographic-based criteria, such as device platform, for the
    -- segment.
    SegmentDimensions -> Maybe SegmentDemographics
demographic :: Prelude.Maybe SegmentDemographics,
    -- | One or more custom user attributes to use as criteria for the segment.
    SegmentDimensions -> Maybe (HashMap Text AttributeDimension)
userAttributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeDimension),
    -- | The behavior-based criteria, such as how recently users have used your
    -- app, for the segment.
    SegmentDimensions -> Maybe SegmentBehaviors
behavior :: Prelude.Maybe SegmentBehaviors,
    -- | One or more custom attributes to use as criteria for the segment.
    SegmentDimensions -> Maybe (HashMap Text AttributeDimension)
attributes :: Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeDimension)
  }
  deriving (SegmentDimensions -> SegmentDimensions -> Bool
(SegmentDimensions -> SegmentDimensions -> Bool)
-> (SegmentDimensions -> SegmentDimensions -> Bool)
-> Eq SegmentDimensions
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SegmentDimensions -> SegmentDimensions -> Bool
$c/= :: SegmentDimensions -> SegmentDimensions -> Bool
== :: SegmentDimensions -> SegmentDimensions -> Bool
$c== :: SegmentDimensions -> SegmentDimensions -> Bool
Prelude.Eq, ReadPrec [SegmentDimensions]
ReadPrec SegmentDimensions
Int -> ReadS SegmentDimensions
ReadS [SegmentDimensions]
(Int -> ReadS SegmentDimensions)
-> ReadS [SegmentDimensions]
-> ReadPrec SegmentDimensions
-> ReadPrec [SegmentDimensions]
-> Read SegmentDimensions
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SegmentDimensions]
$creadListPrec :: ReadPrec [SegmentDimensions]
readPrec :: ReadPrec SegmentDimensions
$creadPrec :: ReadPrec SegmentDimensions
readList :: ReadS [SegmentDimensions]
$creadList :: ReadS [SegmentDimensions]
readsPrec :: Int -> ReadS SegmentDimensions
$creadsPrec :: Int -> ReadS SegmentDimensions
Prelude.Read, Int -> SegmentDimensions -> ShowS
[SegmentDimensions] -> ShowS
SegmentDimensions -> String
(Int -> SegmentDimensions -> ShowS)
-> (SegmentDimensions -> String)
-> ([SegmentDimensions] -> ShowS)
-> Show SegmentDimensions
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SegmentDimensions] -> ShowS
$cshowList :: [SegmentDimensions] -> ShowS
show :: SegmentDimensions -> String
$cshow :: SegmentDimensions -> String
showsPrec :: Int -> SegmentDimensions -> ShowS
$cshowsPrec :: Int -> SegmentDimensions -> ShowS
Prelude.Show, (forall x. SegmentDimensions -> Rep SegmentDimensions x)
-> (forall x. Rep SegmentDimensions x -> SegmentDimensions)
-> Generic SegmentDimensions
forall x. Rep SegmentDimensions x -> SegmentDimensions
forall x. SegmentDimensions -> Rep SegmentDimensions x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SegmentDimensions x -> SegmentDimensions
$cfrom :: forall x. SegmentDimensions -> Rep SegmentDimensions x
Prelude.Generic)

-- |
-- Create a value of 'SegmentDimensions' 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:
--
-- 'metrics', 'segmentDimensions_metrics' - One or more custom metrics to use as criteria for the segment.
--
-- 'location', 'segmentDimensions_location' - The location-based criteria, such as region or GPS coordinates, for the
-- segment.
--
-- 'demographic', 'segmentDimensions_demographic' - The demographic-based criteria, such as device platform, for the
-- segment.
--
-- 'userAttributes', 'segmentDimensions_userAttributes' - One or more custom user attributes to use as criteria for the segment.
--
-- 'behavior', 'segmentDimensions_behavior' - The behavior-based criteria, such as how recently users have used your
-- app, for the segment.
--
-- 'attributes', 'segmentDimensions_attributes' - One or more custom attributes to use as criteria for the segment.
newSegmentDimensions ::
  SegmentDimensions
newSegmentDimensions :: SegmentDimensions
newSegmentDimensions =
  SegmentDimensions' :: Maybe (HashMap Text MetricDimension)
-> Maybe SegmentLocation
-> Maybe SegmentDemographics
-> Maybe (HashMap Text AttributeDimension)
-> Maybe SegmentBehaviors
-> Maybe (HashMap Text AttributeDimension)
-> SegmentDimensions
SegmentDimensions'
    { $sel:metrics:SegmentDimensions' :: Maybe (HashMap Text MetricDimension)
metrics = Maybe (HashMap Text MetricDimension)
forall a. Maybe a
Prelude.Nothing,
      $sel:location:SegmentDimensions' :: Maybe SegmentLocation
location = Maybe SegmentLocation
forall a. Maybe a
Prelude.Nothing,
      $sel:demographic:SegmentDimensions' :: Maybe SegmentDemographics
demographic = Maybe SegmentDemographics
forall a. Maybe a
Prelude.Nothing,
      $sel:userAttributes:SegmentDimensions' :: Maybe (HashMap Text AttributeDimension)
userAttributes = Maybe (HashMap Text AttributeDimension)
forall a. Maybe a
Prelude.Nothing,
      $sel:behavior:SegmentDimensions' :: Maybe SegmentBehaviors
behavior = Maybe SegmentBehaviors
forall a. Maybe a
Prelude.Nothing,
      $sel:attributes:SegmentDimensions' :: Maybe (HashMap Text AttributeDimension)
attributes = Maybe (HashMap Text AttributeDimension)
forall a. Maybe a
Prelude.Nothing
    }

-- | One or more custom metrics to use as criteria for the segment.
segmentDimensions_metrics :: Lens.Lens' SegmentDimensions (Prelude.Maybe (Prelude.HashMap Prelude.Text MetricDimension))
segmentDimensions_metrics :: (Maybe (HashMap Text MetricDimension)
 -> f (Maybe (HashMap Text MetricDimension)))
-> SegmentDimensions -> f SegmentDimensions
segmentDimensions_metrics = (SegmentDimensions -> Maybe (HashMap Text MetricDimension))
-> (SegmentDimensions
    -> Maybe (HashMap Text MetricDimension) -> SegmentDimensions)
-> Lens
     SegmentDimensions
     SegmentDimensions
     (Maybe (HashMap Text MetricDimension))
     (Maybe (HashMap Text MetricDimension))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SegmentDimensions' {Maybe (HashMap Text MetricDimension)
metrics :: Maybe (HashMap Text MetricDimension)
$sel:metrics:SegmentDimensions' :: SegmentDimensions -> Maybe (HashMap Text MetricDimension)
metrics} -> Maybe (HashMap Text MetricDimension)
metrics) (\s :: SegmentDimensions
s@SegmentDimensions' {} Maybe (HashMap Text MetricDimension)
a -> SegmentDimensions
s {$sel:metrics:SegmentDimensions' :: Maybe (HashMap Text MetricDimension)
metrics = Maybe (HashMap Text MetricDimension)
a} :: SegmentDimensions) ((Maybe (HashMap Text MetricDimension)
  -> f (Maybe (HashMap Text MetricDimension)))
 -> SegmentDimensions -> f SegmentDimensions)
-> ((Maybe (HashMap Text MetricDimension)
     -> f (Maybe (HashMap Text MetricDimension)))
    -> Maybe (HashMap Text MetricDimension)
    -> f (Maybe (HashMap Text MetricDimension)))
-> (Maybe (HashMap Text MetricDimension)
    -> f (Maybe (HashMap Text MetricDimension)))
-> SegmentDimensions
-> f SegmentDimensions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text MetricDimension)
  (HashMap Text MetricDimension)
  (HashMap Text MetricDimension)
  (HashMap Text MetricDimension)
-> Iso
     (Maybe (HashMap Text MetricDimension))
     (Maybe (HashMap Text MetricDimension))
     (Maybe (HashMap Text MetricDimension))
     (Maybe (HashMap Text MetricDimension))
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
  (HashMap Text MetricDimension)
  (HashMap Text MetricDimension)
  (HashMap Text MetricDimension)
  (HashMap Text MetricDimension)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The location-based criteria, such as region or GPS coordinates, for the
-- segment.
segmentDimensions_location :: Lens.Lens' SegmentDimensions (Prelude.Maybe SegmentLocation)
segmentDimensions_location :: (Maybe SegmentLocation -> f (Maybe SegmentLocation))
-> SegmentDimensions -> f SegmentDimensions
segmentDimensions_location = (SegmentDimensions -> Maybe SegmentLocation)
-> (SegmentDimensions
    -> Maybe SegmentLocation -> SegmentDimensions)
-> Lens
     SegmentDimensions
     SegmentDimensions
     (Maybe SegmentLocation)
     (Maybe SegmentLocation)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SegmentDimensions' {Maybe SegmentLocation
location :: Maybe SegmentLocation
$sel:location:SegmentDimensions' :: SegmentDimensions -> Maybe SegmentLocation
location} -> Maybe SegmentLocation
location) (\s :: SegmentDimensions
s@SegmentDimensions' {} Maybe SegmentLocation
a -> SegmentDimensions
s {$sel:location:SegmentDimensions' :: Maybe SegmentLocation
location = Maybe SegmentLocation
a} :: SegmentDimensions)

-- | The demographic-based criteria, such as device platform, for the
-- segment.
segmentDimensions_demographic :: Lens.Lens' SegmentDimensions (Prelude.Maybe SegmentDemographics)
segmentDimensions_demographic :: (Maybe SegmentDemographics -> f (Maybe SegmentDemographics))
-> SegmentDimensions -> f SegmentDimensions
segmentDimensions_demographic = (SegmentDimensions -> Maybe SegmentDemographics)
-> (SegmentDimensions
    -> Maybe SegmentDemographics -> SegmentDimensions)
-> Lens
     SegmentDimensions
     SegmentDimensions
     (Maybe SegmentDemographics)
     (Maybe SegmentDemographics)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SegmentDimensions' {Maybe SegmentDemographics
demographic :: Maybe SegmentDemographics
$sel:demographic:SegmentDimensions' :: SegmentDimensions -> Maybe SegmentDemographics
demographic} -> Maybe SegmentDemographics
demographic) (\s :: SegmentDimensions
s@SegmentDimensions' {} Maybe SegmentDemographics
a -> SegmentDimensions
s {$sel:demographic:SegmentDimensions' :: Maybe SegmentDemographics
demographic = Maybe SegmentDemographics
a} :: SegmentDimensions)

-- | One or more custom user attributes to use as criteria for the segment.
segmentDimensions_userAttributes :: Lens.Lens' SegmentDimensions (Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeDimension))
segmentDimensions_userAttributes :: (Maybe (HashMap Text AttributeDimension)
 -> f (Maybe (HashMap Text AttributeDimension)))
-> SegmentDimensions -> f SegmentDimensions
segmentDimensions_userAttributes = (SegmentDimensions -> Maybe (HashMap Text AttributeDimension))
-> (SegmentDimensions
    -> Maybe (HashMap Text AttributeDimension) -> SegmentDimensions)
-> Lens
     SegmentDimensions
     SegmentDimensions
     (Maybe (HashMap Text AttributeDimension))
     (Maybe (HashMap Text AttributeDimension))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SegmentDimensions' {Maybe (HashMap Text AttributeDimension)
userAttributes :: Maybe (HashMap Text AttributeDimension)
$sel:userAttributes:SegmentDimensions' :: SegmentDimensions -> Maybe (HashMap Text AttributeDimension)
userAttributes} -> Maybe (HashMap Text AttributeDimension)
userAttributes) (\s :: SegmentDimensions
s@SegmentDimensions' {} Maybe (HashMap Text AttributeDimension)
a -> SegmentDimensions
s {$sel:userAttributes:SegmentDimensions' :: Maybe (HashMap Text AttributeDimension)
userAttributes = Maybe (HashMap Text AttributeDimension)
a} :: SegmentDimensions) ((Maybe (HashMap Text AttributeDimension)
  -> f (Maybe (HashMap Text AttributeDimension)))
 -> SegmentDimensions -> f SegmentDimensions)
-> ((Maybe (HashMap Text AttributeDimension)
     -> f (Maybe (HashMap Text AttributeDimension)))
    -> Maybe (HashMap Text AttributeDimension)
    -> f (Maybe (HashMap Text AttributeDimension)))
-> (Maybe (HashMap Text AttributeDimension)
    -> f (Maybe (HashMap Text AttributeDimension)))
-> SegmentDimensions
-> f SegmentDimensions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text AttributeDimension)
  (HashMap Text AttributeDimension)
  (HashMap Text AttributeDimension)
  (HashMap Text AttributeDimension)
-> Iso
     (Maybe (HashMap Text AttributeDimension))
     (Maybe (HashMap Text AttributeDimension))
     (Maybe (HashMap Text AttributeDimension))
     (Maybe (HashMap Text AttributeDimension))
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
  (HashMap Text AttributeDimension)
  (HashMap Text AttributeDimension)
  (HashMap Text AttributeDimension)
  (HashMap Text AttributeDimension)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The behavior-based criteria, such as how recently users have used your
-- app, for the segment.
segmentDimensions_behavior :: Lens.Lens' SegmentDimensions (Prelude.Maybe SegmentBehaviors)
segmentDimensions_behavior :: (Maybe SegmentBehaviors -> f (Maybe SegmentBehaviors))
-> SegmentDimensions -> f SegmentDimensions
segmentDimensions_behavior = (SegmentDimensions -> Maybe SegmentBehaviors)
-> (SegmentDimensions
    -> Maybe SegmentBehaviors -> SegmentDimensions)
-> Lens
     SegmentDimensions
     SegmentDimensions
     (Maybe SegmentBehaviors)
     (Maybe SegmentBehaviors)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SegmentDimensions' {Maybe SegmentBehaviors
behavior :: Maybe SegmentBehaviors
$sel:behavior:SegmentDimensions' :: SegmentDimensions -> Maybe SegmentBehaviors
behavior} -> Maybe SegmentBehaviors
behavior) (\s :: SegmentDimensions
s@SegmentDimensions' {} Maybe SegmentBehaviors
a -> SegmentDimensions
s {$sel:behavior:SegmentDimensions' :: Maybe SegmentBehaviors
behavior = Maybe SegmentBehaviors
a} :: SegmentDimensions)

-- | One or more custom attributes to use as criteria for the segment.
segmentDimensions_attributes :: Lens.Lens' SegmentDimensions (Prelude.Maybe (Prelude.HashMap Prelude.Text AttributeDimension))
segmentDimensions_attributes :: (Maybe (HashMap Text AttributeDimension)
 -> f (Maybe (HashMap Text AttributeDimension)))
-> SegmentDimensions -> f SegmentDimensions
segmentDimensions_attributes = (SegmentDimensions -> Maybe (HashMap Text AttributeDimension))
-> (SegmentDimensions
    -> Maybe (HashMap Text AttributeDimension) -> SegmentDimensions)
-> Lens
     SegmentDimensions
     SegmentDimensions
     (Maybe (HashMap Text AttributeDimension))
     (Maybe (HashMap Text AttributeDimension))
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SegmentDimensions' {Maybe (HashMap Text AttributeDimension)
attributes :: Maybe (HashMap Text AttributeDimension)
$sel:attributes:SegmentDimensions' :: SegmentDimensions -> Maybe (HashMap Text AttributeDimension)
attributes} -> Maybe (HashMap Text AttributeDimension)
attributes) (\s :: SegmentDimensions
s@SegmentDimensions' {} Maybe (HashMap Text AttributeDimension)
a -> SegmentDimensions
s {$sel:attributes:SegmentDimensions' :: Maybe (HashMap Text AttributeDimension)
attributes = Maybe (HashMap Text AttributeDimension)
a} :: SegmentDimensions) ((Maybe (HashMap Text AttributeDimension)
  -> f (Maybe (HashMap Text AttributeDimension)))
 -> SegmentDimensions -> f SegmentDimensions)
-> ((Maybe (HashMap Text AttributeDimension)
     -> f (Maybe (HashMap Text AttributeDimension)))
    -> Maybe (HashMap Text AttributeDimension)
    -> f (Maybe (HashMap Text AttributeDimension)))
-> (Maybe (HashMap Text AttributeDimension)
    -> f (Maybe (HashMap Text AttributeDimension)))
-> SegmentDimensions
-> f SegmentDimensions
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  (HashMap Text AttributeDimension)
  (HashMap Text AttributeDimension)
  (HashMap Text AttributeDimension)
  (HashMap Text AttributeDimension)
-> Iso
     (Maybe (HashMap Text AttributeDimension))
     (Maybe (HashMap Text AttributeDimension))
     (Maybe (HashMap Text AttributeDimension))
     (Maybe (HashMap Text AttributeDimension))
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
  (HashMap Text AttributeDimension)
  (HashMap Text AttributeDimension)
  (HashMap Text AttributeDimension)
  (HashMap Text AttributeDimension)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

instance Core.FromJSON SegmentDimensions where
  parseJSON :: Value -> Parser SegmentDimensions
parseJSON =
    String
-> (Object -> Parser SegmentDimensions)
-> Value
-> Parser SegmentDimensions
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"SegmentDimensions"
      ( \Object
x ->
          Maybe (HashMap Text MetricDimension)
-> Maybe SegmentLocation
-> Maybe SegmentDemographics
-> Maybe (HashMap Text AttributeDimension)
-> Maybe SegmentBehaviors
-> Maybe (HashMap Text AttributeDimension)
-> SegmentDimensions
SegmentDimensions'
            (Maybe (HashMap Text MetricDimension)
 -> Maybe SegmentLocation
 -> Maybe SegmentDemographics
 -> Maybe (HashMap Text AttributeDimension)
 -> Maybe SegmentBehaviors
 -> Maybe (HashMap Text AttributeDimension)
 -> SegmentDimensions)
-> Parser (Maybe (HashMap Text MetricDimension))
-> Parser
     (Maybe SegmentLocation
      -> Maybe SegmentDemographics
      -> Maybe (HashMap Text AttributeDimension)
      -> Maybe SegmentBehaviors
      -> Maybe (HashMap Text AttributeDimension)
      -> SegmentDimensions)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object
-> Text -> Parser (Maybe (Maybe (HashMap Text MetricDimension)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Metrics" Parser (Maybe (Maybe (HashMap Text MetricDimension)))
-> Maybe (HashMap Text MetricDimension)
-> Parser (Maybe (HashMap Text MetricDimension))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text MetricDimension)
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe SegmentLocation
   -> Maybe SegmentDemographics
   -> Maybe (HashMap Text AttributeDimension)
   -> Maybe SegmentBehaviors
   -> Maybe (HashMap Text AttributeDimension)
   -> SegmentDimensions)
-> Parser (Maybe SegmentLocation)
-> Parser
     (Maybe SegmentDemographics
      -> Maybe (HashMap Text AttributeDimension)
      -> Maybe SegmentBehaviors
      -> Maybe (HashMap Text AttributeDimension)
      -> SegmentDimensions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SegmentLocation)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Location")
            Parser
  (Maybe SegmentDemographics
   -> Maybe (HashMap Text AttributeDimension)
   -> Maybe SegmentBehaviors
   -> Maybe (HashMap Text AttributeDimension)
   -> SegmentDimensions)
-> Parser (Maybe SegmentDemographics)
-> Parser
     (Maybe (HashMap Text AttributeDimension)
      -> Maybe SegmentBehaviors
      -> Maybe (HashMap Text AttributeDimension)
      -> SegmentDimensions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SegmentDemographics)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Demographic")
            Parser
  (Maybe (HashMap Text AttributeDimension)
   -> Maybe SegmentBehaviors
   -> Maybe (HashMap Text AttributeDimension)
   -> SegmentDimensions)
-> Parser (Maybe (HashMap Text AttributeDimension))
-> Parser
     (Maybe SegmentBehaviors
      -> Maybe (HashMap Text AttributeDimension) -> SegmentDimensions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Parser (Maybe (Maybe (HashMap Text AttributeDimension)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"UserAttributes" Parser (Maybe (Maybe (HashMap Text AttributeDimension)))
-> Maybe (HashMap Text AttributeDimension)
-> Parser (Maybe (HashMap Text AttributeDimension))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text AttributeDimension)
forall a. Monoid a => a
Prelude.mempty)
            Parser
  (Maybe SegmentBehaviors
   -> Maybe (HashMap Text AttributeDimension) -> SegmentDimensions)
-> Parser (Maybe SegmentBehaviors)
-> Parser
     (Maybe (HashMap Text AttributeDimension) -> SegmentDimensions)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe SegmentBehaviors)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Behavior")
            Parser
  (Maybe (HashMap Text AttributeDimension) -> SegmentDimensions)
-> Parser (Maybe (HashMap Text AttributeDimension))
-> Parser SegmentDimensions
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object
-> Text -> Parser (Maybe (Maybe (HashMap Text AttributeDimension)))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"Attributes" Parser (Maybe (Maybe (HashMap Text AttributeDimension)))
-> Maybe (HashMap Text AttributeDimension)
-> Parser (Maybe (HashMap Text AttributeDimension))
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe (HashMap Text AttributeDimension)
forall a. Monoid a => a
Prelude.mempty)
      )

instance Prelude.Hashable SegmentDimensions

instance Prelude.NFData SegmentDimensions

instance Core.ToJSON SegmentDimensions where
  toJSON :: SegmentDimensions -> Value
toJSON SegmentDimensions' {Maybe (HashMap Text AttributeDimension)
Maybe (HashMap Text MetricDimension)
Maybe SegmentBehaviors
Maybe SegmentLocation
Maybe SegmentDemographics
attributes :: Maybe (HashMap Text AttributeDimension)
behavior :: Maybe SegmentBehaviors
userAttributes :: Maybe (HashMap Text AttributeDimension)
demographic :: Maybe SegmentDemographics
location :: Maybe SegmentLocation
metrics :: Maybe (HashMap Text MetricDimension)
$sel:attributes:SegmentDimensions' :: SegmentDimensions -> Maybe (HashMap Text AttributeDimension)
$sel:behavior:SegmentDimensions' :: SegmentDimensions -> Maybe SegmentBehaviors
$sel:userAttributes:SegmentDimensions' :: SegmentDimensions -> Maybe (HashMap Text AttributeDimension)
$sel:demographic:SegmentDimensions' :: SegmentDimensions -> Maybe SegmentDemographics
$sel:location:SegmentDimensions' :: SegmentDimensions -> Maybe SegmentLocation
$sel:metrics:SegmentDimensions' :: SegmentDimensions -> Maybe (HashMap Text MetricDimension)
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Metrics" Text -> HashMap Text MetricDimension -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text MetricDimension -> Pair)
-> Maybe (HashMap Text MetricDimension) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text MetricDimension)
metrics,
            (Text
"Location" Text -> SegmentLocation -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SegmentLocation -> Pair) -> Maybe SegmentLocation -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SegmentLocation
location,
            (Text
"Demographic" Text -> SegmentDemographics -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SegmentDemographics -> Pair)
-> Maybe SegmentDemographics -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SegmentDemographics
demographic,
            (Text
"UserAttributes" Text -> HashMap Text AttributeDimension -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              (HashMap Text AttributeDimension -> Pair)
-> Maybe (HashMap Text AttributeDimension) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text AttributeDimension)
userAttributes,
            (Text
"Behavior" Text -> SegmentBehaviors -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (SegmentBehaviors -> Pair) -> Maybe SegmentBehaviors -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe SegmentBehaviors
behavior,
            (Text
"Attributes" Text -> HashMap Text AttributeDimension -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (HashMap Text AttributeDimension -> Pair)
-> Maybe (HashMap Text AttributeDimension) -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe (HashMap Text AttributeDimension)
attributes
          ]
      )