discourse_api 0.11.0 → 0.12.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/.gitignore +21 -21
- data/.travis.yml +5 -5
- data/CHANGELOG.md +105 -99
- data/Gemfile +4 -4
- data/Guardfile +5 -5
- data/LICENSE.txt +22 -22
- data/README.md +73 -73
- data/Rakefile +7 -7
- data/discourse_api.gemspec +35 -35
- data/examples/backups.rb +18 -18
- data/examples/category.rb +21 -21
- data/examples/change_topic_status.rb +33 -33
- data/examples/create_topic.rb +23 -23
- data/examples/create_user.rb +14 -14
- data/examples/dashboard.rb +13 -13
- data/examples/disposable_invite_tokens.rb +18 -18
- data/examples/example.rb +9 -9
- data/examples/groups.rb +25 -25
- data/examples/invite_users.rb +15 -15
- data/examples/post_action.rb +25 -25
- data/examples/search.rb +9 -9
- data/examples/sso.rb +14 -14
- data/examples/topic_lists.rb +15 -15
- data/examples/update_user.rb +22 -22
- data/lib/discourse_api.rb +5 -5
- data/lib/discourse_api/api/api_key.rb +31 -31
- data/lib/discourse_api/api/backups.rb +24 -24
- data/lib/discourse_api/api/badges.rb +28 -28
- data/lib/discourse_api/api/categories.rb +57 -57
- data/lib/discourse_api/api/dashboard.rb +24 -24
- data/lib/discourse_api/api/email.rb +15 -15
- data/lib/discourse_api/api/groups.rb +52 -52
- data/lib/discourse_api/api/invite.rb +17 -17
- data/lib/discourse_api/api/notifications.rb +9 -9
- data/lib/discourse_api/api/params.rb +55 -55
- data/lib/discourse_api/api/posts.rb +41 -41
- data/lib/discourse_api/api/private_messages.rb +10 -10
- data/lib/discourse_api/api/search.rb +19 -19
- data/lib/discourse_api/api/sso.rb +22 -22
- data/lib/discourse_api/api/tags.rb +10 -10
- data/lib/discourse_api/api/topics.rb +78 -78
- data/lib/discourse_api/api/users.rb +93 -85
- data/lib/discourse_api/client.rb +133 -133
- data/lib/discourse_api/error.rb +17 -17
- data/lib/discourse_api/single_sign_on.rb +110 -110
- data/lib/discourse_api/version.rb +3 -3
- data/routes.txt +203 -203
- data/spec/discourse_api/api/api_key_spec.rb +121 -121
- data/spec/discourse_api/api/backups_spec.rb +23 -23
- data/spec/discourse_api/api/badges_spec.rb +40 -40
- data/spec/discourse_api/api/categories_spec.rb +87 -87
- data/spec/discourse_api/api/email_spec.rb +39 -39
- data/spec/discourse_api/api/groups_spec.rb +94 -94
- data/spec/discourse_api/api/notifications_spec.rb +24 -24
- data/spec/discourse_api/api/params_spec.rb +32 -32
- data/spec/discourse_api/api/posts_spec.rb +41 -41
- data/spec/discourse_api/api/private_messages_spec.rb +22 -22
- data/spec/discourse_api/api/search_spec.rb +30 -30
- data/spec/discourse_api/api/sso_spec.rb +16 -16
- data/spec/discourse_api/api/topics_spec.rb +113 -113
- data/spec/discourse_api/api/users_spec.rb +255 -227
- data/spec/discourse_api/client_spec.rb +115 -115
- data/spec/fixtures/api.json +12 -12
- data/spec/fixtures/backups.json +12 -12
- data/spec/fixtures/badges.json +569 -569
- data/spec/fixtures/categories.json +72 -72
- data/spec/fixtures/category_latest_topics.json +92 -92
- data/spec/fixtures/category_topics.json +91 -91
- data/spec/fixtures/email_list_all.json +749 -749
- data/spec/fixtures/email_settings.json +13 -13
- data/spec/fixtures/generate_api_key.json +12 -12
- data/spec/fixtures/generate_master_key.json +7 -7
- data/spec/fixtures/groups.json +18 -18
- data/spec/fixtures/hot.json +113 -113
- data/spec/fixtures/latest.json +115 -115
- data/spec/fixtures/members_0.json +403 -403
- data/spec/fixtures/members_1.json +363 -363
- data/spec/fixtures/new.json +113 -113
- data/spec/fixtures/notifications.json +16 -16
- data/spec/fixtures/post.json +94 -94
- data/spec/fixtures/post_action_users.json +18 -18
- data/spec/fixtures/private_messages.json +69 -69
- data/spec/fixtures/regenerate_api_key.json +7 -7
- data/spec/fixtures/search.json +24 -24
- data/spec/fixtures/topic.json +739 -739
- data/spec/fixtures/topic_invite_user.json +3 -3
- data/spec/fixtures/topics_created_by.json +49 -49
- data/spec/fixtures/update_trust_level.json +37 -37
- data/spec/fixtures/upload_avatar.json +13 -13
- data/spec/fixtures/user.json +65 -65
- data/spec/fixtures/user_activate_success.json +3 -3
- data/spec/fixtures/user_badges.json +170 -170
- data/spec/fixtures/user_create_success.json +5 -5
- data/spec/fixtures/user_grant_admin.json +37 -37
- data/spec/fixtures/user_list.json +583 -583
- data/spec/fixtures/user_log_out_success.json +3 -3
- data/spec/fixtures/user_update_avatar_success.json +3 -3
- data/spec/fixtures/user_update_user.json +3 -3
- data/spec/fixtures/user_update_username.json +4 -4
- data/spec/spec_helper.rb +61 -61
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dd0f97c2f0145c221f69cb373249f6a86f676452
|
|
4
|
+
data.tar.gz: 79f6fc05d914c6c166ac982dcb91d9975894b70d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 93dac12e3814440fc9a76d6deebdbacee7fd11b7a17532863db640982024cf2d498e00c649d6d6d0c1901bc29b181daa2821b5ba8e3fe5a67202b1e4aa3102e6
|
|
7
|
+
data.tar.gz: ca30cadbaa7677528a6c8f6771417a85e42c7c24bd619c48afe57283536c1657df0f391b1ae2f0cdf9c754189b5b77a3a73c29ca2017edebed0b1df7ac98e78d
|
data/.gitignore
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
*.gem
|
|
2
|
-
*.rbc
|
|
3
|
-
.bundle
|
|
4
|
-
.config
|
|
5
|
-
.yardoc
|
|
6
|
-
Gemfile.lock
|
|
7
|
-
InstalledFiles
|
|
8
|
-
_yardoc
|
|
9
|
-
coverage
|
|
10
|
-
doc/
|
|
11
|
-
lib/bundler/man
|
|
12
|
-
pkg
|
|
13
|
-
rdoc
|
|
14
|
-
spec/reports
|
|
15
|
-
test/tmp
|
|
16
|
-
test/version_tmp
|
|
17
|
-
tmp
|
|
18
|
-
bin/
|
|
19
|
-
.ruby-gemset
|
|
20
|
-
.ruby-version
|
|
21
|
-
.env
|
|
1
|
+
*.gem
|
|
2
|
+
*.rbc
|
|
3
|
+
.bundle
|
|
4
|
+
.config
|
|
5
|
+
.yardoc
|
|
6
|
+
Gemfile.lock
|
|
7
|
+
InstalledFiles
|
|
8
|
+
_yardoc
|
|
9
|
+
coverage
|
|
10
|
+
doc/
|
|
11
|
+
lib/bundler/man
|
|
12
|
+
pkg
|
|
13
|
+
rdoc
|
|
14
|
+
spec/reports
|
|
15
|
+
test/tmp
|
|
16
|
+
test/version_tmp
|
|
17
|
+
tmp
|
|
18
|
+
bin/
|
|
19
|
+
.ruby-gemset
|
|
20
|
+
.ruby-version
|
|
21
|
+
.env
|
data/.travis.yml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
language: ruby
|
|
2
|
-
rvm:
|
|
3
|
-
- 2.2.5
|
|
4
|
-
- 2.3.1
|
|
5
|
-
script: 'bundle exec rake test'
|
|
1
|
+
language: ruby
|
|
2
|
+
rvm:
|
|
3
|
+
- 2.2.5
|
|
4
|
+
- 2.3.1
|
|
5
|
+
script: 'bundle exec rake test'
|
data/CHANGELOG.md
CHANGED
|
@@ -1,99 +1,105 @@
|
|
|
1
|
-
# Change Log
|
|
2
|
-
All notable changes to this project will be documented in this file.
|
|
3
|
-
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
|
-
|
|
5
|
-
## [0.
|
|
6
|
-
###
|
|
7
|
-
- add
|
|
8
|
-
- `
|
|
9
|
-
|
|
10
|
-
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
-
|
|
17
|
-
-
|
|
18
|
-
|
|
19
|
-
## [0.10.
|
|
20
|
-
###
|
|
21
|
-
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
- list
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
-
|
|
90
|
-
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
1
|
+
# Change Log
|
|
2
|
+
All notable changes to this project will be documented in this file.
|
|
3
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
|
+
|
|
5
|
+
## [0.12.0] - 2016-10-06
|
|
6
|
+
### Added
|
|
7
|
+
- add endpoint for `/admin/users/{id}/suspend`
|
|
8
|
+
- add endpoint for `/admin/users/{id}/unsuspend`
|
|
9
|
+
|
|
10
|
+
## [0.11.0] - 2016-09-03
|
|
11
|
+
### Fixed
|
|
12
|
+
- add destination folder to backup download
|
|
13
|
+
- `post_action_users`
|
|
14
|
+
|
|
15
|
+
### Added
|
|
16
|
+
- `change_topic_status`
|
|
17
|
+
- set username of topic on creation
|
|
18
|
+
|
|
19
|
+
## [0.10.1] - 2016-05-04
|
|
20
|
+
### Fixed
|
|
21
|
+
- raise an error if search is empty
|
|
22
|
+
- fix /category path to be just /c
|
|
23
|
+
- return errors for category_latest_topics if there are some
|
|
24
|
+
|
|
25
|
+
## [0.10.0] - 2016-04-19
|
|
26
|
+
### Added
|
|
27
|
+
- group_members: Allows you to retrieve more than 100 users with pagination (offset &
|
|
28
|
+
limit)
|
|
29
|
+
### Fixed
|
|
30
|
+
- Deprication warning with SimpleCov
|
|
31
|
+
- updated rack dependency and added ruby 2.3 to travis config
|
|
32
|
+
|
|
33
|
+
## [0.9.1] - 2016-03-23
|
|
34
|
+
### Fixed
|
|
35
|
+
- topic and post like/flag need to use `:id`
|
|
36
|
+
|
|
37
|
+
## [0.9.0] - 2016-03-22
|
|
38
|
+
### Added
|
|
39
|
+
- can now like/flag topics and posts
|
|
40
|
+
|
|
41
|
+
## [0.8.1] - 2016-03-03
|
|
42
|
+
### Fixed
|
|
43
|
+
- enable use of discourse_api to make unauthenticated requests to discourse
|
|
44
|
+
endpoints like /categories and /topics
|
|
45
|
+
|
|
46
|
+
## [0.8.0] - 2016-02-28
|
|
47
|
+
### Added
|
|
48
|
+
- get stats from admin dashboard
|
|
49
|
+
- get only stat totals from admin dashboard
|
|
50
|
+
|
|
51
|
+
## [0.7.0] - 2015-12-09
|
|
52
|
+
### Added
|
|
53
|
+
- get user by external_id
|
|
54
|
+
|
|
55
|
+
## [0.6.2] - 2015-12-02
|
|
56
|
+
### Fixed
|
|
57
|
+
- `API::Params` will not work correctly when both optional and defaults are
|
|
58
|
+
specified
|
|
59
|
+
|
|
60
|
+
## [0.6.1] - 2015-11-28
|
|
61
|
+
### Fixed
|
|
62
|
+
- typo in topic_posts method
|
|
63
|
+
|
|
64
|
+
## [0.6.0] - 2015-11-27
|
|
65
|
+
### Added
|
|
66
|
+
- get posts in topic by an array of id's
|
|
67
|
+
|
|
68
|
+
## [0.5.1] - 2015-11-21
|
|
69
|
+
### Fixed
|
|
70
|
+
- remove puts statement
|
|
71
|
+
|
|
72
|
+
## [0.5.0] - 2015-11-21
|
|
73
|
+
### Added
|
|
74
|
+
- get latest category topics by page
|
|
75
|
+
|
|
76
|
+
## [0.4.0] - 2015-01-15
|
|
77
|
+
### Added
|
|
78
|
+
- generate an api key for a user
|
|
79
|
+
- revoke an api key for a user
|
|
80
|
+
- update user trust level
|
|
81
|
+
- grant user badge
|
|
82
|
+
|
|
83
|
+
## [0.3.6] - 2015-01-11
|
|
84
|
+
### Added
|
|
85
|
+
- list badges
|
|
86
|
+
- view email settings
|
|
87
|
+
- list emails sent
|
|
88
|
+
- list badges by user
|
|
89
|
+
- be able to specify SSL connection settings
|
|
90
|
+
- list api keys generated
|
|
91
|
+
- list backups created
|
|
92
|
+
|
|
93
|
+
## [0.3.5] - 2015-01-06
|
|
94
|
+
### Added
|
|
95
|
+
- Can now get a list of users by type: active, new, staff, etc.
|
|
96
|
+
- `client.category_latest_posts("category-slug")` endpoint
|
|
97
|
+
|
|
98
|
+
## [0.1.2] - 2014-05-11
|
|
99
|
+
|
|
100
|
+
- Release
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
|
data/Gemfile
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
source 'https://rubygems.org'
|
|
2
|
-
|
|
3
|
-
# Specify your gem's dependencies in discourse_api.gemspec
|
|
4
|
-
gemspec
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# Specify your gem's dependencies in discourse_api.gemspec
|
|
4
|
+
gemspec
|
data/Guardfile
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
guard :rspec do
|
|
2
|
-
watch(%r{^spec/.+_spec\.rb$})
|
|
3
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
|
4
|
-
watch('spec/spec_helper.rb') { "spec" }
|
|
5
|
-
end
|
|
1
|
+
guard :rspec do
|
|
2
|
+
watch(%r{^spec/.+_spec\.rb$})
|
|
3
|
+
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
|
4
|
+
watch('spec/spec_helper.rb') { "spec" }
|
|
5
|
+
end
|
data/LICENSE.txt
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
Copyright (c) 2014 Civilized Discourse Construction Kit, Inc.
|
|
2
|
-
|
|
3
|
-
MIT License
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
-
a copy of this software and associated documentation files (the
|
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
-
the following conditions:
|
|
12
|
-
|
|
13
|
-
The above copyright notice and this permission notice shall be
|
|
14
|
-
included in all copies or substantial portions of the Software.
|
|
15
|
-
|
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
Copyright (c) 2014 Civilized Discourse Construction Kit, Inc.
|
|
2
|
+
|
|
3
|
+
MIT License
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,73 +1,73 @@
|
|
|
1
|
-
# DiscourseApi
|
|
2
|
-
|
|
3
|
-
[][codeclimate]
|
|
4
|
-
|
|
5
|
-
[codeclimate]: https://codeclimate.com/github/discourse/discourse_api
|
|
6
|
-
|
|
7
|
-
The Discourse API gem allows you to consume the Discourse API
|
|
8
|
-
|
|
9
|
-
## Installation
|
|
10
|
-
|
|
11
|
-
Add this line to your application's Gemfile:
|
|
12
|
-
|
|
13
|
-
gem 'discourse_api'
|
|
14
|
-
|
|
15
|
-
And then execute:
|
|
16
|
-
|
|
17
|
-
$ bundle
|
|
18
|
-
|
|
19
|
-
Or install it yourself as:
|
|
20
|
-
|
|
21
|
-
$ gem install discourse_api
|
|
22
|
-
|
|
23
|
-
## Usage
|
|
24
|
-
|
|
25
|
-
Over time this project intends to have a full Discourse API. At the moment there are only a
|
|
26
|
-
few endpoints available:
|
|
27
|
-
|
|
28
|
-
```ruby
|
|
29
|
-
client = DiscourseApi::Client.new("http://try.discourse.org")
|
|
30
|
-
client.api_key = "YOUR_API_KEY"
|
|
31
|
-
client.api_username = "YOUR_USERNAME"
|
|
32
|
-
|
|
33
|
-
client.ssl(...) #=> specify SSL connection settings if needed
|
|
34
|
-
|
|
35
|
-
# Topic endpoints
|
|
36
|
-
client.latest_topics #=> Gets a list of the latest topics
|
|
37
|
-
client.hot_topics #=> Gets a list of hot topics
|
|
38
|
-
client.new_topics #=> Gets a list of new topics
|
|
39
|
-
client.topics_by("sam") #=> Gets a list of topics created by user "sam"
|
|
40
|
-
client.topic(57) #=> Gets the topic with id 57
|
|
41
|
-
|
|
42
|
-
# Search endpoint
|
|
43
|
-
client.search("sandbox") #=> Gets a list of topics that match "sandbox"
|
|
44
|
-
|
|
45
|
-
# Categories endpoint
|
|
46
|
-
client.categories #=> Gets a list of categories
|
|
47
|
-
client.category_latest_posts("category-slug") #=> Gets a list of latest posts in a category
|
|
48
|
-
|
|
49
|
-
# SSO endpoint
|
|
50
|
-
client.sync_sso( #=> Synchronizes the SSO record
|
|
51
|
-
sso_secret: "discourse_sso_rocks",
|
|
52
|
-
name: "Test Name",
|
|
53
|
-
username: "test_name",
|
|
54
|
-
email: "name@example.com",
|
|
55
|
-
external_id: "2"
|
|
56
|
-
)
|
|
57
|
-
```
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
## Contributing
|
|
61
|
-
|
|
62
|
-
1. Fork it
|
|
63
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
64
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
65
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
|
66
|
-
5. Create new Pull Request
|
|
67
|
-
|
|
68
|
-
## Testing
|
|
69
|
-
|
|
70
|
-
1. Install discourse locally
|
|
71
|
-
2. Inside of your discourse directory, run: `bundle exec rake db:api_test_seed`
|
|
72
|
-
3. Start discourse: `bundle exec rails s`
|
|
73
|
-
4. Inside of your discourse_api directory, run: `bundle exec rspec spec/`
|
|
1
|
+
# DiscourseApi
|
|
2
|
+
|
|
3
|
+
[][codeclimate]
|
|
4
|
+
|
|
5
|
+
[codeclimate]: https://codeclimate.com/github/discourse/discourse_api
|
|
6
|
+
|
|
7
|
+
The Discourse API gem allows you to consume the Discourse API
|
|
8
|
+
|
|
9
|
+
## Installation
|
|
10
|
+
|
|
11
|
+
Add this line to your application's Gemfile:
|
|
12
|
+
|
|
13
|
+
gem 'discourse_api'
|
|
14
|
+
|
|
15
|
+
And then execute:
|
|
16
|
+
|
|
17
|
+
$ bundle
|
|
18
|
+
|
|
19
|
+
Or install it yourself as:
|
|
20
|
+
|
|
21
|
+
$ gem install discourse_api
|
|
22
|
+
|
|
23
|
+
## Usage
|
|
24
|
+
|
|
25
|
+
Over time this project intends to have a full Discourse API. At the moment there are only a
|
|
26
|
+
few endpoints available:
|
|
27
|
+
|
|
28
|
+
```ruby
|
|
29
|
+
client = DiscourseApi::Client.new("http://try.discourse.org")
|
|
30
|
+
client.api_key = "YOUR_API_KEY"
|
|
31
|
+
client.api_username = "YOUR_USERNAME"
|
|
32
|
+
|
|
33
|
+
client.ssl(...) #=> specify SSL connection settings if needed
|
|
34
|
+
|
|
35
|
+
# Topic endpoints
|
|
36
|
+
client.latest_topics #=> Gets a list of the latest topics
|
|
37
|
+
client.hot_topics #=> Gets a list of hot topics
|
|
38
|
+
client.new_topics #=> Gets a list of new topics
|
|
39
|
+
client.topics_by("sam") #=> Gets a list of topics created by user "sam"
|
|
40
|
+
client.topic(57) #=> Gets the topic with id 57
|
|
41
|
+
|
|
42
|
+
# Search endpoint
|
|
43
|
+
client.search("sandbox") #=> Gets a list of topics that match "sandbox"
|
|
44
|
+
|
|
45
|
+
# Categories endpoint
|
|
46
|
+
client.categories #=> Gets a list of categories
|
|
47
|
+
client.category_latest_posts("category-slug") #=> Gets a list of latest posts in a category
|
|
48
|
+
|
|
49
|
+
# SSO endpoint
|
|
50
|
+
client.sync_sso( #=> Synchronizes the SSO record
|
|
51
|
+
sso_secret: "discourse_sso_rocks",
|
|
52
|
+
name: "Test Name",
|
|
53
|
+
username: "test_name",
|
|
54
|
+
email: "name@example.com",
|
|
55
|
+
external_id: "2"
|
|
56
|
+
)
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
## Contributing
|
|
61
|
+
|
|
62
|
+
1. Fork it
|
|
63
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
64
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
65
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
|
66
|
+
5. Create new Pull Request
|
|
67
|
+
|
|
68
|
+
## Testing
|
|
69
|
+
|
|
70
|
+
1. Install discourse locally
|
|
71
|
+
2. Inside of your discourse directory, run: `bundle exec rake db:api_test_seed`
|
|
72
|
+
3. Start discourse: `bundle exec rails s`
|
|
73
|
+
4. Inside of your discourse_api directory, run: `bundle exec rspec spec/`
|