All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.kushkipagos.android.KushkiJsonBuilder.kt Maven / Gradle / Ivy

There is a newer version: 1.8.1
Show newest version
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)
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy