discourse_api 0.31.0 → 0.32.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dbdfe96da34bba86f5ce76180d61e442e368ab0a5264188c60c893d30e485e27
4
- data.tar.gz: 107d25837187abc721710043a6ca35c59a5d4fa28431f9f3c3c7c3fbe350c3eb
3
+ metadata.gz: 2d1ed5b5061991f2bad549f4edfe32a6000700848241c3dd31e72b770c4f3cc1
4
+ data.tar.gz: 1375bd4604231e28b361dc5f326574a4cd1f4c68a3af5b34252aeddf5b6b0f84
5
5
  SHA512:
6
- metadata.gz: 96358eb77b7f4b083abef89c1048b0b2ba1f81cd1e64460ca978730f884e00584d2589cefa590b8f45611ca478b692d4a92ce8b9dbdeeb31360913cb31fe4981
7
- data.tar.gz: 1d9ac7f182197efd003a3a98487359d09cec4f50091c56903f01b197de53e84bef06b96c0f3053d2fb8325b1f95bdc9c39942826f4bd48925c11808444856bea
6
+ metadata.gz: afc9b153b80fb9dc4d49c1a7330f6b0ac84b055d6456f9e74fb665c538e11fc33c7264900533aeaa43f1f3732e311dfaafd7076c03f459f1d439b894a2473900
7
+ data.tar.gz: 1a03023036d5d74693ef9fee74774b92a5d4c4b630dc7761dea0a9bde6cdfc88103585da1dc68873f5a25440931d666b7648bd5ac18c4838f4d496e8ca133536
@@ -2,6 +2,10 @@
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.32.0] - 2019-02-13
6
+ ### Added
7
+ - Added a new method to update a users notification level in a group
8
+
5
9
  ## [0.31.0] - 2019-02-07
6
10
  ### Added
7
11
  - Added `deactivate` method
@@ -0,0 +1,37 @@
1
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
+ require File.expand_path('../../lib/discourse_api', __FILE__)
3
+
4
+ client = DiscourseApi::Client.new("http://localhost:3000")
5
+ client.api_key = "YOUR_API_KEY"
6
+ client.api_username = "YOUR_USERNAME"
7
+
8
+ @target_username = "YOUR_TARGET_USERNAME"
9
+ @target_group_id = # YOUR NUMERIC TARGET GROUP ID
10
+
11
+ @user = client.user(@target_username)
12
+
13
+ # each user's group and the group's default notification level are stored under user['groups']
14
+ @user['groups'].each do |group|
15
+ if group['id'] == @target_group_id
16
+ @group_name = group['name']
17
+ @default_level = group['default_notification_level']
18
+ end
19
+ end
20
+
21
+ # and the user's notification setting for each group is stored under user['group_users]
22
+ @user['group_users'].each do |users_group|
23
+ if users_group['group_id'] == @target_group_id
24
+ @notification_level = users_group['notification_level']
25
+ puts "Group ID:#{@target_group_id} #{@group_name} Current Notification Level: #{@notification_level} Default: #{@default_level}"
26
+ response = client.group_set_user_notification_level(@group_name, @user['id'], @default_level)
27
+ puts response
28
+ @users_group_users_after_update = client.user(@target_username)['group_users']
29
+ # this just pulls the user from the database again to make sure we updated the user's group notification level
30
+ @users_group_users_after_update.each do |users_group_second_pass|
31
+ if users_group_second_pass['group_id'] == @target_group_id
32
+ puts "Updated ID:#{@target_group_id} #{@group_name} Notification Level: #{users_group_second_pass['notification_level']} Default: #{@default_level}"
33
+ end
34
+ end
35
+ end
36
+ end
37
+
@@ -113,6 +113,11 @@ module DiscourseApi
113
113
  response = get("/groups/#{group_name}/members.json", params)
114
114
  response.body['members']
115
115
  end
116
+
117
+ def group_set_user_notification_level(group, user_id, notification_level)
118
+ response = post("/groups/#{group}/notifications?user_id=#{user_id}&notification_level=#{notification_level}")
119
+ response
120
+ end
116
121
  end
117
122
  end
118
123
  end
@@ -1,3 +1,3 @@
1
1
  module DiscourseApi
2
- VERSION = "0.31.0"
2
+ VERSION = "0.32.0"
3
3
  end
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.31.0
4
+ version: 0.32.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: 2019-02-07 00:00:00.000000000 Z
14
+ date: 2019-02-13 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: faraday
@@ -197,6 +197,7 @@ files:
197
197
  - examples/dashboard.rb
198
198
  - examples/disposable_invite_tokens.rb
199
199
  - examples/example.rb
200
+ - examples/group_set_user_notification_level.rb
200
201
  - examples/groups.rb
201
202
  - examples/invite_users.rb
202
203
  - examples/post_action.rb