commonMain.com.huawei.hilink.c2c.integration.helper.requestHandlers.UnsubscribeDeviceHiLinkService.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of helper-jvm Show documentation
Show all versions of helper-jvm Show documentation
The helper library streamlines the HiLink C2C integration and exposes a simple API.
package com.huawei.hilink.c2c.integration.helper.requestHandlers
import com.huawei.hilink.c2c.integration.helper.api.UserInfo
import com.huawei.hilink.c2c.integration.helper.dto.HiLinkResultCodes
import com.huawei.hilink.c2c.integration.helper.dto.common.HiLinkHeader
import com.huawei.hilink.c2c.integration.helper.dto.headers.HiLinkHeadersBuilder
import com.huawei.hilink.c2c.integration.helper.dto.inbound.response.HiLinkResponse
import com.huawei.hilink.c2c.integration.helper.dto.inbound.response.UnsubscribeDeviceResponse
internal class UnsubscribeDeviceHiLinkService(
private val hiLinkHeadersBuilder: HiLinkHeadersBuilder,
) : HiLinkService("UnsubscribeDevice") {
override suspend fun handle(requestHeader: HiLinkHeader, requestJson: String, userInfo: UserInfo): HiLinkResponse {
return prepareResponse(requestHeader, HiLinkResultCodes.SUCCESS)
}
override fun prepareErrorResponse(
requestHeader: HiLinkHeader,
resultCode: HiLinkResultCodes,
description: String
): HiLinkResponse {
return prepareResponse(requestHeader, resultCode, description)
}
private fun prepareResponse(
requestHeader: HiLinkHeader,
resultCode: HiLinkResultCodes,
description: String? = null
) =
UnsubscribeDeviceResponse(
header = hiLinkHeadersBuilder.generateResponseHeader(requestHeader),
payload = UnsubscribeDeviceResponse.Payload(
code = resultCode.code,
description = description ?: resultCode.description
)
)
}