Module: DiscourseApi::API::PrivateMessages
- Included in:
- Client
- Defined in:
- lib/discourse_api/api/private_messages.rb
Instance Method Summary collapse
-
#create_pm(args = {}) ⇒ Object
:target_recipients REQUIRED comma separated list of usernames :category OPTIONAL name of category, not ID :created_at OPTIONAL seconds since epoch.
-
#create_private_message(args = {}) ⇒ Object
TODO: Deprecated.
- #private_messages(username, *args) ⇒ Object
- #sent_private_messages(username, *args) ⇒ Object
Instance Method Details
#create_pm(args = {}) ⇒ Object
:target_recipients REQUIRED comma separated list of usernames :category OPTIONAL name of category, not ID :created_at OPTIONAL seconds since epoch.
16 17 18 19 20 21 22 |
# File 'lib/discourse_api/api/private_messages.rb', line 16 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 = {}) ⇒ Object
TODO: Deprecated. Remove after 20220628
7 8 9 10 11 |
# File 'lib/discourse_api/api/private_messages.rb', line 7 def (args = {}) deprecated(__method__, 'create_pm') args[:target_recipients] = args.delete :target_usernames create_pm(args.to_h) end |
#private_messages(username, *args) ⇒ Object
24 25 26 27 |
# File 'lib/discourse_api/api/private_messages.rb', line 24 def (username, *args) response = get("topics/private-messages/#{username}.json", args) response[:body]['topic_list']['topics'] end |
#sent_private_messages(username, *args) ⇒ Object
29 30 31 32 |
# File 'lib/discourse_api/api/private_messages.rb', line 29 def (username, *args) response = get("topics/private-messages-sent/#{username}.json", args) response[:body]['topic_list']['topics'] end |