-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support non consumables by listening to backend response
- Loading branch information
Showing
15 changed files
with
292 additions
and
95 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
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
28 changes: 28 additions & 0 deletions
28
purchases/src/main/kotlin/com/revenuecat/purchases/common/networking/PostReceiptResponse.kt
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.revenuecat.purchases.common.networking | ||
|
||
import com.revenuecat.purchases.CustomerInfo | ||
import com.revenuecat.purchases.common.CustomerInfoFactory | ||
import com.revenuecat.purchases.utils.toMap | ||
import org.json.JSONObject | ||
|
||
internal fun buildPostReceiptResponse(result: HTTPResult) = PostReceiptResponse( | ||
customerInfo = CustomerInfoFactory.buildCustomerInfo(result), | ||
productInfoByProductId = result.body.optJSONObject("purchased_products")?.let { | ||
it.toMap<JSONObject>().mapValues { (_, value) -> | ||
PostReceiptProductInfo( | ||
shouldConsume = value.optBoolean("should_consume"), | ||
) | ||
} | ||
}, | ||
body = result.body, | ||
) | ||
|
||
internal data class PostReceiptProductInfo( | ||
val shouldConsume: Boolean, | ||
) | ||
|
||
internal data class PostReceiptResponse( | ||
val customerInfo: CustomerInfo, | ||
val productInfoByProductId: Map<String, PostReceiptProductInfo>?, | ||
val body: JSONObject, | ||
) |
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
Oops, something went wrong.