Module: DiscourseApi::API::Posts
- Included in:
- Client
- Defined in:
- lib/discourse_api/api/posts.rb
Instance Method Summary collapse
- #create_post(args) ⇒ Object
- #create_post_action(args) ⇒ Object
- #delete_post(id) ⇒ Object
- #destroy_post_action(post_id, post_action_type_id) ⇒ Object
- #edit_post(id, raw) ⇒ Object
- #get_post(id, args = {}) ⇒ Object
- #post_action_users(post_id, post_action_type_id) ⇒ Object
- #wikify_post(id) ⇒ Object
Instance Method Details
#create_post(args) ⇒ Object
4 5 6 7 8 9 |
# File 'lib/discourse_api/api/posts.rb', line 4 def create_post(args) args = API.params(args) .required(:topic_id, :raw) .optional(:created_at, :api_username) post("/posts", args) end |
#create_post_action(args) ⇒ Object
11 12 13 14 15 |
# File 'lib/discourse_api/api/posts.rb', line 11 def create_post_action(args) args = API.params(args) .required(:id, :post_action_type_id) post("/post_actions", args.to_h.merge(flag_topic: false)) end |
#delete_post(id) ⇒ Object
32 33 34 |
# File 'lib/discourse_api/api/posts.rb', line 32 def delete_post(id) delete("/posts/#{id}.json") end |
#destroy_post_action(post_id, post_action_type_id) ⇒ Object
36 37 38 |
# File 'lib/discourse_api/api/posts.rb', line 36 def destroy_post_action(post_id, post_action_type_id) delete("/post_actions/#{post_id}.json", post_action_type_id: post_action_type_id) end |
#edit_post(id, raw) ⇒ Object
28 29 30 |
# File 'lib/discourse_api/api/posts.rb', line 28 def edit_post(id, raw) put("/posts/#{id}", post: {raw: raw}) end |
#get_post(id, args = {}) ⇒ Object
17 18 19 20 21 22 |
# File 'lib/discourse_api/api/posts.rb', line 17 def get_post(id, args = {}) args = API.params(args) .optional(:version) response = get("/posts/#{id}.json", args) response[:body] end |
#post_action_users(post_id, post_action_type_id) ⇒ Object
40 41 42 43 |
# File 'lib/discourse_api/api/posts.rb', line 40 def post_action_users(post_id, post_action_type_id) response = get("/post_action_users.json", {id: post_id, post_action_type_id: post_action_type_id}) response[:body] end |
#wikify_post(id) ⇒ Object
24 25 26 |
# File 'lib/discourse_api/api/posts.rb', line 24 def wikify_post(id) put("/posts/#{id}/wiki", wiki: true) end |