Sha256: 723183fc1886e872a1d000661816a946398034c07e861b575ab00fffe9676fe8

Contents?: true

Size: 931 Bytes

Versions: 17

Compression:

Stored size: 931 Bytes

Contents

# frozen_string_literal: true
module DiscourseApi
  module API
    module PrivateMessages

      # :target_usernames REQUIRED comma separated list of usernames
      # :category OPTIONAL name of category, not ID
      # :created_at OPTIONAL seconds since epoch.
      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

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

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

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
discourse_api-0.46.0 lib/discourse_api/api/private_messages.rb
discourse_api-0.45.1 lib/discourse_api/api/private_messages.rb
discourse_api-0.45.0 lib/discourse_api/api/private_messages.rb
discourse_api-0.44.0 lib/discourse_api/api/private_messages.rb
discourse_api-0.43.1 lib/discourse_api/api/private_messages.rb
discourse_api-0.43.0 lib/discourse_api/api/private_messages.rb
discourse_api-0.42.0 lib/discourse_api/api/private_messages.rb
discourse_api-0.41.0 lib/discourse_api/api/private_messages.rb
discourse_api-0.40.0 lib/discourse_api/api/private_messages.rb
discourse_api-0.39.3 lib/discourse_api/api/private_messages.rb
discourse_api-0.39.2 lib/discourse_api/api/private_messages.rb
discourse_api-0.39.1 lib/discourse_api/api/private_messages.rb
discourse_api-0.39.0 lib/discourse_api/api/private_messages.rb
discourse_api-0.38.0 lib/discourse_api/api/private_messages.rb
discourse_api-0.37.0 lib/discourse_api/api/private_messages.rb
discourse_api-0.36.0 lib/discourse_api/api/private_messages.rb
discourse_api-0.35.0 lib/discourse_api/api/private_messages.rb