main.com.wisetrack.sdk.EventResponseData.kt Maven / Gradle / Ivy
package com.wisetrack.sdk
import org.json.JSONObject
/**
@author hamed (@hamed-hsb)
* @since 06th October 2021
*/
class EventResponseData(activityPackage: ActivityPackage) : ResponseData() {
private var eventToken: String? = activityPackage.parameters?.get("event_token")
private var callbackId: String? = activityPackage.parameters?.get("event_callback_id")
private var sdkPlatform = activityPackage.clientSdk?.let { Util.getSdkPrefixPlatform(it) }
public fun getSuccessResponseData(): WiseTrackEventSuccess? {
if (!success) {
return null
}
val successResponseData = WiseTrackEventSuccess()
if ("unity" == sdkPlatform) {
successResponseData.eventToken = eventToken ?: ""
successResponseData.message = message ?: ""
successResponseData.timestamp = timestamp ?: ""
successResponseData.adid = adid ?: ""
successResponseData.callbackId = callbackId ?: ""
successResponseData.jsonResponse = jsonResponse ?: JSONObject()
} else {
// Rest of all platforms.
successResponseData.eventToken = eventToken
successResponseData.message = message
successResponseData.timestamp = timestamp
successResponseData.adid = adid
successResponseData.callbackId = callbackId
successResponseData.jsonResponse = jsonResponse
}
return successResponseData
}
public fun getFailureResponseData(): WiseTrackEventFailure? {
if (success) {
return null
}
val failureResponseData = WiseTrackEventFailure()
if ("unity" == sdkPlatform) {
failureResponseData.eventToken = eventToken ?: ""
failureResponseData.message = message ?: ""
failureResponseData.timestamp = timestamp ?: ""
failureResponseData.adid = adid ?: ""
failureResponseData.callbackId = callbackId ?: ""
failureResponseData.willRetry = willRetry
failureResponseData.jsonResponse = jsonResponse ?: JSONObject()
} else {
// Rest of all platforms.
failureResponseData.eventToken = eventToken
failureResponseData.message = message
failureResponseData.timestamp = timestamp
failureResponseData.adid = adid
failureResponseData.callbackId = callbackId
failureResponseData.willRetry = willRetry
failureResponseData.jsonResponse = jsonResponse
}
return failureResponseData
}
}