2 * Copyright (c) 2010-2022 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.hydrawise.internal.api.local;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
18 * The {@link HydrawiseZoneCommandBuilder} class builds a command URL string to use when sending commands to the
19 * Hydrawise local controller or cloud based API server
21 * @author Dan Cunningham - Initial contribution
25 class HydrawiseZoneCommandBuilder {
27 private final StringBuilder builder;
30 * Construct a new {@link HydrawiseZoneCommandBuilder} class with a base URL
34 public HydrawiseZoneCommandBuilder(String baseURL) {
35 builder = new StringBuilder(baseURL);
39 * Construct a new {@link HydrawiseZoneCommandBuilder} class with a base URL and API key.
44 public HydrawiseZoneCommandBuilder(String baseURL, String apiKey) {
46 builder.append("&api_key=" + apiKey);
50 * Sets the action parameter
53 * @return {@link HydrawiseZoneCommandBuilder}
55 public HydrawiseZoneCommandBuilder action(String action) {
56 builder.append("&action=" + action);
61 * Sets the relayId parameter
64 * @return {@link HydrawiseZoneCommandBuilder}
66 public HydrawiseZoneCommandBuilder relayId(int relayId) {
67 builder.append("&relay_id=" + relayId);
72 * Sets the relay number parameter
75 * @return {@link HydrawiseZoneCommandBuilder}
77 public HydrawiseZoneCommandBuilder relayNumber(int number) {
78 builder.append("&relay=" + number);
83 * Sets the run duration parameter
86 * @return {@link HydrawiseZoneCommandBuilder}
88 public HydrawiseZoneCommandBuilder duration(int seconds) {
89 builder.append("&custom=" + seconds);
94 * Sets the controller Id parameter
97 * @return {@link HydrawiseZoneCommandBuilder}
99 public HydrawiseZoneCommandBuilder controllerId(int controllerId) {
100 builder.append("&controller_id=" + controllerId);
105 public String toString() {
106 return builder.toString();