{-# LANGUAGE TemplateHaskell #-}

-- | Message embeds
module Calamity.Types.Model.Channel.Embed (
  Embed (..),
  embedFooter,
  embedImage,
  embedThumbnail,
  embedAuthor,
  embedAuthor',
  embedField,
  EmbedFooter (..),
  EmbedImage (..),
  EmbedThumbnail (..),
  EmbedVideo (..),
  EmbedProvider (..),
  EmbedAuthor (..),
  EmbedField (..),
) where

import Calamity.Internal.IntColour (IntColour (..))
import Calamity.Internal.Utils (CalamityToJSON (..), CalamityToJSON' (..), (.=), (.?=))
import Data.Aeson ((.!=), (.:), (.:?))
import Data.Aeson qualified as Aeson
import Data.Colour (Colour)
import Data.Default.Class
import Data.Semigroup
import Data.Text (Text)
import Data.Time
import Data.Word
import Optics ((%~), (&), (^.))
import Optics.TH
import TextShow qualified
import TextShow.TH

data Embed = Embed
  { Embed -> Maybe Text
title :: Maybe Text
  , Embed -> Maybe Text
type_ :: Maybe Text
  , Embed -> Maybe Text
description :: Maybe Text
  , Embed -> Maybe Text
url :: Maybe Text
  , Embed -> Maybe UTCTime
timestamp :: Maybe UTCTime
  , Embed -> Maybe (Colour Double)
color :: Maybe (Colour Double)
  , Embed -> Maybe EmbedFooter
footer :: Maybe EmbedFooter
  , Embed -> Maybe EmbedImage
image :: Maybe EmbedImage
  , Embed -> Maybe EmbedThumbnail
thumbnail :: Maybe EmbedThumbnail
  , Embed -> Maybe EmbedVideo
video :: Maybe EmbedVideo
  , Embed -> Maybe EmbedProvider
provider :: Maybe EmbedProvider
  , Embed -> Maybe EmbedAuthor
author :: Maybe EmbedAuthor
  , Embed -> [EmbedField]
fields :: [EmbedField]
  }
  deriving (Embed -> Embed -> Bool
(Embed -> Embed -> Bool) -> (Embed -> Embed -> Bool) -> Eq Embed
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Embed -> Embed -> Bool
== :: Embed -> Embed -> Bool
$c/= :: Embed -> Embed -> Bool
/= :: Embed -> Embed -> Bool
Eq, Int -> Embed -> ShowS
[Embed] -> ShowS
Embed -> String
(Int -> Embed -> ShowS)
-> (Embed -> String) -> ([Embed] -> ShowS) -> Show Embed
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Embed -> ShowS
showsPrec :: Int -> Embed -> ShowS
$cshow :: Embed -> String
show :: Embed -> String
$cshowList :: [Embed] -> ShowS
showList :: [Embed] -> ShowS
Show)
  deriving (Int -> Embed -> Text
Int -> Embed -> Builder
Int -> Embed -> Text
[Embed] -> Text
[Embed] -> Builder
[Embed] -> Text
Embed -> Text
Embed -> Builder
Embed -> Text
(Int -> Embed -> Builder)
-> (Embed -> Builder)
-> ([Embed] -> Builder)
-> (Int -> Embed -> Text)
-> (Embed -> Text)
-> ([Embed] -> Text)
-> (Int -> Embed -> Text)
-> (Embed -> Text)
-> ([Embed] -> Text)
-> TextShow Embed
forall a.
(Int -> a -> Builder)
-> (a -> Builder)
-> ([a] -> Builder)
-> (Int -> a -> Text)
-> (a -> Text)
-> ([a] -> Text)
-> (Int -> a -> Text)
-> (a -> Text)
-> ([a] -> Text)
-> TextShow a
$cshowbPrec :: Int -> Embed -> Builder
showbPrec :: Int -> Embed -> Builder
$cshowb :: Embed -> Builder
showb :: Embed -> Builder
$cshowbList :: [Embed] -> Builder
showbList :: [Embed] -> Builder
$cshowtPrec :: Int -> Embed -> Text
showtPrec :: Int -> Embed -> Text
$cshowt :: Embed -> Text
showt :: Embed -> Text
$cshowtList :: [Embed] -> Text
showtList :: [Embed] -> Text
$cshowtlPrec :: Int -> Embed -> Text
showtlPrec :: Int -> Embed -> Text
$cshowtl :: Embed -> Text
showtl :: Embed -> Text
$cshowtlList :: [Embed] -> Text
showtlList :: [Embed] -> Text
TextShow.TextShow) via TextShow.FromStringShow Embed
  deriving ([Embed] -> Value
[Embed] -> Encoding
Embed -> Value
Embed -> Encoding
(Embed -> Value)
-> (Embed -> Encoding)
-> ([Embed] -> Value)
-> ([Embed] -> Encoding)
-> ToJSON Embed
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: Embed -> Value
toJSON :: Embed -> Value
$ctoEncoding :: Embed -> Encoding
toEncoding :: Embed -> Encoding
$ctoJSONList :: [Embed] -> Value
toJSONList :: [Embed] -> Value
$ctoEncodingList :: [Embed] -> Encoding
toEncodingList :: [Embed] -> Encoding
Aeson.ToJSON) via CalamityToJSON Embed

instance Default Embed where
  def :: Embed
def =
    Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe UTCTime
-> Maybe (Colour Double)
-> Maybe EmbedFooter
-> Maybe EmbedImage
-> Maybe EmbedThumbnail
-> Maybe EmbedVideo
-> Maybe EmbedProvider
-> Maybe EmbedAuthor
-> [EmbedField]
-> Embed
Embed
      Maybe Text
forall a. Maybe a
Nothing
      Maybe Text
forall a. Maybe a
Nothing
      Maybe Text
forall a. Maybe a
Nothing
      Maybe Text
forall a. Maybe a
Nothing
      Maybe UTCTime
forall a. Maybe a
Nothing
      Maybe (Colour Double)
forall a. Maybe a
Nothing
      Maybe EmbedFooter
forall a. Maybe a
Nothing
      Maybe EmbedImage
forall a. Maybe a
Nothing
      Maybe EmbedThumbnail
forall a. Maybe a
Nothing
      Maybe EmbedVideo
forall a. Maybe a
Nothing
      Maybe EmbedProvider
forall a. Maybe a
Nothing
      Maybe EmbedAuthor
forall a. Maybe a
Nothing
      []

instance CalamityToJSON' Embed where
  toPairs :: forall kv. KeyValue kv => Embed -> [Maybe kv]
toPairs Embed {[EmbedField]
Maybe Text
Maybe UTCTime
Maybe (Colour Double)
Maybe EmbedAuthor
Maybe EmbedProvider
Maybe EmbedVideo
Maybe EmbedThumbnail
Maybe EmbedImage
Maybe EmbedFooter
$sel:title:Embed :: Embed -> Maybe Text
$sel:type_:Embed :: Embed -> Maybe Text
$sel:description:Embed :: Embed -> Maybe Text
$sel:url:Embed :: Embed -> Maybe Text
$sel:timestamp:Embed :: Embed -> Maybe UTCTime
$sel:color:Embed :: Embed -> Maybe (Colour Double)
$sel:footer:Embed :: Embed -> Maybe EmbedFooter
$sel:image:Embed :: Embed -> Maybe EmbedImage
$sel:thumbnail:Embed :: Embed -> Maybe EmbedThumbnail
$sel:video:Embed :: Embed -> Maybe EmbedVideo
$sel:provider:Embed :: Embed -> Maybe EmbedProvider
$sel:author:Embed :: Embed -> Maybe EmbedAuthor
$sel:fields:Embed :: Embed -> [EmbedField]
title :: Maybe Text
type_ :: Maybe Text
description :: Maybe Text
url :: Maybe Text
timestamp :: Maybe UTCTime
color :: Maybe (Colour Double)
footer :: Maybe EmbedFooter
image :: Maybe EmbedImage
thumbnail :: Maybe EmbedThumbnail
video :: Maybe EmbedVideo
provider :: Maybe EmbedProvider
author :: Maybe EmbedAuthor
fields :: [EmbedField]
..} =
    [ Key
"title" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
title
    , Key
"type" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
type_
    , Key
"description" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
description
    , Key
"url" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
url
    , Key
"timestamp" Key -> Maybe UTCTime -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe UTCTime
timestamp
    , Key
"color" Key -> Maybe IntColour -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= (Colour Double -> IntColour
IntColour (Colour Double -> IntColour)
-> Maybe (Colour Double) -> Maybe IntColour
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Maybe (Colour Double)
color)
    , Key
"footer" Key -> Maybe EmbedFooter -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe EmbedFooter
footer
    , Key
"image" Key -> Maybe EmbedImage -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe EmbedImage
image
    , Key
"thumbnail" Key -> Maybe EmbedThumbnail -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe EmbedThumbnail
thumbnail
    , Key
"video" Key -> Maybe EmbedVideo -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe EmbedVideo
video
    , Key
"provider" Key -> Maybe EmbedProvider -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe EmbedProvider
provider
    , Key
"author" Key -> Maybe EmbedAuthor -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe EmbedAuthor
author
    , Key
"fields" Key -> [EmbedField] -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= [EmbedField]
fields
    ]

instance Aeson.FromJSON Embed where
  parseJSON :: Value -> Parser Embed
parseJSON = String -> (Object -> Parser Embed) -> Value -> Parser Embed
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"Embed" ((Object -> Parser Embed) -> Value -> Parser Embed)
-> (Object -> Parser Embed) -> Value -> Parser Embed
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe Text
-> Maybe UTCTime
-> Maybe (Colour Double)
-> Maybe EmbedFooter
-> Maybe EmbedImage
-> Maybe EmbedThumbnail
-> Maybe EmbedVideo
-> Maybe EmbedProvider
-> Maybe EmbedAuthor
-> [EmbedField]
-> Embed
Embed
      (Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe Text
 -> Maybe UTCTime
 -> Maybe (Colour Double)
 -> Maybe EmbedFooter
 -> Maybe EmbedImage
 -> Maybe EmbedThumbnail
 -> Maybe EmbedVideo
 -> Maybe EmbedProvider
 -> Maybe EmbedAuthor
 -> [EmbedField]
 -> Embed)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe Text
      -> Maybe UTCTime
      -> Maybe (Colour Double)
      -> Maybe EmbedFooter
      -> Maybe EmbedImage
      -> Maybe EmbedThumbnail
      -> Maybe EmbedVideo
      -> Maybe EmbedProvider
      -> Maybe EmbedAuthor
      -> [EmbedField]
      -> Embed)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"title"
      Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe Text
   -> Maybe UTCTime
   -> Maybe (Colour Double)
   -> Maybe EmbedFooter
   -> Maybe EmbedImage
   -> Maybe EmbedThumbnail
   -> Maybe EmbedVideo
   -> Maybe EmbedProvider
   -> Maybe EmbedAuthor
   -> [EmbedField]
   -> Embed)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe Text
      -> Maybe UTCTime
      -> Maybe (Colour Double)
      -> Maybe EmbedFooter
      -> Maybe EmbedImage
      -> Maybe EmbedThumbnail
      -> Maybe EmbedVideo
      -> Maybe EmbedProvider
      -> Maybe EmbedAuthor
      -> [EmbedField]
      -> Embed)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"type"
      Parser
  (Maybe Text
   -> Maybe Text
   -> Maybe UTCTime
   -> Maybe (Colour Double)
   -> Maybe EmbedFooter
   -> Maybe EmbedImage
   -> Maybe EmbedThumbnail
   -> Maybe EmbedVideo
   -> Maybe EmbedProvider
   -> Maybe EmbedAuthor
   -> [EmbedField]
   -> Embed)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe UTCTime
      -> Maybe (Colour Double)
      -> Maybe EmbedFooter
      -> Maybe EmbedImage
      -> Maybe EmbedThumbnail
      -> Maybe EmbedVideo
      -> Maybe EmbedProvider
      -> Maybe EmbedAuthor
      -> [EmbedField]
      -> Embed)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"description"
      Parser
  (Maybe Text
   -> Maybe UTCTime
   -> Maybe (Colour Double)
   -> Maybe EmbedFooter
   -> Maybe EmbedImage
   -> Maybe EmbedThumbnail
   -> Maybe EmbedVideo
   -> Maybe EmbedProvider
   -> Maybe EmbedAuthor
   -> [EmbedField]
   -> Embed)
-> Parser (Maybe Text)
-> Parser
     (Maybe UTCTime
      -> Maybe (Colour Double)
      -> Maybe EmbedFooter
      -> Maybe EmbedImage
      -> Maybe EmbedThumbnail
      -> Maybe EmbedVideo
      -> Maybe EmbedProvider
      -> Maybe EmbedAuthor
      -> [EmbedField]
      -> Embed)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"url"
      Parser
  (Maybe UTCTime
   -> Maybe (Colour Double)
   -> Maybe EmbedFooter
   -> Maybe EmbedImage
   -> Maybe EmbedThumbnail
   -> Maybe EmbedVideo
   -> Maybe EmbedProvider
   -> Maybe EmbedAuthor
   -> [EmbedField]
   -> Embed)
-> Parser (Maybe UTCTime)
-> Parser
     (Maybe (Colour Double)
      -> Maybe EmbedFooter
      -> Maybe EmbedImage
      -> Maybe EmbedThumbnail
      -> Maybe EmbedVideo
      -> Maybe EmbedProvider
      -> Maybe EmbedAuthor
      -> [EmbedField]
      -> Embed)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe UTCTime)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"timestamp"
      Parser
  (Maybe (Colour Double)
   -> Maybe EmbedFooter
   -> Maybe EmbedImage
   -> Maybe EmbedThumbnail
   -> Maybe EmbedVideo
   -> Maybe EmbedProvider
   -> Maybe EmbedAuthor
   -> [EmbedField]
   -> Embed)
-> Parser (Maybe (Colour Double))
-> Parser
     (Maybe EmbedFooter
      -> Maybe EmbedImage
      -> Maybe EmbedThumbnail
      -> Maybe EmbedVideo
      -> Maybe EmbedProvider
      -> Maybe EmbedAuthor
      -> [EmbedField]
      -> Embed)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> ((IntColour -> Colour Double)
-> Maybe IntColour -> Maybe (Colour Double)
forall a b. (a -> b) -> Maybe a -> Maybe b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap IntColour -> Colour Double
fromIntColour (Maybe IntColour -> Maybe (Colour Double))
-> Parser (Maybe IntColour) -> Parser (Maybe (Colour Double))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe IntColour)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"color")
      Parser
  (Maybe EmbedFooter
   -> Maybe EmbedImage
   -> Maybe EmbedThumbnail
   -> Maybe EmbedVideo
   -> Maybe EmbedProvider
   -> Maybe EmbedAuthor
   -> [EmbedField]
   -> Embed)
-> Parser (Maybe EmbedFooter)
-> Parser
     (Maybe EmbedImage
      -> Maybe EmbedThumbnail
      -> Maybe EmbedVideo
      -> Maybe EmbedProvider
      -> Maybe EmbedAuthor
      -> [EmbedField]
      -> Embed)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe EmbedFooter)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"footer"
      Parser
  (Maybe EmbedImage
   -> Maybe EmbedThumbnail
   -> Maybe EmbedVideo
   -> Maybe EmbedProvider
   -> Maybe EmbedAuthor
   -> [EmbedField]
   -> Embed)
-> Parser (Maybe EmbedImage)
-> Parser
     (Maybe EmbedThumbnail
      -> Maybe EmbedVideo
      -> Maybe EmbedProvider
      -> Maybe EmbedAuthor
      -> [EmbedField]
      -> Embed)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe EmbedImage)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"image"
      Parser
  (Maybe EmbedThumbnail
   -> Maybe EmbedVideo
   -> Maybe EmbedProvider
   -> Maybe EmbedAuthor
   -> [EmbedField]
   -> Embed)
-> Parser (Maybe EmbedThumbnail)
-> Parser
     (Maybe EmbedVideo
      -> Maybe EmbedProvider
      -> Maybe EmbedAuthor
      -> [EmbedField]
      -> Embed)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe EmbedThumbnail)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"thumbnail"
      Parser
  (Maybe EmbedVideo
   -> Maybe EmbedProvider
   -> Maybe EmbedAuthor
   -> [EmbedField]
   -> Embed)
-> Parser (Maybe EmbedVideo)
-> Parser
     (Maybe EmbedProvider -> Maybe EmbedAuthor -> [EmbedField] -> Embed)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe EmbedVideo)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"video"
      Parser
  (Maybe EmbedProvider -> Maybe EmbedAuthor -> [EmbedField] -> Embed)
-> Parser (Maybe EmbedProvider)
-> Parser (Maybe EmbedAuthor -> [EmbedField] -> Embed)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe EmbedProvider)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"provider"
      Parser (Maybe EmbedAuthor -> [EmbedField] -> Embed)
-> Parser (Maybe EmbedAuthor) -> Parser ([EmbedField] -> Embed)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe EmbedAuthor)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"author"
      Parser ([EmbedField] -> Embed)
-> Parser [EmbedField] -> Parser Embed
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe [EmbedField])
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"fields" Parser (Maybe [EmbedField]) -> [EmbedField] -> Parser [EmbedField]
forall a. Parser (Maybe a) -> a -> Parser a
.!= []

data EmbedFooter = EmbedFooter
  { EmbedFooter -> Text
text :: Text
  , EmbedFooter -> Maybe Text
iconUrl :: Maybe Text
  , EmbedFooter -> Maybe Text
proxyIconUrl :: Maybe Text
  }
  deriving (EmbedFooter -> EmbedFooter -> Bool
(EmbedFooter -> EmbedFooter -> Bool)
-> (EmbedFooter -> EmbedFooter -> Bool) -> Eq EmbedFooter
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EmbedFooter -> EmbedFooter -> Bool
== :: EmbedFooter -> EmbedFooter -> Bool
$c/= :: EmbedFooter -> EmbedFooter -> Bool
/= :: EmbedFooter -> EmbedFooter -> Bool
Eq, Int -> EmbedFooter -> ShowS
[EmbedFooter] -> ShowS
EmbedFooter -> String
(Int -> EmbedFooter -> ShowS)
-> (EmbedFooter -> String)
-> ([EmbedFooter] -> ShowS)
-> Show EmbedFooter
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EmbedFooter -> ShowS
showsPrec :: Int -> EmbedFooter -> ShowS
$cshow :: EmbedFooter -> String
show :: EmbedFooter -> String
$cshowList :: [EmbedFooter] -> ShowS
showList :: [EmbedFooter] -> ShowS
Show)
  deriving ([EmbedFooter] -> Value
[EmbedFooter] -> Encoding
EmbedFooter -> Value
EmbedFooter -> Encoding
(EmbedFooter -> Value)
-> (EmbedFooter -> Encoding)
-> ([EmbedFooter] -> Value)
-> ([EmbedFooter] -> Encoding)
-> ToJSON EmbedFooter
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: EmbedFooter -> Value
toJSON :: EmbedFooter -> Value
$ctoEncoding :: EmbedFooter -> Encoding
toEncoding :: EmbedFooter -> Encoding
$ctoJSONList :: [EmbedFooter] -> Value
toJSONList :: [EmbedFooter] -> Value
$ctoEncodingList :: [EmbedFooter] -> Encoding
toEncodingList :: [EmbedFooter] -> Encoding
Aeson.ToJSON) via CalamityToJSON EmbedFooter

instance CalamityToJSON' EmbedFooter where
  toPairs :: forall kv. KeyValue kv => EmbedFooter -> [Maybe kv]
toPairs EmbedFooter {Maybe Text
Text
$sel:text:EmbedFooter :: EmbedFooter -> Text
$sel:iconUrl:EmbedFooter :: EmbedFooter -> Maybe Text
$sel:proxyIconUrl:EmbedFooter :: EmbedFooter -> Maybe Text
text :: Text
iconUrl :: Maybe Text
proxyIconUrl :: Maybe Text
..} =
    [ Key
"text" Key -> Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Text
text
    , Key
"icon_url" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
iconUrl
    , Key
"proxy_icon_url" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
proxyIconUrl
    ]

instance Aeson.FromJSON EmbedFooter where
  parseJSON :: Value -> Parser EmbedFooter
parseJSON = String
-> (Object -> Parser EmbedFooter) -> Value -> Parser EmbedFooter
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"EmbedFooter" ((Object -> Parser EmbedFooter) -> Value -> Parser EmbedFooter)
-> (Object -> Parser EmbedFooter) -> Value -> Parser EmbedFooter
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Text -> Maybe Text -> Maybe Text -> EmbedFooter
EmbedFooter
      (Text -> Maybe Text -> Maybe Text -> EmbedFooter)
-> Parser Text -> Parser (Maybe Text -> Maybe Text -> EmbedFooter)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"text"
      Parser (Maybe Text -> Maybe Text -> EmbedFooter)
-> Parser (Maybe Text) -> Parser (Maybe Text -> EmbedFooter)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"icon_url"
      Parser (Maybe Text -> EmbedFooter)
-> Parser (Maybe Text) -> Parser EmbedFooter
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"proxy_icon_url"

{- | Create an embed footer with a provided content

 The remaining fields are set to Nothing
-}
embedFooter :: Text -> EmbedFooter
embedFooter :: Text -> EmbedFooter
embedFooter Text
text = Text -> Maybe Text -> Maybe Text -> EmbedFooter
EmbedFooter Text
text Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing

data EmbedImage = EmbedImage
  { EmbedImage -> Text
url :: Text
  , EmbedImage -> Maybe Text
proxyUrl :: Maybe Text
  , EmbedImage -> Maybe Word64
width :: Maybe Word64
  , EmbedImage -> Maybe Word64
height :: Maybe Word64
  }
  deriving (EmbedImage -> EmbedImage -> Bool
(EmbedImage -> EmbedImage -> Bool)
-> (EmbedImage -> EmbedImage -> Bool) -> Eq EmbedImage
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EmbedImage -> EmbedImage -> Bool
== :: EmbedImage -> EmbedImage -> Bool
$c/= :: EmbedImage -> EmbedImage -> Bool
/= :: EmbedImage -> EmbedImage -> Bool
Eq, Int -> EmbedImage -> ShowS
[EmbedImage] -> ShowS
EmbedImage -> String
(Int -> EmbedImage -> ShowS)
-> (EmbedImage -> String)
-> ([EmbedImage] -> ShowS)
-> Show EmbedImage
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EmbedImage -> ShowS
showsPrec :: Int -> EmbedImage -> ShowS
$cshow :: EmbedImage -> String
show :: EmbedImage -> String
$cshowList :: [EmbedImage] -> ShowS
showList :: [EmbedImage] -> ShowS
Show)
  deriving ([EmbedImage] -> Value
[EmbedImage] -> Encoding
EmbedImage -> Value
EmbedImage -> Encoding
(EmbedImage -> Value)
-> (EmbedImage -> Encoding)
-> ([EmbedImage] -> Value)
-> ([EmbedImage] -> Encoding)
-> ToJSON EmbedImage
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: EmbedImage -> Value
toJSON :: EmbedImage -> Value
$ctoEncoding :: EmbedImage -> Encoding
toEncoding :: EmbedImage -> Encoding
$ctoJSONList :: [EmbedImage] -> Value
toJSONList :: [EmbedImage] -> Value
$ctoEncodingList :: [EmbedImage] -> Encoding
toEncodingList :: [EmbedImage] -> Encoding
Aeson.ToJSON) via CalamityToJSON EmbedImage

instance CalamityToJSON' EmbedImage where
  toPairs :: forall kv. KeyValue kv => EmbedImage -> [Maybe kv]
toPairs EmbedImage {Maybe Word64
Maybe Text
Text
$sel:url:EmbedImage :: EmbedImage -> Text
$sel:proxyUrl:EmbedImage :: EmbedImage -> Maybe Text
$sel:width:EmbedImage :: EmbedImage -> Maybe Word64
$sel:height:EmbedImage :: EmbedImage -> Maybe Word64
url :: Text
proxyUrl :: Maybe Text
width :: Maybe Word64
height :: Maybe Word64
..} =
    [ Key
"url" Key -> Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Text
url
    , Key
"proxy_url" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Maybe Text
proxyUrl
    , Key
"width" Key -> Maybe Word64 -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Maybe Word64
width
    , Key
"height" Key -> Maybe Word64 -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Maybe Word64
height
    ]

instance Aeson.FromJSON EmbedImage where
  parseJSON :: Value -> Parser EmbedImage
parseJSON = String
-> (Object -> Parser EmbedImage) -> Value -> Parser EmbedImage
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"EmbedImage" ((Object -> Parser EmbedImage) -> Value -> Parser EmbedImage)
-> (Object -> Parser EmbedImage) -> Value -> Parser EmbedImage
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Text -> Maybe Text -> Maybe Word64 -> Maybe Word64 -> EmbedImage
EmbedImage
      (Text -> Maybe Text -> Maybe Word64 -> Maybe Word64 -> EmbedImage)
-> Parser Text
-> Parser
     (Maybe Text -> Maybe Word64 -> Maybe Word64 -> EmbedImage)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"url"
      Parser (Maybe Text -> Maybe Word64 -> Maybe Word64 -> EmbedImage)
-> Parser (Maybe Text)
-> Parser (Maybe Word64 -> Maybe Word64 -> EmbedImage)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"proxy_url"
      Parser (Maybe Word64 -> Maybe Word64 -> EmbedImage)
-> Parser (Maybe Word64) -> Parser (Maybe Word64 -> EmbedImage)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Word64)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"width"
      Parser (Maybe Word64 -> EmbedImage)
-> Parser (Maybe Word64) -> Parser EmbedImage
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Word64)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"height"

{- | Create an embed image with a provided url

 The remaining fields are set to Nothing
-}
embedImage :: Text -> EmbedImage
embedImage :: Text -> EmbedImage
embedImage Text
url = Text -> Maybe Text -> Maybe Word64 -> Maybe Word64 -> EmbedImage
EmbedImage Text
url Maybe Text
forall a. Maybe a
Nothing Maybe Word64
forall a. Maybe a
Nothing Maybe Word64
forall a. Maybe a
Nothing

data EmbedThumbnail = EmbedThumbnail
  { EmbedThumbnail -> Text
url :: Text
  , EmbedThumbnail -> Maybe Text
proxyUrl :: Maybe Text
  , EmbedThumbnail -> Maybe Word64
width :: Maybe Word64
  , EmbedThumbnail -> Maybe Word64
height :: Maybe Word64
  }
  deriving (EmbedThumbnail -> EmbedThumbnail -> Bool
(EmbedThumbnail -> EmbedThumbnail -> Bool)
-> (EmbedThumbnail -> EmbedThumbnail -> Bool) -> Eq EmbedThumbnail
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EmbedThumbnail -> EmbedThumbnail -> Bool
== :: EmbedThumbnail -> EmbedThumbnail -> Bool
$c/= :: EmbedThumbnail -> EmbedThumbnail -> Bool
/= :: EmbedThumbnail -> EmbedThumbnail -> Bool
Eq, Int -> EmbedThumbnail -> ShowS
[EmbedThumbnail] -> ShowS
EmbedThumbnail -> String
(Int -> EmbedThumbnail -> ShowS)
-> (EmbedThumbnail -> String)
-> ([EmbedThumbnail] -> ShowS)
-> Show EmbedThumbnail
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EmbedThumbnail -> ShowS
showsPrec :: Int -> EmbedThumbnail -> ShowS
$cshow :: EmbedThumbnail -> String
show :: EmbedThumbnail -> String
$cshowList :: [EmbedThumbnail] -> ShowS
showList :: [EmbedThumbnail] -> ShowS
Show)
  deriving ([EmbedThumbnail] -> Value
[EmbedThumbnail] -> Encoding
EmbedThumbnail -> Value
EmbedThumbnail -> Encoding
(EmbedThumbnail -> Value)
-> (EmbedThumbnail -> Encoding)
-> ([EmbedThumbnail] -> Value)
-> ([EmbedThumbnail] -> Encoding)
-> ToJSON EmbedThumbnail
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: EmbedThumbnail -> Value
toJSON :: EmbedThumbnail -> Value
$ctoEncoding :: EmbedThumbnail -> Encoding
toEncoding :: EmbedThumbnail -> Encoding
$ctoJSONList :: [EmbedThumbnail] -> Value
toJSONList :: [EmbedThumbnail] -> Value
$ctoEncodingList :: [EmbedThumbnail] -> Encoding
toEncodingList :: [EmbedThumbnail] -> Encoding
Aeson.ToJSON) via CalamityToJSON EmbedThumbnail

instance CalamityToJSON' EmbedThumbnail where
  toPairs :: forall kv. KeyValue kv => EmbedThumbnail -> [Maybe kv]
toPairs EmbedThumbnail {Maybe Word64
Maybe Text
Text
$sel:url:EmbedThumbnail :: EmbedThumbnail -> Text
$sel:proxyUrl:EmbedThumbnail :: EmbedThumbnail -> Maybe Text
$sel:width:EmbedThumbnail :: EmbedThumbnail -> Maybe Word64
$sel:height:EmbedThumbnail :: EmbedThumbnail -> Maybe Word64
url :: Text
proxyUrl :: Maybe Text
width :: Maybe Word64
height :: Maybe Word64
..} =
    [ Key
"url" Key -> Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Text
url
    , Key
"proxy_url" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
proxyUrl
    , Key
"width" Key -> Maybe Word64 -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Word64
width
    , Key
"height" Key -> Maybe Word64 -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Word64
height
    ]

instance Aeson.FromJSON EmbedThumbnail where
  parseJSON :: Value -> Parser EmbedThumbnail
parseJSON = String
-> (Object -> Parser EmbedThumbnail)
-> Value
-> Parser EmbedThumbnail
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"EmbedThumbnail" ((Object -> Parser EmbedThumbnail)
 -> Value -> Parser EmbedThumbnail)
-> (Object -> Parser EmbedThumbnail)
-> Value
-> Parser EmbedThumbnail
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Text
-> Maybe Text -> Maybe Word64 -> Maybe Word64 -> EmbedThumbnail
EmbedThumbnail
      (Text
 -> Maybe Text -> Maybe Word64 -> Maybe Word64 -> EmbedThumbnail)
-> Parser Text
-> Parser
     (Maybe Text -> Maybe Word64 -> Maybe Word64 -> EmbedThumbnail)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"url"
      Parser
  (Maybe Text -> Maybe Word64 -> Maybe Word64 -> EmbedThumbnail)
-> Parser (Maybe Text)
-> Parser (Maybe Word64 -> Maybe Word64 -> EmbedThumbnail)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"proxy_url"
      Parser (Maybe Word64 -> Maybe Word64 -> EmbedThumbnail)
-> Parser (Maybe Word64) -> Parser (Maybe Word64 -> EmbedThumbnail)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Word64)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"width"
      Parser (Maybe Word64 -> EmbedThumbnail)
-> Parser (Maybe Word64) -> Parser EmbedThumbnail
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Word64)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"height"

{- | Create an embed thumbnail with a provided url

 The remaining fields are set to Nothing
-}
embedThumbnail :: Text -> EmbedThumbnail
embedThumbnail :: Text -> EmbedThumbnail
embedThumbnail Text
url = Text
-> Maybe Text -> Maybe Word64 -> Maybe Word64 -> EmbedThumbnail
EmbedThumbnail Text
url Maybe Text
forall a. Maybe a
Nothing Maybe Word64
forall a. Maybe a
Nothing Maybe Word64
forall a. Maybe a
Nothing

data EmbedVideo = EmbedVideo
  { EmbedVideo -> Maybe Text
url :: Maybe Text
  , EmbedVideo -> Maybe Text
proxyUrl :: Maybe Text
  , EmbedVideo -> Maybe Word64
width :: Maybe Word64
  , EmbedVideo -> Maybe Word64
height :: Maybe Word64
  }
  deriving (EmbedVideo -> EmbedVideo -> Bool
(EmbedVideo -> EmbedVideo -> Bool)
-> (EmbedVideo -> EmbedVideo -> Bool) -> Eq EmbedVideo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EmbedVideo -> EmbedVideo -> Bool
== :: EmbedVideo -> EmbedVideo -> Bool
$c/= :: EmbedVideo -> EmbedVideo -> Bool
/= :: EmbedVideo -> EmbedVideo -> Bool
Eq, Int -> EmbedVideo -> ShowS
[EmbedVideo] -> ShowS
EmbedVideo -> String
(Int -> EmbedVideo -> ShowS)
-> (EmbedVideo -> String)
-> ([EmbedVideo] -> ShowS)
-> Show EmbedVideo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EmbedVideo -> ShowS
showsPrec :: Int -> EmbedVideo -> ShowS
$cshow :: EmbedVideo -> String
show :: EmbedVideo -> String
$cshowList :: [EmbedVideo] -> ShowS
showList :: [EmbedVideo] -> ShowS
Show)
  deriving ([EmbedVideo] -> Value
[EmbedVideo] -> Encoding
EmbedVideo -> Value
EmbedVideo -> Encoding
(EmbedVideo -> Value)
-> (EmbedVideo -> Encoding)
-> ([EmbedVideo] -> Value)
-> ([EmbedVideo] -> Encoding)
-> ToJSON EmbedVideo
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: EmbedVideo -> Value
toJSON :: EmbedVideo -> Value
$ctoEncoding :: EmbedVideo -> Encoding
toEncoding :: EmbedVideo -> Encoding
$ctoJSONList :: [EmbedVideo] -> Value
toJSONList :: [EmbedVideo] -> Value
$ctoEncodingList :: [EmbedVideo] -> Encoding
toEncodingList :: [EmbedVideo] -> Encoding
Aeson.ToJSON) via CalamityToJSON EmbedVideo

instance CalamityToJSON' EmbedVideo where
  toPairs :: forall kv. KeyValue kv => EmbedVideo -> [Maybe kv]
toPairs EmbedVideo {Maybe Word64
Maybe Text
$sel:url:EmbedVideo :: EmbedVideo -> Maybe Text
$sel:proxyUrl:EmbedVideo :: EmbedVideo -> Maybe Text
$sel:width:EmbedVideo :: EmbedVideo -> Maybe Word64
$sel:height:EmbedVideo :: EmbedVideo -> Maybe Word64
url :: Maybe Text
proxyUrl :: Maybe Text
width :: Maybe Word64
height :: Maybe Word64
..} =
    [ Key
"url" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Maybe Text
url
    , Key
"proxy_url" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Maybe Text
proxyUrl
    , Key
"width" Key -> Maybe Word64 -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Maybe Word64
width
    , Key
"height" Key -> Maybe Word64 -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Maybe Word64
height
    ]

instance Aeson.FromJSON EmbedVideo where
  parseJSON :: Value -> Parser EmbedVideo
parseJSON = String
-> (Object -> Parser EmbedVideo) -> Value -> Parser EmbedVideo
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"EmbedVideo" ((Object -> Parser EmbedVideo) -> Value -> Parser EmbedVideo)
-> (Object -> Parser EmbedVideo) -> Value -> Parser EmbedVideo
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Maybe Text
-> Maybe Text -> Maybe Word64 -> Maybe Word64 -> EmbedVideo
EmbedVideo
      (Maybe Text
 -> Maybe Text -> Maybe Word64 -> Maybe Word64 -> EmbedVideo)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text -> Maybe Word64 -> Maybe Word64 -> EmbedVideo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"url"
      Parser (Maybe Text -> Maybe Word64 -> Maybe Word64 -> EmbedVideo)
-> Parser (Maybe Text)
-> Parser (Maybe Word64 -> Maybe Word64 -> EmbedVideo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"proxy_url"
      Parser (Maybe Word64 -> Maybe Word64 -> EmbedVideo)
-> Parser (Maybe Word64) -> Parser (Maybe Word64 -> EmbedVideo)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Word64)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"width"
      Parser (Maybe Word64 -> EmbedVideo)
-> Parser (Maybe Word64) -> Parser EmbedVideo
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Word64)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"height"

data EmbedProvider = EmbedProvider
  { EmbedProvider -> Maybe Text
name :: Maybe Text
  , EmbedProvider -> Maybe Text
url :: Maybe Text
  }
  deriving (EmbedProvider -> EmbedProvider -> Bool
(EmbedProvider -> EmbedProvider -> Bool)
-> (EmbedProvider -> EmbedProvider -> Bool) -> Eq EmbedProvider
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EmbedProvider -> EmbedProvider -> Bool
== :: EmbedProvider -> EmbedProvider -> Bool
$c/= :: EmbedProvider -> EmbedProvider -> Bool
/= :: EmbedProvider -> EmbedProvider -> Bool
Eq, Int -> EmbedProvider -> ShowS
[EmbedProvider] -> ShowS
EmbedProvider -> String
(Int -> EmbedProvider -> ShowS)
-> (EmbedProvider -> String)
-> ([EmbedProvider] -> ShowS)
-> Show EmbedProvider
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EmbedProvider -> ShowS
showsPrec :: Int -> EmbedProvider -> ShowS
$cshow :: EmbedProvider -> String
show :: EmbedProvider -> String
$cshowList :: [EmbedProvider] -> ShowS
showList :: [EmbedProvider] -> ShowS
Show)
  deriving ([EmbedProvider] -> Value
[EmbedProvider] -> Encoding
EmbedProvider -> Value
EmbedProvider -> Encoding
(EmbedProvider -> Value)
-> (EmbedProvider -> Encoding)
-> ([EmbedProvider] -> Value)
-> ([EmbedProvider] -> Encoding)
-> ToJSON EmbedProvider
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: EmbedProvider -> Value
toJSON :: EmbedProvider -> Value
$ctoEncoding :: EmbedProvider -> Encoding
toEncoding :: EmbedProvider -> Encoding
$ctoJSONList :: [EmbedProvider] -> Value
toJSONList :: [EmbedProvider] -> Value
$ctoEncodingList :: [EmbedProvider] -> Encoding
toEncodingList :: [EmbedProvider] -> Encoding
Aeson.ToJSON) via CalamityToJSON EmbedProvider

instance CalamityToJSON' EmbedProvider where
  toPairs :: forall kv. KeyValue kv => EmbedProvider -> [Maybe kv]
toPairs EmbedProvider {Maybe Text
$sel:name:EmbedProvider :: EmbedProvider -> Maybe Text
$sel:url:EmbedProvider :: EmbedProvider -> Maybe Text
name :: Maybe Text
url :: Maybe Text
..} =
    [ Key
"name" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Maybe Text
name
    , Key
"url" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Maybe Text
url
    ]

instance Aeson.FromJSON EmbedProvider where
  parseJSON :: Value -> Parser EmbedProvider
parseJSON = String
-> (Object -> Parser EmbedProvider)
-> Value
-> Parser EmbedProvider
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"EmbedProvider" ((Object -> Parser EmbedProvider) -> Value -> Parser EmbedProvider)
-> (Object -> Parser EmbedProvider)
-> Value
-> Parser EmbedProvider
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Maybe Text -> Maybe Text -> EmbedProvider
EmbedProvider
      (Maybe Text -> Maybe Text -> EmbedProvider)
-> Parser (Maybe Text) -> Parser (Maybe Text -> EmbedProvider)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"name"
      Parser (Maybe Text -> EmbedProvider)
-> Parser (Maybe Text) -> Parser EmbedProvider
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"url"

data EmbedAuthor = EmbedAuthor
  { EmbedAuthor -> Maybe Text
name :: Maybe Text
  , EmbedAuthor -> Maybe Text
url :: Maybe Text
  , EmbedAuthor -> Maybe Text
iconUrl :: Maybe Text
  , EmbedAuthor -> Maybe Text
proxyIconUrl :: Maybe Text
  }
  deriving (EmbedAuthor -> EmbedAuthor -> Bool
(EmbedAuthor -> EmbedAuthor -> Bool)
-> (EmbedAuthor -> EmbedAuthor -> Bool) -> Eq EmbedAuthor
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EmbedAuthor -> EmbedAuthor -> Bool
== :: EmbedAuthor -> EmbedAuthor -> Bool
$c/= :: EmbedAuthor -> EmbedAuthor -> Bool
/= :: EmbedAuthor -> EmbedAuthor -> Bool
Eq, Int -> EmbedAuthor -> ShowS
[EmbedAuthor] -> ShowS
EmbedAuthor -> String
(Int -> EmbedAuthor -> ShowS)
-> (EmbedAuthor -> String)
-> ([EmbedAuthor] -> ShowS)
-> Show EmbedAuthor
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EmbedAuthor -> ShowS
showsPrec :: Int -> EmbedAuthor -> ShowS
$cshow :: EmbedAuthor -> String
show :: EmbedAuthor -> String
$cshowList :: [EmbedAuthor] -> ShowS
showList :: [EmbedAuthor] -> ShowS
Show)
  deriving ([EmbedAuthor] -> Value
[EmbedAuthor] -> Encoding
EmbedAuthor -> Value
EmbedAuthor -> Encoding
(EmbedAuthor -> Value)
-> (EmbedAuthor -> Encoding)
-> ([EmbedAuthor] -> Value)
-> ([EmbedAuthor] -> Encoding)
-> ToJSON EmbedAuthor
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: EmbedAuthor -> Value
toJSON :: EmbedAuthor -> Value
$ctoEncoding :: EmbedAuthor -> Encoding
toEncoding :: EmbedAuthor -> Encoding
$ctoJSONList :: [EmbedAuthor] -> Value
toJSONList :: [EmbedAuthor] -> Value
$ctoEncodingList :: [EmbedAuthor] -> Encoding
toEncodingList :: [EmbedAuthor] -> Encoding
Aeson.ToJSON) via CalamityToJSON EmbedAuthor

instance Default EmbedAuthor where
  def :: EmbedAuthor
def = Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> EmbedAuthor
EmbedAuthor Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing

instance CalamityToJSON' EmbedAuthor where
  toPairs :: forall kv. KeyValue kv => EmbedAuthor -> [Maybe kv]
toPairs EmbedAuthor {Maybe Text
$sel:name:EmbedAuthor :: EmbedAuthor -> Maybe Text
$sel:url:EmbedAuthor :: EmbedAuthor -> Maybe Text
$sel:iconUrl:EmbedAuthor :: EmbedAuthor -> Maybe Text
$sel:proxyIconUrl:EmbedAuthor :: EmbedAuthor -> Maybe Text
name :: Maybe Text
url :: Maybe Text
iconUrl :: Maybe Text
proxyIconUrl :: Maybe Text
..} =
    [ Key
"name" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
name
    , Key
"url" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
url
    , Key
"icon_url" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
iconUrl
    , Key
"proxy_icon_url" Key -> Maybe Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> Maybe v -> Maybe kv
.?= Maybe Text
proxyIconUrl
    ]

instance Aeson.FromJSON EmbedAuthor where
  parseJSON :: Value -> Parser EmbedAuthor
parseJSON = String
-> (Object -> Parser EmbedAuthor) -> Value -> Parser EmbedAuthor
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"EmbedAuthor" ((Object -> Parser EmbedAuthor) -> Value -> Parser EmbedAuthor)
-> (Object -> Parser EmbedAuthor) -> Value -> Parser EmbedAuthor
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> EmbedAuthor
EmbedAuthor
      (Maybe Text
 -> Maybe Text -> Maybe Text -> Maybe Text -> EmbedAuthor)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> Maybe Text -> EmbedAuthor)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"name"
      Parser (Maybe Text -> Maybe Text -> Maybe Text -> EmbedAuthor)
-> Parser (Maybe Text)
-> Parser (Maybe Text -> Maybe Text -> EmbedAuthor)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"url"
      Parser (Maybe Text -> Maybe Text -> EmbedAuthor)
-> Parser (Maybe Text) -> Parser (Maybe Text -> EmbedAuthor)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"icon_url"
      Parser (Maybe Text -> EmbedAuthor)
-> Parser (Maybe Text) -> Parser EmbedAuthor
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"proxy_icon_url"

{- | Create an embed author with the given name

 The remaining fields are set to Nothing
-}
embedAuthor :: Text -> EmbedAuthor
embedAuthor :: Text -> EmbedAuthor
embedAuthor Text
name = Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> EmbedAuthor
EmbedAuthor (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
name) Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing Maybe Text
forall a. Maybe a
Nothing

{- | Create an embed author with the given name, url, and icon url

 The remaining fields are set to Nothing
-}
embedAuthor' ::
  -- | Name
  Text ->
  -- | Url
  Text ->
  -- | Icon url
  Text ->
  EmbedAuthor
embedAuthor' :: Text -> Text -> Text -> EmbedAuthor
embedAuthor' Text
name Text
url Text
iconUrl = Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> EmbedAuthor
EmbedAuthor (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
name) (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
url) (Text -> Maybe Text
forall a. a -> Maybe a
Just Text
iconUrl) Maybe Text
forall a. Maybe a
Nothing

data EmbedField = EmbedField
  { EmbedField -> Text
name :: Text
  , EmbedField -> Text
value :: Text
  , EmbedField -> Bool
inline :: Bool
  }
  deriving (EmbedField -> EmbedField -> Bool
(EmbedField -> EmbedField -> Bool)
-> (EmbedField -> EmbedField -> Bool) -> Eq EmbedField
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: EmbedField -> EmbedField -> Bool
== :: EmbedField -> EmbedField -> Bool
$c/= :: EmbedField -> EmbedField -> Bool
/= :: EmbedField -> EmbedField -> Bool
Eq, Int -> EmbedField -> ShowS
[EmbedField] -> ShowS
EmbedField -> String
(Int -> EmbedField -> ShowS)
-> (EmbedField -> String)
-> ([EmbedField] -> ShowS)
-> Show EmbedField
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> EmbedField -> ShowS
showsPrec :: Int -> EmbedField -> ShowS
$cshow :: EmbedField -> String
show :: EmbedField -> String
$cshowList :: [EmbedField] -> ShowS
showList :: [EmbedField] -> ShowS
Show)
  deriving ([EmbedField] -> Value
[EmbedField] -> Encoding
EmbedField -> Value
EmbedField -> Encoding
(EmbedField -> Value)
-> (EmbedField -> Encoding)
-> ([EmbedField] -> Value)
-> ([EmbedField] -> Encoding)
-> ToJSON EmbedField
forall a.
(a -> Value)
-> (a -> Encoding)
-> ([a] -> Value)
-> ([a] -> Encoding)
-> ToJSON a
$ctoJSON :: EmbedField -> Value
toJSON :: EmbedField -> Value
$ctoEncoding :: EmbedField -> Encoding
toEncoding :: EmbedField -> Encoding
$ctoJSONList :: [EmbedField] -> Value
toJSONList :: [EmbedField] -> Value
$ctoEncodingList :: [EmbedField] -> Encoding
toEncodingList :: [EmbedField] -> Encoding
Aeson.ToJSON) via CalamityToJSON EmbedField

instance CalamityToJSON' EmbedField where
  toPairs :: forall kv. KeyValue kv => EmbedField -> [Maybe kv]
toPairs EmbedField {Bool
Text
$sel:name:EmbedField :: EmbedField -> Text
$sel:value:EmbedField :: EmbedField -> Text
$sel:inline:EmbedField :: EmbedField -> Bool
name :: Text
value :: Text
inline :: Bool
..} =
    [ Key
"name" Key -> Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Text
name
    , Key
"value" Key -> Text -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Text
value
    , Key
"inline" Key -> Bool -> Maybe kv
forall v kv. (ToJSON v, KeyValue kv) => Key -> v -> Maybe kv
.= Bool
inline
    ]

instance Aeson.FromJSON EmbedField where
  parseJSON :: Value -> Parser EmbedField
parseJSON = String
-> (Object -> Parser EmbedField) -> Value -> Parser EmbedField
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Aeson.withObject String
"EmbedField" ((Object -> Parser EmbedField) -> Value -> Parser EmbedField)
-> (Object -> Parser EmbedField) -> Value -> Parser EmbedField
forall a b. (a -> b) -> a -> b
$ \Object
v ->
    Text -> Text -> Bool -> EmbedField
EmbedField
      (Text -> Text -> Bool -> EmbedField)
-> Parser Text -> Parser (Text -> Bool -> EmbedField)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Object
v Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"name"
      Parser (Text -> Bool -> EmbedField)
-> Parser Text -> Parser (Bool -> EmbedField)
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser Text
forall a. FromJSON a => Object -> Key -> Parser a
.: Key
"value"
      Parser (Bool -> EmbedField) -> Parser Bool -> Parser EmbedField
forall a b. Parser (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Object
v Object -> Key -> Parser (Maybe Bool)
forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
.:? Key
"inline" Parser (Maybe Bool) -> Bool -> Parser Bool
forall a. Parser (Maybe a) -> a -> Parser a
.!= Bool
False

-- | Create a non-inline embed field
embedField ::
  -- | Name
  Text ->
  -- | Value
  Text ->
  EmbedField
embedField :: Text -> Text -> EmbedField
embedField Text
name Text
value = Text -> Text -> Bool -> EmbedField
EmbedField Text
name Text
value Bool
False

$(makeFieldLabelsNoPrefix ''Embed)

$(deriveTextShow ''EmbedFooter)
$(makeFieldLabelsNoPrefix ''EmbedFooter)

$(deriveTextShow ''EmbedImage)
$(makeFieldLabelsNoPrefix ''EmbedImage)

$(deriveTextShow ''EmbedThumbnail)
$(makeFieldLabelsNoPrefix ''EmbedThumbnail)

$(deriveTextShow ''EmbedVideo)
$(makeFieldLabelsNoPrefix ''EmbedVideo)

$(deriveTextShow ''EmbedProvider)
$(makeFieldLabelsNoPrefix ''EmbedProvider)

$(deriveTextShow ''EmbedAuthor)
$(makeFieldLabelsNoPrefix ''EmbedAuthor)

$(deriveTextShow ''EmbedField)
$(makeFieldLabelsNoPrefix ''EmbedField)

instance Semigroup EmbedFooter where
  EmbedFooter
l <> :: EmbedFooter -> EmbedFooter -> EmbedFooter
<> EmbedFooter
r =
    EmbedFooter
l
      EmbedFooter -> (EmbedFooter -> EmbedFooter) -> EmbedFooter
forall a b. a -> (a -> b) -> b
& Optic A_Lens NoIx EmbedFooter EmbedFooter Text Text
#text Optic A_Lens NoIx EmbedFooter EmbedFooter Text Text
-> (Text -> Text) -> EmbedFooter -> EmbedFooter
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ (Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> (EmbedFooter
r EmbedFooter
-> Optic A_Lens NoIx EmbedFooter EmbedFooter Text Text -> Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic A_Lens NoIx EmbedFooter EmbedFooter Text Text
#text))
      EmbedFooter -> (EmbedFooter -> EmbedFooter) -> EmbedFooter
forall a b. a -> (a -> b) -> b
& Optic A_Lens NoIx EmbedFooter EmbedFooter (Maybe Text) (Maybe Text)
#iconUrl Optic A_Lens NoIx EmbedFooter EmbedFooter (Maybe Text) (Maybe Text)
-> (Maybe Text -> Maybe Text) -> EmbedFooter -> EmbedFooter
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ Last (Maybe Text) -> Maybe Text
forall a. Last a -> a
getLast (Last (Maybe Text) -> Maybe Text)
-> (Maybe Text -> Last (Maybe Text)) -> Maybe Text -> Maybe Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Last (Maybe Text) -> Last (Maybe Text) -> Last (Maybe Text)
forall a. Semigroup a => a -> a -> a
<> Maybe Text -> Last (Maybe Text)
forall a. a -> Last a
Last (EmbedFooter
r EmbedFooter
-> Optic
     A_Lens NoIx EmbedFooter EmbedFooter (Maybe Text) (Maybe Text)
-> Maybe Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic A_Lens NoIx EmbedFooter EmbedFooter (Maybe Text) (Maybe Text)
#iconUrl)) (Last (Maybe Text) -> Last (Maybe Text))
-> (Maybe Text -> Last (Maybe Text))
-> Maybe Text
-> Last (Maybe Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Text -> Last (Maybe Text)
forall a. a -> Last a
Last
      EmbedFooter -> (EmbedFooter -> EmbedFooter) -> EmbedFooter
forall a b. a -> (a -> b) -> b
& Optic A_Lens NoIx EmbedFooter EmbedFooter (Maybe Text) (Maybe Text)
#proxyIconUrl Optic A_Lens NoIx EmbedFooter EmbedFooter (Maybe Text) (Maybe Text)
-> (Maybe Text -> Maybe Text) -> EmbedFooter -> EmbedFooter
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ Last (Maybe Text) -> Maybe Text
forall a. Last a -> a
getLast (Last (Maybe Text) -> Maybe Text)
-> (Maybe Text -> Last (Maybe Text)) -> Maybe Text -> Maybe Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Last (Maybe Text) -> Last (Maybe Text) -> Last (Maybe Text)
forall a. Semigroup a => a -> a -> a
<> Maybe Text -> Last (Maybe Text)
forall a. a -> Last a
Last (EmbedFooter
r EmbedFooter
-> Optic
     A_Lens NoIx EmbedFooter EmbedFooter (Maybe Text) (Maybe Text)
-> Maybe Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic A_Lens NoIx EmbedFooter EmbedFooter (Maybe Text) (Maybe Text)
#proxyIconUrl)) (Last (Maybe Text) -> Last (Maybe Text))
-> (Maybe Text -> Last (Maybe Text))
-> Maybe Text
-> Last (Maybe Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Text -> Last (Maybe Text)
forall a. a -> Last a
Last

instance Semigroup Embed where
  Embed
l <> :: Embed -> Embed -> Embed
<> Embed
r =
    Embed
l
      Embed -> (Embed -> Embed) -> Embed
forall a b. a -> (a -> b) -> b
& Optic A_Lens NoIx Embed Embed (Maybe Text) (Maybe Text)
#title Optic A_Lens NoIx Embed Embed (Maybe Text) (Maybe Text)
-> (Maybe Text -> Maybe Text) -> Embed -> Embed
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ (Maybe Text -> Maybe Text -> Maybe Text
forall a. Semigroup a => a -> a -> a
<> (Embed
r Embed
-> Optic A_Lens NoIx Embed Embed (Maybe Text) (Maybe Text)
-> Maybe Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic A_Lens NoIx Embed Embed (Maybe Text) (Maybe Text)
#title))
      Embed -> (Embed -> Embed) -> Embed
forall a b. a -> (a -> b) -> b
& Optic A_Lens NoIx Embed Embed (Maybe Text) (Maybe Text)
#type_ Optic A_Lens NoIx Embed Embed (Maybe Text) (Maybe Text)
-> (Maybe Text -> Maybe Text) -> Embed -> Embed
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ Last (Maybe Text) -> Maybe Text
forall a. Last a -> a
getLast (Last (Maybe Text) -> Maybe Text)
-> (Maybe Text -> Last (Maybe Text)) -> Maybe Text -> Maybe Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Last (Maybe Text) -> Last (Maybe Text) -> Last (Maybe Text)
forall a. Semigroup a => a -> a -> a
<> Maybe Text -> Last (Maybe Text)
forall a. a -> Last a
Last (Embed
r Embed
-> Optic A_Lens NoIx Embed Embed (Maybe Text) (Maybe Text)
-> Maybe Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic A_Lens NoIx Embed Embed (Maybe Text) (Maybe Text)
#type_)) (Last (Maybe Text) -> Last (Maybe Text))
-> (Maybe Text -> Last (Maybe Text))
-> Maybe Text
-> Last (Maybe Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Text -> Last (Maybe Text)
forall a. a -> Last a
Last
      Embed -> (Embed -> Embed) -> Embed
forall a b. a -> (a -> b) -> b
& Optic A_Lens NoIx Embed Embed (Maybe Text) (Maybe Text)
#description Optic A_Lens NoIx Embed Embed (Maybe Text) (Maybe Text)
-> (Maybe Text -> Maybe Text) -> Embed -> Embed
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ (Maybe Text -> Maybe Text -> Maybe Text
forall a. Semigroup a => a -> a -> a
<> (Embed
r Embed
-> Optic A_Lens NoIx Embed Embed (Maybe Text) (Maybe Text)
-> Maybe Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic A_Lens NoIx Embed Embed (Maybe Text) (Maybe Text)
#description))
      Embed -> (Embed -> Embed) -> Embed
forall a b. a -> (a -> b) -> b
& Optic A_Lens NoIx Embed Embed (Maybe Text) (Maybe Text)
#url Optic A_Lens NoIx Embed Embed (Maybe Text) (Maybe Text)
-> (Maybe Text -> Maybe Text) -> Embed -> Embed
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ Last (Maybe Text) -> Maybe Text
forall a. Last a -> a
getLast (Last (Maybe Text) -> Maybe Text)
-> (Maybe Text -> Last (Maybe Text)) -> Maybe Text -> Maybe Text
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Last (Maybe Text) -> Last (Maybe Text) -> Last (Maybe Text)
forall a. Semigroup a => a -> a -> a
<> Maybe Text -> Last (Maybe Text)
forall a. a -> Last a
Last (Embed
r Embed
-> Optic A_Lens NoIx Embed Embed (Maybe Text) (Maybe Text)
-> Maybe Text
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic A_Lens NoIx Embed Embed (Maybe Text) (Maybe Text)
#url)) (Last (Maybe Text) -> Last (Maybe Text))
-> (Maybe Text -> Last (Maybe Text))
-> Maybe Text
-> Last (Maybe Text)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe Text -> Last (Maybe Text)
forall a. a -> Last a
Last
      Embed -> (Embed -> Embed) -> Embed
forall a b. a -> (a -> b) -> b
& Optic A_Lens NoIx Embed Embed (Maybe UTCTime) (Maybe UTCTime)
#timestamp Optic A_Lens NoIx Embed Embed (Maybe UTCTime) (Maybe UTCTime)
-> (Maybe UTCTime -> Maybe UTCTime) -> Embed -> Embed
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ Last (Maybe UTCTime) -> Maybe UTCTime
forall a. Last a -> a
getLast (Last (Maybe UTCTime) -> Maybe UTCTime)
-> (Maybe UTCTime -> Last (Maybe UTCTime))
-> Maybe UTCTime
-> Maybe UTCTime
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Last (Maybe UTCTime)
-> Last (Maybe UTCTime) -> Last (Maybe UTCTime)
forall a. Semigroup a => a -> a -> a
<> Maybe UTCTime -> Last (Maybe UTCTime)
forall a. a -> Last a
Last (Embed
r Embed
-> Optic A_Lens NoIx Embed Embed (Maybe UTCTime) (Maybe UTCTime)
-> Maybe UTCTime
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic A_Lens NoIx Embed Embed (Maybe UTCTime) (Maybe UTCTime)
#timestamp)) (Last (Maybe UTCTime) -> Last (Maybe UTCTime))
-> (Maybe UTCTime -> Last (Maybe UTCTime))
-> Maybe UTCTime
-> Last (Maybe UTCTime)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe UTCTime -> Last (Maybe UTCTime)
forall a. a -> Last a
Last
      Embed -> (Embed -> Embed) -> Embed
forall a b. a -> (a -> b) -> b
& Optic
  A_Lens
  NoIx
  Embed
  Embed
  (Maybe (Colour Double))
  (Maybe (Colour Double))
#color Optic
  A_Lens
  NoIx
  Embed
  Embed
  (Maybe (Colour Double))
  (Maybe (Colour Double))
-> (Maybe (Colour Double) -> Maybe (Colour Double))
-> Embed
-> Embed
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ Last (Maybe (Colour Double)) -> Maybe (Colour Double)
forall a. Last a -> a
getLast (Last (Maybe (Colour Double)) -> Maybe (Colour Double))
-> (Maybe (Colour Double) -> Last (Maybe (Colour Double)))
-> Maybe (Colour Double)
-> Maybe (Colour Double)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Last (Maybe (Colour Double))
-> Last (Maybe (Colour Double)) -> Last (Maybe (Colour Double))
forall a. Semigroup a => a -> a -> a
<> Maybe (Colour Double) -> Last (Maybe (Colour Double))
forall a. a -> Last a
Last (Embed
r Embed
-> Optic
     A_Lens
     NoIx
     Embed
     Embed
     (Maybe (Colour Double))
     (Maybe (Colour Double))
-> Maybe (Colour Double)
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic
  A_Lens
  NoIx
  Embed
  Embed
  (Maybe (Colour Double))
  (Maybe (Colour Double))
#color)) (Last (Maybe (Colour Double)) -> Last (Maybe (Colour Double)))
-> (Maybe (Colour Double) -> Last (Maybe (Colour Double)))
-> Maybe (Colour Double)
-> Last (Maybe (Colour Double))
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe (Colour Double) -> Last (Maybe (Colour Double))
forall a. a -> Last a
Last
      Embed -> (Embed -> Embed) -> Embed
forall a b. a -> (a -> b) -> b
& Optic
  A_Lens NoIx Embed Embed (Maybe EmbedFooter) (Maybe EmbedFooter)
#footer Optic
  A_Lens NoIx Embed Embed (Maybe EmbedFooter) (Maybe EmbedFooter)
-> (Maybe EmbedFooter -> Maybe EmbedFooter) -> Embed -> Embed
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ (Maybe EmbedFooter -> Maybe EmbedFooter -> Maybe EmbedFooter
forall a. Semigroup a => a -> a -> a
<> (Embed
r Embed
-> Optic
     A_Lens NoIx Embed Embed (Maybe EmbedFooter) (Maybe EmbedFooter)
-> Maybe EmbedFooter
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic
  A_Lens NoIx Embed Embed (Maybe EmbedFooter) (Maybe EmbedFooter)
#footer))
      Embed -> (Embed -> Embed) -> Embed
forall a b. a -> (a -> b) -> b
& Optic A_Lens NoIx Embed Embed (Maybe EmbedImage) (Maybe EmbedImage)
#image Optic A_Lens NoIx Embed Embed (Maybe EmbedImage) (Maybe EmbedImage)
-> (Maybe EmbedImage -> Maybe EmbedImage) -> Embed -> Embed
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ Last (Maybe EmbedImage) -> Maybe EmbedImage
forall a. Last a -> a
getLast (Last (Maybe EmbedImage) -> Maybe EmbedImage)
-> (Maybe EmbedImage -> Last (Maybe EmbedImage))
-> Maybe EmbedImage
-> Maybe EmbedImage
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Last (Maybe EmbedImage)
-> Last (Maybe EmbedImage) -> Last (Maybe EmbedImage)
forall a. Semigroup a => a -> a -> a
<> Maybe EmbedImage -> Last (Maybe EmbedImage)
forall a. a -> Last a
Last (Embed
r Embed
-> Optic
     A_Lens NoIx Embed Embed (Maybe EmbedImage) (Maybe EmbedImage)
-> Maybe EmbedImage
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic A_Lens NoIx Embed Embed (Maybe EmbedImage) (Maybe EmbedImage)
#image)) (Last (Maybe EmbedImage) -> Last (Maybe EmbedImage))
-> (Maybe EmbedImage -> Last (Maybe EmbedImage))
-> Maybe EmbedImage
-> Last (Maybe EmbedImage)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe EmbedImage -> Last (Maybe EmbedImage)
forall a. a -> Last a
Last
      Embed -> (Embed -> Embed) -> Embed
forall a b. a -> (a -> b) -> b
& Optic
  A_Lens
  NoIx
  Embed
  Embed
  (Maybe EmbedThumbnail)
  (Maybe EmbedThumbnail)
#thumbnail Optic
  A_Lens
  NoIx
  Embed
  Embed
  (Maybe EmbedThumbnail)
  (Maybe EmbedThumbnail)
-> (Maybe EmbedThumbnail -> Maybe EmbedThumbnail) -> Embed -> Embed
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ Last (Maybe EmbedThumbnail) -> Maybe EmbedThumbnail
forall a. Last a -> a
getLast (Last (Maybe EmbedThumbnail) -> Maybe EmbedThumbnail)
-> (Maybe EmbedThumbnail -> Last (Maybe EmbedThumbnail))
-> Maybe EmbedThumbnail
-> Maybe EmbedThumbnail
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Last (Maybe EmbedThumbnail)
-> Last (Maybe EmbedThumbnail) -> Last (Maybe EmbedThumbnail)
forall a. Semigroup a => a -> a -> a
<> Maybe EmbedThumbnail -> Last (Maybe EmbedThumbnail)
forall a. a -> Last a
Last (Embed
r Embed
-> Optic
     A_Lens
     NoIx
     Embed
     Embed
     (Maybe EmbedThumbnail)
     (Maybe EmbedThumbnail)
-> Maybe EmbedThumbnail
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic
  A_Lens
  NoIx
  Embed
  Embed
  (Maybe EmbedThumbnail)
  (Maybe EmbedThumbnail)
#thumbnail)) (Last (Maybe EmbedThumbnail) -> Last (Maybe EmbedThumbnail))
-> (Maybe EmbedThumbnail -> Last (Maybe EmbedThumbnail))
-> Maybe EmbedThumbnail
-> Last (Maybe EmbedThumbnail)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe EmbedThumbnail -> Last (Maybe EmbedThumbnail)
forall a. a -> Last a
Last
      Embed -> (Embed -> Embed) -> Embed
forall a b. a -> (a -> b) -> b
& Optic A_Lens NoIx Embed Embed (Maybe EmbedVideo) (Maybe EmbedVideo)
#video Optic A_Lens NoIx Embed Embed (Maybe EmbedVideo) (Maybe EmbedVideo)
-> (Maybe EmbedVideo -> Maybe EmbedVideo) -> Embed -> Embed
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ Last (Maybe EmbedVideo) -> Maybe EmbedVideo
forall a. Last a -> a
getLast (Last (Maybe EmbedVideo) -> Maybe EmbedVideo)
-> (Maybe EmbedVideo -> Last (Maybe EmbedVideo))
-> Maybe EmbedVideo
-> Maybe EmbedVideo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Last (Maybe EmbedVideo)
-> Last (Maybe EmbedVideo) -> Last (Maybe EmbedVideo)
forall a. Semigroup a => a -> a -> a
<> Maybe EmbedVideo -> Last (Maybe EmbedVideo)
forall a. a -> Last a
Last (Embed
r Embed
-> Optic
     A_Lens NoIx Embed Embed (Maybe EmbedVideo) (Maybe EmbedVideo)
-> Maybe EmbedVideo
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic A_Lens NoIx Embed Embed (Maybe EmbedVideo) (Maybe EmbedVideo)
#video)) (Last (Maybe EmbedVideo) -> Last (Maybe EmbedVideo))
-> (Maybe EmbedVideo -> Last (Maybe EmbedVideo))
-> Maybe EmbedVideo
-> Last (Maybe EmbedVideo)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe EmbedVideo -> Last (Maybe EmbedVideo)
forall a. a -> Last a
Last
      Embed -> (Embed -> Embed) -> Embed
forall a b. a -> (a -> b) -> b
& Optic
  A_Lens NoIx Embed Embed (Maybe EmbedProvider) (Maybe EmbedProvider)
#provider Optic
  A_Lens NoIx Embed Embed (Maybe EmbedProvider) (Maybe EmbedProvider)
-> (Maybe EmbedProvider -> Maybe EmbedProvider) -> Embed -> Embed
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ Last (Maybe EmbedProvider) -> Maybe EmbedProvider
forall a. Last a -> a
getLast (Last (Maybe EmbedProvider) -> Maybe EmbedProvider)
-> (Maybe EmbedProvider -> Last (Maybe EmbedProvider))
-> Maybe EmbedProvider
-> Maybe EmbedProvider
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Last (Maybe EmbedProvider)
-> Last (Maybe EmbedProvider) -> Last (Maybe EmbedProvider)
forall a. Semigroup a => a -> a -> a
<> Maybe EmbedProvider -> Last (Maybe EmbedProvider)
forall a. a -> Last a
Last (Embed
r Embed
-> Optic
     A_Lens NoIx Embed Embed (Maybe EmbedProvider) (Maybe EmbedProvider)
-> Maybe EmbedProvider
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic
  A_Lens NoIx Embed Embed (Maybe EmbedProvider) (Maybe EmbedProvider)
#provider)) (Last (Maybe EmbedProvider) -> Last (Maybe EmbedProvider))
-> (Maybe EmbedProvider -> Last (Maybe EmbedProvider))
-> Maybe EmbedProvider
-> Last (Maybe EmbedProvider)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe EmbedProvider -> Last (Maybe EmbedProvider)
forall a. a -> Last a
Last
      Embed -> (Embed -> Embed) -> Embed
forall a b. a -> (a -> b) -> b
& Optic
  A_Lens NoIx Embed Embed (Maybe EmbedAuthor) (Maybe EmbedAuthor)
#author Optic
  A_Lens NoIx Embed Embed (Maybe EmbedAuthor) (Maybe EmbedAuthor)
-> (Maybe EmbedAuthor -> Maybe EmbedAuthor) -> Embed -> Embed
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ Last (Maybe EmbedAuthor) -> Maybe EmbedAuthor
forall a. Last a -> a
getLast (Last (Maybe EmbedAuthor) -> Maybe EmbedAuthor)
-> (Maybe EmbedAuthor -> Last (Maybe EmbedAuthor))
-> Maybe EmbedAuthor
-> Maybe EmbedAuthor
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (Last (Maybe EmbedAuthor)
-> Last (Maybe EmbedAuthor) -> Last (Maybe EmbedAuthor)
forall a. Semigroup a => a -> a -> a
<> Maybe EmbedAuthor -> Last (Maybe EmbedAuthor)
forall a. a -> Last a
Last (Embed
r Embed
-> Optic
     A_Lens NoIx Embed Embed (Maybe EmbedAuthor) (Maybe EmbedAuthor)
-> Maybe EmbedAuthor
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic
  A_Lens NoIx Embed Embed (Maybe EmbedAuthor) (Maybe EmbedAuthor)
#author)) (Last (Maybe EmbedAuthor) -> Last (Maybe EmbedAuthor))
-> (Maybe EmbedAuthor -> Last (Maybe EmbedAuthor))
-> Maybe EmbedAuthor
-> Last (Maybe EmbedAuthor)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Maybe EmbedAuthor -> Last (Maybe EmbedAuthor)
forall a. a -> Last a
Last
      Embed -> (Embed -> Embed) -> Embed
forall a b. a -> (a -> b) -> b
& Optic A_Lens NoIx Embed Embed [EmbedField] [EmbedField]
#fields Optic A_Lens NoIx Embed Embed [EmbedField] [EmbedField]
-> ([EmbedField] -> [EmbedField]) -> Embed -> Embed
forall k (is :: IxList) s t a b.
Is k A_Setter =>
Optic k is s t a b -> (a -> b) -> s -> t
%~ ([EmbedField] -> [EmbedField] -> [EmbedField]
forall a. Semigroup a => a -> a -> a
<> (Embed
r Embed
-> Optic A_Lens NoIx Embed Embed [EmbedField] [EmbedField]
-> [EmbedField]
forall k s (is :: IxList) a.
Is k A_Getter =>
s -> Optic' k is s a -> a
^. Optic A_Lens NoIx Embed Embed [EmbedField] [EmbedField]
#fields))

instance Monoid Embed where
  mempty :: Embed
mempty = Embed
forall a. Default a => a
def