Sha256: 5b16edb8591a2fe01dc4d7033993f28832f490c0ee2655dd26d722bbdb9ff527

Contents?: true

Size: 1.38 KB

Versions: 18

Compression:

Stored size: 1.38 KB

Contents

# frozen_string_literal: true
module DiscourseApi
  module API
    module Posts
      def create_post(args)
        args = API.params(args)
          .required(:topic_id, :raw)
          .optional(:created_at, :api_username)
        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 posts(args = {})
        args = API.params(args).default(before: 0)
        response = get("/posts.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

18 entries across 18 versions & 1 rubygems

Version Path
discourse_api-1.1.0 lib/discourse_api/api/posts.rb
discourse_api-1.0.0 lib/discourse_api/api/posts.rb
discourse_api-0.48.1 lib/discourse_api/api/posts.rb
discourse_api-0.48.0 lib/discourse_api/api/posts.rb
discourse_api-0.47.0 lib/discourse_api/api/posts.rb
discourse_api-0.46.0 lib/discourse_api/api/posts.rb
discourse_api-0.45.1 lib/discourse_api/api/posts.rb
discourse_api-0.45.0 lib/discourse_api/api/posts.rb
discourse_api-0.44.0 lib/discourse_api/api/posts.rb
discourse_api-0.43.1 lib/discourse_api/api/posts.rb
discourse_api-0.43.0 lib/discourse_api/api/posts.rb
discourse_api-0.42.0 lib/discourse_api/api/posts.rb
discourse_api-0.41.0 lib/discourse_api/api/posts.rb
discourse_api-0.40.0 lib/discourse_api/api/posts.rb
discourse_api-0.39.3 lib/discourse_api/api/posts.rb
discourse_api-0.39.2 lib/discourse_api/api/posts.rb
discourse_api-0.39.1 lib/discourse_api/api/posts.rb
discourse_api-0.39.0 lib/discourse_api/api/posts.rb