Removed 'users-me' endpoint usage. (#20697)

Signed-off-by: clinique <gael@lhopital.org>
This commit is contained in:
Gaël L'hopital
2026-05-10 19:10:08 +02:00
committed by GitHub
parent 31ae94b44c
commit 9f6a27b074
4 changed files with 1 additions and 54 deletions
@@ -18,9 +18,7 @@ import java.time.OffsetDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.osgi.service.component.annotations.Activate;
@@ -31,7 +29,6 @@ import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonDeserializer;
import com.google.gson.JsonSyntaxException;
import com.google.gson.reflect.TypeToken;
/**
* The {@link WorxApiDeserializer} is responsible to instantiate suitable Gson (de)serializer
@@ -70,12 +67,6 @@ public class WorxApiDeserializer {
return gson.toJson(object);
}
public Map<String, String> toMap(Object object) {
Map<String, String> fromObject = gson.fromJson(toJson(object), new TypeToken<HashMap<String, String>>() {
}.getType());
return fromObject != null ? Map.copyOf(fromObject) : Map.of();
}
public <T> T deserialize(Type typeToken, String json) throws WebApiException {
try {
T result = gson.fromJson(json, typeToken);
@@ -26,7 +26,6 @@ import org.eclipse.jetty.http.HttpHeader;
import org.eclipse.jetty.http.HttpMethod;
import org.eclipse.jetty.http.HttpStatus;
import org.openhab.binding.worxlandroid.internal.api.dto.ProductItemStatus;
import org.openhab.binding.worxlandroid.internal.api.dto.UsersMeResponse;
import org.openhab.core.io.net.http.HttpClientFactory;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
@@ -46,15 +45,12 @@ import com.google.gson.reflect.TypeToken;
public class WorxApiHandler {
private static final String URL_BASE = "https://api.worxlandroid.com/api/v2/";
private static final String URL_PRODUCT_ITEMS = URL_BASE + "product-items";
private static final String URL_USERS_ME = URL_BASE + "users/me";
private static final int TIMEOUT_S = 15;
private static final Type PRODUCT_ITEM_STATUS_LIST = new TypeToken<List<ProductItemStatus>>() {
}.getType();
private static final Type PRODUCT_ITEM_STATUS = new TypeToken<ProductItemStatus>() {
}.getType();
private static final Type USERS_ME = new TypeToken<UsersMeResponse>() {
}.getType();
private final Logger logger = LoggerFactory.getLogger(WorxApiHandler.class);
private final HttpClient httpClient;
@@ -123,10 +119,6 @@ public class WorxApiHandler {
return apiGet("%s/%s?status=1".formatted(URL_PRODUCT_ITEMS, serialNumber), token, PRODUCT_ITEM_STATUS);
}
public UsersMeResponse retrieveMe(String token) throws WebApiException {
return apiGet(URL_USERS_ME, token, USERS_ME);
}
public boolean resetBladeTime(String token, String serialNumber) {
return apiPost("%s/%s/counters/blade/reset".formatted(URL_PRODUCT_ITEMS, serialNumber), token);
}
@@ -1,32 +0,0 @@
/*
* Copyright (c) 2010-2026 Contributors to the openHAB project
*
* See the NOTICE file(s) distributed with this work for additional
* information.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.worxlandroid.internal.api.dto;
import org.eclipse.jdt.annotation.NonNullByDefault;
/**
* The {@link UsersMeResponse} class
*
* @author Nils Billing - Initial contribution
*
*/
@NonNullByDefault
public class UsersMeResponse {
public String id = "";
public String userType = "";
public boolean pushNotifications;
public String location = "";
public String actionsOnGooglePinCode = "";
public String createdAt = "";
public String updatedAt = "";
}
@@ -22,7 +22,6 @@ import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.worxlandroid.internal.api.WebApiException;
import org.openhab.binding.worxlandroid.internal.api.WorxApiHandler;
import org.openhab.binding.worxlandroid.internal.api.dto.ProductItemStatus;
import org.openhab.binding.worxlandroid.internal.api.dto.UsersMeResponse;
import org.openhab.binding.worxlandroid.internal.config.WebApiConfiguration;
import org.openhab.core.auth.client.oauth2.AccessTokenRefreshListener;
import org.openhab.core.auth.client.oauth2.AccessTokenResponse;
@@ -100,12 +99,9 @@ public class WorxLandroidBridgeHandler extends BaseBridgeHandler
.getAccessToken();
if (token != null) {
accessToken = token;
UsersMeResponse user = apiHandler.retrieveMe(accessToken);
updateProperties(apiHandler.getDeserializer().toMap(user));
updateStatus(ThingStatus.ONLINE);
}
} catch (IOException | WebApiException e) {
} catch (IOException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR, e.getMessage());
} catch (OAuthResponseException e) {
updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR, "@text/oauth-connection-error");