Module: DiscourseApi::API::PrivateMessages

Included in:
Client
Defined in:
lib/discourse_api/api/private_messages.rb

Instance Method Summary collapse

Instance Method Details

#create_private_message(args = {}) ⇒ Object

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



8
9
10
11
12
13
14
# File 'lib/discourse_api/api/private_messages.rb', line 8

def create_private_message(args={})
  args[:archetype] = 'private_message'
  args = API.params(args)
            .required(:title, :raw, :target_usernames, :archetype)
            .optional(:category, :created_at, :api_username)
  post("/posts", args.to_h)
end

#private_messages(username, *args) ⇒ Object



16
17
18
19
# File 'lib/discourse_api/api/private_messages.rb', line 16

def private_messages(username, *args)
  response = get("topics/private-messages/#{username}.json", args)
  response[:body]['topic_list']['topics']
end

#sent_private_messages(username, *args) ⇒ Object



21
22
23
24
# File 'lib/discourse_api/api/private_messages.rb', line 21

def sent_private_messages(username, *args)
  response = get("topics/private-messages-sent/#{username}.json", args)
  response[:body]['topic_list']['topics']
end