module DiscourseApi::API::PrivateMessages

Public Instance Methods

create_pm(args = {}) click to toggle source

:target_recipients REQUIRED comma separated list of usernames :category OPTIONAL name of category, not ID :created_at OPTIONAL seconds since epoch.

# File lib/discourse_api/api/private_messages.rb, line 15
def create_pm(args = {})
  args[:archetype] = "private_message"
  args =
    API
      .params(args)
      .required(:title, :raw, :target_recipients, :archetype)
      .optional(:category, :created_at, :api_username)
  post("/posts", args.to_h)
end
create_private_message(args = {}) click to toggle source

TODO: Deprecated. Remove after 20220628

# File lib/discourse_api/api/private_messages.rb, line 6
def create_private_message(args = {})
  deprecated(__method__, "create_pm")
  args[:target_recipients] = args.delete :target_usernames
  create_pm(args.to_h)
end
private_messages(username, *args) click to toggle source
# File lib/discourse_api/api/private_messages.rb, line 25
def private_messages(username, *args)
  response = get("topics/private-messages/#{username}.json", args)
  response[:body]["topic_list"]["topics"]
end
sent_private_messages(username, *args) click to toggle source
# File lib/discourse_api/api/private_messages.rb, line 30
def sent_private_messages(username, *args)
  response = get("topics/private-messages-sent/#{username}.json", args)
  response[:body]["topic_list"]["topics"]
end