package com.abbidot.tracker.alipay

import android.text.TextUtils

/**
 * 支付宝支付验证消息
 */
class PayResult(rawResult: Map<String, String>?) {
    /**
     * @return the resultStatus
     */
    var resultStatus: String? = null

    /**
     * @return the result
     */
    var result: String? = null

    /**
     * @return the memo
     */
    var memo: String? = null

    override fun toString(): String {
        return "resultStatus={$resultStatus};memo={$memo};result={$result}"
    }

    init {
        rawResult?.let {
            for (key in it.keys) {
                when {
                    TextUtils.equals(key, "resultStatus") -> {
                        resultStatus = it[key]
                    }
                    TextUtils.equals(key, "result") -> {
                        result = it[key]
                    }
                    TextUtils.equals(key, "memo") -> {
                        memo = it[key]
                    }
                }
            }
        }
    }
}