Skip to content

Commit

Permalink
Requested changes as well as updated endpoint coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
canaangifford committed Mar 6, 2018
1 parent a7a0f4e commit 25bd4a4
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 42 deletions.
15 changes: 8 additions & 7 deletions ENDPOINTS.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!--- Generated 2018-02-23 at 09:53:12 EST. Use `./gradlew :meta:update` to update. DO NOT MODIFY DIRECTLY -->
<!--- Generated 2018-03-05 at 21:54:35 EST. Use `./gradlew :meta:update` to update. DO NOT MODIFY DIRECTLY -->

Endpoints
=========

This file contains a list of all the endpoints (regardless of if they have been implemented) that can be found at the [official reddit API docs](https://www.reddit.com/dev/api/oauth). To update this file, run `./gradlew :meta:update`

So far, **82** endpoints (out of 190) have been implemented.
So far, **85** endpoints (out of 191) have been implemented.

(any scope)
-----------
Expand Down Expand Up @@ -172,20 +172,20 @@ modposts

| Method | Endpoint | Implementation |
|:------:| ------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `POST` | [`/api/approve`](https://www.reddit.com/dev/api/oauth#POST_api_approve) | [`PublicContributionReference.approve()`](https://github.com/mattbdean/JRAW/tree/master/lib/src/main/kotlin/net/dean/jraw/references/PublicContributionReference.kt#L198) |
| `POST` | [`/api/approve`](https://www.reddit.com/dev/api/oauth#POST_api_approve) | [`PublicContributionReference.approve()`](https://github.com/mattbdean/JRAW/tree/master/lib/src/main/kotlin/net/dean/jraw/references/PublicContributionReference.kt#L199) |
| `POST` | [`/api/distinguish`](https://www.reddit.com/dev/api/oauth#POST_api_distinguish) | [`PublicContributionReference.distinguish()`](https://github.com/mattbdean/JRAW/tree/master/lib/src/main/kotlin/net/dean/jraw/references/PublicContributionReference.kt#L151) |
| `POST` | [`/api/remove`](https://www.reddit.com/dev/api/oauth#POST_api_remove) | [`PublicContributionReference.remove()`](https://github.com/mattbdean/JRAW/tree/master/lib/src/main/kotlin/net/dean/jraw/references/PublicContributionReference.kt#L184) |
| `POST` | [`/api/remove`](https://www.reddit.com/dev/api/oauth#POST_api_remove) | [`PublicContributionReference.remove()`](https://github.com/mattbdean/JRAW/tree/master/lib/src/main/kotlin/net/dean/jraw/references/PublicContributionReference.kt#L185) |
| `POST` | [`/api/set_subreddit_sticky`](https://www.reddit.com/dev/api/oauth#POST_api_set_subreddit_sticky) | [`SubmissionReference.stickyPost()`](https://github.com/mattbdean/JRAW/tree/master/lib/src/main/kotlin/net/dean/jraw/references/SubmissionReference.kt#L114) |
| `POST` | [`/api/spoiler`](https://www.reddit.com/dev/api/oauth#POST_api_spoiler) | [`SubmissionReference.flagAsSpoiler()`](https://github.com/mattbdean/JRAW/tree/master/lib/src/main/kotlin/net/dean/jraw/references/SubmissionReference.kt#L91) |
| `POST` | [`/api/unspoiler`](https://www.reddit.com/dev/api/oauth#POST_api_unspoiler) | [`SubmissionReference.flagAsSpoiler()`](https://github.com/mattbdean/JRAW/tree/master/lib/src/main/kotlin/net/dean/jraw/references/SubmissionReference.kt#L91) |
| `POST` | [`/api/ignore_reports`](https://www.reddit.com/dev/api/oauth#POST_api_ignore_reports) | None |
| `POST` | [`/api/lock`](https://www.reddit.com/dev/api/oauth#POST_api_lock) | None |
| `POST` | [`/api/marknsfw`](https://www.reddit.com/dev/api/oauth#POST_api_marknsfw) | None |
| `POST` | [`/api/set_contest_mode`](https://www.reddit.com/dev/api/oauth#POST_api_set_contest_mode) | None |
| `POST` | [`/api/set_subreddit_sticky`](https://www.reddit.com/dev/api/oauth#POST_api_set_subreddit_sticky) | None |
| `POST` | [`/api/set_suggested_sort`](https://www.reddit.com/dev/api/oauth#POST_api_set_suggested_sort) | None |
| `POST` | [`/api/spoiler`](https://www.reddit.com/dev/api/oauth#POST_api_spoiler) | None |
| `POST` | [`/api/unignore_reports`](https://www.reddit.com/dev/api/oauth#POST_api_unignore_reports) | None |
| `POST` | [`/api/unlock`](https://www.reddit.com/dev/api/oauth#POST_api_unlock) | None |
| `POST` | [`/api/unmarknsfw`](https://www.reddit.com/dev/api/oauth#POST_api_unmarknsfw) | None |
| `POST` | [`/api/unspoiler`](https://www.reddit.com/dev/api/oauth#POST_api_unspoiler) | None |

modself
-------
Expand Down Expand Up @@ -280,6 +280,7 @@ read
| `GET` | [`/live/{thread}/discussions`](https://www.reddit.com/dev/api/oauth#GET_live_{thread}_discussions) | None |
| `GET` | [`/live/{thread}/updates/{update_id}`](https://www.reddit.com/dev/api/oauth#GET_live_{thread}_updates_{update_id}) | None |
| `GET` | [`/prefs/{where}`](https://www.reddit.com/dev/api/oauth#GET_prefs_{where}) | None |
| `GET` | [`/profiles/search`](https://www.reddit.com/dev/api/oauth#GET_profiles_search) | None |
| `GET` | [`[/r/{subreddit}]/sidebar`](https://www.reddit.com/dev/api/oauth#GET_sidebar) | None |
| `GET` | [`[/r/{subreddit}]/sticky`](https://www.reddit.com/dev/api/oauth#GET_sticky) | None |
| `GET` | [`/subreddits/{where}`](https://www.reddit.com/dev/api/oauth#GET_subreddits_{where}) | None |
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![travis-ci build status](https://img.shields.io/travis/mattbdean/JRAW.svg)](https://travis-ci.org/mattbdean/JRAW)
[![Latest release](https://img.shields.io/github/release/mattbdean/JRAW.svg)](https://bintray.com/thatjavanerd/maven/JRAW/_latestVersion)
[![Kotlin 1.2.10](https://img.shields.io/badge/Kotlin-1.2.10-blue.svg)](http://kotlinlang.org)
[![API coverage](https://img.shields.io/badge/API_coverage-43%25-9C27B0.svg)](https://github.com/thatJavaNerd/JRAW/blob/master/ENDPOINTS.md)
[![API coverage](https://img.shields.io/badge/API_coverage-45%25-9C27B0.svg)](https://github.com/thatJavaNerd/JRAW/blob/master/ENDPOINTS.md)
[![Codecov branch](https://img.shields.io/codecov/c/github/mattbdean/JRAW.svg)](https://codecov.io/gh/mattbdean/JRAW)

```groovy
Expand Down
4 changes: 4 additions & 0 deletions lib/src/gen/java/net/dean/jraw/Endpoint.java
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,10 @@ public enum Endpoint {
* Represents the endpoint {@code GET /prefs/{where}}. Requires OAuth scope 'read'. See <a href="https://www.reddit.com/dev/api/oauth#GET_prefs_{where}">here</a> for more information */
GET_PREFS_WHERE("GET", "/prefs/{where}", "read"),

/**
* Represents the endpoint {@code GET /profiles/search}. Requires OAuth scope 'read'. See <a href="https://www.reddit.com/dev/api/oauth#GET_profiles_search">here</a> for more information */
GET_PROFILES_SEARCH("GET", "/profiles/search", "read"),

/**
* Represents the endpoint {@code GET /r/{subreddit}/about}. Requires OAuth scope 'read'. See <a href="https://www.reddit.com/dev/api/oauth#GET_r_{subreddit}_about">here</a> for more information */
GET_SUBREDDIT_ABOUT("GET", "/r/{subreddit}/about", "read"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ class SubmissionReference internal constructor(reddit: RedditClient, id: String)
* Sets the [spoilerStatus] of a post using the official Reddit spoiler flair.
*/
@EndpointImplementation(Endpoint.POST_SPOILER, Endpoint.POST_UNSPOILER)
fun flagAsSpoiiler(spoilerStatus: Boolean) {
fun flagAsSpoiler(spoilerStatus: Boolean) {
val endpoint = if (spoilerStatus) Endpoint.POST_SPOILER else Endpoint.POST_UNSPOILER
reddit.request {
it.endpoint(endpoint)
Expand All @@ -99,18 +99,18 @@ class SubmissionReference internal constructor(reddit: RedditClient, id: String)

// TODO - Requires mod privileges for the subreddit that contains the post.
/**
* Set or unset the announcement [state] of a post in its subreddit.
* Reddit provides 2 allowable announcement "slots" for a subreddit,
* often referred to as sticky posts.
* Set or unset the announcement [state] of a post in its subreddit. Reddit provides 2 allowable announcement
* "slots" for a subreddit, often referred to as sticky posts.
*
* Including [num] will specify which sticky slot (of 2) to place the post into,
* if there is already an existing post in that slot, the new one will replace it.
* Setting [num] will specify which sticky slot (of 2) to place the post into. If there is already an existing post
* in that slot, the new one will replace it. Passing in 0 for [num] will ignore that property in the payload and
* place the post into the bottom slot.
*
* Setting [toProfile] will sticky the post to an authenticated user's profile page.
* This is only used with new profile pages, not supported for legacy profiles.
* Setting [toProfile] will sticky the post to an authenticated user's profile page. This is only used with new
* profile pages, not supported for legacy profiles.
*/
@EndpointImplementation(Endpoint.POST_SET_SUBREDDIT_STICKY)
fun stickyPost(state: Boolean, num : Int = 0, toProfile: Boolean = false) {
fun stickyPost(state: Boolean, num: Int = 0, toProfile: Boolean = false) {
val payload = mutableMapOf(
"id" to fullName,
"state" to state.toString(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,26 @@ class SubmissionReferenceTest : Spek({
}
}

describe("set spoiler") {
assume({ SharedObjects.submittedSelfPost != null }, description = "should have a self post created") {
val post = SharedObjects.submittedSelfPost!!
post.flagAsSpoiler(true)
post.inspect().isSpoiler.should.be.`true`
post.flagAsSpoiler(false)
post.inspect().isSpoiler.should.be.`false`
}
}

describe("sticky post submission") {
assume({ SharedObjects.submittedSelfPost != null }, description = "should have a self post created") {
val post = SharedObjects.submittedSelfPost!!
post.stickyPost(true)
post.inspect().isStickied.should.be.`true`
post.stickyPost(false)
post.inspect().isStickied.should.be.`false`
}
}

// This test must go last, since deleting the post will make it uneditable
describe("delete") {
assume({ SharedObjects.submittedSelfPost != null }, "should delete the submission") {
Expand Down Expand Up @@ -194,29 +214,4 @@ class SubmissionReferenceTest : Spek({
SharedObjects.submittedSelfPost!!.sendReplies(true)
}
}

describe("set spoiler") {
assume({ SharedObjects.submittedSelfPost != null }, description = "should have a self post created") {
it("should set/unset the post spoiler flair") {
SharedObjects.submittedSelfPost!!.flagAsSpoiiler(true)
SharedObjects.submittedSelfPost!!.inspect().isSpoiler.should.be.`true`
SharedObjects.submittedSelfPost!!.flagAsSpoiiler(false)
SharedObjects.submittedSelfPost!!.inspect().isSpoiler.should.be.`false`
}
}
}

describe("sticky post submission") {
assume({ SharedObjects.submittedSelfPost != null }, description = "should have a self post created") {
it("should sticky a post into one of the allotted announcement slots") {
SharedObjects.submittedSelfPost!!.stickyPost(true)
SharedObjects.submittedSelfPost!!.inspect().isStickied.should.be.`true`
}

it("should remove the announcement status of the post") {
SharedObjects.submittedSelfPost!!.stickyPost(false)
SharedObjects.submittedSelfPost!!.inspect().isStickied.should.be.`false`
}
}
}
})

0 comments on commit 25bd4a4

Please sign in to comment.