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

commonMain.com.huawei.hilink.c2c.integration.helper.requestHandlers.UnsubscribeDeviceHiLinkService.kt Maven / Gradle / Ivy

Go to download

The helper library streamlines the HiLink C2C integration and exposes a simple API.

There is a newer version: 1.3.2
Show newest version
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
            )
        )
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy