Class: Redd::Models::ModmailConversation

Inherits:
Model
  • Object
show all
Defined in:
lib/redd/models/modmail_conversation.rb

Overview

Represents a conversation in the new modmail.

Instance Attribute Summary collapse

Attributes inherited from Model

#client

Instance Method Summary collapse

Methods inherited from Model

#initialize

Constructor Details

This class inherits a constructor from Redd::Models::Model

Instance Attribute Details

#authorsArray<Hash> (readonly)

Returns FIXME: apply conversions.

Returns:

  • (Array<Hash>)

    FIXME: apply conversions


104
# File 'lib/redd/models/modmail_conversation.rb', line 104

property :authors

#auto?Boolean (readonly)

Returns:

  • (Boolean)

76
# File 'lib/redd/models/modmail_conversation.rb', line 76

property :auto?, from: :isAuto

#highlighted?Boolean (readonly)

Returns whether the conversation is highlighted.

Returns:

  • (Boolean)

    whether the conversation is highlighted


112
# File 'lib/redd/models/modmail_conversation.rb', line 112

property :highlighted?, from: :isHighlighted

#idString (readonly)

Returns the conversation id.

Returns:

  • (String)

    the conversation id


64
# File 'lib/redd/models/modmail_conversation.rb', line 64

property :id, :required

#internal?Boolean (readonly)

Returns:

  • (Boolean)

92
# File 'lib/redd/models/modmail_conversation.rb', line 92

property :internal?, from: :isInternal

#last_mod_updateTime (readonly)

Returns the time of last mod update.

Returns:

  • (Time)

    the time of last mod update


96
# File 'lib/redd/models/modmail_conversation.rb', line 96

property :last_mod_update, from: :lastModUpdate, with: ->(t) { Time.parse(t) }

#last_unreadObject (readonly)

Returns:

  • (Object)

128
# File 'lib/redd/models/modmail_conversation.rb', line 128

property :last_unread, from: :lastUnread

#last_updatedTime (readonly)

Returns the time of last update.

Returns:

  • (Time)

    the time of last update


100
# File 'lib/redd/models/modmail_conversation.rb', line 100

property :last_updated, from: :lastUpdated, with: ->(t) { Time.parse(t) }

#last_user_updateTime (readonly)

Returns the time of last user update.

Returns:

  • (Time)

    the time of last user update


88
# File 'lib/redd/models/modmail_conversation.rb', line 88

property :last_user_update, from: :lastUserUpdate, with: ->(t) { Time.parse(t) }

#message_countInteger (readonly)

Returns the message count.

Returns:

  • (Integer)

    the message count


132
# File 'lib/redd/models/modmail_conversation.rb', line 132

property :message_count, from: :numMessages

#message_idsArray<String> (readonly)

Returns the conversation's message ids.

Returns:

  • (Array<String>)

    the conversation's message ids


80
# File 'lib/redd/models/modmail_conversation.rb', line 80

property :message_ids, from: :objIds

#messagesArray<ModmailMessage> (readonly)

Returns the modmail messages.

Returns:


68
# File 'lib/redd/models/modmail_conversation.rb', line 68

property :messages, with: ->(hsh) { hsh.values.map { |m| ModmailMessage.new(client, m) } }

#ownerHash (readonly)

Returns FIXME: do shit.

Returns:

  • (Hash)

    FIXME: do shit


108
# File 'lib/redd/models/modmail_conversation.rb', line 108

property :owner

#participantHash (readonly)

Returns FIXME: do shit.

Returns:

  • (Hash)

    FIXME: do shit


120
# File 'lib/redd/models/modmail_conversation.rb', line 120

property :participant

#replyable?Boolean (readonly)

Returns whether you can reply to this conversation.

Returns:

  • (Boolean)

    whether you can reply to this conversation


84
# File 'lib/redd/models/modmail_conversation.rb', line 84

property :replyable?, from: :isRepliable

#stateInteger (readonly)

Returns:

  • (Integer)

124
# File 'lib/redd/models/modmail_conversation.rb', line 124

property :state

#subjectString (readonly)

Returns the conversation subject.

Returns:

  • (String)

    the conversation subject


116
# File 'lib/redd/models/modmail_conversation.rb', line 116

property :subject

#userObject (readonly)

Returns FIXME: details about the user the conversation deals with.

Returns:

  • (Object)

    FIXME: details about the user the conversation deals with


72
# File 'lib/redd/models/modmail_conversation.rb', line 72

property :user

Instance Method Details

#archiveObject

Mark this conversation as archived.


33
34
35
# File 'lib/redd/models/modmail_conversation.rb', line 33

def archive
  perform_action(:post, 'archive')
end

#highlightObject

Highlight this conversation.


43
44
45
# File 'lib/redd/models/modmail_conversation.rb', line 43

def highlight
  perform_action(:post, 'highlight')
end

#mark_as_readObject

Mark this conversation as read.


23
24
25
# File 'lib/redd/models/modmail_conversation.rb', line 23

def mark_as_read
  client.post('/api/mod/conversations/read', conversationIds: [read_attribute(:id)])
end

#mark_as_unreadObject

Mark this conversation as unread.


28
29
30
# File 'lib/redd/models/modmail_conversation.rb', line 28

def mark_as_unread
  client.post('/api/mod/conversations/unread', conversationIds: [read_attribute(:id)])
end

#muteObject

Mute this conversation.


53
54
55
# File 'lib/redd/models/modmail_conversation.rb', line 53

def mute
  perform_action(:post, 'mute')
end

#reply(body, hidden: false, internal: false) ⇒ Object

Add a reply to the ongoing conversation.

Parameters:

  • body (String)

    the message body (probably markdown)

  • hidden (Boolean) (defaults to: false)

    whether the message is hidden

  • internal (Boolean) (defaults to: false)

    whether the message is internal


14
15
16
17
18
19
20
# File 'lib/redd/models/modmail_conversation.rb', line 14

def reply(body, hidden: false, internal: false)
  # TODO: merge response into the conversation
  client.post(
    "/api/mod/conversations/#{read_attribute(:id)}",
    body: body, isAuthorHidden: hidden, isInternal: internal
  ).body
end

#unarchiveObject

Removed this conversation from archived.


38
39
40
# File 'lib/redd/models/modmail_conversation.rb', line 38

def unarchive
  perform_action(:post, 'unarchive')
end

#unhighlightObject

Remove the highlight on this conversation.


48
49
50
# File 'lib/redd/models/modmail_conversation.rb', line 48

def unhighlight
  perform_action(:delete, 'highlight')
end

#unmuteObject

Unmute this conversation.


58
59
60
# File 'lib/redd/models/modmail_conversation.rb', line 58

def unmute
  perform_action(:post, 'unmute')
end