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
@@ -1,13 +1,13 @@
1
- {
2
- "delivery_method": "smtp",
3
- "settings": [
4
- {
5
- "name": "address",
6
- "value": "localhost"
7
- },
8
- {
9
- "name": "port",
10
- "value": 1025
11
- }
12
- ]
13
- }
1
+ {
2
+ "delivery_method": "smtp",
3
+ "settings": [
4
+ {
5
+ "name": "address",
6
+ "value": "localhost"
7
+ },
8
+ {
9
+ "name": "port",
10
+ "value": 1025
11
+ }
12
+ ]
13
+ }
@@ -1,12 +1,12 @@
1
- {
2
- "api_key": {
3
- "id": 5,
4
- "key": "e722e04df8cf6d097d565ca04eea1ff8e9e8f09beb405bae6f0c79852916f334",
5
- "user": {
6
- "id": 2,
7
- "username": "robin",
8
- "uploaded_avatar_id": 3,
9
- "avatar_template": "/user_avatar/localhost/robin/{size}/3.png"
10
- }
11
- }
12
- }
1
+ {
2
+ "api_key": {
3
+ "id": 5,
4
+ "key": "e722e04df8cf6d097d565ca04eea1ff8e9e8f09beb405bae6f0c79852916f334",
5
+ "user": {
6
+ "id": 2,
7
+ "username": "robin",
8
+ "uploaded_avatar_id": 3,
9
+ "avatar_template": "/user_avatar/localhost/robin/{size}/3.png"
10
+ }
11
+ }
12
+ }
@@ -1,7 +1,7 @@
1
- {
2
- "api_key": {
3
- "id": 10,
4
- "key": "c999afe41d3a6ed0798a13ef69f90c4cc7d38120818c4a098e402bc5e5ef2085",
5
- "user": null
6
- }
7
- }
1
+ {
2
+ "api_key": {
3
+ "id": 10,
4
+ "key": "c999afe41d3a6ed0798a13ef69f90c4cc7d38120818c4a098e402bc5e5ef2085",
5
+ "user": null
6
+ }
7
+ }
@@ -1,18 +1,18 @@
1
- [
2
- {
3
- "id": 101,
4
- "name": "group_1",
5
- "user_count": 17,
6
- "automatic": false,
7
- "alias_level": 0,
8
- "visible": true
9
- },
10
- {
11
- "id": 102,
12
- "name": "group_2",
13
- "user_count": 4,
14
- "automatic": false,
15
- "alias_level": 0,
16
- "visible": true
17
- }
18
- ]
1
+ [
2
+ {
3
+ "id": 101,
4
+ "name": "group_1",
5
+ "user_count": 17,
6
+ "automatic": false,
7
+ "alias_level": 0,
8
+ "visible": true
9
+ },
10
+ {
11
+ "id": 102,
12
+ "name": "group_2",
13
+ "user_count": 4,
14
+ "automatic": false,
15
+ "alias_level": 0,
16
+ "visible": true
17
+ }
18
+ ]
@@ -1,113 +1,113 @@
1
- {
2
- "users": [
3
- {
4
- "id": 1,
5
- "username": "test_users",
6
- "avatar_template": "//www.gravatar.com/avatar/test.png?s={size}&r=pg&d=identicon"
7
- }
8
- ],
9
- "topic_list": {
10
- "can_create_topic": false,
11
- "draft": null,
12
- "draft_key": "new_topic",
13
- "draft_sequence": null,
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-02-04T14:38:46.480-05:00",
25
- "last_posted_at": "2013-09-13T16:46:59.783-04:00",
26
- "bumped": true,
27
- "bumped_at": "2013-09-13T16:46:59.783-04:00",
28
- "unseen": false,
29
- "pinned": false,
30
- "visible": true,
31
- "closed": false,
32
- "archived": false,
33
- "views": 1,
34
- "like_count": 0,
35
- "has_best_of": false,
36
- "archetype": "regular",
37
- "last_poster_username": "test_user",
38
- "category_id": 1,
39
- "posters": [
40
- {
41
- "extras": "latest",
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-02-04T14:38:46.480-05:00",
57
- "last_posted_at": "2013-09-13T16:46:59.783-04:00",
58
- "bumped": true,
59
- "bumped_at": "2013-09-13T16:46:59.783-04:00",
60
- "unseen": false,
61
- "pinned": false,
62
- "visible": true,
63
- "closed": false,
64
- "archived": false,
65
- "views": 1,
66
- "like_count": 0,
67
- "has_best_of": false,
68
- "archetype": "regular",
69
- "last_poster_username": "test_user",
70
- "category_id": 1,
71
- "posters": [
72
- {
73
- "extras": "latest",
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-02-04T14:38:46.480-05:00",
89
- "last_posted_at": "2013-09-13T16:46:59.783-04:00",
90
- "bumped": true,
91
- "bumped_at": "2013-09-13T16:46:59.783-04:00",
92
- "unseen": false,
93
- "pinned": false,
94
- "visible": true,
95
- "closed": false,
96
- "archived": false,
97
- "views": 1,
98
- "like_count": 0,
99
- "has_best_of": false,
100
- "archetype": "regular",
101
- "last_poster_username": "test_user",
102
- "category_id": 1,
103
- "posters": [
104
- {
105
- "extras": "latest",
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_users",
6
+ "avatar_template": "//www.gravatar.com/avatar/test.png?s={size}&r=pg&d=identicon"
7
+ }
8
+ ],
9
+ "topic_list": {
10
+ "can_create_topic": false,
11
+ "draft": null,
12
+ "draft_key": "new_topic",
13
+ "draft_sequence": null,
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-02-04T14:38:46.480-05:00",
25
+ "last_posted_at": "2013-09-13T16:46:59.783-04:00",
26
+ "bumped": true,
27
+ "bumped_at": "2013-09-13T16:46:59.783-04:00",
28
+ "unseen": false,
29
+ "pinned": false,
30
+ "visible": true,
31
+ "closed": false,
32
+ "archived": false,
33
+ "views": 1,
34
+ "like_count": 0,
35
+ "has_best_of": false,
36
+ "archetype": "regular",
37
+ "last_poster_username": "test_user",
38
+ "category_id": 1,
39
+ "posters": [
40
+ {
41
+ "extras": "latest",
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-02-04T14:38:46.480-05:00",
57
+ "last_posted_at": "2013-09-13T16:46:59.783-04:00",
58
+ "bumped": true,
59
+ "bumped_at": "2013-09-13T16:46:59.783-04:00",
60
+ "unseen": false,
61
+ "pinned": false,
62
+ "visible": true,
63
+ "closed": false,
64
+ "archived": false,
65
+ "views": 1,
66
+ "like_count": 0,
67
+ "has_best_of": false,
68
+ "archetype": "regular",
69
+ "last_poster_username": "test_user",
70
+ "category_id": 1,
71
+ "posters": [
72
+ {
73
+ "extras": "latest",
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-02-04T14:38:46.480-05:00",
89
+ "last_posted_at": "2013-09-13T16:46:59.783-04:00",
90
+ "bumped": true,
91
+ "bumped_at": "2013-09-13T16:46:59.783-04:00",
92
+ "unseen": false,
93
+ "pinned": false,
94
+ "visible": true,
95
+ "closed": false,
96
+ "archived": false,
97
+ "views": 1,
98
+ "like_count": 0,
99
+ "has_best_of": false,
100
+ "archetype": "regular",
101
+ "last_poster_username": "test_user",
102
+ "category_id": 1,
103
+ "posters": [
104
+ {
105
+ "extras": "latest",
106
+ "description": "Original Poster, Most Recent Poster",
107
+ "user_id": 1
108
+ }
109
+ ]
110
+ }
111
+ ]
112
+ }
113
+ }
@@ -1,115 +1,115 @@
1
- {
2
- "users": [
3
- {
4
- "id": 1,
5
- "username": "test_users",
6
- "avatar_template": "//www.gravatar.com/avatar/test.png?s={size}&r=pg&d=identicon"
7
- }
8
- ],
9
- "topic_list": {
10
- "can_create_topic": false,
11
- "more_topics_url": "/latest.json?page=1",
12
- "draft": null,
13
- "draft_key": "new_topic",
14
- "draft_sequence": null,
15
- "topics": [
16
- {
17
- "id": 1,
18
- "title": "Test topic #1",
19
- "fancy_title": "Test topic #1",
20
- "slug": "test-topic-1",
21
- "posts_count": 1,
22
- "reply_count": 0,
23
- "highest_post_number": 1,
24
- "image_url": null,
25
- "created_at": "2013-02-04T15:26:25.977-05:00",
26
- "last_posted_at": "2013-02-05T12:14:17.364-05:00",
27
- "bumped": true,
28
- "bumped_at": "2013-02-07T13:43:11.191-05:00",
29
- "unseen": false,
30
- "pinned": true,
31
- "excerpt": "Welcome! \n\nTry is a sandbox, a safe place to play with Discourse and its features.\n\nThis site is reset every day (or even more often). Any accounts or posts you create here will not exist tomorrow! \n\nFeel free to experim…",
32
- "visible": true,
33
- "closed": false,
34
- "archived": false,
35
- "views": 268,
36
- "like_count": 14,
37
- "has_best_of": false,
38
- "archetype": "regular",
39
- "last_poster_username": "test_user",
40
- "category_id": 1,
41
- "posters": [
42
- {
43
- "extras": null,
44
- "description": "Original Poster, Most Recent Poster",
45
- "user_id": 1
46
- }
47
- ]
48
- },
49
- {
50
- "id": 1,
51
- "title": "Test topic #2",
52
- "fancy_title": "Test topic #2",
53
- "slug": "test-topic-1",
54
- "posts_count": 1,
55
- "reply_count": 0,
56
- "highest_post_number": 2,
57
- "image_url": null,
58
- "created_at": "2013-11-06T13:57:47.984-05:00",
59
- "last_posted_at": "2013-11-06T13:57:48.111-05:00",
60
- "bumped": true,
61
- "bumped_at": "2013-11-06T13:57:48.111-05:00",
62
- "unseen": false,
63
- "pinned": false,
64
- "visible": true,
65
- "closed": false,
66
- "archived": false,
67
- "views": 1,
68
- "like_count": 0,
69
- "has_best_of": false,
70
- "archetype": "regular",
71
- "last_poster_username": "test_user",
72
- "category_id": 1,
73
- "posters": [
74
- {
75
- "extras": null,
76
- "description": "Original Poster, Most Recent Poster",
77
- "user_id": 1
78
- }
79
- ]
80
- },
81
- {
82
- "id": 1,
83
- "title": "Test topic #3",
84
- "fancy_title": "Test topic #3",
85
- "slug": "test-topic-3",
86
- "posts_count": 1,
87
- "reply_count": 0,
88
- "highest_post_number": 1,
89
- "image_url": null,
90
- "created_at": "2013-02-04T21:46:58.194-05:00",
91
- "last_posted_at": "2013-11-06T13:56:27.753-05:00",
92
- "bumped": true,
93
- "bumped_at": "2013-11-06T13:56:27.753-05:00",
94
- "unseen": false,
95
- "pinned": false,
96
- "visible": true,
97
- "closed": false,
98
- "archived": false,
99
- "views": 82,
100
- "like_count": 10,
101
- "has_best_of": false,
102
- "archetype": "regular",
103
- "last_poster_username": "test_user",
104
- "category_id": 1,
105
- "posters": [
106
- {
107
- "extras": null,
108
- "description": "Original Poster, Most Recent Poster",
109
- "user_id": 1
110
- }
111
- ]
112
- }
113
- ]
114
- }
115
- }
1
+ {
2
+ "users": [
3
+ {
4
+ "id": 1,
5
+ "username": "test_users",
6
+ "avatar_template": "//www.gravatar.com/avatar/test.png?s={size}&r=pg&d=identicon"
7
+ }
8
+ ],
9
+ "topic_list": {
10
+ "can_create_topic": false,
11
+ "more_topics_url": "/latest.json?page=1",
12
+ "draft": null,
13
+ "draft_key": "new_topic",
14
+ "draft_sequence": null,
15
+ "topics": [
16
+ {
17
+ "id": 1,
18
+ "title": "Test topic #1",
19
+ "fancy_title": "Test topic #1",
20
+ "slug": "test-topic-1",
21
+ "posts_count": 1,
22
+ "reply_count": 0,
23
+ "highest_post_number": 1,
24
+ "image_url": null,
25
+ "created_at": "2013-02-04T15:26:25.977-05:00",
26
+ "last_posted_at": "2013-02-05T12:14:17.364-05:00",
27
+ "bumped": true,
28
+ "bumped_at": "2013-02-07T13:43:11.191-05:00",
29
+ "unseen": false,
30
+ "pinned": true,
31
+ "excerpt": "Welcome! \n\nTry is a sandbox, a safe place to play with Discourse and its features.\n\nThis site is reset every day (or even more often). Any accounts or posts you create here will not exist tomorrow! \n\nFeel free to experim…",
32
+ "visible": true,
33
+ "closed": false,
34
+ "archived": false,
35
+ "views": 268,
36
+ "like_count": 14,
37
+ "has_best_of": false,
38
+ "archetype": "regular",
39
+ "last_poster_username": "test_user",
40
+ "category_id": 1,
41
+ "posters": [
42
+ {
43
+ "extras": null,
44
+ "description": "Original Poster, Most Recent Poster",
45
+ "user_id": 1
46
+ }
47
+ ]
48
+ },
49
+ {
50
+ "id": 1,
51
+ "title": "Test topic #2",
52
+ "fancy_title": "Test topic #2",
53
+ "slug": "test-topic-1",
54
+ "posts_count": 1,
55
+ "reply_count": 0,
56
+ "highest_post_number": 2,
57
+ "image_url": null,
58
+ "created_at": "2013-11-06T13:57:47.984-05:00",
59
+ "last_posted_at": "2013-11-06T13:57:48.111-05:00",
60
+ "bumped": true,
61
+ "bumped_at": "2013-11-06T13:57:48.111-05:00",
62
+ "unseen": false,
63
+ "pinned": false,
64
+ "visible": true,
65
+ "closed": false,
66
+ "archived": false,
67
+ "views": 1,
68
+ "like_count": 0,
69
+ "has_best_of": false,
70
+ "archetype": "regular",
71
+ "last_poster_username": "test_user",
72
+ "category_id": 1,
73
+ "posters": [
74
+ {
75
+ "extras": null,
76
+ "description": "Original Poster, Most Recent Poster",
77
+ "user_id": 1
78
+ }
79
+ ]
80
+ },
81
+ {
82
+ "id": 1,
83
+ "title": "Test topic #3",
84
+ "fancy_title": "Test topic #3",
85
+ "slug": "test-topic-3",
86
+ "posts_count": 1,
87
+ "reply_count": 0,
88
+ "highest_post_number": 1,
89
+ "image_url": null,
90
+ "created_at": "2013-02-04T21:46:58.194-05:00",
91
+ "last_posted_at": "2013-11-06T13:56:27.753-05:00",
92
+ "bumped": true,
93
+ "bumped_at": "2013-11-06T13:56:27.753-05:00",
94
+ "unseen": false,
95
+ "pinned": false,
96
+ "visible": true,
97
+ "closed": false,
98
+ "archived": false,
99
+ "views": 82,
100
+ "like_count": 10,
101
+ "has_best_of": false,
102
+ "archetype": "regular",
103
+ "last_poster_username": "test_user",
104
+ "category_id": 1,
105
+ "posters": [
106
+ {
107
+ "extras": null,
108
+ "description": "Original Poster, Most Recent Poster",
109
+ "user_id": 1
110
+ }
111
+ ]
112
+ }
113
+ ]
114
+ }
115
+ }