]> git.basschouten.com Git - openhab-addons.git/blob
b43fddf40312be7747f7a7f53583cfe547d72bf1
[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.spotify.internal;
14
15 import java.util.List;
16
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;
21
22 /**
23  * Interface to decouple Spotify Bridge Handler implementation from other code.
24  *
25  * @author Hilbrand Bouwkamp - Initial contribution
26  */
27 @NonNullByDefault
28 public interface SpotifyAccountHandler extends ThingHandler {
29
30     /**
31      * @return The {@link ThingUID} associated with this Spotify Account Handler
32      */
33     ThingUID getUID();
34
35     /**
36      * @return The label of the Spotify Bridge associated with this Spotify Account Handler
37      */
38     String getLabel();
39
40     /**
41      * @return The Spotify user name associated with this Spotify Account Handler
42      */
43     String getUser();
44
45     /**
46      * @return Returns true if the Spotify Bridge is authorized.
47      */
48     boolean isAuthorized();
49
50     /**
51      * @return List of Spotify devices associated with this Spotify Account Handler
52      */
53     List<Device> listDevices();
54
55     /**
56      * @return Returns true if the device is online
57      */
58     boolean isOnline();
59
60     /**
61      * Calls Spotify Api to obtain refresh and access tokens and persist data with Thing.
62      *
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
66      */
67     String authorize(String redirectUrl, String reqCode);
68
69     /**
70      * Returns true if the given Thing UID relates to this {@link SpotifyAccountHandler} instance.
71      *
72      * @param thingUID The Thing UID to check
73      * @return true if it relates to the given Thing UID
74      */
75     boolean equalsThingUID(String thingUID);
76
77     /**
78      * Formats the Url to use to call Spotify to authorize the application.
79      *
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
82      */
83     String formatAuthorizationUrl(String redirectUri);
84 }