discourse_api 0.25.0 → 0.26.0
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/CHANGELOG.md +5 -0
- data/lib/discourse_api/api/user_actions.rb +17 -0
- data/lib/discourse_api/client.rb +2 -0
- data/lib/discourse_api/version.rb +1 -1
- data/spec/discourse_api/api/user_actions_spec.rb +37 -0
- data/spec/fixtures/replies.json +33 -0
- data/spec/fixtures/replies_and_topics.json +61 -0
- metadata +9 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 34fb79c6ebf88b13b27124084931d6cd5f9123e00d322ab7dec1378313a1b7ec
|
4
|
+
data.tar.gz: 2a5eac533a5798735fae8fbb0e6e7d9293b679bfaac7baf19129994a2f079d4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3dd703fefbaae4b70f8011754faef120e430fc6dafcca5bef8020d6618c75d10920caa7455dbcb551b2f0c2105618a94a2c4590d02dcbbe89c1d51b2448f45ea
|
7
|
+
data.tar.gz: 60c1008147db8883a5f0afb0f9f497c22ab8f9b4be06199f25cb2dc94edd7fa14768a9662a06fd5e369cb28187d31eb52289d9ffc7d59b2c2c96959436c62c9d
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,11 @@
|
|
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.26.0] - 2018-09-10
|
6
|
+
### Added
|
7
|
+
- Added user `user_actions` endpoint so you can retrieve `user_replies` and
|
8
|
+
`user_topics_and_replies`
|
9
|
+
|
5
10
|
## [0.25.0] - 2018-08-15
|
6
11
|
### Added
|
7
12
|
- Added ability to rescue certain error classes and inspect the response object
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module DiscourseApi
|
2
|
+
module API
|
3
|
+
module UserActions
|
4
|
+
def user_replies(username)
|
5
|
+
params = {"username": username, "filter": '5'}
|
6
|
+
response = get("/user_actions.json", params)
|
7
|
+
response.body["user_actions"]
|
8
|
+
end
|
9
|
+
|
10
|
+
def user_topics_and_replies(username)
|
11
|
+
params = {"username": username, "filter": "4,5"}
|
12
|
+
response = get("/user_actions.json", params)
|
13
|
+
response.body["user_actions"]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/discourse_api/client.rb
CHANGED
@@ -20,6 +20,7 @@ require 'discourse_api/api/api_key'
|
|
20
20
|
require 'discourse_api/api/backups'
|
21
21
|
require 'discourse_api/api/dashboard'
|
22
22
|
require 'discourse_api/api/uploads'
|
23
|
+
require 'discourse_api/api/user_actions'
|
23
24
|
|
24
25
|
module DiscourseApi
|
25
26
|
class Client
|
@@ -43,6 +44,7 @@ module DiscourseApi
|
|
43
44
|
include DiscourseApi::API::Backups
|
44
45
|
include DiscourseApi::API::Dashboard
|
45
46
|
include DiscourseApi::API::Uploads
|
47
|
+
include DiscourseApi::API::UserActions
|
46
48
|
|
47
49
|
def initialize(host, api_key = nil, api_username = nil)
|
48
50
|
raise ArgumentError, 'host needs to be defined' if host.nil? || host.empty?
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe DiscourseApi::API::UserActions do
|
4
|
+
subject { DiscourseApi::Client.new("http://localhost:3000", "test_d7fd0429940", "test_user") }
|
5
|
+
|
6
|
+
describe "#user_replies" do
|
7
|
+
before do
|
8
|
+
stub_get("http://localhost:3000/user_actions.json?api_key=test_d7fd0429940&api_username=test_user&username=testuser&filter=5").to_return(body: fixture("replies.json"), headers: { content_type: "application/json" })
|
9
|
+
end
|
10
|
+
|
11
|
+
it "requests the correct resource" do
|
12
|
+
subject.user_replies("testuser")
|
13
|
+
expect(a_get("http://localhost:3000/user_actions.json?api_key=test_d7fd0429940&api_username=test_user&username=testuser&filter=5")).to have_been_made
|
14
|
+
end
|
15
|
+
|
16
|
+
it "returns the requested user" do
|
17
|
+
replies = subject.user_replies("testuser")
|
18
|
+
expect(replies).to be_an Array
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "#user_topics_and_replies" do
|
23
|
+
before do
|
24
|
+
stub_get("http://localhost:3000/user_actions.json?api_key=test_d7fd0429940&api_username=test_user&username=testuser&filter=4,5").to_return(body: fixture("replies_and_topics.json"), headers: { content_type: "application/json" })
|
25
|
+
end
|
26
|
+
|
27
|
+
it "requests the correct resource" do
|
28
|
+
subject.user_topics_and_replies("testuser")
|
29
|
+
expect(a_get("http://localhost:3000/user_actions.json?api_key=test_d7fd0429940&api_username=test_user&username=testuser&filter=4,5")).to have_been_made
|
30
|
+
end
|
31
|
+
|
32
|
+
it "returns the requested user" do
|
33
|
+
replies = subject.user_topics_and_replies("testuser")
|
34
|
+
expect(replies).to be_an Array
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
{
|
2
|
+
"user_actions": [
|
3
|
+
{
|
4
|
+
"action_type": 5,
|
5
|
+
"created_at": "2016-06-29T20:27:55.767Z",
|
6
|
+
"excerpt": "Test Reply #1",
|
7
|
+
"avatar_template": "/letter_avatar_proxy/v2/letter/s/71c47a/{size}.png",
|
8
|
+
"acting_avatar_template": "/letter_avatar_proxy/v2/letter/s/71c47a/{size}.png",
|
9
|
+
"slug": "test-topic",
|
10
|
+
"topic_id": 39,
|
11
|
+
"target_user_id": 11,
|
12
|
+
"target_name": "Test User",
|
13
|
+
"target_username": "testuser",
|
14
|
+
"post_number": 3,
|
15
|
+
"post_id": 48,
|
16
|
+
"reply_to_post_number": 2,
|
17
|
+
"username": "testuser",
|
18
|
+
"name": "Test User",
|
19
|
+
"user_id": 11,
|
20
|
+
"acting_username": "testuser",
|
21
|
+
"acting_name": "Test User",
|
22
|
+
"acting_user_id": 11,
|
23
|
+
"title": "Test Topic",
|
24
|
+
"deleted": false,
|
25
|
+
"hidden": false,
|
26
|
+
"post_type": 1,
|
27
|
+
"action_code": null,
|
28
|
+
"category_id": 9,
|
29
|
+
"closed": false,
|
30
|
+
"archived": false
|
31
|
+
}
|
32
|
+
]
|
33
|
+
}
|
@@ -0,0 +1,61 @@
|
|
1
|
+
{
|
2
|
+
"user_actions": [
|
3
|
+
{
|
4
|
+
"action_type": 5,
|
5
|
+
"created_at": "2016-08-10T14:52:49.660Z",
|
6
|
+
"excerpt": "test excerpt",
|
7
|
+
"avatar_template": "/user_avatar/localhost/avatar/{size}/59_1.png",
|
8
|
+
"acting_avatar_template": "/user_avatar/localhost/avatar/{size}/59_1.png",
|
9
|
+
"slug": "test-topic",
|
10
|
+
"topic_id": 11,
|
11
|
+
"target_user_id": 2,
|
12
|
+
"target_name": "Test User",
|
13
|
+
"target_username": "testuser",
|
14
|
+
"post_number": 2,
|
15
|
+
"post_id": 19,
|
16
|
+
"reply_to_post_number": null,
|
17
|
+
"username": "testuser",
|
18
|
+
"name": "Test User",
|
19
|
+
"user_id": 2,
|
20
|
+
"acting_username": "testuser",
|
21
|
+
"acting_name": "Test User",
|
22
|
+
"acting_user_id": 2,
|
23
|
+
"title": "Test Topic",
|
24
|
+
"deleted": false,
|
25
|
+
"hidden": false,
|
26
|
+
"post_type": 1,
|
27
|
+
"action_code": null,
|
28
|
+
"category_id": 1,
|
29
|
+
"closed": false,
|
30
|
+
"archived": false
|
31
|
+
},
|
32
|
+
{
|
33
|
+
"action_type": 4,
|
34
|
+
"created_at": "2016-04-28T17:31:52.527Z",
|
35
|
+
"excerpt": "test reply",
|
36
|
+
"avatar_template": "/user_avatar/localhost/pjdavis1/{size}/59_1.png",
|
37
|
+
"acting_avatar_template": "/user_avatar/localhost/pjdavis1/{size}/59_1.png",
|
38
|
+
"slug": "test-topic",
|
39
|
+
"topic_id": 11,
|
40
|
+
"target_user_id": 2,
|
41
|
+
"target_name": "Test User",
|
42
|
+
"target_username": "testuser",
|
43
|
+
"post_number": 1,
|
44
|
+
"post_id": null,
|
45
|
+
"username": "testuser",
|
46
|
+
"name": "Test User",
|
47
|
+
"user_id": 2,
|
48
|
+
"acting_username": "testuser",
|
49
|
+
"acting_name": "Test User",
|
50
|
+
"acting_user_id": 2,
|
51
|
+
"title": "Test Topic",
|
52
|
+
"deleted": false,
|
53
|
+
"hidden": null,
|
54
|
+
"post_type": null,
|
55
|
+
"action_code": null,
|
56
|
+
"category_id": 1,
|
57
|
+
"closed": false,
|
58
|
+
"archived": false
|
59
|
+
}
|
60
|
+
]
|
61
|
+
}
|
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.26.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: 2018-
|
14
|
+
date: 2018-09-10 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: faraday
|
@@ -224,6 +224,7 @@ files:
|
|
224
224
|
- lib/discourse_api/api/tags.rb
|
225
225
|
- lib/discourse_api/api/topics.rb
|
226
226
|
- lib/discourse_api/api/uploads.rb
|
227
|
+
- lib/discourse_api/api/user_actions.rb
|
227
228
|
- lib/discourse_api/api/users.rb
|
228
229
|
- lib/discourse_api/client.rb
|
229
230
|
- lib/discourse_api/error.rb
|
@@ -244,6 +245,7 @@ files:
|
|
244
245
|
- spec/discourse_api/api/sso_spec.rb
|
245
246
|
- spec/discourse_api/api/topics_spec.rb
|
246
247
|
- spec/discourse_api/api/uploads_spec.rb
|
248
|
+
- spec/discourse_api/api/user_actions_spec.rb
|
247
249
|
- spec/discourse_api/api/users_spec.rb
|
248
250
|
- spec/discourse_api/client_spec.rb
|
249
251
|
- spec/fixtures/admin_user.json
|
@@ -269,6 +271,8 @@ files:
|
|
269
271
|
- spec/fixtures/post_action_users.json
|
270
272
|
- spec/fixtures/private_messages.json
|
271
273
|
- spec/fixtures/regenerate_api_key.json
|
274
|
+
- spec/fixtures/replies.json
|
275
|
+
- spec/fixtures/replies_and_topics.json
|
272
276
|
- spec/fixtures/search.json
|
273
277
|
- spec/fixtures/topic.json
|
274
278
|
- spec/fixtures/topic_invite_user.json
|
@@ -326,6 +330,7 @@ test_files:
|
|
326
330
|
- spec/discourse_api/api/sso_spec.rb
|
327
331
|
- spec/discourse_api/api/topics_spec.rb
|
328
332
|
- spec/discourse_api/api/uploads_spec.rb
|
333
|
+
- spec/discourse_api/api/user_actions_spec.rb
|
329
334
|
- spec/discourse_api/api/users_spec.rb
|
330
335
|
- spec/discourse_api/client_spec.rb
|
331
336
|
- spec/fixtures/admin_user.json
|
@@ -351,6 +356,8 @@ test_files:
|
|
351
356
|
- spec/fixtures/post_action_users.json
|
352
357
|
- spec/fixtures/private_messages.json
|
353
358
|
- spec/fixtures/regenerate_api_key.json
|
359
|
+
- spec/fixtures/replies.json
|
360
|
+
- spec/fixtures/replies_and_topics.json
|
354
361
|
- spec/fixtures/search.json
|
355
362
|
- spec/fixtures/topic.json
|
356
363
|
- spec/fixtures/topic_invite_user.json
|