Skip to content
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

add original_purchase_date #164

Merged
merged 7 commits into from
Jun 25, 2020
Merged

Conversation

aboedo
Copy link
Member

@aboedo aboedo commented Jun 19, 2020

Added parsing of original_purchase_date in subscriber to purchaserInfo

@aboedo aboedo requested a review from vegaro June 19, 2020 20:09
@aboedo aboedo self-assigned this Jun 19, 2020
@@ -193,6 +193,9 @@ internal fun String.sha1() =
}

internal fun JSONObject.getNullableString(name: String): String? = this.getString(name).takeUnless { this.isNull(name) }
internal fun JSONObject.optNullableString(name: String): String? = this.optString(name)?.takeUnless {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think optString returns "" if the JSON doesn't contain the name, which is very very annoying

Copy link
Member Author

@aboedo aboedo Jun 20, 2020

Choose a reason for hiding this comment

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

good catch. I got bit by looking at the search result
image

but not reading in the actual doc

Returns the value mapped by name if it exists, coercing it if necessary, or the empty string if no such mapping exists.

Fixing

Copy link
Member Author

Choose a reason for hiding this comment

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

the method actually does work, though, because of the takeUnless, which checks if the object isNull. That check will return true if the key isn't found in the JSON https://developer.android.com/reference/org/json/JSONObject#isNull(java.lang.String)

Copy link
Member Author

Choose a reason for hiding this comment

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

I added an extra test case to make sure (also tested manually)

Copy link
Contributor

Choose a reason for hiding this comment

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

I see. optString will never return null though, so ?. should be . right?

Copy link
Contributor

@vegaro vegaro left a comment

Choose a reason for hiding this comment

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

Besides the small comment about the ?. this lgtm

@aboedo
Copy link
Member Author

aboedo commented Jun 25, 2020

@vegaro I removed the ?, now it looks almost like the other method 👍

@aboedo aboedo merged commit eeb7a47 into develop Jun 25, 2020
@aboedo aboedo deleted the feature/add_original_purchase_date branch June 25, 2020 12:29
@vegaro vegaro mentioned this pull request Jul 8, 2020
@vegaro vegaro mentioned this pull request Oct 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants