![JAR search and dependency download from the Maven repository](/logo.png)
commonMain.com.huawei.hilink.c2c.integration.helper.dto.HiLinkResultCodes.kt Maven / Gradle / Ivy
package com.huawei.hilink.c2c.integration.helper.dto
import com.huawei.hilink.c2c.integration.helper.api.CommandResult
internal enum class HiLinkResultCodes(val code: Int, val description: String) {
SUCCESS(0, "success"),
INTERNAL_ERROR(10001, "internal error"),
/**
* Important note: this code was altered in it's meaning, from the original
* one used by HiLink Protocol Access. This is in order to achieve a behavior
* such that partner doesn't need to explain whether an AT is expired
* or downright invalid - in both cases the same value is returned.
*
* Originally there was an UNAUTHORIZED(10002, "unauthorized"), code and HiLink
* expects a distinction between UNAUTHORIZED and EXPIRED_ACCESSTOKEN_CREDENTIAL.
*
* When UNAUTHORIZED is returned, Ai Life requires user
* to re-authorize by providing their password to partner's OAuth again.
* On 10
*/
UNAUTHORIZED_OR_EXPIRED_AT(10003, "invalid or expired token"),
UNAUTHORIZED_ILLEGAL_ACCESS(10002, "invalid token"),
EXPIRED_ACCESSTOKEN_CREDENTIAL(10003, "expired AT"),
EXPIRED_REFRESHTOKEN_CREDENTIAL(10004, "expired RT"),
INVALID_PARAMETER(10005, "invalid parameter"),
DEVICE_DOES_NOT_EXIST(10009, "device does not exist"),
DEVICE_COMMAND_NOT_SUPPORT(10010, "device command not supported"),
DEVICE_OFFLINE(10011, "device is offline"),
}
internal fun CommandResult.toHiLinkResultCode() = when (this) {
CommandResult.SUCCESS -> HiLinkResultCodes.SUCCESS
CommandResult.DEVICE_IS_OFFLINE -> HiLinkResultCodes.DEVICE_OFFLINE
CommandResult.DEVICE_DOES_NOT_EXIST -> HiLinkResultCodes.DEVICE_DOES_NOT_EXIST
CommandResult.UNSUPPORTED_COMMAND -> HiLinkResultCodes.DEVICE_COMMAND_NOT_SUPPORT
CommandResult.FAILURE -> HiLinkResultCodes.INTERNAL_ERROR
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy