2 * Copyright (c) 2010-2023 Contributors to the openHAB project
4 * See the NOTICE file(s) distributed with this work for additional
7 * This program and the accompanying materials are made available under the
8 * terms of the Eclipse Public License 2.0 which is available at
9 * http://www.eclipse.org/legal/epl-2.0
11 * SPDX-License-Identifier: EPL-2.0
13 package org.openhab.binding.ecovacs.internal.api.impl.dto.response.portal;
15 import com.google.gson.annotations.SerializedName;
18 * @author Danny Baumann - Initial contribution
20 public class AbstractPortalIotCommandResponse {
21 @SerializedName("ret")
22 private final String result;
24 @SerializedName("errno")
25 private final int errorCode;
26 @SerializedName("error")
27 private final String errorMessage;
29 // unused field: 'id' (string)
31 public AbstractPortalIotCommandResponse(String result, int errorCode, String errorMessage) {
33 this.errorCode = errorCode;
34 this.errorMessage = errorMessage;
37 public boolean wasSuccessful() {
38 return "ok".equals(result);
41 public boolean failedDueToAuthProblem() {
42 return "fail".equals(result) && errorMessage != null && errorMessage.toLowerCase().contains("auth error");
45 public String getErrorMessage() {
46 if (wasSuccessful()) {
49 return "result=" + result + ", errno=" + errorCode + ", error=" + errorMessage;