-- | Contains subreddit wiki-related actions.
module Reddit.Actions.Wiki
  ( getWikiPage
  , editWikiPage ) where

import Reddit.Types.Empty
import Reddit.Types.Reddit
import Reddit.Types.Subreddit
import Reddit.Types.Wiki
import qualified Reddit.Routes as Route

import Data.Text (Text)

-- | Get the specified wiki page on a particular subreddit. Requires
--   permission to view the specified wiki page.
getWikiPage :: Monad m => SubredditName -> Text -> RedditT m WikiPage
getWikiPage :: SubredditName -> Text -> RedditT m WikiPage
getWikiPage SubredditName
sub Text
page = Route -> RedditT m WikiPage
forall a (m :: * -> *).
(FromJSON a, Monad m) =>
Route -> RedditT m a
runRoute (Route -> RedditT m WikiPage) -> Route -> RedditT m WikiPage
forall a b. (a -> b) -> a -> b
$ SubredditName -> Text -> Route
Route.wikiPage SubredditName
sub Text
page

-- | Edit the specified wiki page on a particular subreddit. Requires
--   permission to edit the specified wiki page.
editWikiPage :: Monad m
             => SubredditName -- ^ Subreddit whose wiki to modify
             -> Text -- ^ The name of the page you're editing
             -> Text -- ^ The new markdown content of the page you're editing
             -> Text -- ^ The reason for the edit
             -> RedditT m ()
editWikiPage :: SubredditName -> Text -> Text -> Text -> RedditT m ()
editWikiPage SubredditName
sub Text
page Text
content Text
reason = RedditT m Empty -> RedditT m ()
forall (m :: * -> *). Monad m => m Empty -> m ()
nothing (RedditT m Empty -> RedditT m ())
-> RedditT m Empty -> RedditT m ()
forall a b. (a -> b) -> a -> b
$ Route -> RedditT m Empty
forall a (m :: * -> *).
(FromJSON a, Monad m) =>
Route -> RedditT m a
runRoute (Route -> RedditT m Empty) -> Route -> RedditT m Empty
forall a b. (a -> b) -> a -> b
$ SubredditName -> Text -> Text -> Text -> Route
Route.editPage SubredditName
sub Text
page Text
content Text
reason