packages feed

jsaddle-dom-0.10.0.0: src/JSDOM/Generated/CookieInit.hs

{-# LANGUAGE PatternSynonyms #-}
{-# LANGUAGE ImplicitParams, ConstraintKinds, KindSignatures #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
-- | Generated by dom-gen from cookiestore (webref). Do not edit.
module JSDOM.Generated.CookieInit
       (newCookieInit, setName, getName, setValue, getValue, setExpires, getExpires, getExpiresUnsafe, getExpiresUnchecked, setDomain, getDomain, getDomainUnsafe, getDomainUnchecked, setPath, getPath, getPathUnsafe, getPathUnchecked, setSameSite, getSameSite, getSameSiteUnsafe, getSameSiteUnchecked, setPartitioned, getPartitioned, getPartitionedUnsafe, getPartitionedUnchecked, setMaxAge, getMaxAge, getMaxAgeUnsafe, getMaxAgeUnchecked, CookieInit(..), gTypeCookieInit)
       where
import Prelude ((.), (==), (>>=), (<$>), (++), Bool(..), Maybe(..), IO, Int, Word, Double, Float)
import qualified Prelude as P
import Control.Monad (void)
import Control.Lens.Operators ((^.))
import Language.Javascript.JSaddle (JSM, JSVal, JSString, toJSVal, valToBool, valToNumber, js, jss, jsf, jsg, new, function, asyncFunction, jsUndefined, jsNull)
import JSDOM.Types
import qualified JSDOM.Types as Types
import JSDOM.EventTargetClosures (EventName, unsafeEventName, unsafeEventNameAsync)
import JSDOM.Generated.Enums

-- | <https://cookiestore.spec.whatwg.org/#dictdef-cookieinit CookieInit specification>
newCookieInit :: (MonadDOM m, ToJSString name, ToJSString value) => name -> value -> m CookieInit
newCookieInit name value = liftDOM ((((new (jsg "Object") () >>= \o -> (o ^. jss "name" (toJSVal name)) P.>> (o ^. jss "value" (toJSVal value)) P.>> P.return o)) >>= fromJSValUnchecked))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-name CookieInit.name specification>
setName :: (MonadDOM m, ToJSString val) => CookieInit -> val -> m ()
setName self val = liftDOM (void (self ^. jss "name" (toJSVal val)))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-name CookieInit.name specification>
getName :: (MonadDOM m, FromJSString result) => CookieInit -> m result
getName self = liftDOM (((self ^. js "name") >>= fromJSValUnchecked))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-value CookieInit.value specification>
setValue :: (MonadDOM m, ToJSString val) => CookieInit -> val -> m ()
setValue self val = liftDOM (void (self ^. jss "value" (toJSVal val)))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-value CookieInit.value specification>
getValue :: (MonadDOM m, FromJSString result) => CookieInit -> m result
getValue self = liftDOM (((self ^. js "value") >>= fromJSValUnchecked))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-expires CookieInit.expires specification>
setExpires :: (MonadDOM m) => CookieInit -> Maybe Double -> m ()
setExpires self val = liftDOM (void (self ^. jss "expires" (toJSVal val)))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-expires CookieInit.expires specification>
getExpires :: (MonadDOM m) => CookieInit -> m (Maybe Double)
getExpires self = liftDOM (((self ^. js "expires") >>= fromJSValUnchecked))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-expires CookieInit.expires specification>
getExpiresUnsafe :: (MonadDOM m, HasCallStack) => CookieInit -> m Double
getExpiresUnsafe self = liftDOM ((((self ^. js "expires") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-expires CookieInit.expires specification>
getExpiresUnchecked :: (MonadDOM m) => CookieInit -> m Double
getExpiresUnchecked self = liftDOM (((self ^. js "expires") >>= valToNumber))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-domain CookieInit.domain specification>
setDomain :: (MonadDOM m, ToJSString val) => CookieInit -> Maybe val -> m ()
setDomain self val = liftDOM (void (self ^. jss "domain" (toJSVal val)))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-domain CookieInit.domain specification>
getDomain :: (MonadDOM m, FromJSString result) => CookieInit -> m (Maybe result)
getDomain self = liftDOM (((self ^. js "domain") >>= fromMaybeJSString))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-domain CookieInit.domain specification>
getDomainUnsafe :: (MonadDOM m, HasCallStack, FromJSString result) => CookieInit -> m result
getDomainUnsafe self = liftDOM ((((self ^. js "domain") >>= fromMaybeJSString) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-domain CookieInit.domain specification>
getDomainUnchecked :: (MonadDOM m, FromJSString result) => CookieInit -> m result
getDomainUnchecked self = liftDOM (((self ^. js "domain") >>= fromJSValUnchecked))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-path CookieInit.path specification>
setPath :: (MonadDOM m, ToJSString val) => CookieInit -> val -> m ()
setPath self val = liftDOM (void (self ^. jss "path" (toJSVal val)))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-path CookieInit.path specification>
getPath :: (MonadDOM m, FromJSString result) => CookieInit -> m (Maybe result)
getPath self = liftDOM (((self ^. js "path") >>= fromMaybeJSString))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-path CookieInit.path specification>
getPathUnsafe :: (MonadDOM m, HasCallStack, FromJSString result) => CookieInit -> m result
getPathUnsafe self = liftDOM ((((self ^. js "path") >>= fromMaybeJSString) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-path CookieInit.path specification>
getPathUnchecked :: (MonadDOM m, FromJSString result) => CookieInit -> m result
getPathUnchecked self = liftDOM (((self ^. js "path") >>= fromJSValUnchecked))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-samesite CookieInit.sameSite specification>
setSameSite :: (MonadDOM m) => CookieInit -> CookieSameSite -> m ()
setSameSite self val = liftDOM (void (self ^. jss "sameSite" (toJSVal val)))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-samesite CookieInit.sameSite specification>
getSameSite :: (MonadDOM m) => CookieInit -> m (Maybe CookieSameSite)
getSameSite self = liftDOM (((self ^. js "sameSite") >>= fromJSValUnchecked))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-samesite CookieInit.sameSite specification>
getSameSiteUnsafe :: (MonadDOM m, HasCallStack) => CookieInit -> m CookieSameSite
getSameSiteUnsafe self = liftDOM ((((self ^. js "sameSite") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-samesite CookieInit.sameSite specification>
getSameSiteUnchecked :: (MonadDOM m) => CookieInit -> m CookieSameSite
getSameSiteUnchecked self = liftDOM (((self ^. js "sameSite") >>= fromJSValUnchecked))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-partitioned CookieInit.partitioned specification>
setPartitioned :: (MonadDOM m) => CookieInit -> Bool -> m ()
setPartitioned self val = liftDOM (void (self ^. jss "partitioned" (toJSVal val)))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-partitioned CookieInit.partitioned specification>
getPartitioned :: (MonadDOM m) => CookieInit -> m (Maybe Bool)
getPartitioned self = liftDOM (((self ^. js "partitioned") >>= fromJSValUnchecked))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-partitioned CookieInit.partitioned specification>
getPartitionedUnsafe :: (MonadDOM m, HasCallStack) => CookieInit -> m Bool
getPartitionedUnsafe self = liftDOM ((((self ^. js "partitioned") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-partitioned CookieInit.partitioned specification>
getPartitionedUnchecked :: (MonadDOM m) => CookieInit -> m Bool
getPartitionedUnchecked self = liftDOM (((self ^. js "partitioned") >>= valToBool))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-maxage CookieInit.maxAge specification>
setMaxAge :: (MonadDOM m) => CookieInit -> Maybe Int53 -> m ()
setMaxAge self val = liftDOM (void (self ^. jss "maxAge" (toJSVal val)))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-maxage CookieInit.maxAge specification>
getMaxAge :: (MonadDOM m) => CookieInit -> m (Maybe Int53)
getMaxAge self = liftDOM (((self ^. js "maxAge") >>= fromJSValUnchecked))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-maxage CookieInit.maxAge specification>
getMaxAgeUnsafe :: (MonadDOM m, HasCallStack) => CookieInit -> m Int53
getMaxAgeUnsafe self = liftDOM ((((self ^. js "maxAge") >>= fromJSValUnchecked) >>= P.maybe (P.error "Nothing to return") P.return))

-- | <https://cookiestore.spec.whatwg.org/#dom-cookieinit-maxage CookieInit.maxAge specification>
getMaxAgeUnchecked :: (MonadDOM m) => CookieInit -> m Int53
getMaxAgeUnchecked self = liftDOM (((self ^. js "maxAge") >>= fromJSValUnchecked))