spinels-redd 0.9.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.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/.github/dependabot.yml +7 -0
  3. data/.github/workflows/ci.yml +52 -0
  4. data/.gitignore +10 -0
  5. data/.rspec +3 -0
  6. data/.rubocop.yml +29 -0
  7. data/CONTRIBUTING.md +63 -0
  8. data/Gemfile +6 -0
  9. data/Guardfile +7 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +119 -0
  12. data/Rakefile +12 -0
  13. data/TODO.md +423 -0
  14. data/bin/console +127 -0
  15. data/bin/guard +2 -0
  16. data/bin/setup +8 -0
  17. data/docs/guides/.keep +0 -0
  18. data/docs/tutorials/creating-bots-with-redd.md +101 -0
  19. data/docs/tutorials/creating-webapps-with-redd.md +124 -0
  20. data/docs/tutorials/make-a-grammar-bot.md +5 -0
  21. data/docs/tutorials.md +7 -0
  22. data/lib/redd/api_client.rb +116 -0
  23. data/lib/redd/assist/delete_badly_scoring.rb +64 -0
  24. data/lib/redd/auth_strategies/auth_strategy.rb +68 -0
  25. data/lib/redd/auth_strategies/script.rb +35 -0
  26. data/lib/redd/auth_strategies/userless.rb +29 -0
  27. data/lib/redd/auth_strategies/web.rb +36 -0
  28. data/lib/redd/client.rb +91 -0
  29. data/lib/redd/errors.rb +65 -0
  30. data/lib/redd/middleware.rb +125 -0
  31. data/lib/redd/models/access.rb +54 -0
  32. data/lib/redd/models/comment.rb +229 -0
  33. data/lib/redd/models/front_page.rb +55 -0
  34. data/lib/redd/models/gildable.rb +13 -0
  35. data/lib/redd/models/inboxable.rb +33 -0
  36. data/lib/redd/models/listing.rb +52 -0
  37. data/lib/redd/models/live_thread.rb +133 -0
  38. data/lib/redd/models/live_update.rb +46 -0
  39. data/lib/redd/models/messageable.rb +20 -0
  40. data/lib/redd/models/mod_action.rb +59 -0
  41. data/lib/redd/models/model.rb +23 -0
  42. data/lib/redd/models/moderatable.rb +46 -0
  43. data/lib/redd/models/modmail.rb +61 -0
  44. data/lib/redd/models/modmail_conversation.rb +154 -0
  45. data/lib/redd/models/modmail_message.rb +35 -0
  46. data/lib/redd/models/more_comments.rb +96 -0
  47. data/lib/redd/models/multireddit.rb +104 -0
  48. data/lib/redd/models/paginated_listing.rb +124 -0
  49. data/lib/redd/models/postable.rb +83 -0
  50. data/lib/redd/models/private_message.rb +105 -0
  51. data/lib/redd/models/replyable.rb +16 -0
  52. data/lib/redd/models/reportable.rb +14 -0
  53. data/lib/redd/models/searchable.rb +35 -0
  54. data/lib/redd/models/self.rb +17 -0
  55. data/lib/redd/models/session.rb +198 -0
  56. data/lib/redd/models/submission.rb +405 -0
  57. data/lib/redd/models/subreddit.rb +670 -0
  58. data/lib/redd/models/trophy.rb +34 -0
  59. data/lib/redd/models/user.rb +239 -0
  60. data/lib/redd/models/wiki_page.rb +56 -0
  61. data/lib/redd/utilities/error_handler.rb +73 -0
  62. data/lib/redd/utilities/rate_limiter.rb +21 -0
  63. data/lib/redd/utilities/unmarshaller.rb +70 -0
  64. data/lib/redd/version.rb +5 -0
  65. data/lib/redd.rb +129 -0
  66. data/lib/spinels-redd.rb +3 -0
  67. data/logo.png +0 -0
  68. data/spinels-redd.gemspec +39 -0
  69. metadata +298 -0
data/TODO.md ADDED
@@ -0,0 +1,423 @@
1
+ # TODO
2
+
3
+ This page contains all the calls from the reddit api along with their
4
+ implementations in Redd. The API docs are located
5
+ [**here**](https://www.reddit.com/dev/api).
6
+
7
+ ## Account
8
+
9
+ - **GET /api/v1/me**
10
+ - **Implemented**: [Redd::Models::Session#me](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Session#me-instance_method)
11
+ - **GET /api/v1/me/karma**
12
+ - **Implemented**: [Redd::Models::Session#karma_breakdown](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Session#karma_breakdown-instance_method)
13
+ - **GET /api/v1/me/prefs**
14
+ - **Implemented**: [Redd::Models::Session#my_preferences](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Session#my_preferences-instance_method)
15
+ - **PATCH /api/v1/me/prefs**
16
+ - **Implemented**: [Redd::Models::Session#edit_preferences](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Session#edit_preferences-instance_method)
17
+ - **GET /api/v1/me/trophies**
18
+ - **Won't Implement**: Already implemented for User.
19
+ - **GET /prefs/where**
20
+ - **Partially Implemented**: [Redd::Models::Session](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Session) (for friends, blocked, and trusted)
21
+
22
+ ## Captcha
23
+
24
+ - **GET /api/needs_captcha**
25
+ - **Won't Implement**: Not necessary for OAuth2 clients
26
+
27
+ ## Flair
28
+
29
+ - **POST [/r/subreddit]/api/clearflairtemplates**
30
+ - **Not Implemented**
31
+ - **POST [/r/subreddit]/api/deleteflair**
32
+ - **Implemented**: [Redd::Models::Subreddit#delete_flair](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#delete_flair-instance_method)
33
+ - **POST [/r/subreddit]/api/deleteflairtemplate**
34
+ - **Not Implemented**
35
+ - **POST [/r/subreddit]/api/flair**
36
+ - **Implemented**: [Redd::Models::Subreddit#set_flair](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#set_flair-instance_method)
37
+ - **POST [/r/subreddit]/api/flairconfig**
38
+ - **Not Implemented**
39
+ - **POST [/r/subreddit]/api/flaircsv**
40
+ - **Not Implemented**
41
+ - **GET [/r/subreddit]/api/flairlist**
42
+ - **Implemented**: [Redd::Models::Subreddit#flair_listing](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#flair_listing-instance_method)
43
+ - **POST [/r/subreddit]/api/flairselector**
44
+ - **Not Implemented**
45
+ - **POST [/r/subreddit]/api/flairtemplate**
46
+ - **Not Implemented**
47
+ - **GET [/r/subreddit]/api/link_flair**
48
+ - **Not Implemented**
49
+ - **POST [/r/subreddit]/api/selectflair**
50
+ - **Implemented**: [Redd::Models::Subreddit#set_flair_template](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#set_flair_template-instance_method)
51
+ - **POST [/r/subreddit]/api/setflairenabled**
52
+ - **Not Implemented**
53
+ - **GET [/r/subreddit]/api/user_flair**
54
+ - **Not Implemented**
55
+
56
+ ## Reddit Gold
57
+
58
+ - **POST /api/v1/gold/gild/fullname**
59
+ - **Implemented**: [Redd::Models::Gildable#gild](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Gildable#gild-instance_method)
60
+ - **POST /api/v1/gold/give/username**
61
+ - **Implemented**: [Redd::Models::User#gift_gold](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/User#gift_gold-instance_method)
62
+
63
+ ## Links & Comments
64
+
65
+ - **POST /api/comment**
66
+ - **Implemented**: [Redd::Models::Replyable#reply](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Replyable#reply-instance_method)
67
+ - **POST /api/del**
68
+ - **Implemented**: [Redd::Models::Postable#delete](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Postable#delete-instance_method)
69
+ - **POST /api/editusertext**
70
+ - **Implemented**: [Redd::Models::Postable#edit](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Postable#edit-instance_method)
71
+ - **POST /api/hide**
72
+ - **Implemented**: [Redd::Models::Postable#hide](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Postable#hide-instance_method)
73
+ - **GET [/r/subreddit]/api/info**
74
+ - **Implemented**
75
+ - [Redd::Models::Session#from_fullnames](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Session#from_fullnames-instance_method)
76
+ - Also implemented as part of lazy loaders.
77
+ - **POST /api/lock**
78
+ - **Implemented**: [Redd::Models::Submission#lock](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Submission#lock-instance_method)
79
+ - **POST /api/marknsfw**
80
+ - **Implemented**: [Redd::Models::Submission#mark_as_nsfw](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Submission#mark_as_nsfw-instance_method)
81
+ - **GET /api/morechildren**
82
+ - TODO: add implementation/documentation link
83
+ - **POST /api/report**
84
+ - **Implemented**: [Redd::Models::Reportable#report](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Reportable#report-instance_method)
85
+ - **POST /api/save**
86
+ - **Implemented**: [Redd::Models::Postable#save](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Postable#save-instance_method)
87
+ - **GET /api/saved_categories**
88
+ - **Implemented**: [Redd::Models::Session#saved_categories](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Session#saved_categories-instance_method)
89
+ - **POST /api/sendreplies**
90
+ - **Implemented**: [Redd::Models::Postable#enable_inbox_replies](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Postable#enable_inbox_replies-instance_method)
91
+ - **POST /api/set_contest_mode**
92
+ - **Implemented**: [Redd::Models::Submission#enable_contest_mode](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Submission#enable_contest_mode-instance_method)
93
+ - **POST /api/set_subreddit_sticky**
94
+ - **Implemented**: [Redd::Models::Submission#make_sticky](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Submission#make_sticky-instance_method)
95
+ - **POST /api/set_suggested_sort**
96
+ - **Implemented**: [Redd::Models::Submission#set_suggested_sort](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Submission#set_suggested_sort-instance_method)
97
+ - **POST /api/spoiler**
98
+ - **Implemented**: [Redd::Models::Submission#mark_as_spoiler](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Submission#mark_as_spoiler-instance_method)
99
+ - **POST /api/store_visits**
100
+ - **Not Implemented**
101
+ - **POST /api/submit**
102
+ - **Implemented**: [Redd::Models::Subreddit#submit](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#submit-instance_method)
103
+ - **POST /api/unhide**
104
+ - **Implemented**: [Redd::Models::Postable#unhide](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Postable#unhide-instance_method)
105
+ - **POST /api/unlock**
106
+ - **Implemented**: [Redd::Models::Submission#unlock](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Submission#unlock-instance_method)
107
+ - **POST /api/unmarknsfw**
108
+ - **Implemented**: [Redd::Models::Submission#unmark_as_nsfw](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Submission#unmark_as_nsfw-instance_method)
109
+ - **POST /api/unsave**
110
+ - **Implemented**: [Redd::Models::Postable#unsave](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Postable#unsave-instance_method)
111
+ - **POST /api/unspoiler**
112
+ - **Implemented**: [Redd::Models::Submission#unmark_as_spoiler](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Submission#unmark_as_spoiler-instance_method)
113
+ - **POST /api/vote**
114
+ - **Implemented**:
115
+ - [Redd::Models::Postable#upvote](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Postable#upvote-instance_method)
116
+ - [Redd::Models::Postable#downvote](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Postable#downvote-instance_method)
117
+ - [Redd::Models::Postable#undo_vote](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Postable#undo_vote-instance_method)
118
+
119
+ ## Listings
120
+
121
+ - **GET /api/trending_subreddits**
122
+ - **Implemented**: [Redd::Models::Session#trending_subreddits](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Session#trending_subreddits-instance_method)
123
+ - **GET /by_id/names**
124
+ - **Not Implemented**: See `/api/info`.
125
+ - **GET [/r/subreddit]/comments/article**
126
+ - **Implemented**: Part of lazy-loading in Submission and Comment.
127
+ - **GET /duplicates/article**
128
+ - **Implemented**: [Redd::Models::Submission#duplicates](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Submission#duplicates-instance_method)
129
+ - **GET [/r/subreddit]/hot**
130
+ - **Implemented**: [Redd::Models::FrontPage#hot](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/FrontPage#hot-instance_method)
131
+ - **Implemented**: [Redd::Models::Submission#hot](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Submission#hot-instance_method)
132
+ - **GET [/r/subreddit]/new**
133
+ - **Implemented**: [Redd::Models::FrontPage#new](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/FrontPage#new-instance_method)
134
+ - **Implemented**: [Redd::Models::Submission#new](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Submission#new-instance_method)
135
+ - **GET [/r/subreddit]/random**
136
+ - **Implemented**: [Redd::Models::FrontPage#random](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/FrontPage#random-instance_method)
137
+ - **Implemented**: [Redd::Models::Submission#random](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Submission#random-instance_method)
138
+ - **GET [/r/subreddit]/rising**
139
+ - **Implemented**: [Redd::Models::FrontPage#rising](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/FrontPage#rising-instance_method)
140
+ - **Implemented**: [Redd::Models::Submission#rising](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Submission#rising-instance_method)
141
+ - **GET [/r/subreddit]/sort**
142
+ - **Implemented**: [Redd::Models::FrontPage#listing](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/FrontPage#listing-instance_method)
143
+ - **Implemented**: [Redd::Models::Submission#listing](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Submission#listing-instance_method)
144
+
145
+ ## Live Threads
146
+
147
+ - **GET /api/live/by_id/names**
148
+ - **Not Implemented**
149
+ - **POST /api/live/create**
150
+ - **Not Implemented**
151
+ - **GET /api/live/happening_now**
152
+ - **Not Implemented**
153
+ - **POST /api/live/thread/accept_contributor_invite**
154
+ - **Not Implemented**
155
+ - **POST /api/live/thread/close_thread**
156
+ - **Not Implemented**
157
+ - **POST /api/live/thread/delete_update**
158
+ - **Implemented**: [Redd::Models::LiveThread#delete_update](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/LiveThread#delete_update-instance_method)
159
+ - **POST /api/live/thread/edit**
160
+ - **Implemented**: [Redd::Models::LiveThread#configure](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/LiveThread#configure-instance_method)
161
+ - **POST /api/live/thread/invite_contributor**
162
+ - **Not Implemented**
163
+ - **POST /api/live/thread/leave_contributor**
164
+ - **Not Implemented**
165
+ - **POST /api/live/thread/report**
166
+ - **Not Implemented**
167
+ - **POST /api/live/thread/rm_contributor**
168
+ - **Not Implemented**
169
+ - **POST /api/live/thread/rm_contributor_invite**
170
+ - **Not Implemented**
171
+ - **POST /api/live/thread/set_contributor_permissions**
172
+ - **Not Implemented**
173
+ - **POST /api/live/thread/strike_update**
174
+ - **Implemented**: [Redd::Models::LiveThread#strike_update](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/LiveThread#strike_update-instance_method)
175
+ - **POST /api/live/thread/update**
176
+ - **Implemented**: [Redd::Models::LiveThread#update](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/LiveThread#update-instance_method)
177
+ - **GET /live/thread**
178
+ - **Implemented**: [Redd::Models::LiveThread#updates](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/LiveThread#updates-instance_method)
179
+ - **GET /live/thread/about**
180
+ - **Implemented**: [Redd::Models::Session#live_thread](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Session#live_thread-instance_method)
181
+ - **GET /live/thread/contributors**
182
+ - **Implemented**: [Redd::Models::LiveThread#contributors](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/LiveThread#contributors-instance_method)
183
+ - **GET /live/thread/discussions**
184
+ - **Implemented**: [Redd::Models::LiveThread#discussions](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/LiveThread#discussions-instance_method)
185
+
186
+ ## Private Messages
187
+
188
+ - **POST /api/block**
189
+ - **Implemented**: [Redd::Models::Inboxable#block](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Inboxable#block-instance_method)
190
+ - **POST /api/collapse_message**
191
+ - **Implemented**: [Redd::Models::Inboxable#collapse](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Inboxable#collapse-instance_method)
192
+ - **POST /api/compose**
193
+ - **Implemented**: [Redd::Models::Messageable#send_message](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Messageable#send_message-instance_method)
194
+ - **POST /api/del_msg**
195
+ - **Implemented**: [Redd::Models::PrivateMessage#delete](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/PrivateMessage#delete-instance_method)
196
+ - **POST /api/read_all_messages**
197
+ - **Implemented**: [Redd::Models::Session#read_all_messages](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Session#read_all_messages-instance_method)
198
+ - **POST /api/read_message**
199
+ - **Implemented**: [Redd::Models::Inboxable#mark_as_read](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Inboxable#mark_as_read-instance_method)
200
+ - **POST /api/unblock_subreddit**
201
+ - **Not Implemented**
202
+ - **POST /api/uncollapse_message**
203
+ - **Implemented**: [Redd::Models::Inboxable#uncollapse](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Inboxable#uncollapse-instance_method)
204
+ - **POST /api/unread_message**
205
+ - **Implemented**: [Redd::Models::Inboxable#mark_as_unread](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Inboxable#mark_as_unread-instance_method)
206
+ - **GET /message/where**
207
+ - **Implemented**: [Redd::Models::Session#my_messages](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Session#my_messages-instance_method)
208
+
209
+ ## Miscellaneous
210
+
211
+ - **GET /api/v1/scopes**
212
+ - **Not Implemented**
213
+
214
+ ## Moderation
215
+
216
+ - **GET [/r/subreddit]/about/log**
217
+ - **Implemented**: [Redd::Models::Subreddit#mod_log](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#mod_log-instance_method)
218
+ - **GET [/r/subreddit]/about/location**
219
+ - **Implemented**: [Redd::Models::Subreddit#moderator_listing](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#moderator_listing-instance_method)
220
+ - **POST [/r/subreddit]/api/accept_moderator_invite**
221
+ - **Implemented**: [Redd::Models::Subreddit#accept_moderator_invite](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#accept_moderator_invite-instance_method)
222
+ - **POST /api/approve**
223
+ - **Implemented**: [Redd::Models::Moderatable#approve](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Moderatable#approve-instance_method)
224
+ - **POST /api/distinguish**
225
+ - **Implemented**: [Redd::Models::Moderatable#distinguish](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Moderatable#distinguish-instance_method)
226
+ - **POST /api/ignore_reports**
227
+ - **Implemented**: [Redd::Models::Moderatable#ignore_reports](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Moderatable#ignore_reports-instance_method)
228
+ - **POST /api/leavecontributor**
229
+ - **Implemented**: [Redd::Models::Subreddit#leave_contributor](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#leave_contributor-instance_method)
230
+ - **POST /api/leavemoderator**
231
+ - **Implemented**: [Redd::Models::Subreddit#leave_moderator](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#leave_moderator-instance_method)
232
+ - **POST /api/mute_message_author**
233
+ - **Implemented**: [Redd::Models::PrivateMessage#mute_author](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/PrivateMessage#mute_author-instance_method)
234
+ - **POST /api/remove**
235
+ - **Implemented**: [Redd::Models::Moderatable#remove](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Moderatable#remove-instance_method)
236
+ - **POST /api/unignore_reports**
237
+ - **Implemented**: [Redd::Models::Moderatable#unignore_reports](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Moderatable#unignore_reports-instance_method)
238
+ - **POST /api/unmute_message_author**
239
+ - **Implemented**: [Redd::Models::PrivateMessage#unmute_author](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/PrivateMessage#unmute_author-instance_method)
240
+ - **GET [/r/subreddit]/stylesheet**
241
+ - **Implemented**: [Redd::Models::Subreddit#stylesheet](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#stylesheet-instance_method)
242
+
243
+ ## New Modmail
244
+
245
+ - **POST /api/mod/bulk_read**
246
+ - **Not Implemented**
247
+ - **GET /api/mod/conversations**
248
+ - **Implemented**: [Redd::Models::Modmail#conversations](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Modmail#conversations-instance_method)
249
+ - **POST /api/mod/conversations**
250
+ - **Implemented**: [Redd::Models::Modmail#create](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Modmail#create-instance_method)
251
+ - **GET /api/mod/conversations/:conversation_id**
252
+ - **Implemented**: [Redd::Models::Modmail#get](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Modmail#get-instance_method)
253
+ - **POST /api/mod/conversations/:conversation_id**
254
+ - **Implemented**: [Redd::Models::ModmailConversation#reply](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/ModmailConversation#reply-instance_method)
255
+ - **POST /api/mod/conversations/:conversation_id/archive**
256
+ - **Implemented**: [Redd::Models::ModmailConversation#archive](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/ModmailConversation#archive-instance_method)
257
+ - **DELETE /api/mod/conversations/:conversation_id/highlight**
258
+ - **Implemented**: [Redd::Models::ModmailConversation#unhighlight](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/ModmailConversation#unhighlight-instance_method)
259
+ - **POST /api/mod/conversations/:conversation_id/highlight**
260
+ - **Implemented**: [Redd::Models::ModmailConversation#highlight](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/ModmailConversation#highlight-instance_method)
261
+ - **POST /api/mod/conversations/:conversation_id/mute**
262
+ - **Implemented**: [Redd::Models::ModmailConversation#mute](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/ModmailConversation#mute-instance_method)
263
+ - **POST /api/mod/conversations/:conversation_id/unarchive**
264
+ - **Implemented**: [Redd::Models::ModmailConversation#unarchive](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/ModmailConversation#unarchive-instance_method)
265
+ - **POST /api/mod/conversations/:conversation_id/unmute**
266
+ - **Implemented**: [Redd::Models::ModmailConversation#unmute](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/ModmailConversation#unmute-instance_method)
267
+ - **GET /api/mod/conversations/:conversation_id/user**
268
+ - **Not Implemented**
269
+ - **POST /api/mod/conversations/read**
270
+ - **Partially Implemented**: [Redd::Models::ModmailConversation#mark_as_read](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/ModmailConversation#mark_as_read-instance_method)
271
+ - Bulk read not implemented
272
+ - **GET /api/mod/conversations/subreddits**
273
+ - **Implemented**: [Redd::Models::Modmail#enrolled](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Modmail#enrolled-instance_method)
274
+ - **POST /api/mod/conversations/unread**
275
+ - **Partially Implemented**: [Redd::Models::ModmailConversation#mark_as_unread](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/ModmailConversation#mark_as_unread-instance_method)
276
+ - Bulk unread not implemented
277
+ - **GET /api/mod/conversations/unread/count**
278
+ - **Implemented**: [Redd::Models::Modmail#unread_count](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Modmail#unread_count-instance_method)
279
+
280
+ ## Multis
281
+
282
+ - **POST /api/multi/copy**
283
+ - **Not Implemented**
284
+ - **GET /api/multi/mine**
285
+ - **Not Implemented**
286
+ - **POST /api/multi/rename**
287
+ - **Not Implemented**
288
+ - **GET /api/multi/user/username**
289
+ - **Not Implemented**
290
+ - **DELETE /api/multi/multipath**
291
+ - **Not Implemented**
292
+ - **GET /api/multi/multipath**
293
+ - **Implemented**: [Redd::Models::Session#multi](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Session#multi-instance_method)
294
+ - **POST /api/multi/multipath**
295
+ - **Not Implemented**
296
+ - **PUT /api/multi/multipath**
297
+ - **Not Implemented**
298
+ - **GET /api/multi/multipath/description**
299
+ - **Not Implemented**
300
+ - **PUT /api/multi/multipath/description**
301
+ - **Not Implemented**
302
+ - **DELETE /api/multi/multipath/r/srname**
303
+ - **Not Implemented**
304
+ - **GET /api/multi/multipath/r/srname**
305
+ - **Not Implemented**
306
+ - **PUT /api/multi/multipath/r/srname**
307
+ - **Not Implemented**
308
+
309
+ ## Search
310
+
311
+ - **GET [/r/subreddit]/search**
312
+ - **Implemented**: [Redd::Models::Searchable#search](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Searchable#search-instance_method)
313
+
314
+ ## Subreddits
315
+
316
+ - **GET [/r/subreddit]/about/where**
317
+ - **Implemented**: [Redd::Models::Subreddit#relationship_listing](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#relationship_listing-instance_method)
318
+ - **POST [/r/subreddit]/api/delete_sr_banner**
319
+ - **Implemented**: [Redd::Models::Subreddit#delete_image](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#delete_image-instance_method)
320
+ - **POST [/r/subreddit]/api/delete_sr_header**
321
+ - **Implemented**: [Redd::Models::Subreddit#delete_image](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#delete_image-instance_method)
322
+ - **POST [/r/subreddit]/api/delete_sr_icon**
323
+ - **Implemented**: [Redd::Models::Subreddit#delete_image](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#delete_image-instance_method)
324
+ - **POST [/r/subreddit]/api/delete_sr_img**
325
+ - **Implemented**: [Redd::Models::Subreddit#delete_image](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#delete_image-instance_method)
326
+ - **GET /api/recommend/sr/srnames**
327
+ - **Not Implemented**
328
+ - **POST /api/search_reddit_names**
329
+ - **Not Implemented**
330
+ - **POST /api/search_subreddits**
331
+ - **Not Implemented**
332
+ - **POST /api/site_admin**
333
+ - **Implemented**: [Redd::Models::Subreddit#modify_settings](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#modify_settings-instance_method)
334
+ - **GET [/r/subreddit]/api/submit_text**
335
+ - **Won't Implement**: Already covered by the Subreddit model.
336
+ - **GET /api/subreddit_autocomplete**
337
+ - **Not Implemented**
338
+ - **POST [/r/subreddit]/api/subreddit_stylesheet**
339
+ - **Implemented**: [Redd::Models::Subreddit#update_stylesheet](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#update_stylesheet-instance_method)
340
+ - **GET /api/subreddits_by_topic**
341
+ - **Not Implemented**
342
+ - **POST /api/subscribe**
343
+ - **Implemented**: [Redd::Models::Subreddit#subscribe](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#subscribe-instance_method)
344
+ - **POST [/r/subreddit]/api/upload_sr_img**
345
+ - **Implemented**: [Redd::Models::Subreddit#upload_image](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#upload_image-instance_method)
346
+ - **GET /r/subreddit/about**
347
+ - **Implemented**: [Redd::Models::Session#subreddit](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Session#subreddit-instance_method)
348
+ - **GET /r/subreddit/about/edit**
349
+ - **Implemented**: [Redd::Models::Subreddit#settings](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#settings-instance_method)
350
+ - **GET /r/subreddit/about/rules**
351
+ - **Not Implemented**
352
+ - **GET /r/subreddit/about/traffic**
353
+ - **Not Implemented**
354
+ - **GET [/r/subreddit]/sidebar**
355
+ - **Won't Implement**: Already covered by Subreddit's "description" property.
356
+ - **GET [/r/subreddit]/sticky**
357
+ - **Not Implemented**
358
+ - **GET /subreddits/mine/where**
359
+ - **Implemented**: [Redd::Models::Session#my_subreddits](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Session#my_subreddits-instance_method)
360
+ - **GET /subreddits/search**
361
+ - **Not Implemented**
362
+ - **GET /subreddits/where**
363
+ - **Not Implemented**
364
+ - **GET /users/where**
365
+ - **Not Implemented**
366
+
367
+ ## Users
368
+
369
+ - **POST /api/block_user**
370
+ - **Implemented**: [Redd::Models::User#block](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/User#block-instance_method)
371
+ - **POST [/r/subreddit]/api/friend**
372
+ - **Implemented**: Used in multiple methods.
373
+ - **POST /api/report_user**
374
+ - **Not Implemented**
375
+ - **POST [/r/subreddit]/api/setpermissions**
376
+ - **Not Implemented**
377
+ - **POST [/r/subreddit]/api/unfriend**
378
+ - **Implemented**: Used in multiple methods.
379
+ - **GET /api/user_data_by_account_ids**
380
+ - **Not Implemented**: [Redd::Models::Session#from_fullnames](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Session#from_fullnames-instance_method)
381
+ - Currently commented out (will uncoment when adding cache check feature to lazy_lazer).
382
+ - Not implemented for batch calls, only individual.
383
+ - **GET /api/username_available**
384
+ - **Implemented**: [Redd::Models::Session#username_available?](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Session#username_available?-instance_method)
385
+ - **DELETE /api/v1/me/friends/username**
386
+ - **Implemented**: [Redd::Models::User#unfriend](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/User#unfriend-instance_method)
387
+ - **GET /api/v1/me/friends/username**
388
+ - TODO: add implementation/documentation link
389
+ - **PUT /api/v1/me/friends/username**
390
+ - **Implemented**: [Redd::Models::User#friend](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/User#friend-instance_method)
391
+ - **GET /api/v1/user/username/trophies**
392
+ - **Implemented**: [Redd::Models::User#trophies](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/User#trophies-instance_method)
393
+ - **GET /user/username/about**
394
+ - **Implemented**: [Redd::Models::Session#user](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Session#user-instance_method)
395
+ - **GET /user/username/where**
396
+ - **Implemented**: [Redd::Models::User#listing](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/User#listing-instance_method)
397
+
398
+ ## Wiki
399
+
400
+ - **POST [/r/subreddit]/api/wiki/alloweditor/act**
401
+ - **Not Implemented**
402
+ - **POST [/r/subreddit]/api/wiki/edit**
403
+ - **Implemented**: [Redd::Models::WikiPage#edit](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/WikiPage#edit-instance_method)
404
+ - **POST [/r/subreddit]/api/wiki/hide**
405
+ - **Not Implemented**
406
+ - **POST [/r/subreddit]/api/wiki/revert**
407
+ - **Not Implemented**
408
+ - **GET [/r/subreddit]/wiki/discussions/page**
409
+ - **Not Implemented**
410
+ - **GET [/r/subreddit]/wiki/pages**
411
+ - **Implemented**: [Redd::Models::FrontPage#wiki_pages](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/FrontPage#wiki_pages-instance_method)
412
+ - **Implemented**: [Redd::Models::Subreddit#wiki_pages](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#wiki_pages-instance_method)
413
+ - **GET [/r/subreddit]/wiki/revisions**
414
+ - **Not Implemented**
415
+ - **GET [/r/subreddit]/wiki/revisions/page**
416
+ - **Not Implemented**
417
+ - **GET [/r/subreddit]/wiki/settings/page**
418
+ - **Not Implemented**
419
+ - **POST [/r/subreddit]/wiki/settings/page**
420
+ - **Not Implemented**
421
+ - **GET [/r/subreddit]/wiki/page**
422
+ - **Implemented**: [Redd::Models::FrontPage#wiki_page](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/FrontPage#wiki_page-instance_method)
423
+ - **Implemented**: [Redd::Models::Subreddit#wiki_page](http://www.rubydoc.info/github/avinashbot/redd/master/Redd/Models/Subreddit#wiki_page-instance_method)
data/bin/console ADDED
@@ -0,0 +1,127 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require 'webrick'
5
+ require 'pry'
6
+ require_relative '../lib/redd'
7
+
8
+ USER_AGENT = "Ruby:Redd-Quickstart:v#{Redd::VERSION} (by /u/Mustermind)"
9
+
10
+ # The REPL session to initialize Pry in.
11
+ class Reddit
12
+ attr_accessor :session
13
+ end
14
+ reddit = Reddit.new
15
+
16
+ redd_file_path = File.join(Dir.home, '.redd.key')
17
+ if File.exist?(redd_file_path)
18
+ auth = Redd::AuthStrategies::Web.new(
19
+ client_id: 'P4txR-D6TzF8cg',
20
+ redirect_uri: 'http://localhost:8000/redirect'
21
+ )
22
+ access = Redd::Models::Access.new(refresh_token: File.read(redd_file_path))
23
+ client = Redd::APIClient.new(auth, user_agent: USER_AGENT)
24
+ client.access = auth.refresh(access)
25
+ reddit.session = Redd::Models::Session.new(client)
26
+ else
27
+ server = WEBrick::HTTPServer.new(
28
+ Port: 8000,
29
+ BindAddress: '0.0.0.0',
30
+ Logger: WEBrick::Log.new(File.open(File::NULL, 'w')),
31
+ AccessLog: []
32
+ )
33
+
34
+ server.mount_proc '/' do |_, res|
35
+ res.body = <<-HTML
36
+ <!doctype html>
37
+ <title>Redd Quickstart</title>
38
+ <style>
39
+ html, body { margin: 0; height: 100vh; }
40
+ .wrapper { padding-top: 30vh; text-align: center; font-family: sans-serif; }
41
+ #btn { background-color: #3D9970; margin: 5px; border-radius: 5px; padding: 10px; color: #fff; text-decoration: none; }
42
+ </style>
43
+ <div class="wrapper">
44
+ <h1>redd // quickstart</h1>
45
+ <a href="/authenticate" target="_blank" id="btn">Start</a>
46
+ <span>a new session in your terminal?</span>
47
+ </div>
48
+ HTML
49
+ end
50
+
51
+ server.mount_proc '/authenticate' do |_, res|
52
+ res.set_redirect(
53
+ WEBrick::HTTPStatus[302],
54
+ Redd.url(
55
+ client_id: 'P4txR-D6TzF8cg',
56
+ response_type: 'code',
57
+ state: '0',
58
+ redirect_uri: 'http://localhost:8000/redirect',
59
+ duration: 'permanent',
60
+ scope: %w[account creddits edit flair history identity livemanage modconfig modcontributors
61
+ modflair modlog modmail modothers modposts modself modwiki mysubreddits
62
+ privatemessages read report save submit subscribe vote wikiedit wikiread]
63
+ )
64
+ )
65
+ end
66
+
67
+ server.mount_proc '/redirect' do |req, res|
68
+ err = req.query['error']
69
+ should_exit = err.nil? || err == 'access_denied'
70
+ res.body = <<-HTML
71
+ <!doctype html>
72
+ <title>Done!</title>
73
+ #{should_exit ? '<script>window.close();</script>' : "<p>Uh oh, there was an error: #{err}</p>"}
74
+ HTML
75
+
76
+ unless err
77
+ server.stop
78
+ reddit.session = Redd.it(
79
+ user_agent: "Ruby:Redd-Quickstart:v#{Redd::VERSION} (by /u/Mustermind)",
80
+ client_id: 'P4txR-D6TzF8cg',
81
+ redirect_uri: 'http://localhost:8000/redirect',
82
+ code: req.query['code'],
83
+ auto_refresh: true
84
+ )
85
+ File.open(redd_file_path, 'w') do |f|
86
+ f.write(reddit.session.client.access.refresh_token)
87
+ end
88
+ end
89
+ end
90
+
91
+ # Get the server going and shut it all down if user hits Ctrl-C
92
+ begin
93
+ puts "Listening at \e[34mhttp://localhost:8000\e[0m..."
94
+ server.start
95
+ rescue Interrupt
96
+ server.shutdown
97
+ exit
98
+ end
99
+ end
100
+
101
+ reddit.instance_exec do
102
+ # Post a colourful welcome message
103
+ suggestions = [
104
+ # Session#me
105
+ 'session.me.link_karma',
106
+ # Subreddit listings
107
+ "session.subreddit('pics').hot.first.title",
108
+ # User listings
109
+ 'puts session.me.comments(sort: :top).first.body',
110
+ # Sending messages
111
+ "session.user('Mustermind').send_message(subject: 'Hi!', text: 'How are you?')",
112
+ # Subscribing to subreddits
113
+ "session.subreddit('EarthPorn').subscribe",
114
+ # Upvoting
115
+ 'session.front_page.hot(time: :month).first.upvote',
116
+ # Add friend
117
+ "session.user('Mustermind').friend",
118
+ # List friends
119
+ 'session.friends.each { |friend| puts friend.name };',
120
+ # Hiding / Duplicates
121
+ 'session.front_page.hot.each { |l| l.hide if l.duplicates.count > 2 }'
122
+ ]
123
+ puts "Hi \e[35m/u/#{session.me.name}\e[0m! Try `\e[34m#{suggestions.sample}\e[0m`."
124
+
125
+ # Load Pry
126
+ Pry.start(self)
127
+ end
data/bin/guard ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env bash
2
+ bundle exec guard
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
data/docs/guides/.keep ADDED
File without changes