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

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

-- | Specifies the status and settings of the GCM channel for an application.
-- This channel enables Amazon Pinpoint to send push notifications through
-- the Firebase Cloud Messaging (FCM), formerly Google Cloud Messaging
-- (GCM), service.
--
-- /See:/ 'newGCMChannelRequest' smart constructor.
data GCMChannelRequest = GCMChannelRequest'
  { -- | Specifies whether to enable the GCM channel for the application.
    GCMChannelRequest -> Maybe Bool
enabled :: Prelude.Maybe Prelude.Bool,
    -- | The Web API Key, also referred to as an /API_KEY/ or /server key/, that
    -- you received from Google to communicate with Google services.
    GCMChannelRequest -> Text
apiKey :: Prelude.Text
  }
  deriving (GCMChannelRequest -> GCMChannelRequest -> Bool
(GCMChannelRequest -> GCMChannelRequest -> Bool)
-> (GCMChannelRequest -> GCMChannelRequest -> Bool)
-> Eq GCMChannelRequest
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: GCMChannelRequest -> GCMChannelRequest -> Bool
$c/= :: GCMChannelRequest -> GCMChannelRequest -> Bool
== :: GCMChannelRequest -> GCMChannelRequest -> Bool
$c== :: GCMChannelRequest -> GCMChannelRequest -> Bool
Prelude.Eq, ReadPrec [GCMChannelRequest]
ReadPrec GCMChannelRequest
Int -> ReadS GCMChannelRequest
ReadS [GCMChannelRequest]
(Int -> ReadS GCMChannelRequest)
-> ReadS [GCMChannelRequest]
-> ReadPrec GCMChannelRequest
-> ReadPrec [GCMChannelRequest]
-> Read GCMChannelRequest
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [GCMChannelRequest]
$creadListPrec :: ReadPrec [GCMChannelRequest]
readPrec :: ReadPrec GCMChannelRequest
$creadPrec :: ReadPrec GCMChannelRequest
readList :: ReadS [GCMChannelRequest]
$creadList :: ReadS [GCMChannelRequest]
readsPrec :: Int -> ReadS GCMChannelRequest
$creadsPrec :: Int -> ReadS GCMChannelRequest
Prelude.Read, Int -> GCMChannelRequest -> ShowS
[GCMChannelRequest] -> ShowS
GCMChannelRequest -> String
(Int -> GCMChannelRequest -> ShowS)
-> (GCMChannelRequest -> String)
-> ([GCMChannelRequest] -> ShowS)
-> Show GCMChannelRequest
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [GCMChannelRequest] -> ShowS
$cshowList :: [GCMChannelRequest] -> ShowS
show :: GCMChannelRequest -> String
$cshow :: GCMChannelRequest -> String
showsPrec :: Int -> GCMChannelRequest -> ShowS
$cshowsPrec :: Int -> GCMChannelRequest -> ShowS
Prelude.Show, (forall x. GCMChannelRequest -> Rep GCMChannelRequest x)
-> (forall x. Rep GCMChannelRequest x -> GCMChannelRequest)
-> Generic GCMChannelRequest
forall x. Rep GCMChannelRequest x -> GCMChannelRequest
forall x. GCMChannelRequest -> Rep GCMChannelRequest x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep GCMChannelRequest x -> GCMChannelRequest
$cfrom :: forall x. GCMChannelRequest -> Rep GCMChannelRequest x
Prelude.Generic)

-- |
-- Create a value of 'GCMChannelRequest' 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:
--
-- 'enabled', 'gCMChannelRequest_enabled' - Specifies whether to enable the GCM channel for the application.
--
-- 'apiKey', 'gCMChannelRequest_apiKey' - The Web API Key, also referred to as an /API_KEY/ or /server key/, that
-- you received from Google to communicate with Google services.
newGCMChannelRequest ::
  -- | 'apiKey'
  Prelude.Text ->
  GCMChannelRequest
newGCMChannelRequest :: Text -> GCMChannelRequest
newGCMChannelRequest Text
pApiKey_ =
  GCMChannelRequest' :: Maybe Bool -> Text -> GCMChannelRequest
GCMChannelRequest'
    { $sel:enabled:GCMChannelRequest' :: Maybe Bool
enabled = Maybe Bool
forall a. Maybe a
Prelude.Nothing,
      $sel:apiKey:GCMChannelRequest' :: Text
apiKey = Text
pApiKey_
    }

-- | Specifies whether to enable the GCM channel for the application.
gCMChannelRequest_enabled :: Lens.Lens' GCMChannelRequest (Prelude.Maybe Prelude.Bool)
gCMChannelRequest_enabled :: (Maybe Bool -> f (Maybe Bool))
-> GCMChannelRequest -> f GCMChannelRequest
gCMChannelRequest_enabled = (GCMChannelRequest -> Maybe Bool)
-> (GCMChannelRequest -> Maybe Bool -> GCMChannelRequest)
-> Lens
     GCMChannelRequest GCMChannelRequest (Maybe Bool) (Maybe Bool)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GCMChannelRequest' {Maybe Bool
enabled :: Maybe Bool
$sel:enabled:GCMChannelRequest' :: GCMChannelRequest -> Maybe Bool
enabled} -> Maybe Bool
enabled) (\s :: GCMChannelRequest
s@GCMChannelRequest' {} Maybe Bool
a -> GCMChannelRequest
s {$sel:enabled:GCMChannelRequest' :: Maybe Bool
enabled = Maybe Bool
a} :: GCMChannelRequest)

-- | The Web API Key, also referred to as an /API_KEY/ or /server key/, that
-- you received from Google to communicate with Google services.
gCMChannelRequest_apiKey :: Lens.Lens' GCMChannelRequest Prelude.Text
gCMChannelRequest_apiKey :: (Text -> f Text) -> GCMChannelRequest -> f GCMChannelRequest
gCMChannelRequest_apiKey = (GCMChannelRequest -> Text)
-> (GCMChannelRequest -> Text -> GCMChannelRequest)
-> Lens GCMChannelRequest GCMChannelRequest Text Text
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\GCMChannelRequest' {Text
apiKey :: Text
$sel:apiKey:GCMChannelRequest' :: GCMChannelRequest -> Text
apiKey} -> Text
apiKey) (\s :: GCMChannelRequest
s@GCMChannelRequest' {} Text
a -> GCMChannelRequest
s {$sel:apiKey:GCMChannelRequest' :: Text
apiKey = Text
a} :: GCMChannelRequest)

instance Prelude.Hashable GCMChannelRequest

instance Prelude.NFData GCMChannelRequest

instance Core.ToJSON GCMChannelRequest where
  toJSON :: GCMChannelRequest -> Value
toJSON GCMChannelRequest' {Maybe Bool
Text
apiKey :: Text
enabled :: Maybe Bool
$sel:apiKey:GCMChannelRequest' :: GCMChannelRequest -> Text
$sel:enabled:GCMChannelRequest' :: GCMChannelRequest -> Maybe Bool
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"Enabled" Text -> Bool -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Bool -> Pair) -> Maybe Bool -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Bool
enabled,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just (Text
"ApiKey" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= Text
apiKey)
          ]
      )