discourse_api 0.38.0 → 0.39.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -2
- data/CHANGELOG.md +11 -0
- data/config_example.yml +11 -0
- data/discourse_api.gemspec +3 -1
- data/examples/backups.rb +5 -3
- data/examples/badges.rb +5 -3
- data/examples/category.rb +5 -3
- data/examples/change_topic_status.rb +5 -3
- data/examples/create_private_message.rb +5 -3
- data/examples/create_topic.rb +5 -3
- data/examples/create_update_category.rb +4 -7
- data/examples/create_user.rb +5 -3
- data/examples/dashboard.rb +5 -3
- data/examples/disposable_invite_tokens.rb +5 -3
- data/examples/example.rb +5 -3
- data/examples/group_set_user_notification_level.rb +5 -3
- data/examples/groups.rb +5 -3
- data/examples/invite_users.rb +5 -3
- data/examples/polls.rb +5 -3
- data/examples/post_action.rb +5 -3
- data/examples/search.rb +5 -3
- data/examples/sent_private_messages.rb +5 -3
- data/examples/sso.rb +5 -3
- data/examples/topic_lists.rb +5 -3
- data/examples/update_user.rb +5 -3
- data/examples/upload_file.rb +5 -3
- data/lib/discourse_api.rb +1 -0
- data/lib/discourse_api/api/categories.rb +3 -2
- data/lib/discourse_api/api/params.rb +3 -1
- data/lib/discourse_api/api/posts.rb +6 -0
- data/lib/discourse_api/api/topics.rb +5 -7
- data/lib/discourse_api/example_helper.rb +19 -0
- data/lib/discourse_api/version.rb +1 -1
- data/spec/discourse_api/api/params_spec.rb +4 -0
- data/spec/discourse_api/api/posts_spec.rb +19 -0
- data/spec/discourse_api/api/topics_spec.rb +37 -0
- data/spec/fixtures/posts_before.json +148 -0
- data/spec/fixtures/posts_latest.json +196 -0
- data/spec/fixtures/topic_posts.json +60 -0
- metadata +41 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 949fba1e4447d9615d8d3457b79328a866cfe61f325c3cd4f6a2cf3083ad9322
|
4
|
+
data.tar.gz: 2cc4f93ec719eb99e0bbd02caeecc02c3ed36bcd33b4b6435b9cb56835e622ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 781247a4d7644d9f58609f221da038f8f59e58114ba2450c63c1ef8e7adfda029c775e8b58b0237220c76d3db1d95232249a6d04ff9138da2aa759eaa6938fa2
|
7
|
+
data.tar.gz: 995b7de67aef36acab3ef778201032aa9c2e9c9762a02d80e6cfeeacccd8dac64c433fc5cda75bfca6fbbcade605ea3917fd6c92283253c7a79618b24d2b644d
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,17 @@
|
|
2
2
|
All notable changes to this project will be documented in this file.
|
3
3
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
4
4
|
|
5
|
+
## [0.39.0] - 2020-03-27
|
6
|
+
### Added
|
7
|
+
- Get latest posts across topics via posts.json
|
8
|
+
- Allow more options parameters when creating a category
|
9
|
+
- Don't require topic slug when updating topic status
|
10
|
+
- Example files now read config.yml file when present for client settings
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
- Issue with `topic_posts` and frozen strings
|
14
|
+
- Fixed some topic and category methods
|
15
|
+
|
5
16
|
## [0.38.0] - 2019-10-18
|
6
17
|
### Added
|
7
18
|
- Allow setting locale in SingleSignOn
|
data/config_example.yml
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Specify your environment by making a copy of this file to create a file in your root directory called config.yml with your environment settings.
|
2
|
+
|
3
|
+
# host e.g. localhost:3000 or discourse.my_domain.com
|
4
|
+
host: YOUR_HOST_NAME
|
5
|
+
|
6
|
+
# api user (can effect results returned, e.g. .categories method returns only the categories your api_username can see)
|
7
|
+
# create a new client with when changing api user
|
8
|
+
api_username: YOUR_API_USERNAME
|
9
|
+
|
10
|
+
# api key from Discourse admin panel /admin/api/keys
|
11
|
+
api_key: YOUR_API_KEY
|
data/discourse_api.gemspec
CHANGED
@@ -28,9 +28,11 @@ Gem::Specification.new do |spec|
|
|
28
28
|
spec.add_development_dependency 'rake', '~> 11.1'
|
29
29
|
spec.add_development_dependency 'rb-inotify', '~> 0.9'
|
30
30
|
spec.add_development_dependency 'rspec', '~> 3.4'
|
31
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
31
|
+
spec.add_development_dependency 'rubocop', '~> 0.69'
|
32
32
|
spec.add_development_dependency 'simplecov', '~> 0.11'
|
33
33
|
spec.add_development_dependency 'webmock', '~> 2.0'
|
34
|
+
spec.add_development_dependency 'rubocop-discourse', '~> 1.0'
|
35
|
+
spec.add_development_dependency 'rubocop-rspec', '~> 1.0'
|
34
36
|
|
35
37
|
spec.required_ruby_version = '>= 2.2.3'
|
36
38
|
end
|
data/examples/backups.rb
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
# get list of backup files
|
10
12
|
puts client.backups()
|
data/examples/badges.rb
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
# get badges
|
10
12
|
puts client.badges
|
data/examples/category.rb
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
# get categories
|
10
12
|
puts client.categories()
|
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
response = client.create_topic(
|
10
12
|
category: 1,
|
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
client.create_private_message(
|
10
12
|
title: "Confidential: Hello World!",
|
data/examples/create_topic.rb
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
client.create_topic(
|
10
12
|
category: 1,
|
@@ -2,14 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
# client.api_key = "YOUR_API_KEY"
|
7
|
-
# client.api_username = "YOUR_USERNAME"
|
8
|
-
#
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
9
6
|
|
10
|
-
client = DiscourseApi::Client.new(
|
11
|
-
client.api_key = "
|
12
|
-
client.api_username = "
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
13
10
|
|
14
11
|
###
|
15
12
|
# Required category params:
|
data/examples/create_user.rb
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
# create user
|
10
12
|
user = client.create_user(
|
data/examples/dashboard.rb
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
# get all dashboard status as json
|
10
12
|
puts client.get_dashboard_stats
|
@@ -6,9 +6,11 @@ require 'csv'
|
|
6
6
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
7
7
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
client
|
9
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
10
|
+
|
11
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
12
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
13
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
12
14
|
|
13
15
|
# fetch email-less invite tokens
|
14
16
|
invite_tokens = client.disposable_tokens(username: "eviltrout", quantity: 5, group_names: "security,support")
|
data/examples/example.rb
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
# get latest topics
|
10
12
|
puts client.latest_topics
|
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
@target_username = "YOUR_TARGET_USERNAME"
|
10
12
|
@target_group_id = # YOUR NUMERIC TARGET GROUP ID
|
data/examples/groups.rb
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
response = client.create_group(name: "engineering_team")
|
10
12
|
group_id = response["basic_group"]["id"]
|
data/examples/invite_users.rb
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
# invite user
|
10
12
|
client.invite_user(email: "name@example.com", group_ids: "41,42")
|
data/examples/polls.rb
CHANGED
@@ -3,9 +3,11 @@
|
|
3
3
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
4
4
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
client
|
6
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
7
|
+
|
8
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
9
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
10
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
9
11
|
|
10
12
|
options = ['8b4736b1ae3dfb5a28088530f036f9e5']
|
11
13
|
poll_option_votes = client.poll_vote post_id: 5, poll_name: 'poll', options: options
|
data/examples/post_action.rb
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
# Post Action Type IDs
|
10
12
|
# 1 - Bookmark
|
data/examples/search.rb
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
# search for term
|
10
12
|
puts client.search("discourse")
|
@@ -2,8 +2,10 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
client.sent_private_messages('test_user')
|
data/examples/sso.rb
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
client.sync_sso(
|
10
12
|
sso_secret: "discourse_sso_rocks",
|
data/examples/topic_lists.rb
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
# get latest topics
|
10
12
|
puts client.latest_topics({})
|
data/examples/update_user.rb
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
# update username from "robin" to "batman"
|
10
12
|
puts client.update_username("robin", "batman")
|
data/examples/upload_file.rb
CHANGED
@@ -2,9 +2,11 @@
|
|
2
2
|
$LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
|
3
3
|
require File.expand_path('../../lib/discourse_api', __FILE__)
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
client
|
5
|
+
config = DiscourseApi::ExampleHelper.load_yml
|
6
|
+
|
7
|
+
client = DiscourseApi::Client.new(config['host'] || 'http://localhost:3000')
|
8
|
+
client.api_key = config['api_key'] || "YOUR_API_KEY"
|
9
|
+
client.api_username = config['api_username'] || "YOUR_USERNAME"
|
8
10
|
|
9
11
|
# Upload a file
|
10
12
|
file = Faraday::UploadIO.new('grumpy_cat.pdf', "application/pdf")
|
data/lib/discourse_api.rb
CHANGED
@@ -8,7 +8,8 @@ module DiscourseApi
|
|
8
8
|
def create_category(args = {})
|
9
9
|
args = API.params(args)
|
10
10
|
.required(:name, :color, :text_color)
|
11
|
-
.optional(:
|
11
|
+
.optional(:slug, :permissions, :auto_close_hours, :auto_close_based_on_last_post, :position, :email_in,
|
12
|
+
:email_in_allow_strangers, :logo_url, :background_url, :allow_badges, :topic_template, :custom_fields, :description)
|
12
13
|
.default(parent_category_id: nil)
|
13
14
|
response = post("/categories", args)
|
14
15
|
response['category']
|
@@ -19,7 +20,7 @@ module DiscourseApi
|
|
19
20
|
args = API.params(args)
|
20
21
|
.required(:id, :name, :color, :text_color)
|
21
22
|
.optional(:slug, :permissions, :auto_close_hours, :auto_close_based_on_last_post, :position, :email_in,
|
22
|
-
:email_in_allow_strangers, :logo_url, :background_url, :allow_badges, :topic_template, :custom_fields)
|
23
|
+
:email_in_allow_strangers, :logo_url, :background_url, :allow_badges, :topic_template, :custom_fields, :description)
|
23
24
|
.default(parent_category_id: nil)
|
24
25
|
response = put("/categories/#{category_id}", args)
|
25
26
|
response['body']['category'] if response['body']
|
@@ -16,6 +16,9 @@ module DiscourseApi
|
|
16
16
|
|
17
17
|
def required(*keys)
|
18
18
|
@required.concat(keys)
|
19
|
+
@required.each do |k|
|
20
|
+
raise ArgumentError.new("#{k} is required but not specified") unless @args.key?(k)
|
21
|
+
end
|
19
22
|
self
|
20
23
|
end
|
21
24
|
|
@@ -36,7 +39,6 @@ module DiscourseApi
|
|
36
39
|
|
37
40
|
@required.each do |k|
|
38
41
|
h[k] = @args[k]
|
39
|
-
raise ArgumentError.new("#{k} is required but not specified") unless h[k]
|
40
42
|
end
|
41
43
|
|
42
44
|
@optional.each do |k|
|
@@ -22,6 +22,12 @@ module DiscourseApi
|
|
22
22
|
response[:body]
|
23
23
|
end
|
24
24
|
|
25
|
+
def posts(args = {})
|
26
|
+
args = API.params(args).default(before: 0)
|
27
|
+
response = get("/posts.json", args)
|
28
|
+
response[:body]
|
29
|
+
end
|
30
|
+
|
25
31
|
def wikify_post(id)
|
26
32
|
put("/posts/#{id}/wiki", wiki: true)
|
27
33
|
end
|
@@ -46,7 +46,7 @@ module DiscourseApi
|
|
46
46
|
params = API.params(params)
|
47
47
|
.required(:status, :enabled)
|
48
48
|
.optional(:api_username)
|
49
|
-
put("/t/#{
|
49
|
+
put("/t/#{topic_id}/status", params.to_h)
|
50
50
|
end
|
51
51
|
|
52
52
|
def topic(id, params = {})
|
@@ -64,14 +64,12 @@ module DiscourseApi
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def topic_posts(topic_id, post_ids = [])
|
67
|
-
url = "/t/#{topic_id}/posts.json"
|
67
|
+
url = ["/t/#{topic_id}/posts.json"]
|
68
68
|
if post_ids.count > 0
|
69
|
-
url
|
70
|
-
post_ids.
|
71
|
-
url << "post_ids[]=#{id}&"
|
72
|
-
end
|
69
|
+
url.push('?')
|
70
|
+
url.push(post_ids.map { |id| "post_ids[]=#{id}" }.join('&'))
|
73
71
|
end
|
74
|
-
response = get(url)
|
72
|
+
response = get(url.join)
|
75
73
|
response[:body]
|
76
74
|
end
|
77
75
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'yaml'
|
3
|
+
|
4
|
+
module DiscourseApi
|
5
|
+
class ExampleHelper
|
6
|
+
|
7
|
+
def self.load_yml
|
8
|
+
config_yml = File.expand_path('../../../config.yml', __FILE__)
|
9
|
+
puts config_yml
|
10
|
+
begin
|
11
|
+
config = YAML.load_file config_yml
|
12
|
+
rescue Errno::ENOENT
|
13
|
+
config = {}
|
14
|
+
end
|
15
|
+
config
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -9,6 +9,10 @@ describe DiscourseApi::API::Params do
|
|
9
9
|
expect { params_for({o1: "test"}).to_h }.to raise_error(ArgumentError)
|
10
10
|
end
|
11
11
|
|
12
|
+
it "should not raise when a required param is false" do
|
13
|
+
expect { params_for({r1: false}).to_h }.not_to raise_error
|
14
|
+
end
|
15
|
+
|
12
16
|
it "should not include optional params when not provided" do
|
13
17
|
expect(params_for({r1: "test"}).to_h).not_to include(:o1)
|
14
18
|
end
|
@@ -15,6 +15,25 @@ describe DiscourseApi::API::Posts do
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
describe "#posts" do
|
19
|
+
before do
|
20
|
+
stub_get("#{host}/posts.json?before=0").to_return(body: fixture("posts_latest.json"), headers: { content_type: "application/json" })
|
21
|
+
stub_get("#{host}/posts.json?before=14").to_return(body: fixture("posts_before.json"), headers: { content_type: "application/json" })
|
22
|
+
end
|
23
|
+
|
24
|
+
it "fetches latest posts" do
|
25
|
+
the_posts = client.posts()
|
26
|
+
expect(the_posts).to be_a Hash
|
27
|
+
expect(the_posts['latest_posts'][0]['id']).to eq(15)
|
28
|
+
end
|
29
|
+
|
30
|
+
it "fetches posts before 14" do
|
31
|
+
the_posts = client.posts(before: 14)
|
32
|
+
expect(the_posts).to be_a Hash
|
33
|
+
expect(the_posts['latest_posts'][0]['id']).to eq(14)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
18
37
|
describe "#wikify_post" do
|
19
38
|
before do
|
20
39
|
stub_put("#{host}/posts/9999/wiki")
|
@@ -3,6 +3,17 @@ require 'spec_helper'
|
|
3
3
|
describe DiscourseApi::API::Topics do
|
4
4
|
subject { DiscourseApi::Client.new("#{host}", "test_d7fd0429940", "test_user") }
|
5
5
|
|
6
|
+
describe "#change_topic_status" do
|
7
|
+
before do
|
8
|
+
stub_put("#{host}/t/57/status").to_return(body: fixture("topic.json"), headers: { content_type: "application/json" })
|
9
|
+
end
|
10
|
+
|
11
|
+
it "changes the topic status" do
|
12
|
+
subject.change_topic_status(nil, 57, { status: 'visible', enabled: false })
|
13
|
+
expect(a_put("#{host}/t/57/status")).to have_been_made
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
6
17
|
describe "#invite_user_to_topic" do
|
7
18
|
before do
|
8
19
|
stub_post("#{host}/t/12/invite").to_return(body: fixture("topic_invite_user.json"), headers: { content_type: "application/json" })
|
@@ -110,4 +121,30 @@ describe DiscourseApi::API::Topics do
|
|
110
121
|
expect(topics.first).to be_a Hash
|
111
122
|
end
|
112
123
|
end
|
124
|
+
|
125
|
+
describe "#topic_posts" do
|
126
|
+
before do
|
127
|
+
stub_get(/#{host}\/t\/57\/posts\.json/).to_return(
|
128
|
+
body: fixture("topic_posts.json"),
|
129
|
+
headers: { content_type: "application/json" }
|
130
|
+
)
|
131
|
+
end
|
132
|
+
|
133
|
+
it "requests the correct resource" do
|
134
|
+
subject.topic_posts(57)
|
135
|
+
expect(a_get("#{host}/t/57/posts.json")).to have_been_made
|
136
|
+
end
|
137
|
+
|
138
|
+
it 'allows scoping to specific post ids' do
|
139
|
+
subject.topic_posts(57, [123, 456])
|
140
|
+
expect(a_get("#{host}/t/57/posts.json?post_ids[]=123&post_ids[]=456")).to have_been_made
|
141
|
+
end
|
142
|
+
|
143
|
+
it "returns the requested topic posts" do
|
144
|
+
body = subject.topic_posts(57, [123])
|
145
|
+
expect(body).to be_a Hash
|
146
|
+
expect(body['post_stream']['posts']).to be_an Array
|
147
|
+
expect(body['post_stream']['posts'].first).to be_a Hash
|
148
|
+
end
|
149
|
+
end
|
113
150
|
end
|
@@ -0,0 +1,148 @@
|
|
1
|
+
{
|
2
|
+
"latest_posts": [
|
3
|
+
{
|
4
|
+
"id": 14,
|
5
|
+
"name": null,
|
6
|
+
"username": "johndoe",
|
7
|
+
"avatar_template": "/letter_avatar_proxy/v3/letter/p/df705f/{size}.png",
|
8
|
+
"created_at": "2020-01-25T00:58:35.475Z",
|
9
|
+
"cooked": "<p>hi there. hi there. hi there.</p>",
|
10
|
+
"post_number": 1,
|
11
|
+
"post_type": 1,
|
12
|
+
"updated_at": "2020-01-25T00:58:35.475Z",
|
13
|
+
"reply_count": 0,
|
14
|
+
"reply_to_post_number": null,
|
15
|
+
"quote_count": 0,
|
16
|
+
"avg_time": null,
|
17
|
+
"incoming_link_count": 0,
|
18
|
+
"reads": 1,
|
19
|
+
"score": 0.2,
|
20
|
+
"yours": false,
|
21
|
+
"topic_id": 11,
|
22
|
+
"topic_slug": "this-is-an-uncategorized-title",
|
23
|
+
"topic_title": "This is an uncategorized title",
|
24
|
+
"topic_html_title": "This is an uncategorized title",
|
25
|
+
"category_id": 1,
|
26
|
+
"display_username": null,
|
27
|
+
"primary_group_name": null,
|
28
|
+
"primary_group_flair_url": null,
|
29
|
+
"primary_group_flair_bg_color": null,
|
30
|
+
"primary_group_flair_color": null,
|
31
|
+
"version": 1,
|
32
|
+
"can_edit": false,
|
33
|
+
"can_delete": false,
|
34
|
+
"can_recover": false,
|
35
|
+
"can_wiki": false,
|
36
|
+
"user_title": null,
|
37
|
+
"raw": "hi there. hi there. hi there.",
|
38
|
+
"actions_summary": [],
|
39
|
+
"moderator": false,
|
40
|
+
"admin": true,
|
41
|
+
"staff": true,
|
42
|
+
"user_id": 1,
|
43
|
+
"hidden": false,
|
44
|
+
"trust_level": 1,
|
45
|
+
"deleted_at": null,
|
46
|
+
"user_deleted": false,
|
47
|
+
"edit_reason": null,
|
48
|
+
"can_view_edit_history": true,
|
49
|
+
"wiki": false
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"id": 10,
|
53
|
+
"name": "system",
|
54
|
+
"username": "system",
|
55
|
+
"avatar_template": "/user_avatar/localhost/system/{size}/1_2.png",
|
56
|
+
"created_at": "2020-01-24T23:26:09.014Z",
|
57
|
+
"cooked": "<p>The first paragraph of this pinned topic will be visible as a welcome message to all new visitors on your homepage. It’s important!</p>\n<p><strong>Edit this</strong> into a brief description of your community:</p>\n<ul>\n<li>Who is it for?</li>\n<li>What can they find here?</li>\n<li>Why should they come here?</li>\n<li>Where can they read more (links, resources, etc)?</li>\n</ul>\n<p><img src=\"//localhost/images/welcome/discourse-edit-post-animated.gif\" width=\"508\" height=\"106\"></p>\n<p>You may want to close this topic via the admin <img src=\"//localhost/images/emoji/twitter/wrench.png?v=6\" title=\":wrench:\" class=\"emoji\" alt=\":wrench:\"> (at the upper right and bottom), so that replies don’t pile up on an announcement.</p>",
|
58
|
+
"post_number": 1,
|
59
|
+
"post_type": 1,
|
60
|
+
"updated_at": "2020-01-24T23:26:09.014Z",
|
61
|
+
"reply_count": 0,
|
62
|
+
"reply_to_post_number": null,
|
63
|
+
"quote_count": 0,
|
64
|
+
"avg_time": null,
|
65
|
+
"incoming_link_count": 0,
|
66
|
+
"reads": 1,
|
67
|
+
"score": 0.2,
|
68
|
+
"yours": false,
|
69
|
+
"topic_id": 7,
|
70
|
+
"topic_slug": "welcome-to-discourse",
|
71
|
+
"topic_title": "Welcome to Discourse",
|
72
|
+
"topic_html_title": "Welcome to Discourse",
|
73
|
+
"category_id": 1,
|
74
|
+
"display_username": "system",
|
75
|
+
"primary_group_name": null,
|
76
|
+
"primary_group_flair_url": null,
|
77
|
+
"primary_group_flair_bg_color": null,
|
78
|
+
"primary_group_flair_color": null,
|
79
|
+
"version": 1,
|
80
|
+
"can_edit": false,
|
81
|
+
"can_delete": false,
|
82
|
+
"can_recover": false,
|
83
|
+
"can_wiki": false,
|
84
|
+
"user_title": null,
|
85
|
+
"raw": "\nThe first paragraph of this pinned topic will be visible as a welcome message to all new visitors on your homepage. It's important!\n\n**Edit this** into a brief description of your community:\n\n- Who is it for?\n- What can they find here?\n- Why should they come here?\n- Where can they read more (links, resources, etc)?\n\n<img src=\"/images/welcome/discourse-edit-post-animated.gif\" width=\"508\" height=\"106\">\n\nYou may want to close this topic via the admin :wrench: (at the upper right and bottom), so that replies don't pile up on an announcement.",
|
86
|
+
"actions_summary": [],
|
87
|
+
"moderator": true,
|
88
|
+
"admin": true,
|
89
|
+
"staff": true,
|
90
|
+
"user_id": -1,
|
91
|
+
"hidden": false,
|
92
|
+
"trust_level": 4,
|
93
|
+
"deleted_at": null,
|
94
|
+
"user_deleted": false,
|
95
|
+
"edit_reason": null,
|
96
|
+
"can_view_edit_history": true,
|
97
|
+
"wiki": false
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"id": 2,
|
101
|
+
"name": "system",
|
102
|
+
"username": "system",
|
103
|
+
"avatar_template": "/user_avatar/localhost/system/{size}/1_2.png",
|
104
|
+
"created_at": "2020-01-24T23:26:05.551Z",
|
105
|
+
"cooked": "<p>Discussion about this site, its organization, how it works, and how we can improve it.</p>",
|
106
|
+
"post_number": 1,
|
107
|
+
"post_type": 1,
|
108
|
+
"updated_at": "2020-01-24T23:26:05.551Z",
|
109
|
+
"reply_count": 0,
|
110
|
+
"reply_to_post_number": null,
|
111
|
+
"quote_count": 0,
|
112
|
+
"avg_time": null,
|
113
|
+
"incoming_link_count": 0,
|
114
|
+
"reads": 1,
|
115
|
+
"score": 0.2,
|
116
|
+
"yours": false,
|
117
|
+
"topic_id": 2,
|
118
|
+
"topic_slug": "about-the-site-feedback-category",
|
119
|
+
"topic_title": "About the Site Feedback category",
|
120
|
+
"topic_html_title": "About the Site Feedback category",
|
121
|
+
"category_id": 3,
|
122
|
+
"display_username": "system",
|
123
|
+
"primary_group_name": null,
|
124
|
+
"primary_group_flair_url": null,
|
125
|
+
"primary_group_flair_bg_color": null,
|
126
|
+
"primary_group_flair_color": null,
|
127
|
+
"version": 1,
|
128
|
+
"can_edit": false,
|
129
|
+
"can_delete": false,
|
130
|
+
"can_recover": false,
|
131
|
+
"can_wiki": false,
|
132
|
+
"user_title": null,
|
133
|
+
"raw": "Discussion about this site, its organization, how it works, and how we can improve it.",
|
134
|
+
"actions_summary": [],
|
135
|
+
"moderator": true,
|
136
|
+
"admin": true,
|
137
|
+
"staff": true,
|
138
|
+
"user_id": -1,
|
139
|
+
"hidden": false,
|
140
|
+
"trust_level": 4,
|
141
|
+
"deleted_at": null,
|
142
|
+
"user_deleted": false,
|
143
|
+
"edit_reason": null,
|
144
|
+
"can_view_edit_history": true,
|
145
|
+
"wiki": false
|
146
|
+
}
|
147
|
+
]
|
148
|
+
}
|
@@ -0,0 +1,196 @@
|
|
1
|
+
{
|
2
|
+
"latest_posts": [
|
3
|
+
{
|
4
|
+
"id": 15,
|
5
|
+
"name": null,
|
6
|
+
"username": "johndoe",
|
7
|
+
"avatar_template": "/letter_avatar_proxy/v3/letter/p/df705f/{size}.png",
|
8
|
+
"created_at": "2020-01-25T02:10:07.971Z",
|
9
|
+
"cooked": "<p>holla bullhonky.</p>",
|
10
|
+
"post_number": 2,
|
11
|
+
"post_type": 1,
|
12
|
+
"updated_at": "2020-01-25T02:10:07.971Z",
|
13
|
+
"reply_count": 0,
|
14
|
+
"reply_to_post_number": null,
|
15
|
+
"quote_count": 0,
|
16
|
+
"avg_time": null,
|
17
|
+
"incoming_link_count": 0,
|
18
|
+
"reads": 1,
|
19
|
+
"score": 0.2,
|
20
|
+
"yours": false,
|
21
|
+
"topic_id": 11,
|
22
|
+
"topic_slug": "this-is-an-uncategorized-title",
|
23
|
+
"topic_title": "This is an uncategorized title",
|
24
|
+
"topic_html_title": "This is an uncategorized title",
|
25
|
+
"category_id": 1,
|
26
|
+
"display_username": null,
|
27
|
+
"primary_group_name": null,
|
28
|
+
"primary_group_flair_url": null,
|
29
|
+
"primary_group_flair_bg_color": null,
|
30
|
+
"primary_group_flair_color": null,
|
31
|
+
"version": 1,
|
32
|
+
"can_edit": false,
|
33
|
+
"can_delete": false,
|
34
|
+
"can_recover": false,
|
35
|
+
"can_wiki": false,
|
36
|
+
"user_title": null,
|
37
|
+
"raw": "holla bullhonky.",
|
38
|
+
"actions_summary": [],
|
39
|
+
"moderator": false,
|
40
|
+
"admin": true,
|
41
|
+
"staff": true,
|
42
|
+
"user_id": 1,
|
43
|
+
"hidden": false,
|
44
|
+
"trust_level": 1,
|
45
|
+
"deleted_at": null,
|
46
|
+
"user_deleted": false,
|
47
|
+
"edit_reason": null,
|
48
|
+
"can_view_edit_history": true,
|
49
|
+
"wiki": false
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"id": 14,
|
53
|
+
"name": null,
|
54
|
+
"username": "johndoe",
|
55
|
+
"avatar_template": "/letter_avatar_proxy/v3/letter/p/df705f/{size}.png",
|
56
|
+
"created_at": "2020-01-25T00:58:35.475Z",
|
57
|
+
"cooked": "<p>hi there. hi there. hi there.</p>",
|
58
|
+
"post_number": 1,
|
59
|
+
"post_type": 1,
|
60
|
+
"updated_at": "2020-01-25T00:58:35.475Z",
|
61
|
+
"reply_count": 0,
|
62
|
+
"reply_to_post_number": null,
|
63
|
+
"quote_count": 0,
|
64
|
+
"avg_time": null,
|
65
|
+
"incoming_link_count": 0,
|
66
|
+
"reads": 1,
|
67
|
+
"score": 0.2,
|
68
|
+
"yours": false,
|
69
|
+
"topic_id": 11,
|
70
|
+
"topic_slug": "this-is-an-uncategorized-title",
|
71
|
+
"topic_title": "This is an uncategorized title",
|
72
|
+
"topic_html_title": "This is an uncategorized title",
|
73
|
+
"category_id": 1,
|
74
|
+
"display_username": null,
|
75
|
+
"primary_group_name": null,
|
76
|
+
"primary_group_flair_url": null,
|
77
|
+
"primary_group_flair_bg_color": null,
|
78
|
+
"primary_group_flair_color": null,
|
79
|
+
"version": 1,
|
80
|
+
"can_edit": false,
|
81
|
+
"can_delete": false,
|
82
|
+
"can_recover": false,
|
83
|
+
"can_wiki": false,
|
84
|
+
"user_title": null,
|
85
|
+
"raw": "hi there. hi there. hi there.",
|
86
|
+
"actions_summary": [],
|
87
|
+
"moderator": false,
|
88
|
+
"admin": true,
|
89
|
+
"staff": true,
|
90
|
+
"user_id": 1,
|
91
|
+
"hidden": false,
|
92
|
+
"trust_level": 1,
|
93
|
+
"deleted_at": null,
|
94
|
+
"user_deleted": false,
|
95
|
+
"edit_reason": null,
|
96
|
+
"can_view_edit_history": true,
|
97
|
+
"wiki": false
|
98
|
+
},
|
99
|
+
{
|
100
|
+
"id": 10,
|
101
|
+
"name": "system",
|
102
|
+
"username": "system",
|
103
|
+
"avatar_template": "/user_avatar/localhost/system/{size}/1_2.png",
|
104
|
+
"created_at": "2020-01-24T23:26:09.014Z",
|
105
|
+
"cooked": "<p>The first paragraph of this pinned topic will be visible as a welcome message to all new visitors on your homepage. It’s important!</p>\n<p><strong>Edit this</strong> into a brief description of your community:</p>\n<ul>\n<li>Who is it for?</li>\n<li>What can they find here?</li>\n<li>Why should they come here?</li>\n<li>Where can they read more (links, resources, etc)?</li>\n</ul>\n<p><img src=\"//localhost/images/welcome/discourse-edit-post-animated.gif\" width=\"508\" height=\"106\"></p>\n<p>You may want to close this topic via the admin <img src=\"//localhost/images/emoji/twitter/wrench.png?v=6\" title=\":wrench:\" class=\"emoji\" alt=\":wrench:\"> (at the upper right and bottom), so that replies don’t pile up on an announcement.</p>",
|
106
|
+
"post_number": 1,
|
107
|
+
"post_type": 1,
|
108
|
+
"updated_at": "2020-01-24T23:26:09.014Z",
|
109
|
+
"reply_count": 0,
|
110
|
+
"reply_to_post_number": null,
|
111
|
+
"quote_count": 0,
|
112
|
+
"avg_time": null,
|
113
|
+
"incoming_link_count": 0,
|
114
|
+
"reads": 1,
|
115
|
+
"score": 0.2,
|
116
|
+
"yours": false,
|
117
|
+
"topic_id": 7,
|
118
|
+
"topic_slug": "welcome-to-discourse",
|
119
|
+
"topic_title": "Welcome to Discourse",
|
120
|
+
"topic_html_title": "Welcome to Discourse",
|
121
|
+
"category_id": 1,
|
122
|
+
"display_username": "system",
|
123
|
+
"primary_group_name": null,
|
124
|
+
"primary_group_flair_url": null,
|
125
|
+
"primary_group_flair_bg_color": null,
|
126
|
+
"primary_group_flair_color": null,
|
127
|
+
"version": 1,
|
128
|
+
"can_edit": false,
|
129
|
+
"can_delete": false,
|
130
|
+
"can_recover": false,
|
131
|
+
"can_wiki": false,
|
132
|
+
"user_title": null,
|
133
|
+
"raw": "\nThe first paragraph of this pinned topic will be visible as a welcome message to all new visitors on your homepage. It's important!\n\n**Edit this** into a brief description of your community:\n\n- Who is it for?\n- What can they find here?\n- Why should they come here?\n- Where can they read more (links, resources, etc)?\n\n<img src=\"/images/welcome/discourse-edit-post-animated.gif\" width=\"508\" height=\"106\">\n\nYou may want to close this topic via the admin :wrench: (at the upper right and bottom), so that replies don't pile up on an announcement.",
|
134
|
+
"actions_summary": [],
|
135
|
+
"moderator": true,
|
136
|
+
"admin": true,
|
137
|
+
"staff": true,
|
138
|
+
"user_id": -1,
|
139
|
+
"hidden": false,
|
140
|
+
"trust_level": 4,
|
141
|
+
"deleted_at": null,
|
142
|
+
"user_deleted": false,
|
143
|
+
"edit_reason": null,
|
144
|
+
"can_view_edit_history": true,
|
145
|
+
"wiki": false
|
146
|
+
},
|
147
|
+
{
|
148
|
+
"id": 2,
|
149
|
+
"name": "system",
|
150
|
+
"username": "system",
|
151
|
+
"avatar_template": "/user_avatar/localhost/system/{size}/1_2.png",
|
152
|
+
"created_at": "2020-01-24T23:26:05.551Z",
|
153
|
+
"cooked": "<p>Discussion about this site, its organization, how it works, and how we can improve it.</p>",
|
154
|
+
"post_number": 1,
|
155
|
+
"post_type": 1,
|
156
|
+
"updated_at": "2020-01-24T23:26:05.551Z",
|
157
|
+
"reply_count": 0,
|
158
|
+
"reply_to_post_number": null,
|
159
|
+
"quote_count": 0,
|
160
|
+
"avg_time": null,
|
161
|
+
"incoming_link_count": 0,
|
162
|
+
"reads": 1,
|
163
|
+
"score": 0.2,
|
164
|
+
"yours": false,
|
165
|
+
"topic_id": 2,
|
166
|
+
"topic_slug": "about-the-site-feedback-category",
|
167
|
+
"topic_title": "About the Site Feedback category",
|
168
|
+
"topic_html_title": "About the Site Feedback category",
|
169
|
+
"category_id": 3,
|
170
|
+
"display_username": "system",
|
171
|
+
"primary_group_name": null,
|
172
|
+
"primary_group_flair_url": null,
|
173
|
+
"primary_group_flair_bg_color": null,
|
174
|
+
"primary_group_flair_color": null,
|
175
|
+
"version": 1,
|
176
|
+
"can_edit": false,
|
177
|
+
"can_delete": false,
|
178
|
+
"can_recover": false,
|
179
|
+
"can_wiki": false,
|
180
|
+
"user_title": null,
|
181
|
+
"raw": "Discussion about this site, its organization, how it works, and how we can improve it.",
|
182
|
+
"actions_summary": [],
|
183
|
+
"moderator": true,
|
184
|
+
"admin": true,
|
185
|
+
"staff": true,
|
186
|
+
"user_id": -1,
|
187
|
+
"hidden": false,
|
188
|
+
"trust_level": 4,
|
189
|
+
"deleted_at": null,
|
190
|
+
"user_deleted": false,
|
191
|
+
"edit_reason": null,
|
192
|
+
"can_view_edit_history": true,
|
193
|
+
"wiki": false
|
194
|
+
}
|
195
|
+
]
|
196
|
+
}
|
@@ -0,0 +1,60 @@
|
|
1
|
+
{
|
2
|
+
"post_stream":{
|
3
|
+
"posts":[
|
4
|
+
{
|
5
|
+
"id":123456,
|
6
|
+
"name":"Someones Name",
|
7
|
+
"username":"Some-username",
|
8
|
+
"avatar_template":"https://avatars.discourse.org/v4/letter/w/abcd123/{size}.png",
|
9
|
+
"created_at":"2020-01-27T11:32:03.646Z",
|
10
|
+
"cooked":"<p>Some text.</p>",
|
11
|
+
"post_number":2,
|
12
|
+
"post_type":1,
|
13
|
+
"updated_at":"2020-01-27T11:32:03.646Z",
|
14
|
+
"reply_count":0,
|
15
|
+
"reply_to_post_number":null,
|
16
|
+
"quote_count":0,
|
17
|
+
"incoming_link_count":0,
|
18
|
+
"reads":2,
|
19
|
+
"readers_count":1,
|
20
|
+
"score":45.2,
|
21
|
+
"yours":false,
|
22
|
+
"topic_id":57,
|
23
|
+
"topic_slug":"some-topic-slug",
|
24
|
+
"display_username":"Someones Name",
|
25
|
+
"primary_group_name":null,
|
26
|
+
"primary_group_flair_url":null,
|
27
|
+
"primary_group_flair_bg_color":null,
|
28
|
+
"primary_group_flair_color":null,
|
29
|
+
"version":1,
|
30
|
+
"can_edit":true,
|
31
|
+
"can_delete":true,
|
32
|
+
"can_recover":false,
|
33
|
+
"can_wiki":true,
|
34
|
+
"read":true,
|
35
|
+
"user_title":null,
|
36
|
+
"actions_summary":[{"id":2,"count":3,"can_act":true}],
|
37
|
+
"moderator":false,
|
38
|
+
"admin":false,
|
39
|
+
"staff":false,
|
40
|
+
"user_id":123,
|
41
|
+
"hidden":false,
|
42
|
+
"trust_level":3,
|
43
|
+
"deleted_at":null,
|
44
|
+
"user_deleted":false,
|
45
|
+
"edit_reason":null,
|
46
|
+
"can_view_edit_history":true,
|
47
|
+
"wiki":false,
|
48
|
+
"reviewable_id":0,
|
49
|
+
"reviewable_score_count":0,
|
50
|
+
"reviewable_score_pending_count":0,
|
51
|
+
"user_created_at":"2018-01-10T21:29:15.554Z",
|
52
|
+
"user_date_of_birth":null,
|
53
|
+
"can_accept_answer":false,
|
54
|
+
"can_unaccept_answer":false,
|
55
|
+
"accepted_answer":false
|
56
|
+
}
|
57
|
+
]
|
58
|
+
},
|
59
|
+
"id":57
|
60
|
+
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: discourse_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.39.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2020-03-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: faraday
|
@@ -145,14 +145,14 @@ dependencies:
|
|
145
145
|
requirements:
|
146
146
|
- - "~>"
|
147
147
|
- !ruby/object:Gem::Version
|
148
|
-
version: 0.
|
148
|
+
version: '0.69'
|
149
149
|
type: :development
|
150
150
|
prerelease: false
|
151
151
|
version_requirements: !ruby/object:Gem::Requirement
|
152
152
|
requirements:
|
153
153
|
- - "~>"
|
154
154
|
- !ruby/object:Gem::Version
|
155
|
-
version: 0.
|
155
|
+
version: '0.69'
|
156
156
|
- !ruby/object:Gem::Dependency
|
157
157
|
name: simplecov
|
158
158
|
requirement: !ruby/object:Gem::Requirement
|
@@ -181,6 +181,34 @@ dependencies:
|
|
181
181
|
- - "~>"
|
182
182
|
- !ruby/object:Gem::Version
|
183
183
|
version: '2.0'
|
184
|
+
- !ruby/object:Gem::Dependency
|
185
|
+
name: rubocop-discourse
|
186
|
+
requirement: !ruby/object:Gem::Requirement
|
187
|
+
requirements:
|
188
|
+
- - "~>"
|
189
|
+
- !ruby/object:Gem::Version
|
190
|
+
version: '1.0'
|
191
|
+
type: :development
|
192
|
+
prerelease: false
|
193
|
+
version_requirements: !ruby/object:Gem::Requirement
|
194
|
+
requirements:
|
195
|
+
- - "~>"
|
196
|
+
- !ruby/object:Gem::Version
|
197
|
+
version: '1.0'
|
198
|
+
- !ruby/object:Gem::Dependency
|
199
|
+
name: rubocop-rspec
|
200
|
+
requirement: !ruby/object:Gem::Requirement
|
201
|
+
requirements:
|
202
|
+
- - "~>"
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: '1.0'
|
205
|
+
type: :development
|
206
|
+
prerelease: false
|
207
|
+
version_requirements: !ruby/object:Gem::Requirement
|
208
|
+
requirements:
|
209
|
+
- - "~>"
|
210
|
+
- !ruby/object:Gem::Version
|
211
|
+
version: '1.0'
|
184
212
|
description: Discourse API
|
185
213
|
email:
|
186
214
|
- sam.saffron@gmail.com
|
@@ -200,6 +228,7 @@ files:
|
|
200
228
|
- LICENSE.txt
|
201
229
|
- README.md
|
202
230
|
- Rakefile
|
231
|
+
- config_example.yml
|
203
232
|
- discourse_api.gemspec
|
204
233
|
- examples/backups.rb
|
205
234
|
- examples/badges.rb
|
@@ -247,6 +276,7 @@ files:
|
|
247
276
|
- lib/discourse_api/api/users.rb
|
248
277
|
- lib/discourse_api/client.rb
|
249
278
|
- lib/discourse_api/error.rb
|
279
|
+
- lib/discourse_api/example_helper.rb
|
250
280
|
- lib/discourse_api/single_sign_on.rb
|
251
281
|
- lib/discourse_api/version.rb
|
252
282
|
- spec/discourse_api/api/api_key_spec.rb
|
@@ -293,6 +323,8 @@ files:
|
|
293
323
|
- spec/fixtures/polls_voters.json
|
294
324
|
- spec/fixtures/post.json
|
295
325
|
- spec/fixtures/post_action_users.json
|
326
|
+
- spec/fixtures/posts_before.json
|
327
|
+
- spec/fixtures/posts_latest.json
|
296
328
|
- spec/fixtures/private_messages.json
|
297
329
|
- spec/fixtures/regenerate_api_key.json
|
298
330
|
- spec/fixtures/replies.json
|
@@ -300,6 +332,7 @@ files:
|
|
300
332
|
- spec/fixtures/search.json
|
301
333
|
- spec/fixtures/topic.json
|
302
334
|
- spec/fixtures/topic_invite_user.json
|
335
|
+
- spec/fixtures/topic_posts.json
|
303
336
|
- spec/fixtures/topics_created_by.json
|
304
337
|
- spec/fixtures/update_trust_level.json
|
305
338
|
- spec/fixtures/upload_avatar.json
|
@@ -335,7 +368,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
335
368
|
- !ruby/object:Gem::Version
|
336
369
|
version: '0'
|
337
370
|
requirements: []
|
338
|
-
rubygems_version: 3.0.
|
371
|
+
rubygems_version: 3.0.3
|
339
372
|
signing_key:
|
340
373
|
specification_version: 4
|
341
374
|
summary: Allows access to the Discourse API
|
@@ -384,6 +417,8 @@ test_files:
|
|
384
417
|
- spec/fixtures/polls_voters.json
|
385
418
|
- spec/fixtures/post.json
|
386
419
|
- spec/fixtures/post_action_users.json
|
420
|
+
- spec/fixtures/posts_before.json
|
421
|
+
- spec/fixtures/posts_latest.json
|
387
422
|
- spec/fixtures/private_messages.json
|
388
423
|
- spec/fixtures/regenerate_api_key.json
|
389
424
|
- spec/fixtures/replies.json
|
@@ -391,6 +426,7 @@ test_files:
|
|
391
426
|
- spec/fixtures/search.json
|
392
427
|
- spec/fixtures/topic.json
|
393
428
|
- spec/fixtures/topic_invite_user.json
|
429
|
+
- spec/fixtures/topic_posts.json
|
394
430
|
- spec/fixtures/topics_created_by.json
|
395
431
|
- spec/fixtures/update_trust_level.json
|
396
432
|
- spec/fixtures/upload_avatar.json
|