Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Kamo Spertsyan <[email protected]>
  • Loading branch information
suriksarkisyan and SpertsyanKM authored Aug 22, 2024
1 parent 7f06e08 commit 2793e53
Showing 1 changed file with 11 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -381,40 +381,38 @@ class QonversionSandwich(
}

private fun configurePurchaseOptions(
offerId: String? = null,
applyOffer: Boolean? = null,
offerId: String?,
applyOffer: Boolean?,
oldProduct: QProduct? = null,
updatePolicyKey: String? = null,
contextKeys: List<String>? = null,
): QPurchaseOptions {
val builder = QPurchaseOptions.Builder()

if (oldProduct != null) {
builder.setOldProduct(oldProduct)
oldProduct?.let {
builder.setOldProduct(it)
}

val updatePolicy = updatePolicyKey?.let {
updatePolicyKey?.let {
try {
QPurchaseUpdatePolicy.valueOf(it)
} catch (e: IllegalArgumentException) {
null
}
}?.let {
builder.setUpdatePolicy(it)
}

if (updatePolicy != null) {
builder.setUpdatePolicy(updatePolicy)
}

if (offerId != null) {
builder.setOfferId(offerId)
offerId?.let {
builder.setOfferId(it)
}

if (applyOffer == false) {
builder.removeOffer()
}

if (contextKeys != null) {
builder.setContextKeys(contextKeys)
contextKeys?.let {
builder.setContextKeys(it)
}

val purchaseOptions = builder.build()
Expand Down

0 comments on commit 2793e53

Please sign in to comment.