module Calamity.HTTP.Internal.Types
( RestError(..)
, RateLimitState(..)
, DiscordResponseType(..)
, GatewayResponse
, BotGatewayResponse ) where
import Calamity.HTTP.Internal.Route
import Calamity.Internal.AesonThings
import Control.Concurrent.Event ( Event )
import Control.Concurrent.STM.Lock ( Lock )
import Data.Aeson
import qualified Data.ByteString.Lazy as LB
import Data.Text.Lazy
import GHC.Generics
import qualified StmContainers.Map as SC
data RestError
= HTTPError
{ status :: Int
, response :: Maybe Value
}
| DecodeError Text
deriving ( Show, Generic )
data RateLimitState = RateLimitState
{ rateLimits :: SC.Map Route Lock
, globalLock :: Event
}
deriving ( Generic )
data DiscordResponseType
=
Good LB.ByteString
| ExhaustedBucket LB.ByteString Int
| Ratelimited Int
Bool
| ServerError Int
| ClientError Int LB.ByteString
newtype GatewayResponse = GatewayResponse
{ url :: Text
}
deriving ( Generic, Show )
deriving ( FromJSON ) via CalamityJSON GatewayResponse
data BotGatewayResponse = BotGatewayResponse
{ url :: Text
, shards :: Int
}
deriving ( Generic, Show )
deriving ( FromJSON ) via CalamityJSON BotGatewayResponse