]> git.basschouten.com Git - openhab-addons.git/blob
384d9451f921d9d8176bad72c81786d13ac1c0cc
[openhab-addons.git] /
1 /**
2  * Copyright (c) 2010-2023 Contributors to the openHAB project
3  *
4  * See the NOTICE file(s) distributed with this work for additional
5  * information.
6  *
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
10  *
11  * SPDX-License-Identifier: EPL-2.0
12  */
13 package org.openhab.binding.easee.internal.command.site;
14
15 import static org.openhab.binding.easee.internal.EaseeBindingConstants.*;
16
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jetty.client.api.Request;
19 import org.eclipse.jetty.http.HttpMethod;
20 import org.openhab.binding.easee.internal.command.AbstractCommand;
21 import org.openhab.binding.easee.internal.command.JsonResultProcessor;
22 import org.openhab.binding.easee.internal.handler.EaseeBridgeHandler;
23
24 /**
25  * implements the get sites api call of the site.
26  *
27  * @author Alexander Friese - initial contribution
28  */
29 @NonNullByDefault
30 public class GetSite extends AbstractCommand {
31
32     public GetSite(EaseeBridgeHandler handler, JsonResultProcessor resultProcessor) {
33         // retry does not make much sense as it is a polling command, command should always succeed therefore update
34         // handler on failure.
35         super(handler, RetryOnFailure.NO, ProcessFailureResponse.YES, resultProcessor);
36     }
37
38     @Override
39     protected Request prepareRequest(Request requestToPrepare) {
40         requestToPrepare.method(HttpMethod.GET);
41         return requestToPrepare;
42     }
43
44     @Override
45     protected String getURL() {
46         String url = GET_SITE_URL;
47         url = url.replaceAll("\\{siteId\\}", handler.getBridgeConfiguration().getSiteId());
48         return url;
49     }
50
51     @Override
52     protected String getChannelGroup() {
53         return CHANNEL_GROUP_SITE_INFO;
54     }
55 }