{-# OPTIONS_GHC -Wno-orphans #-}

-- | Swagger implementation of 'WG.Cookie' and 'WG.SetCookie' traits.
module WebGear.Swagger.Trait.Cookie () where

import WebGear.Core.Trait (Get (..), Set (..))
import qualified WebGear.Core.Trait.Cookie as WG
import WebGear.Swagger.Handler (SwaggerHandler (..))

-- Cookie information is not captured by Swagger

instance Get (SwaggerHandler m) (WG.Cookie e name val) where
  {-# INLINE getTrait #-}
  getTrait :: forall (ts :: [*]).
Prerequisite (Cookie e name val) ts =>
Cookie e name val
-> SwaggerHandler
     m
     (With Request ts)
     (Either
        (Absence (Cookie e name val))
        (Attribute (Cookie e name val) Request))
getTrait Cookie e name val
WG.Cookie = (Swagger -> State Documentation Swagger)
-> SwaggerHandler
     m
     (With Request ts)
     (Either
        (Absence (Cookie e name val))
        (Attribute (Cookie e name val) Request))
forall {k} {k1} {k2} (m :: k) (a :: k1) (b :: k2).
(Swagger -> State Documentation Swagger) -> SwaggerHandler m a b
SwaggerHandler Swagger -> State Documentation Swagger
forall a. a -> StateT Documentation Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure

instance Set (SwaggerHandler m) (WG.SetCookie e name) where
  {-# INLINE setTrait #-}
  setTrait :: forall (ts :: [*]).
SetCookie e name
-> (With Response ts
    -> Response
    -> Attribute (SetCookie e name) Response
    -> With Response (SetCookie e name : ts))
-> SwaggerHandler
     m
     (With Response ts, Attribute (SetCookie e name) Response)
     (With Response (SetCookie e name : ts))
setTrait SetCookie e name
WG.SetCookie With Response ts
-> Response
-> Attribute (SetCookie e name) Response
-> With Response (SetCookie e name : ts)
_ = (Swagger -> State Documentation Swagger)
-> SwaggerHandler
     m
     (With Response ts, Attribute (SetCookie e name) Response)
     (With Response (SetCookie e name : ts))
forall {k} {k1} {k2} (m :: k) (a :: k1) (b :: k2).
(Swagger -> State Documentation Swagger) -> SwaggerHandler m a b
SwaggerHandler Swagger -> State Documentation Swagger
forall a. a -> StateT Documentation Identity a
forall (f :: * -> *) a. Applicative f => a -> f a
pure