class Redd::Models::ModMail
A container for the new modmail. XXX: Instead of making ModMail
a dumb container, could it be a lazy wrapper for unread_count?
Public Instance Methods
Get the conversations @param subreddits [Subreddit, Array<Subreddit>] the subreddits to limit to @param params [Hash] additional request parameters @option params [String] :after base36 modmail conversation id @option params [Integer] :limit an integer (default: 25) @option params [:recent, :mod, :user, :unread] :sort the sort order @option params [:new, :inprogress, :mod, :notifications, :archived, :highlighted, :all]
:state the state to limit the conversations by
# File lib/redd/models/mod_mail.rb, line 113 def conversations(subreddits: nil, **params) params[:entity] = Array(subreddits).map(&:display_name).join(',') if subreddits @client.get('/api/mod/conversations', **params).body[:conversations].map do |_, conv| Conversation.new(@client, conv) end end
Create a new conversation. @param from [Subreddit] the subreddit to send the conversation from @param to [User] the person to send the message to @param subject [String] the message subject @param body [String] the message body @return [Conversation] the created conversation
# File lib/redd/models/mod_mail.rb, line 126 def create(from:, to:, subject:, body:, hidden: false) Conversation.new(@client, @client.post( '/api/mod/conversations', srName: from.display_name, to: to.name, subject: subject, body: body, isAuthorHidden: hidden ).body[:conversation]) end
@return [Array<Subreddit>] moderated subreddits that are enrolled in the new modmail
# File lib/redd/models/mod_mail.rb, line 99 def enrolled @client.get('/api/mod/conversations/subreddits').body[:subreddits].map do |_, s| Subreddit.new(@client, s.merge(last_updated: s.delete(:lastUpdated))) end end
Get a conversation from its base36 id. @param id [String] the conversation's id @return [Conversation]
# File lib/redd/models/mod_mail.rb, line 137 def get(id) Conversation.from_id(@client, id) end
@return [#highlighted, notifications, archived, new, inprogress, mod] the number of
unread messages in each category
# File lib/redd/models/mod_mail.rb, line 94 def unread_count BasicModel.new(nil, @client.get('/api/mod/conversations/unread/count').body) end