2 * Copyright (c) 2010-2021 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;
16 * The {@link HydrawiseZoneCommandBuilder} class builds a command URL string to use when sending commands to the
17 * Hydrawise local controller or cloud based API server
19 * @author Dan Cunningham - Initial contribution
22 class HydrawiseZoneCommandBuilder {
24 private final StringBuilder builder;
27 * Construct a new {@link HydrawiseZoneCommandBuilder} class with a base URL
31 public HydrawiseZoneCommandBuilder(String baseURL) {
32 builder = new StringBuilder(baseURL);
36 * Construct a new {@link HydrawiseZoneCommandBuilder} class with a base URL and API key.
41 public HydrawiseZoneCommandBuilder(String baseURL, String apiKey) {
43 builder.append("&api_key=" + apiKey);
47 * Sets the action parameter
50 * @return {@link HydrawiseZoneCommandBuilder}
52 public HydrawiseZoneCommandBuilder action(String action) {
53 builder.append("&action=" + action);
58 * Sets the relayId parameter
61 * @return {@link HydrawiseZoneCommandBuilder}
63 public HydrawiseZoneCommandBuilder relayId(int relayId) {
64 builder.append("&relay_id=" + relayId);
69 * Sets the relay number parameter
72 * @return {@link HydrawiseZoneCommandBuilder}
74 public HydrawiseZoneCommandBuilder relayNumber(int number) {
75 builder.append("&relay=" + number);
80 * Sets the run duration parameter
83 * @return {@link HydrawiseZoneCommandBuilder}
85 public HydrawiseZoneCommandBuilder duration(int seconds) {
86 builder.append("&custom=" + seconds);
91 * Sets the controller Id parameter
94 * @return {@link HydrawiseZoneCommandBuilder}
96 public HydrawiseZoneCommandBuilder controllerId(int controllerId) {
97 builder.append("&controller_id=" + controllerId);
102 public String toString() {
103 return builder.toString();