-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Replace GSON by Moshi. Fix #72. * Small refactor to use deconstruction * Add some explanation on the issues with flaky tests
- Loading branch information
Showing
8 changed files
with
32 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
package data.common | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import com.squareup.moshi.Json | ||
|
||
/** | ||
* Models the relevant information about a post. Note that it is located here because it is not | ||
* specific to top requests. | ||
*/ | ||
internal data class DataPost(@SerializedName("title") val title: String, | ||
@SerializedName("subreddit") val subreddit: String, | ||
@SerializedName("score") val score: Int, | ||
@SerializedName("permalink") val permalink: String) | ||
internal data class DataPost(@Json(name = "title") val title: String, | ||
@Json(name = "subreddit") val subreddit: String, | ||
@Json(name = "score") val score: Int, | ||
@Json(name = "permalink") val permalink: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,21 @@ | ||
package data.top | ||
|
||
import com.google.gson.annotations.SerializedName | ||
import com.squareup.moshi.Json | ||
import data.common.DataPost | ||
|
||
/** | ||
* Models the relevant information about information that comes in a container with a type (kind) | ||
* and payload (data). | ||
* Actually, this could be used for the whole Reddit API since there are probably more requests | ||
* that used this "contained" format. Unfortunately, using generics to support that approach | ||
* would not be possible because type erasure would cause gson to fail to deserialize correctly | ||
* and inheritance is not possible either because data classes cannot be open. | ||
*/ | ||
internal data class TopRequestDataContainer(@SerializedName("data") val data: TopRequestData) | ||
internal data class TopRequestDataContainer(@Json(name = "data") val data: TopRequestData) | ||
|
||
/** | ||
* Models the relevant information about a top request data. | ||
*/ | ||
internal data class TopRequestData(@SerializedName("children") val children: List<DataPostContainer>, | ||
@SerializedName("after") val after: String) | ||
internal data class TopRequestData(@Json(name = "children") val children: List<DataPostContainer>, | ||
@Json(name = "after") val after: String) | ||
|
||
/** | ||
* Wraps posts. | ||
*/ | ||
internal data class DataPostContainer(@SerializedName("data") val data: DataPost) | ||
internal data class DataPostContainer(@Json(name = "data") val data: DataPost) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters