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

main.com.wisetrack.sdk.ResponseData.kt Maven / Gradle / Ivy

There is a newer version: 1.5.8-alpha
Show newest version
package com.wisetrack.sdk

import org.json.JSONObject

/**
@author hamed (@hamed-hsb)
 * @since 04th October 2021
 */

open class ResponseData {
    var success = false
    var willRetry = false

    /*
     The HTTP 423 Locked client error response status code indicates that a resource is locked, meaning it can't be accessed.
     In a database system, a record may be locked during a transaction to ensure data integrity.
     Other transactions attempting to access it will receive a lock message until the first transaction is completed.
    */
    var resourceLocked = false


    var adid: String? = null
    var message: String? = null
    var timestamp: String? = null
    var jsonResponse: JSONObject? = null
    var activityKind: ActivityKind? = null
    var trackingState: TrackingState? = null
    var attribution: WiseTrackAttribution? = null
    var askIn: Long? = null
    var retryIn: Long? = null
    var continueIn: Long? = null

    var activityPackage: ActivityPackage? = null
    var sendingParameters: Map? = null

    companion object {
        @JvmStatic
        fun buildResponseData(
            activityPackage: ActivityPackage,
            sendingParameters: Map?
        ): ResponseData {
            val responseData: ResponseData?
            val activityKind = activityPackage.activityKind

            responseData = when (activityKind) {
                ActivityKind.SESSION -> SessionResponseData(activityPackage)
                ActivityKind.CLICK -> SdkClickResponseData()
                ActivityKind.ATTRIBUTION -> AttributionResponseData()
                ActivityKind.EVENT -> EventResponseData(activityPackage)
                else -> ResponseData()
            }
            responseData.activityKind = activityKind
            responseData.activityPackage = activityPackage
            responseData.sendingParameters = sendingParameters

            return responseData
        }
    }

    override fun toString(): String {
        return "message:$message timestamp:$timestamp json:$jsonResponse"
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy