discourse_api 1.0.0 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (78) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +23 -10
  3. data/.rubocop.yml +1 -1
  4. data/.streerc +2 -0
  5. data/CHANGELOG.md +10 -0
  6. data/Gemfile +1 -1
  7. data/README.md +0 -4
  8. data/discourse_api.gemspec +7 -4
  9. data/examples/backups.rb +5 -5
  10. data/examples/badges.rb +5 -5
  11. data/examples/bookmark_topic.rb +5 -5
  12. data/examples/category.rb +10 -6
  13. data/examples/change_topic_status.rb +12 -11
  14. data/examples/create_private_message.rb +6 -6
  15. data/examples/create_topic.rb +9 -9
  16. data/examples/create_update_category.rb +13 -16
  17. data/examples/create_user.rb +12 -11
  18. data/examples/dashboard.rb +5 -5
  19. data/examples/disposable_invite_tokens.rb +9 -10
  20. data/examples/example.rb +5 -5
  21. data/examples/group_set_user_notification_level.rb +18 -19
  22. data/examples/groups.rb +7 -7
  23. data/examples/invite_users.rb +5 -5
  24. data/examples/manage_api_keys.rb +6 -11
  25. data/examples/notifications.rb +6 -6
  26. data/examples/polls.rb +12 -12
  27. data/examples/post_action.rb +5 -5
  28. data/examples/search.rb +5 -5
  29. data/examples/sent_private_messages.rb +6 -6
  30. data/examples/sso.rb +6 -6
  31. data/examples/topic_lists.rb +5 -5
  32. data/examples/update_user.rb +15 -7
  33. data/examples/upload_file.rb +7 -7
  34. data/lib/discourse_api/api/api_key.rb +1 -3
  35. data/lib/discourse_api/api/backups.rb +1 -1
  36. data/lib/discourse_api/api/badges.rb +21 -6
  37. data/lib/discourse_api/api/categories.rb +69 -37
  38. data/lib/discourse_api/api/dashboard.rb +2 -6
  39. data/lib/discourse_api/api/groups.rb +68 -73
  40. data/lib/discourse_api/api/invite.rb +30 -30
  41. data/lib/discourse_api/api/notifications.rb +2 -3
  42. data/lib/discourse_api/api/params.rb +4 -14
  43. data/lib/discourse_api/api/polls.rb +9 -12
  44. data/lib/discourse_api/api/posts.rb +5 -8
  45. data/lib/discourse_api/api/private_messages.rb +9 -8
  46. data/lib/discourse_api/api/search.rb +2 -2
  47. data/lib/discourse_api/api/topics.rb +20 -22
  48. data/lib/discourse_api/api/uploads.rb +7 -5
  49. data/lib/discourse_api/api/user_actions.rb +2 -2
  50. data/lib/discourse_api/api/users.rb +31 -19
  51. data/lib/discourse_api/client.rb +58 -56
  52. data/lib/discourse_api/example_helper.rb +2 -4
  53. data/lib/discourse_api/single_sign_on.rb +56 -57
  54. data/lib/discourse_api/version.rb +1 -1
  55. data/spec/discourse_api/api/api_key_spec.rb +39 -25
  56. data/spec/discourse_api/api/backups_spec.rb +8 -3
  57. data/spec/discourse_api/api/badges_spec.rb +17 -7
  58. data/spec/discourse_api/api/categories_spec.rb +95 -53
  59. data/spec/discourse_api/api/email_spec.rb +17 -7
  60. data/spec/discourse_api/api/groups_spec.rb +71 -52
  61. data/spec/discourse_api/api/invite_spec.rb +41 -21
  62. data/spec/discourse_api/api/notifications_spec.rb +8 -4
  63. data/spec/discourse_api/api/params_spec.rb +5 -3
  64. data/spec/discourse_api/api/polls_spec.rb +53 -44
  65. data/spec/discourse_api/api/posts_spec.rb +33 -16
  66. data/spec/discourse_api/api/private_messages_spec.rb +25 -12
  67. data/spec/discourse_api/api/search_spec.rb +8 -3
  68. data/spec/discourse_api/api/site_settings_spec.rb +2 -3
  69. data/spec/discourse_api/api/sso_spec.rb +29 -25
  70. data/spec/discourse_api/api/topics_spec.rb +100 -31
  71. data/spec/discourse_api/api/uploads_spec.rb +16 -7
  72. data/spec/discourse_api/api/user_actions_spec.rb +13 -3
  73. data/spec/discourse_api/api/users_spec.rb +137 -55
  74. data/spec/discourse_api/client_spec.rb +32 -32
  75. data/spec/discourse_api/single_sign_on_spec.rb +43 -0
  76. data/spec/fixtures/categories.json +1 -1
  77. data/spec/spec_helper.rb +10 -15
  78. metadata +57 -12
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
- require File.expand_path('../../lib/discourse_api', __FILE__)
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['host'] || 'http://localhost:3000')
8
- client.api_key = config['api_key'] || "YOUR_API_KEY"
9
- client.api_username = config['api_username'] || "YOUR_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"
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: 'discourse')
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('../../lib', __FILE__)
4
- require File.expand_path('../../lib/discourse_api', __FILE__)
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['host'] || 'http://localhost:3000')
9
- client.api_key = config['api_key'] || "YOUR_API_KEY"
10
- client.api_username = config['api_username'] || "YOUR_USERNAME"
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 = ['8b4736b1ae3dfb5a28088530f036f9e5']
13
- poll_option_votes = client.poll_vote post_id: 5, poll_name: 'poll', options: options
14
- puts poll_option_votes.body['vote']
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: 'poll', status: 'closed')
17
- puts poll_option_votes[:body]['poll']['status']
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: 'poll')
20
- puts poll_option_votes['voters']
19
+ poll_option_votes = client.poll_voters(post_id: 5, poll_name: "poll")
20
+ puts poll_option_votes["voters"]
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
- require File.expand_path('../../lib/discourse_api', __FILE__)
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['host'] || 'http://localhost:3000')
8
- client.api_key = config['api_key'] || "YOUR_API_KEY"
9
- client.api_username = config['api_username'] || "YOUR_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"
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('../../lib', __FILE__)
3
- require File.expand_path('../../lib/discourse_api', __FILE__)
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['host'] || 'http://localhost:3000')
8
- client.api_key = config['api_key'] || "YOUR_API_KEY"
9
- client.api_username = config['api_username'] || "YOUR_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"
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('../../lib', __FILE__)
3
- require File.expand_path('../../lib/discourse_api', __FILE__)
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['host'] || 'http://localhost:3000')
8
- client.api_key = config['api_key'] || "YOUR_API_KEY"
9
- client.api_username = config['api_username'] || "YOUR_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"
10
10
 
11
- client.sent_private_messages('test_user')
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('../../lib', __FILE__)
3
- require File.expand_path('../../lib/discourse_api', __FILE__)
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['host'] || 'http://localhost:3000')
8
- client.api_key = config['api_key'] || "YOUR_API_KEY"
9
- client.api_username = config['api_username'] || "YOUR_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"
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
  )
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
- require File.expand_path('../../lib/discourse_api', __FILE__)
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['host'] || 'http://localhost:3000')
8
- client.api_key = config['api_key'] || "YOUR_API_KEY"
9
- client.api_username = config['api_username'] || "YOUR_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"
10
10
 
11
11
  # get latest topics
12
12
  puts client.latest_topics({})
@@ -1,12 +1,12 @@
1
1
  # frozen_string_literal: true
2
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
- require File.expand_path('../../lib/discourse_api', __FILE__)
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['host'] || 'http://localhost:3000')
8
- client.api_key = config['api_key'] || "YOUR_API_KEY"
9
- client.api_username = config['api_username'] || "YOUR_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"
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(username: "batman", url: "http://meta-discourse.r.worldssl.net/uploads/default/2497/724a6ef2e79d2bc7.png")
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("batman", bio_raw: "I am Batman.", location: "Gotham", website: "https://en.wikipedia.org/wiki/Batman")
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)
@@ -1,16 +1,16 @@
1
1
  # frozen_string_literal: true
2
- $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
3
- require File.expand_path('../../lib/discourse_api', __FILE__)
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['host'] || 'http://localhost:3000')
8
- client.api_key = config['api_key'] || "YOUR_API_KEY"
9
- client.api_username = config['api_username'] || "YOUR_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"
10
10
 
11
11
  # Upload a file
12
- file = Faraday::UploadIO.new('grumpy_cat.pdf', "application/pdf")
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: 'https://giphy.com/grumpy_cat.gif')
16
+ client.upload_file(url: "https://giphy.com/grumpy_cat.gif")
@@ -8,9 +8,7 @@ module DiscourseApi
8
8
  end
9
9
 
10
10
  def create_api_key(args)
11
- args = API.params(args)
12
- .required(:key)
13
- .to_h
11
+ args = API.params(args).required(:key).to_h
14
12
  post("/admin/api/keys", args)
15
13
  end
16
14
 
@@ -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}", 'wb') { |fp| fp.write(response.body) }
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['badges']
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 = API.params(params)
21
- .required(:name, :badge_type_id)
22
- .optional(:description, :allow_title, :multiple_grant, :icon, :listable,
23
- :target_posts, :query, :enabled, :auto_revoke, :badge_grouping_id,
24
- :trigger, :show_posts, :image, :long_description)
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 = API.params(args)
10
- .required(:name, :color, :text_color)
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,
13
- :reviewable_by_group_name, :show_subcategory_list, :subcategory_list_style,
14
- :allowed_tags, :allowed_tag_groups, :required_tag_group_name)
15
- .default(parent_category_id: nil)
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['category']
36
+ response["category"]
18
37
  end
19
38
 
20
39
  def update_category(args = {})
21
40
  category_id = args[:id]
22
- args = API.params(args)
23
- .required(:id, :name, :color, :text_color)
24
- .optional(:slug, :permissions, :auto_close_hours, :auto_close_based_on_last_post, :position, :email_in,
25
- :email_in_allow_strangers, :logo_url, :background_url, :allow_badges, :topic_template, :custom_fields, :description,
26
- :reviewable_by_group_name, :show_subcategory_list, :subcategory_list_style,
27
- :allowed_tags, :allowed_tag_groups, :required_tag_group_name)
28
- .default(parent_category_id: nil)
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['body']['category'] if response['body']
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]['success']
73
+ response[:body]["success"]
36
74
  end
37
75
 
38
76
  def categories(params = {})
39
- categories_full(params)['category_list']['categories']
77
+ categories_full(params)["category_list"]["categories"]
40
78
  end
41
79
 
42
80
  def categories_full(params = {})
43
- response = get('/categories.json', params)
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['errors']
50
- response['errors']
87
+ if response["errors"]
88
+ response["errors"]
51
89
  else
52
- response['topic_list']['topics']
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['errors']
71
- response['errors']
104
+ if response["errors"]
105
+ response["errors"]
72
106
  else
73
- response['topic_list']['topics']
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['topic_list']['topics']
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]['category']
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['global_reports']
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