-
Notifications
You must be signed in to change notification settings - Fork 52
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
Conversation
@@ -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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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?
There was a problem hiding this 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
@vegaro I removed the ?, now it looks almost like the other method 👍 |
Added parsing of
original_purchase_date
insubscriber
to purchaserInfo