discourse_api 1.1.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +23 -10
- data/.rubocop.yml +1 -1
- data/.streerc +2 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -1
- data/README.md +0 -4
- data/discourse_api.gemspec +7 -4
- data/examples/backups.rb +5 -5
- data/examples/badges.rb +5 -5
- data/examples/bookmark_topic.rb +5 -5
- data/examples/category.rb +10 -6
- data/examples/change_topic_status.rb +12 -11
- data/examples/create_private_message.rb +6 -6
- data/examples/create_topic.rb +9 -9
- data/examples/create_update_category.rb +13 -16
- data/examples/create_user.rb +12 -11
- data/examples/dashboard.rb +5 -5
- data/examples/disposable_invite_tokens.rb +9 -10
- data/examples/example.rb +5 -5
- data/examples/group_set_user_notification_level.rb +18 -19
- data/examples/groups.rb +7 -7
- data/examples/invite_users.rb +5 -5
- data/examples/manage_api_keys.rb +6 -11
- data/examples/notifications.rb +6 -6
- data/examples/polls.rb +12 -12
- data/examples/post_action.rb +5 -5
- data/examples/search.rb +5 -5
- data/examples/sent_private_messages.rb +6 -6
- data/examples/sso.rb +6 -6
- data/examples/topic_lists.rb +5 -5
- data/examples/update_user.rb +15 -7
- data/examples/upload_file.rb +7 -7
- data/lib/discourse_api/api/api_key.rb +1 -3
- data/lib/discourse_api/api/backups.rb +1 -1
- data/lib/discourse_api/api/badges.rb +21 -6
- data/lib/discourse_api/api/categories.rb +69 -37
- data/lib/discourse_api/api/dashboard.rb +2 -6
- data/lib/discourse_api/api/groups.rb +68 -73
- data/lib/discourse_api/api/invite.rb +30 -30
- data/lib/discourse_api/api/notifications.rb +2 -3
- data/lib/discourse_api/api/params.rb +4 -14
- data/lib/discourse_api/api/polls.rb +9 -12
- data/lib/discourse_api/api/posts.rb +5 -8
- data/lib/discourse_api/api/private_messages.rb +9 -8
- data/lib/discourse_api/api/search.rb +2 -2
- data/lib/discourse_api/api/topics.rb +20 -22
- data/lib/discourse_api/api/uploads.rb +7 -5
- data/lib/discourse_api/api/user_actions.rb +2 -2
- data/lib/discourse_api/api/users.rb +31 -23
- data/lib/discourse_api/client.rb +58 -56
- data/lib/discourse_api/example_helper.rb +2 -4
- data/lib/discourse_api/single_sign_on.rb +53 -57
- data/lib/discourse_api/version.rb +1 -1
- data/spec/discourse_api/api/api_key_spec.rb +39 -25
- data/spec/discourse_api/api/backups_spec.rb +8 -3
- data/spec/discourse_api/api/badges_spec.rb +17 -7
- data/spec/discourse_api/api/categories_spec.rb +95 -53
- data/spec/discourse_api/api/email_spec.rb +17 -7
- data/spec/discourse_api/api/groups_spec.rb +71 -52
- data/spec/discourse_api/api/invite_spec.rb +41 -21
- data/spec/discourse_api/api/notifications_spec.rb +8 -4
- data/spec/discourse_api/api/params_spec.rb +5 -3
- data/spec/discourse_api/api/polls_spec.rb +53 -44
- data/spec/discourse_api/api/posts_spec.rb +33 -16
- data/spec/discourse_api/api/private_messages_spec.rb +25 -12
- data/spec/discourse_api/api/search_spec.rb +8 -3
- data/spec/discourse_api/api/site_settings_spec.rb +2 -3
- data/spec/discourse_api/api/sso_spec.rb +29 -25
- data/spec/discourse_api/api/topics_spec.rb +100 -31
- data/spec/discourse_api/api/uploads_spec.rb +16 -7
- data/spec/discourse_api/api/user_actions_spec.rb +13 -3
- data/spec/discourse_api/api/users_spec.rb +137 -55
- data/spec/discourse_api/client_spec.rb +32 -32
- data/spec/discourse_api/single_sign_on_spec.rb +15 -15
- data/spec/fixtures/categories.json +1 -1
- data/spec/spec_helper.rb +10 -15
- metadata +55 -12
data/examples/notifications.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
$LOAD_PATH.unshift File.expand_path(
|
3
|
-
require File.expand_path(
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
3
|
+
require File.expand_path("../../lib/discourse_api", __FILE__)
|
4
4
|
|
5
5
|
config = DiscourseApi::ExampleHelper.load_yml
|
6
6
|
|
7
|
-
client = DiscourseApi::Client.new(config[
|
8
|
-
client.api_key = config[
|
9
|
-
client.api_username = config[
|
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"
|
10
10
|
|
11
11
|
# watch an entire category
|
12
12
|
client.category_set_user_notification_level(1, notification_level: 3)
|
@@ -15,4 +15,4 @@ client.category_set_user_notification_level(1, notification_level: 3)
|
|
15
15
|
client.topic_set_user_notification_level(1, notification_level: 0)
|
16
16
|
|
17
17
|
# get user notifications
|
18
|
-
client.notifications(username:
|
18
|
+
client.notifications(username: "discourse")
|
data/examples/polls.rb
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
$LOAD_PATH.unshift File.expand_path(
|
4
|
-
require File.expand_path(
|
3
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
4
|
+
require File.expand_path("../../lib/discourse_api", __FILE__)
|
5
5
|
|
6
6
|
config = DiscourseApi::ExampleHelper.load_yml
|
7
7
|
|
8
|
-
client = DiscourseApi::Client.new(config[
|
9
|
-
client.api_key = config[
|
10
|
-
client.api_username = config[
|
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"
|
11
11
|
|
12
|
-
options = [
|
13
|
-
poll_option_votes = client.poll_vote post_id: 5, poll_name:
|
14
|
-
puts poll_option_votes.body[
|
12
|
+
options = ["8b4736b1ae3dfb5a28088530f036f9e5"]
|
13
|
+
poll_option_votes = client.poll_vote post_id: 5, poll_name: "poll", options: options
|
14
|
+
puts poll_option_votes.body["vote"]
|
15
15
|
|
16
|
-
poll_option_votes = client.toggle_poll_status(post_id: 5, poll_name:
|
17
|
-
puts poll_option_votes[:body][
|
16
|
+
poll_option_votes = client.toggle_poll_status(post_id: 5, poll_name: "poll", status: "closed")
|
17
|
+
puts poll_option_votes[:body]["poll"]["status"]
|
18
18
|
|
19
|
-
poll_option_votes = client.poll_voters(post_id: 5, poll_name:
|
20
|
-
puts poll_option_votes[
|
19
|
+
poll_option_votes = client.poll_voters(post_id: 5, poll_name: "poll")
|
20
|
+
puts poll_option_votes["voters"]
|
data/examples/post_action.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
$LOAD_PATH.unshift File.expand_path(
|
3
|
-
require File.expand_path(
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
3
|
+
require File.expand_path("../../lib/discourse_api", __FILE__)
|
4
4
|
|
5
5
|
config = DiscourseApi::ExampleHelper.load_yml
|
6
6
|
|
7
|
-
client = DiscourseApi::Client.new(config[
|
8
|
-
client.api_key = config[
|
9
|
-
client.api_username = config[
|
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"
|
10
10
|
|
11
11
|
# Post Action Type IDs
|
12
12
|
# 1 - Bookmark
|
data/examples/search.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
$LOAD_PATH.unshift File.expand_path(
|
3
|
-
require File.expand_path(
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
3
|
+
require File.expand_path("../../lib/discourse_api", __FILE__)
|
4
4
|
|
5
5
|
config = DiscourseApi::ExampleHelper.load_yml
|
6
6
|
|
7
|
-
client = DiscourseApi::Client.new(config[
|
8
|
-
client.api_key = config[
|
9
|
-
client.api_username = config[
|
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"
|
10
10
|
|
11
11
|
# search for term
|
12
12
|
puts client.search("discourse")
|
@@ -1,11 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
$LOAD_PATH.unshift File.expand_path(
|
3
|
-
require File.expand_path(
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
3
|
+
require File.expand_path("../../lib/discourse_api", __FILE__)
|
4
4
|
|
5
5
|
config = DiscourseApi::ExampleHelper.load_yml
|
6
6
|
|
7
|
-
client = DiscourseApi::Client.new(config[
|
8
|
-
client.api_key = config[
|
9
|
-
client.api_username = config[
|
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"
|
10
10
|
|
11
|
-
client.sent_private_messages(
|
11
|
+
client.sent_private_messages("test_user")
|
data/examples/sso.rb
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
$LOAD_PATH.unshift File.expand_path(
|
3
|
-
require File.expand_path(
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
3
|
+
require File.expand_path("../../lib/discourse_api", __FILE__)
|
4
4
|
|
5
5
|
config = DiscourseApi::ExampleHelper.load_yml
|
6
6
|
|
7
|
-
client = DiscourseApi::Client.new(config[
|
8
|
-
client.api_key = config[
|
9
|
-
client.api_username = config[
|
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"
|
10
10
|
|
11
11
|
client.sync_sso(
|
12
12
|
sso_secret: "discourse_sso_rocks",
|
13
13
|
name: "Test Name",
|
14
14
|
username: "test_name",
|
15
15
|
email: "name@example.com",
|
16
|
-
external_id: "2"
|
16
|
+
external_id: "2",
|
17
17
|
)
|
data/examples/topic_lists.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
$LOAD_PATH.unshift File.expand_path(
|
3
|
-
require File.expand_path(
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
3
|
+
require File.expand_path("../../lib/discourse_api", __FILE__)
|
4
4
|
|
5
5
|
config = DiscourseApi::ExampleHelper.load_yml
|
6
6
|
|
7
|
-
client = DiscourseApi::Client.new(config[
|
8
|
-
client.api_key = config[
|
9
|
-
client.api_username = config[
|
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"
|
10
10
|
|
11
11
|
# get latest topics
|
12
12
|
puts client.latest_topics({})
|
data/examples/update_user.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
$LOAD_PATH.unshift File.expand_path(
|
3
|
-
require File.expand_path(
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
3
|
+
require File.expand_path("../../lib/discourse_api", __FILE__)
|
4
4
|
|
5
5
|
config = DiscourseApi::ExampleHelper.load_yml
|
6
6
|
|
7
|
-
client = DiscourseApi::Client.new(config[
|
8
|
-
client.api_key = config[
|
9
|
-
client.api_username = config[
|
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"
|
10
10
|
|
11
11
|
# update username from "robin" to "batman"
|
12
12
|
puts client.update_username("robin", "batman")
|
@@ -15,11 +15,19 @@ puts client.update_user("batman", name: "Bruce Wayne")
|
|
15
15
|
# update email of user whose username is "batman"
|
16
16
|
puts client.update_email("batman", "batman@gotham.com")
|
17
17
|
# update avatar of user whose username is "batman"
|
18
|
-
puts client.update_avatar(
|
18
|
+
puts client.update_avatar(
|
19
|
+
username: "batman",
|
20
|
+
url: "http://meta-discourse.r.worldssl.net/uploads/default/2497/724a6ef2e79d2bc7.png",
|
21
|
+
)
|
19
22
|
# update trust level of user whose id is "102"
|
20
23
|
puts client.update_trust_level(user_id: 102, level: 2)
|
21
24
|
# update user bio, location or website
|
22
|
-
puts client.update_user(
|
25
|
+
puts client.update_user(
|
26
|
+
"batman",
|
27
|
+
bio_raw: "I am Batman.",
|
28
|
+
location: "Gotham",
|
29
|
+
website: "https://en.wikipedia.org/wiki/Batman",
|
30
|
+
)
|
23
31
|
|
24
32
|
# log out everywhere and refresh browser of user whose id is "2"
|
25
33
|
puts client.log_out(2)
|
data/examples/upload_file.rb
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
$LOAD_PATH.unshift File.expand_path(
|
3
|
-
require File.expand_path(
|
2
|
+
$LOAD_PATH.unshift File.expand_path("../../lib", __FILE__)
|
3
|
+
require File.expand_path("../../lib/discourse_api", __FILE__)
|
4
4
|
|
5
5
|
config = DiscourseApi::ExampleHelper.load_yml
|
6
6
|
|
7
|
-
client = DiscourseApi::Client.new(config[
|
8
|
-
client.api_key = config[
|
9
|
-
client.api_username = config[
|
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"
|
10
10
|
|
11
11
|
# Upload a file
|
12
|
-
file = Faraday::UploadIO.new(
|
12
|
+
file = Faraday::UploadIO.new("grumpy_cat.pdf", "application/pdf")
|
13
13
|
client.upload_file(file: file)
|
14
14
|
|
15
15
|
# Upload a file via URL
|
16
|
-
client.upload_file(url:
|
16
|
+
client.upload_file(url: "https://giphy.com/grumpy_cat.gif")
|
@@ -18,7 +18,7 @@ module DiscourseApi
|
|
18
18
|
def download_backup(file_name, destination)
|
19
19
|
response = get("/admin/backups/#{file_name}")
|
20
20
|
# write file
|
21
|
-
File.open("#{destination}/#{file_name}",
|
21
|
+
File.open("#{destination}/#{file_name}", "wb") { |fp| fp.write(response.body) }
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -9,7 +9,7 @@ module DiscourseApi
|
|
9
9
|
|
10
10
|
def user_badges(username)
|
11
11
|
response = get("/user-badges/#{username}.json")
|
12
|
-
response.body[
|
12
|
+
response.body["badges"]
|
13
13
|
end
|
14
14
|
|
15
15
|
def grant_user_badge(params = {})
|
@@ -17,11 +17,26 @@ module DiscourseApi
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def create_badge(params = {})
|
20
|
-
args =
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
args =
|
21
|
+
API
|
22
|
+
.params(params)
|
23
|
+
.required(:name, :badge_type_id)
|
24
|
+
.optional(
|
25
|
+
:description,
|
26
|
+
:allow_title,
|
27
|
+
:multiple_grant,
|
28
|
+
:icon,
|
29
|
+
:listable,
|
30
|
+
:target_posts,
|
31
|
+
:query,
|
32
|
+
:enabled,
|
33
|
+
:auto_revoke,
|
34
|
+
:badge_grouping_id,
|
35
|
+
:trigger,
|
36
|
+
:show_posts,
|
37
|
+
:image,
|
38
|
+
:long_description,
|
39
|
+
)
|
25
40
|
post("/admin/badges.json", args)
|
26
41
|
end
|
27
42
|
end
|
@@ -6,71 +6,105 @@ module DiscourseApi
|
|
6
6
|
# :permissions is a hash with the group name and permission_type which is
|
7
7
|
# an integer 1 = Full 2 = Create Post 3 = Read Only
|
8
8
|
def create_category(args = {})
|
9
|
-
args =
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
9
|
+
args =
|
10
|
+
API
|
11
|
+
.params(args)
|
12
|
+
.required(:name, :color, :text_color)
|
13
|
+
.optional(
|
14
|
+
:slug,
|
15
|
+
:permissions,
|
16
|
+
:auto_close_hours,
|
17
|
+
:auto_close_based_on_last_post,
|
18
|
+
:position,
|
19
|
+
:email_in,
|
20
|
+
:email_in_allow_strangers,
|
21
|
+
:logo_url,
|
22
|
+
:background_url,
|
23
|
+
:allow_badges,
|
24
|
+
:topic_template,
|
25
|
+
:custom_fields,
|
26
|
+
:description,
|
27
|
+
:reviewable_by_group_name,
|
28
|
+
:show_subcategory_list,
|
29
|
+
:subcategory_list_style,
|
30
|
+
:allowed_tags,
|
31
|
+
:allowed_tag_groups,
|
32
|
+
:required_tag_group_name,
|
33
|
+
)
|
34
|
+
.default(parent_category_id: nil)
|
16
35
|
response = post("/categories", args)
|
17
|
-
response[
|
36
|
+
response["category"]
|
18
37
|
end
|
19
38
|
|
20
39
|
def update_category(args = {})
|
21
40
|
category_id = args[:id]
|
22
|
-
args =
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
41
|
+
args =
|
42
|
+
API
|
43
|
+
.params(args)
|
44
|
+
.required(:id, :name, :color, :text_color)
|
45
|
+
.optional(
|
46
|
+
:slug,
|
47
|
+
:permissions,
|
48
|
+
:auto_close_hours,
|
49
|
+
:auto_close_based_on_last_post,
|
50
|
+
:position,
|
51
|
+
:email_in,
|
52
|
+
:email_in_allow_strangers,
|
53
|
+
:logo_url,
|
54
|
+
:background_url,
|
55
|
+
:allow_badges,
|
56
|
+
:topic_template,
|
57
|
+
:custom_fields,
|
58
|
+
:description,
|
59
|
+
:reviewable_by_group_name,
|
60
|
+
:show_subcategory_list,
|
61
|
+
:subcategory_list_style,
|
62
|
+
:allowed_tags,
|
63
|
+
:allowed_tag_groups,
|
64
|
+
:required_tag_group_name,
|
65
|
+
)
|
66
|
+
.default(parent_category_id: nil)
|
29
67
|
response = put("/categories/#{category_id}", args)
|
30
|
-
response[
|
68
|
+
response["body"]["category"] if response["body"]
|
31
69
|
end
|
32
70
|
|
33
71
|
def delete_category(id)
|
34
72
|
response = delete("/categories/#{id}")
|
35
|
-
response[:body][
|
73
|
+
response[:body]["success"]
|
36
74
|
end
|
37
75
|
|
38
76
|
def categories(params = {})
|
39
|
-
categories_full(params)[
|
77
|
+
categories_full(params)["category_list"]["categories"]
|
40
78
|
end
|
41
79
|
|
42
80
|
def categories_full(params = {})
|
43
|
-
response = get(
|
81
|
+
response = get("/categories.json", params)
|
44
82
|
response[:body]
|
45
83
|
end
|
46
84
|
|
47
85
|
def category_latest_topics(args = {})
|
48
86
|
response = category_latest_topics_full(args)
|
49
|
-
if response[
|
50
|
-
response[
|
87
|
+
if response["errors"]
|
88
|
+
response["errors"]
|
51
89
|
else
|
52
|
-
response[
|
90
|
+
response["topic_list"]["topics"]
|
53
91
|
end
|
54
92
|
end
|
55
93
|
|
56
94
|
def category_latest_topics_full(args = {})
|
57
|
-
params = API.params(args)
|
58
|
-
.required(:category_slug)
|
59
|
-
.optional(:page).to_h
|
95
|
+
params = API.params(args).required(:category_slug).optional(:page).to_h
|
60
96
|
url = "/c/#{params[:category_slug]}/l/latest.json"
|
61
|
-
if params.include?(:page)
|
62
|
-
url = "#{url}?page=#{params[:page]}"
|
63
|
-
end
|
97
|
+
url = "#{url}?page=#{params[:page]}" if params.include?(:page)
|
64
98
|
response = get(url)
|
65
99
|
response[:body]
|
66
100
|
end
|
67
101
|
|
68
102
|
def category_top_topics(category_slug)
|
69
103
|
response = category_top_topics_full(category_slug)
|
70
|
-
if response[
|
71
|
-
response[
|
104
|
+
if response["errors"]
|
105
|
+
response["errors"]
|
72
106
|
else
|
73
|
-
response[
|
107
|
+
response["topic_list"]["topics"]
|
74
108
|
end
|
75
109
|
end
|
76
110
|
|
@@ -81,7 +115,7 @@ module DiscourseApi
|
|
81
115
|
|
82
116
|
def category_new_topics(category_slug)
|
83
117
|
response = category_new_topics_full(category_slug)
|
84
|
-
response[
|
118
|
+
response["topic_list"]["topics"]
|
85
119
|
end
|
86
120
|
|
87
121
|
def category_new_topics_full(category_slug)
|
@@ -91,20 +125,18 @@ module DiscourseApi
|
|
91
125
|
|
92
126
|
def category(id)
|
93
127
|
response = get("/c/#{id}/show")
|
94
|
-
response[:body][
|
128
|
+
response[:body]["category"]
|
95
129
|
end
|
96
130
|
|
97
131
|
# TODO: Deprecated. Remove after 20210727
|
98
132
|
def category_set_user_notification(args = {})
|
99
133
|
category_id = args[:id]
|
100
|
-
args = API.params(args)
|
101
|
-
.required(:notification_level)
|
134
|
+
args = API.params(args).required(:notification_level)
|
102
135
|
post("/category/#{category_id}/notifications", args)
|
103
136
|
end
|
104
137
|
|
105
138
|
def category_set_user_notification_level(category_id, params)
|
106
|
-
params = API.params(params)
|
107
|
-
.required(:notification_level)
|
139
|
+
params = API.params(params).required(:notification_level)
|
108
140
|
post("/category/#{category_id}/notifications", params)
|
109
141
|
end
|
110
142
|
end
|
@@ -9,16 +9,12 @@ module DiscourseApi
|
|
9
9
|
|
10
10
|
def get_dashboard_stats_totals
|
11
11
|
stats = get_dashboard_stats
|
12
|
-
global_reports = stats[
|
12
|
+
global_reports = stats["global_reports"]
|
13
13
|
users = global_reports[1]
|
14
14
|
topics = global_reports[3]
|
15
15
|
posts = global_reports[4]
|
16
16
|
|
17
|
-
{
|
18
|
-
'users' => users['total'],
|
19
|
-
'topics' => topics['total'],
|
20
|
-
'posts' => posts['total'],
|
21
|
-
}
|
17
|
+
{ "users" => users["total"], "topics" => topics["total"], "posts" => posts["total"] }
|
22
18
|
end
|
23
19
|
end
|
24
20
|
end
|