Skip to content

Feat/ccrama force sr_detail #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .idea/markdown-navigator-enh.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions .idea/markdown-navigator.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions lib/src/main/java/com/kirkbushman/araw/RedditApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ interface RedditApi {
fun submission(
@Query("id") submissionId: String,
@Query("raw_json") rawJson: Int? = null,
@Query("sr_detail") srDetail: Int = 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better if we make this field nullable, and the default parameter null. In this case Retrofit will not set this by default. And the user will opt-in if necessary.

@HeaderMap header: HashMap<String, String>
): Call<EnvelopedSubmissionListing>

Expand Down Expand Up @@ -297,6 +298,7 @@ interface RedditApi {
@Query("after") after: String? = null,
@Query("before") before: String? = null,
@Query("raw_json") rawJson: Int? = null,
@Query("sr_detail") srDetail: Int = 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the type nullable and the default null, please.

@HeaderMap header: HashMap<String, String>
): Call<EnvelopedSubmissionListing>

Expand All @@ -310,6 +312,7 @@ interface RedditApi {
@Query("after") after: String? = null,
@Query("before") before: String? = null,
@Query("raw_json") rawJson: Int? = null,
@Query("sr_detail") srDetail: Int = 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the type nullable and the default null, please.

@HeaderMap header: HashMap<String, String>
): Call<EnvelopedSubmissionListing>

Expand All @@ -322,6 +325,7 @@ interface RedditApi {
@Query("limit") limit: Long? = null,
@Query("depth") depth: Int? = null,
@Query("raw_json") rawJson: Int? = null,
@Query("sr_detail") srDetail: Int = 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the type nullable and the default null, please.

@HeaderMap header: HashMap<String, String>
): Call<List<EnvelopedContributionListing>>

Expand All @@ -337,6 +341,7 @@ interface RedditApi {
@Query("after") after: String? = null,
@Query("before") before: String? = null,
@Query("raw_json") rawJson: Int? = null,
@Query("sr_detail") srDetail: Int = 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the type nullable and the default null, please.

@HeaderMap header: HashMap<String, String>
): Call<EnvelopedMessageListing>

Expand Down Expand Up @@ -383,6 +388,7 @@ interface RedditApi {
@Query("after") after: String? = null,
@Query("before") before: String? = null,
@Query("raw_json") rawJson: Int? = null,
@Query("sr_detail") srDetail: Int = 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the type nullable and the default null, please.

@HeaderMap header: HashMap<String, String>
): Call<EnvelopedSubmissionListing>

Expand Down Expand Up @@ -522,6 +528,7 @@ interface RedditApi {
@Query("after") after: String? = null,
@Query("before") before: String? = null,
@Query("raw_json") rawJson: Int? = null,
@Query("sr_detail") srDetail: Int = 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the type nullable and the default null, please.

@HeaderMap header: HashMap<String, String>
): Call<EnvelopedContributionListing>

Expand All @@ -536,6 +543,7 @@ interface RedditApi {
@Query("after") after: String? = null,
@Query("before") before: String? = null,
@Query("raw_json") rawJson: Int? = null,
@Query("sr_detail") srDetail: Int = 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the type nullable and the default null, please.

@HeaderMap header: HashMap<String, String>
): Call<EnvelopedContributionListing>

Expand Down Expand Up @@ -608,6 +616,7 @@ interface RedditApi {
@Query("after") after: String? = null,
@Query("before") before: String? = null,
@Query("raw_json") rawJson: Int? = null,
@Query("sr_detail") srDetail: Int = 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the type nullable and the default null, please.

@HeaderMap header: HashMap<String, String>
): Call<List<Listing<EnvelopedData>>>

Expand All @@ -623,6 +632,7 @@ interface RedditApi {
@Query("before") before: String? = null,
@Query("restrict_sr") restrictToSubreddit: Boolean? = null,
@Query("raw_json") rawJson: Int? = null,
@Query("sr_detail") srDetail: Int = 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the type nullable and the default null, please.

@HeaderMap header: HashMap<String, String>
): Call<EnvelopedSubmissionListing>

Expand All @@ -639,6 +649,7 @@ interface RedditApi {
@Query("before") before: String? = null,
@Query("restrict_sr") restrictToSubreddit: Boolean? = null,
@Query("raw_json") rawJson: Int? = null,
@Query("sr_detail") srDetail: Int = 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the type nullable and the default null, please.

@HeaderMap header: HashMap<String, String>
): Call<EnvelopedSubmissionListing>

Expand All @@ -654,6 +665,7 @@ interface RedditApi {
@Query("after") after: String? = null,
@Query("before") before: String? = null,
@Query("raw_json") rawJson: Int? = null,
@Query("sr_detail") srDetail: Int = 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the type nullable and the default null, please.

@HeaderMap header: HashMap<String, String>
): Call<EnvelopedSubredditDataListing>

Expand All @@ -669,6 +681,7 @@ interface RedditApi {
@Query("after") after: String? = null,
@Query("before") before: String? = null,
@Query("raw_json") rawJson: Int? = null,
@Query("sr_detail") srDetail: Int = 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the type nullable and the default null, please.

@HeaderMap header: HashMap<String, String>
): Call<EnvelopedSubmissionListing>

Expand All @@ -684,6 +697,7 @@ interface RedditApi {
@Query("after") after: String? = null,
@Query("before") before: String? = null,
@Query("raw_json") rawJson: Int? = null,
@Query("sr_detail") srDetail: Int = 1,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make the type nullable and the default null, please.

@HeaderMap header: HashMap<String, String>
): Call<EnvelopedRedditorDataListing>

Expand Down
84 changes: 84 additions & 0 deletions lib/src/main/java/com/kirkbushman/araw/models/SrDetail.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package com.kirkbushman.araw.models

import android.os.Parcelable
import com.kirkbushman.araw.models.base.Thing
import com.kirkbushman.araw.models.commons.ImageDetail
import com.squareup.moshi.Json
import com.squareup.moshi.JsonClass
import kotlinx.parcelize.Parcelize
import java.util.*

@JsonClass(generateAdapter = true)
@Parcelize
data class SrDetail(

@Json(name = "name")
override val fullname: String,

//sr_detail doesn't have an ID field, split the fullname
override val id: String = fullname.split("_").last(),

@Json(name = "default_set")
val defaultSet: Boolean,

@Json(name = "banner_img")
val bannerImg: String?,

@Json(name = "community_icon")
val communityIcon: String?,

@Json(name = "description")
val description: String?,

@Json(name = "user_is_muted")
val userIsMuted: Boolean?,

@Json(name = "display_name")
val displayName: String,

@Json(name = "header_img")
val headerImg: String?,

@Json(name = "title")
val title: String?,

@Json(name = "user_is_moderator")
val userIsModerator: Boolean?,

@Json(name = "over_18")
val over18: Boolean,

@Json(name = "icon_size")
val iconSize: List<Long>?,

@Json(name = "primary_color")
val primaryColor: String?,

@Json(name = "icon_img")
val iconImg: String?,

@Json(name = "icon_color")
val iconColor: String?,

@Json(name = "subscribers")
val subscribers: Long,

@Json(name = "display_name_prefixed")
val displayNamePrefixed: String,

@Json(name = "key_color")
val keyColor: String?,

@Json(name = "created_utc")
val createdUTC: Long,

@Json(name = "banner_size")
val bannerSize: List<Long>?,

@Json(name = "public_description")
val publicDescription: String?,

@Json(name = "user_is_subscriber")
val userIsSubscriber: Boolean?
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Convert the naming into isSubscriber, isMuted like the rest, please


) : Thing, Parcelable
3 changes: 3 additions & 0 deletions lib/src/main/java/com/kirkbushman/araw/models/Submission.kt
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,9 @@ data class Submission(
@Json(name = "gildings")
override val gildings: Gildings,

@Json(name = "sr_detail")
val sr_detail: SrDetail?,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use camel case for the variable name here, otherwise detekt will error the build in Travis. Move it to srDetail, please.


@Json(name = "archived")
val isArchived: Boolean,

Expand Down