discourse_api 1.1.0 → 2.0.1

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 +5 -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 -23
  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 +53 -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 +15 -15
  76. data/spec/fixtures/categories.json +1 -1
  77. data/spec/spec_helper.rb +10 -15
  78. metadata +55 -12
@@ -3,83 +3,83 @@ module DiscourseApi
3
3
  module API
4
4
  module Groups
5
5
  def create_group(args)
6
- args = API.params(args)
7
- .required(:name)
8
- .default(visibility_level: 0)
9
- .optional(:mentionable_level,
10
- :messageable_level,
11
- :automatic_membership_email_domains,
12
- :automatic_membership_retroactive,
13
- :title,
14
- :primary_group,
15
- :grant_trust_level,
16
- :incoming_email,
17
- :flair_url,
18
- :flair_bg_color,
19
- :flair_color,
20
- :bio_raw,
21
- :members_visibility_level,
22
- :public_admission,
23
- :public_exit,
24
- :allow_membership_requests,
25
- :full_name,
26
- :default_notification_level,
27
- :usernames,
28
- :owner_usernames,
29
- :membership_request_template)
30
- .to_h
6
+ args =
7
+ API
8
+ .params(args)
9
+ .required(:name)
10
+ .default(visibility_level: 0)
11
+ .optional(
12
+ :mentionable_level,
13
+ :messageable_level,
14
+ :automatic_membership_email_domains,
15
+ :automatic_membership_retroactive,
16
+ :title,
17
+ :primary_group,
18
+ :grant_trust_level,
19
+ :incoming_email,
20
+ :flair_url,
21
+ :flair_bg_color,
22
+ :flair_color,
23
+ :bio_raw,
24
+ :members_visibility_level,
25
+ :public_admission,
26
+ :public_exit,
27
+ :allow_membership_requests,
28
+ :full_name,
29
+ :default_notification_level,
30
+ :usernames,
31
+ :owner_usernames,
32
+ :membership_request_template,
33
+ )
34
+ .to_h
31
35
  post("/admin/groups", group: args)
32
36
  end
33
37
 
34
38
  def update_group(group_id, args)
35
- args = API.params(args)
36
- .default(visibility_level: 0)
37
- .optional(:mentionable_level,
38
- :messageable_level,
39
- :name,
40
- :automatic_membership_email_domains,
41
- :title,
42
- :primary_group,
43
- :grant_trust_level,
44
- :incoming_email,
45
- :flair_url,
46
- :flair_bg_color,
47
- :flair_color,
48
- :bio_raw,
49
- :visibility_level,
50
- :public_admission,
51
- :public_exit,
52
- :allow_membership_requests,
53
- :full_name,
54
- :default_notification_level,
55
- :membership_request_template)
56
- .to_h
39
+ args =
40
+ API
41
+ .params(args)
42
+ .default(visibility_level: 0)
43
+ .optional(
44
+ :mentionable_level,
45
+ :messageable_level,
46
+ :name,
47
+ :automatic_membership_email_domains,
48
+ :title,
49
+ :primary_group,
50
+ :grant_trust_level,
51
+ :incoming_email,
52
+ :flair_url,
53
+ :flair_bg_color,
54
+ :flair_color,
55
+ :bio_raw,
56
+ :visibility_level,
57
+ :public_admission,
58
+ :public_exit,
59
+ :allow_membership_requests,
60
+ :full_name,
61
+ :default_notification_level,
62
+ :membership_request_template,
63
+ )
64
+ .to_h
57
65
  put("/groups/#{group_id}", group: args)
58
66
  end
59
67
 
60
68
  def group_add_owners(group_id, args)
61
- args = API.params(args)
62
- .required(:usernames)
63
- .to_h
69
+ args = API.params(args).required(:usernames).to_h
64
70
  put("/admin/groups/#{group_id}/owners.json", group: args)
65
71
  end
66
72
 
67
73
  def group_remove_owners(group_id, args)
68
- args = API.params(args)
69
- .required(:usernames)
70
- .to_h
74
+ args = API.params(args).required(:usernames).to_h
71
75
  delete("/admin/groups/#{group_id}/owners.json", group: args)
72
76
  end
73
77
 
74
78
  def groups(args = {})
75
- params = API.params(args)
76
- .optional(:page)
77
- .to_h
79
+ params = API.params(args).optional(:page).to_h
78
80
 
79
81
  url = "/groups.json"
80
- if params.include?(:page)
81
- url += "?page=#{params[:page]}"
82
- end
82
+ url += "?page=#{params[:page]}" if params.include?(:page)
83
83
  response = get(url)
84
84
  response.body
85
85
  end
@@ -92,12 +92,10 @@ module DiscourseApi
92
92
  def group_add(group_id, users)
93
93
  users.keys.each do |key|
94
94
  # Accept arrays and convert to comma-delimited string.
95
- if users[key].respond_to? :join
96
- users[key] = users[key].join(",")
97
- end
95
+ users[key] = users[key].join(",") if users[key].respond_to? :join
98
96
 
99
97
  # Accept non-plural user_id or username, but send pluralized version in the request.
100
- if key.to_s[-1] != 's'
98
+ if key.to_s[-1] != "s"
101
99
  users["#{key}s"] = users[key]
102
100
  users.delete(key)
103
101
  end
@@ -109,12 +107,10 @@ module DiscourseApi
109
107
  def group_remove(group_id, users)
110
108
  users.keys.each do |key|
111
109
  # Accept arrays and convert to comma-delimited string.
112
- if users[key].respond_to? :join
113
- users[key] = users[key].join(",")
114
- end
110
+ users[key] = users[key].join(",") if users[key].respond_to? :join
115
111
 
116
112
  # Accept non-plural user_id or username, but send pluralized version in the request.
117
- if key.to_s[-1] != 's'
113
+ if key.to_s[-1] != "s"
118
114
  users["#{key}s"] = users[key]
119
115
  users.delete(key)
120
116
  end
@@ -129,21 +125,20 @@ module DiscourseApi
129
125
 
130
126
  def group_members(group_name, params = {})
131
127
  options = params
132
- params = API.params(params)
133
- .optional(:offset, :limit)
134
- .default(offset: 0, limit: 100)
135
- .to_h
128
+ params = API.params(params).optional(:offset, :limit).default(offset: 0, limit: 100).to_h
136
129
  response = get("/groups/#{group_name}/members.json", params)
137
130
 
138
131
  if options[:all] == true
139
132
  response.body
140
133
  else
141
- response.body['members']
134
+ response.body["members"]
142
135
  end
143
136
  end
144
137
 
145
138
  def group_set_user_notification_level(group, user_id, notification_level)
146
- post("/groups/#{group}/notifications?user_id=#{user_id}&notification_level=#{notification_level}")
139
+ post(
140
+ "/groups/#{group}/notifications?user_id=#{user_id}&notification_level=#{notification_level}",
141
+ )
147
142
  end
148
143
  end
149
144
  end
@@ -3,34 +3,31 @@ module DiscourseApi
3
3
  module API
4
4
  module Invite
5
5
  def invite_user(params = {})
6
- args = API.params(params)
7
- .optional(
8
- :email,
9
- :skip_email,
10
- :custom_message,
11
- :max_redemptions_allowed,
12
- :topic_id,
13
- :group_ids,
14
- :expires_at
15
- ).to_h
6
+ args =
7
+ API
8
+ .params(params)
9
+ .optional(
10
+ :email,
11
+ :skip_email,
12
+ :custom_message,
13
+ :max_redemptions_allowed,
14
+ :topic_id,
15
+ :group_ids,
16
+ :expires_at,
17
+ )
18
+ .to_h
16
19
 
17
20
  post("/invites", args)
18
21
  end
19
22
 
20
23
  # TODO: Deprecated. Remove after 20220506
21
24
  def invite_user_to_topic(params = {})
22
- deprecated(__method__, 'invite_to_topic')
25
+ deprecated(__method__, "invite_to_topic")
23
26
  invite_to_topic(params[:topic_id], params)
24
27
  end
25
28
 
26
29
  def invite_to_topic(topic_id, params = {})
27
- args = API.params(params)
28
- .optional(
29
- :email,
30
- :user,
31
- :group_ids,
32
- :custom_message
33
- ).to_h
30
+ args = API.params(params).optional(:email, :user, :group_ids, :custom_message).to_h
34
31
 
35
32
  post("/t/#{topic_id}/invite", args)
36
33
  end
@@ -49,17 +46,20 @@ module DiscourseApi
49
46
  end
50
47
 
51
48
  def update_invite(invite_id, params = {})
52
- args = API.params(params)
53
- .optional(
54
- :topic_id,
55
- :group_ids,
56
- :group_names,
57
- :email,
58
- :send_email,
59
- :custom_message,
60
- :max_redemptions_allowed,
61
- :expires_at
62
- ).to_h
49
+ args =
50
+ API
51
+ .params(params)
52
+ .optional(
53
+ :topic_id,
54
+ :group_ids,
55
+ :group_names,
56
+ :email,
57
+ :send_email,
58
+ :custom_message,
59
+ :max_redemptions_allowed,
60
+ :expires_at,
61
+ )
62
+ .to_h
63
63
 
64
64
  put("invites/#{invite_id}", args)
65
65
  end
@@ -73,7 +73,7 @@ module DiscourseApi
73
73
  end
74
74
 
75
75
  def resend_invite(email)
76
- post("invites/reinvite", { "email": email })
76
+ post("invites/reinvite", { email: email })
77
77
  end
78
78
 
79
79
  def destroy_invite(invite_id)
@@ -3,10 +3,9 @@ module DiscourseApi
3
3
  module API
4
4
  module Notifications
5
5
  def notifications(params = {})
6
- params = API.params(params)
7
- .optional(:username, :recent, :limit, :offset, :filter)
6
+ params = API.params(params).optional(:username, :recent, :limit, :offset, :filter)
8
7
 
9
- response = get('/notifications.json', params)
8
+ response = get("/notifications.json", params)
10
9
  response[:body]
11
10
  end
12
11
  end
@@ -28,31 +28,21 @@ module DiscourseApi
28
28
  end
29
29
 
30
30
  def default(args)
31
- args.each do |k, v|
32
- @defaults[k] = v
33
- end
31
+ args.each { |k, v| @defaults[k] = v }
34
32
  self
35
33
  end
36
34
 
37
35
  def to_h
38
36
  h = {}
39
37
 
40
- @required.each do |k|
41
- h[k] = @args[k]
42
- end
38
+ @required.each { |k| h[k] = @args[k] }
43
39
 
44
- @optional.each do |k|
45
- h[k] = @args[k] if @args.include?(k)
46
- end
40
+ @optional.each { |k| h[k] = @args[k] if @args.include?(k) }
47
41
 
48
- @defaults.each do |k, v|
49
- @args.key?(k) ? h[k] = @args[k] : h[k] = v
50
- end
42
+ @defaults.each { |k, v| @args.key?(k) ? h[k] = @args[k] : h[k] = v }
51
43
 
52
44
  h
53
-
54
45
  end
55
46
  end
56
-
57
47
  end
58
48
  end
@@ -4,28 +4,25 @@ module DiscourseApi
4
4
  module API
5
5
  module Polls
6
6
  def poll_vote(args)
7
- args = API.params(args)
8
- .required(:post_id, :poll_name, :options)
9
- .optional(:created_at)
7
+ args = API.params(args).required(:post_id, :poll_name, :options).optional(:created_at)
10
8
  put("/polls/vote", args)
11
9
  end
12
10
 
13
11
  def toggle_poll_status(args)
14
- args = API.params(args)
15
- .required(:post_id, :poll_name, :status)
16
- .optional(:api_username)
17
- .optional(:raise_errors)
18
- put("/polls/toggle_status", args)
12
+ args =
13
+ API
14
+ .params(args)
15
+ .required(:post_id, :poll_name, :status)
16
+ .optional(:api_username)
17
+ .optional(:raise_errors)
18
+ put("/polls/toggle_status", args)
19
19
  end
20
20
 
21
21
  def poll_voters(args)
22
- args = API.params(args)
23
- .required(:post_id, :poll_name)
24
- .optional(:opts)
22
+ args = API.params(args).required(:post_id, :poll_name).optional(:opts)
25
23
  response = get("/polls/voters.json", args)
26
24
  response[:body]
27
25
  end
28
-
29
26
  end
30
27
  end
31
28
  end
@@ -3,21 +3,17 @@ module DiscourseApi
3
3
  module API
4
4
  module Posts
5
5
  def create_post(args)
6
- args = API.params(args)
7
- .required(:topic_id, :raw)
8
- .optional(:created_at, :api_username)
6
+ args = API.params(args).required(:topic_id, :raw).optional(:created_at, :api_username)
9
7
  post("/posts", args)
10
8
  end
11
9
 
12
10
  def create_post_action(args)
13
- args = API.params(args)
14
- .required(:id, :post_action_type_id)
11
+ args = API.params(args).required(:id, :post_action_type_id)
15
12
  post("/post_actions", args.to_h.merge(flag_topic: false))
16
13
  end
17
14
 
18
15
  def get_post(id, args = {})
19
- args = API.params(args)
20
- .optional(:version)
16
+ args = API.params(args).optional(:version)
21
17
  response = get("/posts/#{id}.json", args)
22
18
  response[:body]
23
19
  end
@@ -45,7 +41,8 @@ module DiscourseApi
45
41
  end
46
42
 
47
43
  def post_action_users(post_id, post_action_type_id)
48
- response = get("/post_action_users.json", id: post_id, post_action_type_id: post_action_type_id)
44
+ response =
45
+ get("/post_action_users.json", id: post_id, post_action_type_id: post_action_type_id)
49
46
  response[:body]
50
47
  end
51
48
  end
@@ -2,10 +2,9 @@
2
2
  module DiscourseApi
3
3
  module API
4
4
  module PrivateMessages
5
-
6
5
  # TODO: Deprecated. Remove after 20220628
7
6
  def create_private_message(args = {})
8
- deprecated(__method__, 'create_pm')
7
+ deprecated(__method__, "create_pm")
9
8
  args[:target_recipients] = args.delete :target_usernames
10
9
  create_pm(args.to_h)
11
10
  end
@@ -14,21 +13,23 @@ module DiscourseApi
14
13
  # :category OPTIONAL name of category, not ID
15
14
  # :created_at OPTIONAL seconds since epoch.
16
15
  def create_pm(args = {})
17
- args[:archetype] = 'private_message'
18
- args = API.params(args)
19
- .required(:title, :raw, :target_recipients, :archetype)
20
- .optional(:category, :created_at, :api_username)
16
+ args[:archetype] = "private_message"
17
+ args =
18
+ API
19
+ .params(args)
20
+ .required(:title, :raw, :target_recipients, :archetype)
21
+ .optional(:category, :created_at, :api_username)
21
22
  post("/posts", args.to_h)
22
23
  end
23
24
 
24
25
  def private_messages(username, *args)
25
26
  response = get("topics/private-messages/#{username}.json", args)
26
- response[:body]['topic_list']['topics']
27
+ response[:body]["topic_list"]["topics"]
27
28
  end
28
29
 
29
30
  def sent_private_messages(username, *args)
30
31
  response = get("topics/private-messages-sent/#{username}.json", args)
31
- response[:body]['topic_list']['topics']
32
+ response[:body]["topic_list"]["topics"]
32
33
  end
33
34
  end
34
35
  end
@@ -10,9 +10,9 @@ module DiscourseApi
10
10
  # @return [Array] Return results as an array of Hashes.
11
11
  def search(term, options = {})
12
12
  raise ArgumentError.new("#{term} is required but not specified") unless term
13
- raise ArgumentError.new("#{term} is required but not specified") unless !term.empty?
13
+ raise ArgumentError.new("#{term} is required but not specified") if term.empty?
14
14
 
15
- response = get('/search', options.merge(q: term))
15
+ response = get("/search", options.merge(q: term))
16
16
  response[:body]
17
17
  end
18
18
  end
@@ -7,15 +7,16 @@ module DiscourseApi
7
7
  # :auto_track OPTIONAL boolean
8
8
  # :created_at OPTIONAL seconds since epoch.
9
9
  def create_topic(args = {})
10
- args = API.params(args)
11
- .required(:title, :raw)
12
- .optional(:skip_validations, :category, :auto_track, :created_at, :api_username, :tags)
10
+ args =
11
+ API
12
+ .params(args)
13
+ .required(:title, :raw)
14
+ .optional(:skip_validations, :category, :auto_track, :created_at, :api_username, :tags)
13
15
  post("/posts", args.to_h)
14
16
  end
15
17
 
16
18
  def create_topic_action(args)
17
- args = API.params(args)
18
- .required(:id, :post_action_type_id)
19
+ args = API.params(args).required(:id, :post_action_type_id)
19
20
  post("/post_actions", args.to_h.merge(flag_topic: true))
20
21
  end
21
22
 
@@ -25,18 +26,18 @@ module DiscourseApi
25
26
  end
26
27
 
27
28
  def latest_topics(params = {})
28
- response = get('/latest.json', params)
29
- response[:body]['topic_list']['topics']
29
+ response = get("/latest.json", params)
30
+ response[:body]["topic_list"]["topics"]
30
31
  end
31
32
 
32
33
  def top_topics(params = {})
33
34
  response = get("/top.json", params)
34
- response[:body]['topic_list']['topics']
35
+ response[:body]["topic_list"]["topics"]
35
36
  end
36
37
 
37
38
  def new_topics(params = {})
38
39
  response = get("/new.json", params)
39
- response[:body]['topic_list']['topics']
40
+ response[:body]["topic_list"]["topics"]
40
41
  end
41
42
 
42
43
  def rename_topic(topic_id, title)
@@ -49,14 +50,12 @@ module DiscourseApi
49
50
 
50
51
  # TODO: Deprecated. Remove after 20201231
51
52
  def change_topic_status(topic_slug, topic_id, params = {})
52
- deprecated(__method__, 'update_topic_status')
53
+ deprecated(__method__, "update_topic_status")
53
54
  update_topic_status(topic_id, params)
54
55
  end
55
56
 
56
57
  def update_topic_status(topic_id, params = {})
57
- params = API.params(params)
58
- .required(:status, :enabled)
59
- .optional(:api_username)
58
+ params = API.params(params).required(:status, :enabled).optional(:api_username)
60
59
  put("/t/#{topic_id}/status", params)
61
60
  end
62
61
 
@@ -67,7 +66,7 @@ module DiscourseApi
67
66
 
68
67
  def topics_by(username, params = {})
69
68
  response = get("/topics/created-by/#{username}.json", params)
70
- response[:body]['topic_list']['topics']
69
+ response[:body]["topic_list"]["topics"]
71
70
  end
72
71
 
73
72
  def delete_topic(id)
@@ -75,8 +74,9 @@ module DiscourseApi
75
74
  end
76
75
 
77
76
  def topic_posts(topic_id, post_ids = [], params = {})
78
- params = API.params(params)
79
- .optional(:asc,
77
+ params =
78
+ API.params(params).optional(
79
+ :asc,
80
80
  :filter,
81
81
  :include_raw,
82
82
  :include_suggested,
@@ -86,23 +86,21 @@ module DiscourseApi
86
86
 
87
87
  url = ["/t/#{topic_id}/posts.json"]
88
88
  if post_ids.count > 0
89
- url.push('?')
90
- url.push(post_ids.map { |id| "post_ids[]=#{id}" }.join('&'))
89
+ url.push("?")
90
+ url.push(post_ids.map { |id| "post_ids[]=#{id}" }.join("&"))
91
91
  end
92
92
  response = get(url.join, params)
93
93
  response[:body]
94
94
  end
95
95
 
96
96
  def change_owner(topic_id, params = {})
97
- params = API.params(params)
98
- .required(:username, :post_ids)
97
+ params = API.params(params).required(:username, :post_ids)
99
98
 
100
99
  post("/t/#{topic_id}/change-owner.json", params)
101
100
  end
102
101
 
103
102
  def topic_set_user_notification_level(topic_id, params)
104
- params = API.params(params)
105
- .required(:notification_level)
103
+ params = API.params(params).required(:notification_level)
106
104
  post("/t/#{topic_id}/notifications", params)
107
105
  end
108
106
 
@@ -3,11 +3,13 @@ module DiscourseApi
3
3
  module API
4
4
  module Uploads
5
5
  def upload_file(args)
6
- args = API.params(args)
7
- .optional(:file, :url, :user_id)
8
- .default(type: 'composer', synchronous: true)
9
- .to_h
10
- post('/uploads', args)
6
+ args =
7
+ API
8
+ .params(args)
9
+ .optional(:file, :url, :user_id)
10
+ .default(type: "composer", synchronous: true)
11
+ .to_h
12
+ post("/uploads", args)
11
13
  end
12
14
  end
13
15
  end
@@ -3,13 +3,13 @@ module DiscourseApi
3
3
  module API
4
4
  module UserActions
5
5
  def user_replies(username)
6
- params = { "username": username, "filter": '5' }
6
+ params = { username: username, filter: "5" }
7
7
  response = get("/user_actions.json", params)
8
8
  response.body["user_actions"]
9
9
  end
10
10
 
11
11
  def user_topics_and_replies(username)
12
- params = { "username": username, "filter": "4,5" }
12
+ params = { username: username, filter: "4,5" }
13
13
  response = get("/user_actions.json", params)
14
14
  response.body["user_actions"]
15
15
  end