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.spotify.internal;
15 import java.util.List;
17 import org.eclipse.jdt.annotation.NonNullByDefault;
18 import org.openhab.binding.spotify.internal.api.model.Device;
19 import org.openhab.core.thing.ThingUID;
20 import org.openhab.core.thing.binding.ThingHandler;
23 * Interface to decouple Spotify Bridge Handler implementation from other code.
25 * @author Hilbrand Bouwkamp - Initial contribution
28 public interface SpotifyAccountHandler extends ThingHandler {
31 * @return The {@link ThingUID} associated with this Spotify Account Handler
36 * @return The label of the Spotify Bridge associated with this Spotify Account Handler
41 * @return The Spotify user name associated with this Spotify Account Handler
46 * @return Returns true if the Spotify Bridge is authorized.
48 boolean isAuthorized();
51 * @return List of Spotify devices associated with this Spotify Account Handler
53 List<Device> listDevices();
56 * @return Returns true if the device is online
61 * Calls Spotify Api to obtain refresh and access tokens and persist data with Thing.
63 * @param redirectUrl The redirect url Spotify calls back to
64 * @param reqCode The unique code passed by Spotify to obtain the refresh and access tokens
65 * @return returns the name of the Spotify user that is authorized
67 String authorize(String redirectUrl, String reqCode);
70 * Returns true if the given Thing UID relates to this {@link SpotifyAccountHandler} instance.
72 * @param thingUID The Thing UID to check
73 * @return true if it relates to the given Thing UID
75 boolean equalsThingUID(String thingUID);
78 * Formats the Url to use to call Spotify to authorize the application.
80 * @param redirectUri The uri Spotify will redirect back to
81 * @return the formatted url that should be used to call Spotify Web Api with
83 String formatAuthorizationUrl(String redirectUri);