Sha256: 453eb1e7e26ed66d9f7a0e0d0cbcb4c0755b4cb8292a47c446c02f1c9f62af4e

Contents?: true

Size: 1.17 KB

Versions: 7

Compression:

Stored size: 1.17 KB

Contents

module DiscourseApi
  module API
    module Posts
      def create_post(args)
        args = API.params(args)
                  .required(:topic_id, :raw)
        post("/posts", args)
      end

      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

      def get_post(id, args = {})
        args = API.params(args)
                  .optional(:version)
        response = get("/posts/#{id}.json", args)
        response[:body]
      end

      def wikify_post(id)
        put("/posts/#{id}/wiki", wiki: true)
      end

      def edit_post(id, raw)
        put("/posts/#{id}", post: {raw: raw})
      end

      def delete_post(id)
        delete("/posts/#{id}.json")
      end

      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

      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
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
discourse_api-0.18.0 lib/discourse_api/api/posts.rb
discourse_api-0.17.0 lib/discourse_api/api/posts.rb
discourse_api-0.16.1 lib/discourse_api/api/posts.rb
discourse_api-0.16.0 lib/discourse_api/api/posts.rb
discourse_api-0.15.0 lib/discourse_api/api/posts.rb
discourse_api-0.14.1 lib/discourse_api/api/posts.rb
discourse_api-0.14.0 lib/discourse_api/api/posts.rb