discourse_api 0.11.0 → 0.12.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +21 -21
  3. data/.travis.yml +5 -5
  4. data/CHANGELOG.md +105 -99
  5. data/Gemfile +4 -4
  6. data/Guardfile +5 -5
  7. data/LICENSE.txt +22 -22
  8. data/README.md +73 -73
  9. data/Rakefile +7 -7
  10. data/discourse_api.gemspec +35 -35
  11. data/examples/backups.rb +18 -18
  12. data/examples/category.rb +21 -21
  13. data/examples/change_topic_status.rb +33 -33
  14. data/examples/create_topic.rb +23 -23
  15. data/examples/create_user.rb +14 -14
  16. data/examples/dashboard.rb +13 -13
  17. data/examples/disposable_invite_tokens.rb +18 -18
  18. data/examples/example.rb +9 -9
  19. data/examples/groups.rb +25 -25
  20. data/examples/invite_users.rb +15 -15
  21. data/examples/post_action.rb +25 -25
  22. data/examples/search.rb +9 -9
  23. data/examples/sso.rb +14 -14
  24. data/examples/topic_lists.rb +15 -15
  25. data/examples/update_user.rb +22 -22
  26. data/lib/discourse_api.rb +5 -5
  27. data/lib/discourse_api/api/api_key.rb +31 -31
  28. data/lib/discourse_api/api/backups.rb +24 -24
  29. data/lib/discourse_api/api/badges.rb +28 -28
  30. data/lib/discourse_api/api/categories.rb +57 -57
  31. data/lib/discourse_api/api/dashboard.rb +24 -24
  32. data/lib/discourse_api/api/email.rb +15 -15
  33. data/lib/discourse_api/api/groups.rb +52 -52
  34. data/lib/discourse_api/api/invite.rb +17 -17
  35. data/lib/discourse_api/api/notifications.rb +9 -9
  36. data/lib/discourse_api/api/params.rb +55 -55
  37. data/lib/discourse_api/api/posts.rb +41 -41
  38. data/lib/discourse_api/api/private_messages.rb +10 -10
  39. data/lib/discourse_api/api/search.rb +19 -19
  40. data/lib/discourse_api/api/sso.rb +22 -22
  41. data/lib/discourse_api/api/tags.rb +10 -10
  42. data/lib/discourse_api/api/topics.rb +78 -78
  43. data/lib/discourse_api/api/users.rb +93 -85
  44. data/lib/discourse_api/client.rb +133 -133
  45. data/lib/discourse_api/error.rb +17 -17
  46. data/lib/discourse_api/single_sign_on.rb +110 -110
  47. data/lib/discourse_api/version.rb +3 -3
  48. data/routes.txt +203 -203
  49. data/spec/discourse_api/api/api_key_spec.rb +121 -121
  50. data/spec/discourse_api/api/backups_spec.rb +23 -23
  51. data/spec/discourse_api/api/badges_spec.rb +40 -40
  52. data/spec/discourse_api/api/categories_spec.rb +87 -87
  53. data/spec/discourse_api/api/email_spec.rb +39 -39
  54. data/spec/discourse_api/api/groups_spec.rb +94 -94
  55. data/spec/discourse_api/api/notifications_spec.rb +24 -24
  56. data/spec/discourse_api/api/params_spec.rb +32 -32
  57. data/spec/discourse_api/api/posts_spec.rb +41 -41
  58. data/spec/discourse_api/api/private_messages_spec.rb +22 -22
  59. data/spec/discourse_api/api/search_spec.rb +30 -30
  60. data/spec/discourse_api/api/sso_spec.rb +16 -16
  61. data/spec/discourse_api/api/topics_spec.rb +113 -113
  62. data/spec/discourse_api/api/users_spec.rb +255 -227
  63. data/spec/discourse_api/client_spec.rb +115 -115
  64. data/spec/fixtures/api.json +12 -12
  65. data/spec/fixtures/backups.json +12 -12
  66. data/spec/fixtures/badges.json +569 -569
  67. data/spec/fixtures/categories.json +72 -72
  68. data/spec/fixtures/category_latest_topics.json +92 -92
  69. data/spec/fixtures/category_topics.json +91 -91
  70. data/spec/fixtures/email_list_all.json +749 -749
  71. data/spec/fixtures/email_settings.json +13 -13
  72. data/spec/fixtures/generate_api_key.json +12 -12
  73. data/spec/fixtures/generate_master_key.json +7 -7
  74. data/spec/fixtures/groups.json +18 -18
  75. data/spec/fixtures/hot.json +113 -113
  76. data/spec/fixtures/latest.json +115 -115
  77. data/spec/fixtures/members_0.json +403 -403
  78. data/spec/fixtures/members_1.json +363 -363
  79. data/spec/fixtures/new.json +113 -113
  80. data/spec/fixtures/notifications.json +16 -16
  81. data/spec/fixtures/post.json +94 -94
  82. data/spec/fixtures/post_action_users.json +18 -18
  83. data/spec/fixtures/private_messages.json +69 -69
  84. data/spec/fixtures/regenerate_api_key.json +7 -7
  85. data/spec/fixtures/search.json +24 -24
  86. data/spec/fixtures/topic.json +739 -739
  87. data/spec/fixtures/topic_invite_user.json +3 -3
  88. data/spec/fixtures/topics_created_by.json +49 -49
  89. data/spec/fixtures/update_trust_level.json +37 -37
  90. data/spec/fixtures/upload_avatar.json +13 -13
  91. data/spec/fixtures/user.json +65 -65
  92. data/spec/fixtures/user_activate_success.json +3 -3
  93. data/spec/fixtures/user_badges.json +170 -170
  94. data/spec/fixtures/user_create_success.json +5 -5
  95. data/spec/fixtures/user_grant_admin.json +37 -37
  96. data/spec/fixtures/user_list.json +583 -583
  97. data/spec/fixtures/user_log_out_success.json +3 -3
  98. data/spec/fixtures/user_update_avatar_success.json +3 -3
  99. data/spec/fixtures/user_update_user.json +3 -3
  100. data/spec/fixtures/user_update_username.json +4 -4
  101. data/spec/spec_helper.rb +61 -61
  102. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b96cb437020181b21b8ee3d42e65483029431aaa
4
- data.tar.gz: e78ccede0ae62ae085a66b704a5f89d2299a6236
3
+ metadata.gz: dd0f97c2f0145c221f69cb373249f6a86f676452
4
+ data.tar.gz: 79f6fc05d914c6c166ac982dcb91d9975894b70d
5
5
  SHA512:
6
- metadata.gz: 4eff3f9a2d5ebdb95776dde3d3b64eba61699ea73d4a467ac8be6a6994dae5bfae8bc097769ec0f4b5b8804921e7db656b685173d15c3b10ecc6943af16a22d9
7
- data.tar.gz: 9582bf8fc7278050d8638d288904c5ab922ae1eef85850aef1086853b0f721d57b662aca741b025970aef96bd2935c1e0759dee6bf713acfbdb35b6a61a3b62c
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.11.0] - 2016-09-03
6
- ### Fixed
7
- - add destination folder to backup download
8
- - `post_action_users`
9
- ### Added
10
- - `change_topic_status`
11
- - set username of topic on creation
12
-
13
- ## [0.10.1] - 2016-05-04
14
- ### Fixed
15
- - raise an error if search is empty
16
- - fix /category path to be just /c
17
- - return errors for category_latest_topics if there are some
18
-
19
- ## [0.10.0] - 2016-04-19
20
- ### Added
21
- - group_members: Allows you to retrieve more than 100 users with pagination (offset &
22
- limit)
23
- ### Fixed
24
- - Deprication warning with SimpleCov
25
- - updated rack dependency and added ruby 2.3 to travis config
26
-
27
- ## [0.9.1] - 2016-03-23
28
- ### Fixed
29
- - topic and post like/flag need to use `:id`
30
-
31
- ## [0.9.0] - 2016-03-22
32
- ### Added
33
- - can now like/flag topics and posts
34
-
35
- ## [0.8.1] - 2016-03-03
36
- ### Fixed
37
- - enable use of discourse_api to make unauthenticated requests to discourse
38
- endpoints like /categories and /topics
39
-
40
- ## [0.8.0] - 2016-02-28
41
- ### Added
42
- - get stats from admin dashboard
43
- - get only stat totals from admin dashboard
44
-
45
- ## [0.7.0] - 2015-12-09
46
- ### Added
47
- - get user by external_id
48
-
49
- ## [0.6.2] - 2015-12-02
50
- ### Fixed
51
- - `API::Params` will not work correctly when both optional and defaults are
52
- specified
53
-
54
- ## [0.6.1] - 2015-11-28
55
- ### Fixed
56
- - typo in topic_posts method
57
-
58
- ## [0.6.0] - 2015-11-27
59
- ### Added
60
- - get posts in topic by an array of id's
61
-
62
- ## [0.5.1] - 2015-11-21
63
- ### Fixed
64
- - remove puts statement
65
-
66
- ## [0.5.0] - 2015-11-21
67
- ### Added
68
- - get latest category topics by page
69
-
70
- ## [0.4.0] - 2015-01-15
71
- ### Added
72
- - generate an api key for a user
73
- - revoke an api key for a user
74
- - update user trust level
75
- - grant user badge
76
-
77
- ## [0.3.6] - 2015-01-11
78
- ### Added
79
- - list badges
80
- - view email settings
81
- - list emails sent
82
- - list badges by user
83
- - be able to specify SSL connection settings
84
- - list api keys generated
85
- - list backups created
86
-
87
- ## [0.3.5] - 2015-01-06
88
- ### Added
89
- - Can now get a list of users by type: active, new, staff, etc.
90
- - `client.category_latest_posts("category-slug")` endpoint
91
-
92
- ## [0.1.2] - 2014-05-11
93
-
94
- - Release
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
- [![Code Climate](https://codeclimate.com/github/discourse/discourse_api.png)][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
+ [![Code Climate](https://codeclimate.com/github/discourse/discourse_api.png)][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/`