discourse_api 0.10.1 → 0.11.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 -7
  4. data/CHANGELOG.md +99 -85
  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 -33
  11. data/examples/backups.rb +18 -18
  12. data/examples/category.rb +21 -21
  13. data/examples/change_topic_status.rb +33 -0
  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 -42
  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 -65
  43. data/lib/discourse_api/api/users.rb +85 -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 -29
  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 +227 -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 -0
  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 +31 -28
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3af8ad3a0d23af70f79f3ddb2f65793588101c8f
4
- data.tar.gz: 05ad2d4a02ea54c36327e6a8b2f0802cc9bf1481
3
+ metadata.gz: b96cb437020181b21b8ee3d42e65483029431aaa
4
+ data.tar.gz: e78ccede0ae62ae085a66b704a5f89d2299a6236
5
5
  SHA512:
6
- metadata.gz: 68449b81818c0e042ac7b55f016e8919b3f91a2ab58fdc84b07f4fd311a149f9d5854ef9dcd54516f52b8616d29e630833c68fae30bd0473550d7429459f4a35
7
- data.tar.gz: 9992861878efb6dc3448b2fc6893c4e11b4f191091599ba2b4ab31d3d5c8e7137a40ae3aa7bc6cba7f1a0a16d010577d4724b19a32383a4c26b73bf49656fa17
6
+ metadata.gz: 4eff3f9a2d5ebdb95776dde3d3b64eba61699ea73d4a467ac8be6a6994dae5bfae8bc097769ec0f4b5b8804921e7db656b685173d15c3b10ecc6943af16a22d9
7
+ data.tar.gz: 9582bf8fc7278050d8638d288904c5ab922ae1eef85850aef1086853b0f721d57b662aca741b025970aef96bd2935c1e0759dee6bf713acfbdb35b6a61a3b62c
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,7 +1,5 @@
1
- language: ruby
2
- rvm:
3
- - 2.0.0
4
- - 2.1
5
- - 2.2
6
- - 2.3
7
- 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,85 +1,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.10.0] - 2016-04-19
6
- ### Added
7
- - group_members: Allows you to retrieve more than 100 users with pagination (offset &
8
- limit)
9
- ### Fixed
10
- - Deprication warning with SimpleCov
11
- - updated rack dependency and added ruby 2.3 to travis config
12
-
13
- ## [0.9.1] - 2016-03-23
14
- ### Fixed
15
- - topic and post like/flag need to use `:id`
16
-
17
- ## [0.9.0] - 2016-03-22
18
- ### Added
19
- - can now like/flag topics and posts
20
-
21
- ## [0.8.1] - 2016-03-03
22
- ### Fixed
23
- - enable use of discourse_api to make unauthenticated requests to discourse
24
- endpoints like /categories and /topics
25
-
26
- ## [0.8.0] - 2016-02-28
27
- ### Added
28
- - get stats from admin dashboard
29
- - get only stat totals from admin dashboard
30
-
31
- ## [0.7.0] - 2015-12-09
32
- ### Added
33
- - get user by external_id
34
-
35
- ## [0.6.2] - 2015-12-02
36
- ### Fixed
37
- - `API::Params` will not work correctly when both optional and defaults are
38
- specified
39
-
40
- ## [0.6.1] - 2015-11-28
41
- ### Fixed
42
- - typo in topic_posts method
43
-
44
- ## [0.6.0] - 2015-11-27
45
- ### Added
46
- - get posts in topic by an array of id's
47
-
48
- ## [0.5.1] - 2015-11-21
49
- ### Fixed
50
- - remove puts statement
51
-
52
- ## [0.5.0] - 2015-11-21
53
- ### Added
54
- - get latest category topics by page
55
-
56
- ## [0.4.0] - 2015-01-15
57
- ### Added
58
- - generate an api key for a user
59
- - revoke an api key for a user
60
- - update user trust level
61
- - grant user badge
62
-
63
- ## [0.3.6] - 2015-01-11
64
- ### Added
65
- - list badges
66
- - view email settings
67
- - list emails sent
68
- - list badges by user
69
- - be able to specify SSL connection settings
70
- - list api keys generated
71
- - list backups created
72
-
73
- ## [0.3.5] - 2015-01-06
74
- ### Added
75
- - Can now get a list of users by type: active, new, staff, etc.
76
- - `client.category_latest_posts("category-slug")` endpoint
77
-
78
- ## [0.1.2] - 2014-05-11
79
-
80
- - Release
81
-
82
-
83
-
84
-
85
-
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
+
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/`