]> git.basschouten.com Git - openhab-addons.git/blob
591a0c5bc2bb08a2ea31968dcf51fda02d3c22f1
[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.homeconnect.internal.client.model;
14
15 import static org.openhab.binding.homeconnect.internal.HomeConnectBindingConstants.API_BASE_URL;
16 import static org.openhab.binding.homeconnect.internal.HomeConnectBindingConstants.API_SIMULATOR_BASE_URL;
17
18 import java.util.Map;
19
20 import org.eclipse.jdt.annotation.NonNullByDefault;
21 import org.eclipse.jdt.annotation.Nullable;
22
23 /**
24  *
25  * HTTP request model.
26  *
27  * @author Jonas BrĂ¼stel - Initial Contribution
28  */
29 @NonNullByDefault
30 public class HomeConnectRequest {
31     private final String url;
32     private final String method;
33     private final Map<String, String> header;
34     private @Nullable final String body;
35
36     public HomeConnectRequest(String url, String method, Map<String, String> header, @Nullable String body) {
37         this.url = url;
38         this.method = method;
39         this.header = header;
40         this.body = body;
41     }
42
43     public String getUrl() {
44         return url;
45     }
46
47     public String getShortUrl() {
48         return url.replace(API_BASE_URL, "").replace(API_SIMULATOR_BASE_URL, "");
49     }
50
51     public String getMethod() {
52         return method;
53     }
54
55     public Map<String, String> getHeader() {
56         return header;
57     }
58
59     public @Nullable String getBody() {
60         return body;
61     }
62
63     @Override
64     public String toString() {
65         return "Request [url=" + url + ", method=" + method + ", header=" + header + ", body=" + body + "]";
66     }
67 }