module Patrol.Type.Breadcrumbs where

import qualified Data.Aeson as Aeson
import qualified Patrol.Extra.Aeson as Aeson
import qualified Patrol.Type.Breadcrumb as Breadcrumb

-- | <https://develop.sentry.dev/sdk/event-payloads/types/#breadcrumbs>
newtype Breadcrumbs = Breadcrumbs
  { Breadcrumbs -> [Breadcrumb]
values :: [Breadcrumb.Breadcrumb]
  }
  deriving (Breadcrumbs -> Breadcrumbs -> Bool
(Breadcrumbs -> Breadcrumbs -> Bool)
-> (Breadcrumbs -> Breadcrumbs -> Bool) -> Eq Breadcrumbs
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Breadcrumbs -> Breadcrumbs -> Bool
== :: Breadcrumbs -> Breadcrumbs -> Bool
$c/= :: Breadcrumbs -> Breadcrumbs -> Bool
/= :: Breadcrumbs -> Breadcrumbs -> Bool
Eq, Int -> Breadcrumbs -> ShowS
[Breadcrumbs] -> ShowS
Breadcrumbs -> String
(Int -> Breadcrumbs -> ShowS)
-> (Breadcrumbs -> String)
-> ([Breadcrumbs] -> ShowS)
-> Show Breadcrumbs
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Breadcrumbs -> ShowS
showsPrec :: Int -> Breadcrumbs -> ShowS
$cshow :: Breadcrumbs -> String
show :: Breadcrumbs -> String
$cshowList :: [Breadcrumbs] -> ShowS
showList :: [Breadcrumbs] -> ShowS
Show)

instance Aeson.ToJSON Breadcrumbs where
  toJSON :: Breadcrumbs -> Value
toJSON Breadcrumbs
breadcrumbs =
    [Pair] -> Value
Aeson.intoObject
      [ String -> [Breadcrumb] -> Pair
forall a. ToJSON a => String -> a -> Pair
Aeson.pair String
"values" ([Breadcrumb] -> Pair) -> [Breadcrumb] -> Pair
forall a b. (a -> b) -> a -> b
$ Breadcrumbs -> [Breadcrumb]
values Breadcrumbs
breadcrumbs
      ]

empty :: Breadcrumbs
empty :: Breadcrumbs
empty =
  Breadcrumbs
    { values :: [Breadcrumb]
values = []
    }