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.vesync.internal.dto.requests;
15 import org.openhab.binding.vesync.internal.dto.responses.VeSyncUserSession;
16 import org.openhab.binding.vesync.internal.exceptions.AuthenticationException;
18 import com.google.gson.annotations.SerializedName;
21 * The {@link VeSyncAuthenticatedRequest} is a Java class used as a DTO to hold the Vesync's API's common request data.
23 * @author David Goodyear - Initial contribution
25 public class VeSyncAuthenticatedRequest extends VeSyncRequest {
27 @SerializedName("accountID")
28 public String accountId;
30 @SerializedName("token")
33 public VeSyncAuthenticatedRequest() {
37 public VeSyncAuthenticatedRequest(final VeSyncUserSession user) throws AuthenticationException {
40 throw new AuthenticationException("User is not logged in");
42 this.token = user.getToken();
43 this.accountId = user.getAccountId();
46 public void applyAuthentication(final VeSyncUserSession userSession) throws AuthenticationException {
47 if (userSession == null) {
48 throw new AuthenticationException("User is not logged in");
50 this.accountId = userSession.getAccountId();
51 this.token = userSession.getToken();