2 * Copyright (c) 2010-2023 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.jellyfin.internal.util;
15 import org.eclipse.jdt.annotation.NonNullByDefault;
16 import org.jellyfin.sdk.api.client.Response;
17 import org.jellyfin.sdk.api.client.exception.ApiClientException;
20 * The {@link SyncResponse} util to consume sdk api calls.
22 * @author Miguel Álvarez - Initial contribution
25 public class SyncResponse<T> extends SyncCallback<Response<T>> {
26 public Response<T> awaitResponse() throws ApiClientException, SyncCallbackError {
29 } catch (SyncCallbackError e) {
30 var cause = e.getCause();
31 if (cause instanceof ApiClientException) {
32 throw (ApiClientException) cause;
38 public T awaitContent() throws ApiClientException, SyncCallbackError {
39 var responseContent = awaitResponse().getContent();
40 if (responseContent == null) {
41 throw new SyncCallbackError("Missing content");
43 return responseContent;