2 * Copyright (c) 2010-2024 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.salus.internal.rest;
15 import java.util.List;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.eclipse.jdt.annotation.Nullable;
21 * @author Martin GrzeĊlowski - Initial contribution
24 public interface RestClient {
26 * GET request to server
28 * @param url to send request
29 * @param headers to send
30 * @return response from server
33 String get(String url, @Nullable Header... headers) throws SalusApiException;
36 * POST request to server
38 * @param url to send request
39 * @param headers to send
40 * @param content to send
41 * @return response from server
44 String post(String url, Content content, @Nullable Header... headers) throws SalusApiException;
47 * Represents content with a body and a type.
49 record Content(String body, String type) {
51 * Creates a Content instance with the given body and default type ("application/json").
53 * @param body The content body.
55 public Content(String body) {
56 this(body, "application/json");
61 * Represents an HTTP header with a name and a list of values.
63 record Header(String name, List<String> values) {
65 * Creates a Header instance with the given name and a single value.
67 * @param name The header name.
68 * @param value The header value.
70 public Header(String name, String value) {
71 this(name, List.of(value));