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
@@ -1,113 +1,113 @@
1
- {
2
- "users": [
3
- {
4
- "id": 1,
5
- "username": "test_user",
6
- "avatar_template": "//www.gravatar.com/avatar/test.png?s={size}&r=pg&d=identicon"
7
- }
8
- ],
9
- "topic_list": {
10
- "can_create_topic": true,
11
- "draft": null,
12
- "draft_key": "new_topic",
13
- "draft_sequence": 0,
14
- "topics": [
15
- {
16
- "id": 1,
17
- "title": "Test topic #1",
18
- "fancy_title": "Test topic #1",
19
- "slug": "test-topic-1",
20
- "posts_count": 1,
21
- "reply_count": 0,
22
- "highest_post_number": 1,
23
- "image_url": null,
24
- "created_at": "2013-11-07T03:02:03.615-05:00",
25
- "last_posted_at": "2013-11-07T09:42:57.094-05:00",
26
- "bumped": true,
27
- "bumped_at": "2013-11-07T09:42:57.094-05:00",
28
- "unseen": true,
29
- "pinned": false,
30
- "visible": true,
31
- "closed": false,
32
- "archived": false,
33
- "views": 20,
34
- "like_count": 1,
35
- "has_best_of": false,
36
- "archetype": "regular",
37
- "last_poster_username": "test_user",
38
- "category_id": 1,
39
- "posters": [
40
- {
41
- "extras": null,
42
- "description": "Original Poster, Most Recent Poster",
43
- "user_id": 1
44
- }
45
- ]
46
- },
47
- {
48
- "id": 2,
49
- "title": "Test topic #2",
50
- "fancy_title": "Test topic #2",
51
- "slug": "test-topic-2",
52
- "posts_count": 1,
53
- "reply_count": 0,
54
- "highest_post_number": 1,
55
- "image_url": null,
56
- "created_at": "2013-11-06T12:21:37.811-05:00",
57
- "last_posted_at": "2013-11-07T05:41:55.171-05:00",
58
- "bumped": true,
59
- "bumped_at": "2013-11-07T05:41:55.171-05:00",
60
- "unseen": true,
61
- "pinned": false,
62
- "visible": true,
63
- "closed": false,
64
- "archived": false,
65
- "views": 50,
66
- "like_count": 0,
67
- "has_best_of": false,
68
- "archetype": "regular",
69
- "last_poster_username": "cowboytomash",
70
- "category_id": 1,
71
- "posters": [
72
- {
73
- "extras": null,
74
- "description": "Original Poster, Most Recent Poster",
75
- "user_id": 1
76
- }
77
- ]
78
- },
79
- {
80
- "id": 3,
81
- "title": "Test topic #3",
82
- "fancy_title": "Test topic #3",
83
- "slug": "test-topic-3",
84
- "posts_count": 1,
85
- "reply_count": 0,
86
- "highest_post_number": 1,
87
- "image_url": null,
88
- "created_at": "2013-11-07T02:43:19.243-05:00",
89
- "last_posted_at": "2013-11-07T02:43:19.389-05:00",
90
- "bumped": true,
91
- "bumped_at": "2013-11-07T02:43:19.389-05:00",
92
- "unseen": true,
93
- "pinned": false,
94
- "visible": true,
95
- "closed": false,
96
- "archived": false,
97
- "views": 14,
98
- "like_count": 0,
99
- "has_best_of": false,
100
- "archetype": "regular",
101
- "last_poster_username": "akshar",
102
- "category_id": 1,
103
- "posters": [
104
- {
105
- "extras": null,
106
- "description": "Original Poster, Most Recent Poster",
107
- "user_id": 1
108
- }
109
- ]
110
- }
111
- ]
112
- }
113
- }
1
+ {
2
+ "users": [
3
+ {
4
+ "id": 1,
5
+ "username": "test_user",
6
+ "avatar_template": "//www.gravatar.com/avatar/test.png?s={size}&r=pg&d=identicon"
7
+ }
8
+ ],
9
+ "topic_list": {
10
+ "can_create_topic": true,
11
+ "draft": null,
12
+ "draft_key": "new_topic",
13
+ "draft_sequence": 0,
14
+ "topics": [
15
+ {
16
+ "id": 1,
17
+ "title": "Test topic #1",
18
+ "fancy_title": "Test topic #1",
19
+ "slug": "test-topic-1",
20
+ "posts_count": 1,
21
+ "reply_count": 0,
22
+ "highest_post_number": 1,
23
+ "image_url": null,
24
+ "created_at": "2013-11-07T03:02:03.615-05:00",
25
+ "last_posted_at": "2013-11-07T09:42:57.094-05:00",
26
+ "bumped": true,
27
+ "bumped_at": "2013-11-07T09:42:57.094-05:00",
28
+ "unseen": true,
29
+ "pinned": false,
30
+ "visible": true,
31
+ "closed": false,
32
+ "archived": false,
33
+ "views": 20,
34
+ "like_count": 1,
35
+ "has_best_of": false,
36
+ "archetype": "regular",
37
+ "last_poster_username": "test_user",
38
+ "category_id": 1,
39
+ "posters": [
40
+ {
41
+ "extras": null,
42
+ "description": "Original Poster, Most Recent Poster",
43
+ "user_id": 1
44
+ }
45
+ ]
46
+ },
47
+ {
48
+ "id": 2,
49
+ "title": "Test topic #2",
50
+ "fancy_title": "Test topic #2",
51
+ "slug": "test-topic-2",
52
+ "posts_count": 1,
53
+ "reply_count": 0,
54
+ "highest_post_number": 1,
55
+ "image_url": null,
56
+ "created_at": "2013-11-06T12:21:37.811-05:00",
57
+ "last_posted_at": "2013-11-07T05:41:55.171-05:00",
58
+ "bumped": true,
59
+ "bumped_at": "2013-11-07T05:41:55.171-05:00",
60
+ "unseen": true,
61
+ "pinned": false,
62
+ "visible": true,
63
+ "closed": false,
64
+ "archived": false,
65
+ "views": 50,
66
+ "like_count": 0,
67
+ "has_best_of": false,
68
+ "archetype": "regular",
69
+ "last_poster_username": "cowboytomash",
70
+ "category_id": 1,
71
+ "posters": [
72
+ {
73
+ "extras": null,
74
+ "description": "Original Poster, Most Recent Poster",
75
+ "user_id": 1
76
+ }
77
+ ]
78
+ },
79
+ {
80
+ "id": 3,
81
+ "title": "Test topic #3",
82
+ "fancy_title": "Test topic #3",
83
+ "slug": "test-topic-3",
84
+ "posts_count": 1,
85
+ "reply_count": 0,
86
+ "highest_post_number": 1,
87
+ "image_url": null,
88
+ "created_at": "2013-11-07T02:43:19.243-05:00",
89
+ "last_posted_at": "2013-11-07T02:43:19.389-05:00",
90
+ "bumped": true,
91
+ "bumped_at": "2013-11-07T02:43:19.389-05:00",
92
+ "unseen": true,
93
+ "pinned": false,
94
+ "visible": true,
95
+ "closed": false,
96
+ "archived": false,
97
+ "views": 14,
98
+ "like_count": 0,
99
+ "has_best_of": false,
100
+ "archetype": "regular",
101
+ "last_poster_username": "akshar",
102
+ "category_id": 1,
103
+ "posters": [
104
+ {
105
+ "extras": null,
106
+ "description": "Original Poster, Most Recent Poster",
107
+ "user_id": 1
108
+ }
109
+ ]
110
+ }
111
+ ]
112
+ }
113
+ }
@@ -1,16 +1,16 @@
1
- [
2
- {
3
- "notification_type": 9,
4
- "read": false,
5
- "created_at": "2014-04-02T11:58:00.670-04:00",
6
- "post_number": 2,
7
- "topic_id": 14404,
8
- "slug": "json-feed-for-notifications",
9
- "data": {
10
- "topic_title": ".json feed for notifications",
11
- "original_post_id": 47600,
12
- "original_username": "riking",
13
- "display_username": "riking"
14
- }
15
- }
16
- ]
1
+ [
2
+ {
3
+ "notification_type": 9,
4
+ "read": false,
5
+ "created_at": "2014-04-02T11:58:00.670-04:00",
6
+ "post_number": 2,
7
+ "topic_id": 14404,
8
+ "slug": "json-feed-for-notifications",
9
+ "data": {
10
+ "topic_title": ".json feed for notifications",
11
+ "original_post_id": 47600,
12
+ "original_username": "riking",
13
+ "display_username": "riking"
14
+ }
15
+ }
16
+ ]
@@ -1,94 +1,94 @@
1
- {
2
- "id": 11,
3
- "name": "system",
4
- "username": "system",
5
- "avatar_template": "/user_avatar/localhost/system/{size}/1.png",
6
- "uploaded_avatar_id": 1,
7
- "created_at": "2014-10-31T04:37:32.553Z",
8
- "cooked": "<p>The first paragraph of this pinned topic will be visible as a welcome message to all new visitors on your homepage. It's important!</p>\n\n<p><strong>Edit this</strong> into a brief description of your community:</p>\n\n<ul><li>Who is it for?</li><li>What can they find here?</li><li>Why should they come here?</li><li>Where can they read more (links, resources, etc)?</li></ul>\n\n<p>You may want to close this topic via the admin wrench (at the upper right and bottom), so that replies don't pile up on an announcement.</p>",
9
- "post_number": 1,
10
- "post_type": 1,
11
- "updated_at": "2014-10-31T04:37:32.553Z",
12
- "reply_count": 0,
13
- "reply_to_post_number": null,
14
- "quote_count": 0,
15
- "avg_time": null,
16
- "incoming_link_count": 0,
17
- "reads": 1,
18
- "score": 0.2,
19
- "yours": false,
20
- "topic_id": 8,
21
- "topic_slug": "welcome-to-discourse",
22
- "topic_auto_close_at": null,
23
- "display_username": "system",
24
- "primary_group_name": null,
25
- "version": 1,
26
- "can_edit": true,
27
- "can_delete": false,
28
- "can_recover": true,
29
- "user_title": null,
30
- "raw": "The first paragraph of this pinned topic will be visible as a welcome message to all new visitors on your homepage. It's important!\n\n**Edit this** into a brief description of your community:\n\n- Who is it for?\n- What can they find here?\n- Why should they come here?\n- Where can they read more (links, resources, etc)?\n\nYou may want to close this topic via the admin wrench (at the upper right and bottom), so that replies don't pile up on an announcement.",
31
- "actions_summary": [
32
- {
33
- "id": 2,
34
- "count": 0,
35
- "hidden": false,
36
- "can_act": true,
37
- "can_defer_flags": false
38
- },
39
- {
40
- "id": 3,
41
- "count": 0,
42
- "hidden": false,
43
- "can_act": true,
44
- "can_defer_flags": false
45
- },
46
- {
47
- "id": 4,
48
- "count": 0,
49
- "hidden": false,
50
- "can_act": true,
51
- "can_defer_flags": false
52
- },
53
- {
54
- "id": 5,
55
- "count": 0,
56
- "hidden": true,
57
- "can_act": true,
58
- "can_defer_flags": false
59
- },
60
- {
61
- "id": 6,
62
- "count": 0,
63
- "hidden": false,
64
- "can_act": true,
65
- "can_defer_flags": false
66
- },
67
- {
68
- "id": 7,
69
- "count": 0,
70
- "hidden": false,
71
- "can_act": true,
72
- "can_defer_flags": false
73
- },
74
- {
75
- "id": 8,
76
- "count": 0,
77
- "hidden": false,
78
- "can_act": true,
79
- "can_defer_flags": false
80
- }
81
- ],
82
- "moderator": true,
83
- "admin": true,
84
- "staff": true,
85
- "user_id": -1,
86
- "hidden": false,
87
- "hidden_reason_id": null,
88
- "trust_level": 4,
89
- "deleted_at": null,
90
- "user_deleted": false,
91
- "edit_reason": null,
92
- "can_view_edit_history": true,
93
- "wiki": false
94
- }
1
+ {
2
+ "id": 11,
3
+ "name": "system",
4
+ "username": "system",
5
+ "avatar_template": "/user_avatar/localhost/system/{size}/1.png",
6
+ "uploaded_avatar_id": 1,
7
+ "created_at": "2014-10-31T04:37:32.553Z",
8
+ "cooked": "<p>The first paragraph of this pinned topic will be visible as a welcome message to all new visitors on your homepage. It's important!</p>\n\n<p><strong>Edit this</strong> into a brief description of your community:</p>\n\n<ul><li>Who is it for?</li><li>What can they find here?</li><li>Why should they come here?</li><li>Where can they read more (links, resources, etc)?</li></ul>\n\n<p>You may want to close this topic via the admin wrench (at the upper right and bottom), so that replies don't pile up on an announcement.</p>",
9
+ "post_number": 1,
10
+ "post_type": 1,
11
+ "updated_at": "2014-10-31T04:37:32.553Z",
12
+ "reply_count": 0,
13
+ "reply_to_post_number": null,
14
+ "quote_count": 0,
15
+ "avg_time": null,
16
+ "incoming_link_count": 0,
17
+ "reads": 1,
18
+ "score": 0.2,
19
+ "yours": false,
20
+ "topic_id": 8,
21
+ "topic_slug": "welcome-to-discourse",
22
+ "topic_auto_close_at": null,
23
+ "display_username": "system",
24
+ "primary_group_name": null,
25
+ "version": 1,
26
+ "can_edit": true,
27
+ "can_delete": false,
28
+ "can_recover": true,
29
+ "user_title": null,
30
+ "raw": "The first paragraph of this pinned topic will be visible as a welcome message to all new visitors on your homepage. It's important!\n\n**Edit this** into a brief description of your community:\n\n- Who is it for?\n- What can they find here?\n- Why should they come here?\n- Where can they read more (links, resources, etc)?\n\nYou may want to close this topic via the admin wrench (at the upper right and bottom), so that replies don't pile up on an announcement.",
31
+ "actions_summary": [
32
+ {
33
+ "id": 2,
34
+ "count": 0,
35
+ "hidden": false,
36
+ "can_act": true,
37
+ "can_defer_flags": false
38
+ },
39
+ {
40
+ "id": 3,
41
+ "count": 0,
42
+ "hidden": false,
43
+ "can_act": true,
44
+ "can_defer_flags": false
45
+ },
46
+ {
47
+ "id": 4,
48
+ "count": 0,
49
+ "hidden": false,
50
+ "can_act": true,
51
+ "can_defer_flags": false
52
+ },
53
+ {
54
+ "id": 5,
55
+ "count": 0,
56
+ "hidden": true,
57
+ "can_act": true,
58
+ "can_defer_flags": false
59
+ },
60
+ {
61
+ "id": 6,
62
+ "count": 0,
63
+ "hidden": false,
64
+ "can_act": true,
65
+ "can_defer_flags": false
66
+ },
67
+ {
68
+ "id": 7,
69
+ "count": 0,
70
+ "hidden": false,
71
+ "can_act": true,
72
+ "can_defer_flags": false
73
+ },
74
+ {
75
+ "id": 8,
76
+ "count": 0,
77
+ "hidden": false,
78
+ "can_act": true,
79
+ "can_defer_flags": false
80
+ }
81
+ ],
82
+ "moderator": true,
83
+ "admin": true,
84
+ "staff": true,
85
+ "user_id": -1,
86
+ "hidden": false,
87
+ "hidden_reason_id": null,
88
+ "trust_level": 4,
89
+ "deleted_at": null,
90
+ "user_deleted": false,
91
+ "edit_reason": null,
92
+ "can_view_edit_history": true,
93
+ "wiki": false
94
+ }
@@ -1,18 +1,18 @@
1
- {
2
- "post_action_users": [
3
- {
4
- "id": 1286,
5
- "username": "john_smith",
6
- "avatar_template": "/user_avatar/domain/john_smith/size/1609_1.png",
7
- "post_url": null,
8
- "username_lower": "john_smith"
9
- },
10
- {
11
- "id": 1,
12
- "username": "jane_smith",
13
- "avatar_template": "/user_avatar/domain/jane_smith/size/17_1.png",
14
- "post_url": null,
15
- "username_lower": "jane_smith"
16
- }
17
- ]
18
- }
1
+ {
2
+ "post_action_users": [
3
+ {
4
+ "id": 1286,
5
+ "username": "john_smith",
6
+ "avatar_template": "/user_avatar/domain/john_smith/size/1609_1.png",
7
+ "post_url": null,
8
+ "username_lower": "john_smith"
9
+ },
10
+ {
11
+ "id": 1,
12
+ "username": "jane_smith",
13
+ "avatar_template": "/user_avatar/domain/jane_smith/size/17_1.png",
14
+ "post_url": null,
15
+ "username_lower": "jane_smith"
16
+ }
17
+ ]
18
+ }