]> git.basschouten.com Git - openhab-addons.git/blob
cb0fd28ba4a7d8e4c3f8a8e565b63f4c0b01c42f
[openhab-addons.git] /
1 /*
2  * Copyright 2017 Gregory Moyer
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 package org.openhab.binding.sleepiq.api;
17
18 import java.net.URI;
19 import java.util.logging.Level;
20
21 /**
22  * This class represents configuration parameters for using {@link SleepIQ}.
23  *
24  * @author Gregory Moyer
25  */
26 public class Configuration
27 {
28     private String username;
29     private String password;
30
31     private URI baseUri = URI.create("https://api.sleepiq.sleepnumber.com/rest");
32
33     private boolean logging = false;
34
35     /**
36      * Get the username on the account.
37      *
38      * @return the username
39      */
40     public String getUsername()
41     {
42         return username;
43     }
44
45     /**
46      * Set the username on the account. This should be the username used to
47      * register with SleepIQ.
48      *
49      * @param username
50      *            the value to set
51      */
52     public void setUsername(String username)
53     {
54         this.username = username;
55     }
56
57     /**
58      * Set the username on the account. This should be the username used to
59      * register with SleepIQ.
60      *
61      * @param username
62      *            the value to set
63      * @return this configuration instance
64      */
65     public Configuration withUsername(String username)
66     {
67         setUsername(username);
68         return this;
69     }
70
71     /**
72      * Get the password on the account.
73      *
74      * @return the password
75      */
76     public String getPassword()
77     {
78         return password;
79     }
80
81     /**
82      * Set the password on the account. This should be the password used to
83      * register with SleepIQ.
84      *
85      * @param password
86      *            the value to set
87      */
88     public void setPassword(String password)
89     {
90         this.password = password;
91     }
92
93     /**
94      * Set the password on the account. This should be the password used to
95      * register with SleepIQ.
96      *
97      * @param password
98      *            the value to set
99      * @return this configuration instance
100      */
101     public Configuration withPassword(String password)
102     {
103         setPassword(password);
104         return this;
105     }
106
107     /**
108      * Get the base URI of the SleepIQ cloud service.
109      *
110      * @return the base URI
111      */
112     public URI getBaseUri()
113     {
114         return baseUri;
115     }
116
117     /**
118      * Set the base URI of the SleepIQ cloud service. It is unlikely that this
119      * will need to be changed from its default value.
120      *
121      * @param baseUri
122      *            the value to set
123      */
124     public void setBaseUri(URI baseUri)
125     {
126         this.baseUri = baseUri;
127     }
128
129     /**
130      * Set the base URI of the SleepIQ cloud service. It is unlikely that this
131      * will need to be changed from its default value.
132      *
133      * @param baseUri
134      *            the value to set
135      * @return this configuration instance
136      */
137     public Configuration withBaseUri(URI baseUri)
138     {
139         setBaseUri(baseUri);
140         return this;
141     }
142
143     /**
144      * Get the logging flag.
145      *
146      * @return the logging flag
147      */
148     public boolean isLogging()
149     {
150         return logging;
151     }
152
153     /**
154      * Set the logging flag. When this is set to <code>true</code>, all requests
155      * and responses will be logged at the {@link Level#INFO} level. <b>This
156      * includes usernames and passwords!</b>
157      *
158      * @param logging
159      *            the value to set
160      */
161     public void setLogging(boolean logging)
162     {
163         this.logging = logging;
164     }
165
166     /**
167      * Set the logging flag. When this is set to <code>true</code>, all requests
168      * and responses will be logged at the {@link Level#INFO} level. <b>This
169      * includes usernames and passwords!</b>
170      *
171      * @param logging
172      *            the value to set
173      * @return this configuration instance
174      */
175     public Configuration withLogging(boolean logging)
176     {
177         setLogging(logging);
178         return this;
179     }
180 }