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.gardena.internal.config;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.eclipse.jdt.annotation.Nullable;
19 * The main Gardena config class.
21 * @author Gerhard Riegler - Initial contribution
24 public class GardenaConfig {
25 private static final Integer DEFAULT_CONNECTION_TIMEOUT = 10;
27 private @Nullable String apiSecret;
28 private @Nullable String apiKey;
30 private transient Integer connectionTimeout = DEFAULT_CONNECTION_TIMEOUT;
32 public GardenaConfig() {
35 public GardenaConfig(String apiKey, String apiSecret) {
37 this.apiSecret = apiSecret;
41 * Returns the apiSecret to connect to Gardena smart system.
43 public @Nullable String getApiSecret() {
48 * Sets the apiSecret to connect to Gardena smart system.
50 public void setApiSecret(String apiSecret) {
51 this.apiSecret = apiSecret;
55 * Returns the connection timeout to Gardena smart system.
57 public Integer getConnectionTimeout() {
58 return connectionTimeout;
62 * Sets the connection timeout to Gardena smart system.
64 public void setConnectionTimeout(Integer connectionTimeout) {
65 this.connectionTimeout = connectionTimeout;
69 * Returns the api key.
71 public @Nullable String getApiKey() {
78 public void setApiKey(String apiKey) {
83 * Validate the config if email, password and apiKey is specified.
85 public boolean isValid() {
86 final String apiSecret = this.apiSecret;
87 final String apiKey = this.apiKey;
88 return apiSecret != null && !apiSecret.isBlank() && apiKey != null && !apiKey.isBlank();
92 public String toString() {
93 StringBuilder sb = new StringBuilder(GardenaConfig.class.getSimpleName()).append("[");
94 sb.append("connectionTimeout: ").append(connectionTimeout).append(", ");
95 sb.append("apiKey: ").append(apiKey);
96 return sb.append("]").toString();