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

main.com.wisetrack.sdk.SessionResponseData.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 06th October 2021
 */

class SessionResponseData(activityPackage: ActivityPackage) : ResponseData() {

    private val sdkPlatform = activityPackage.clientSdk?.let { Util.getSdkPrefixPlatform(it) }

    public fun getSuccessResponseData(): WiseTrackSessionSuccess? {
        if (!success) {
            return null
        }

        val successResponseData = WiseTrackSessionSuccess()
        if ("unity" == sdkPlatform) {
            successResponseData.adid = adid ?: ""
            successResponseData.message = message ?: ""
            successResponseData.timestamp = timestamp ?: ""
            successResponseData.jsonResponse = jsonResponse ?: JSONObject()
        } else {
            // Rest of all platforms.
            successResponseData.message = message
            successResponseData.timestamp = timestamp
            successResponseData.adid = adid
            successResponseData.jsonResponse = jsonResponse
        }

        return successResponseData
    }

    fun getFailureResponseData(): WiseTrackSessionFailure? {
        if (success) {
            return null
        }
        val failureResponseData = WiseTrackSessionFailure()
        if ("unity" == sdkPlatform) {
            // Unity platform.
            failureResponseData.message = if (message != null) message else ""
            failureResponseData.timestamp = if (timestamp != null) timestamp else ""
            failureResponseData.adid = if (adid != null) adid else ""
            failureResponseData.willRetry = willRetry
            failureResponseData.jsonResponse =
                if (jsonResponse != null) jsonResponse else JSONObject()
        } else {
            // Rest of all platforms.
            failureResponseData.message = message
            failureResponseData.timestamp = timestamp
            failureResponseData.adid = adid
            failureResponseData.willRetry = willRetry
            failureResponseData.jsonResponse = jsonResponse
        }
        return failureResponseData
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy