com.kushkipagos.android.KushkiJsonBuilder.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kushki-android Show documentation
Show all versions of kushki-android Show documentation
Libreria para integrarse con kushki desde Android
package com.kushkipagos.android
import org.json.JSONObject
import java.util.*
internal class KushkiJsonBuilder {
fun buildJson(card: Card, currency: String): String {
return buildJsonObject(card, currency).toString()
}
fun buildJson(card: Card, totalAmount: Double, currency: String, months: Int): String {
return buildJsonObject(card, totalAmount, currency, months).toString()
}
private fun buildJsonObject(card: Card, totalAmount: Double, currency: String, months: Int): JSONObject {
var response = buildJsonObject(card, currency)
if(months!== null && months>0) {
response.put("months", months)
}
response.put("totalAmount", totalAmount)
return response
}
private fun buildJsonObject(card: Card, currency: String): JSONObject {
return JSONObject()
.put("card", card.toJsonObject())
.put("currency", currency)
}
}