1111import javax .crypto .Mac ;
1212import javax .crypto .spec .SecretKeySpec ;
1313import lombok .Getter ;
14+ import lombok .extern .slf4j .Slf4j ;
1415import okhttp3 .Response ;
15- import org .slf4j .Logger ;
16- import org .slf4j .LoggerFactory ;
1716
1817/** */
18+ @ Slf4j
1919@ Getter
2020public class SwitchBotApi {
21- private static final Logger logger = LoggerFactory .getLogger (SwitchBotApi .class );
2221 protected static final String baseUrl = "https://api.switch-bot.com/" ;
2322
2423 private static SwitchBotApi instance ;
@@ -38,7 +37,7 @@ private SwitchBotApi(String token, String secret) {
3837
3938 public static SwitchBotApi getInstance (String token , String secret ) {
4039 if (token == null || secret == null ) {
41- logger .error ("need to define token and secret values." );
40+ log .error ("need to define token and secret values." );
4241 throw new RuntimeException ("need to define token and secret values." );
4342 }
4443 return Optional .ofNullable (instance ).orElseGet (() -> {
@@ -67,7 +66,7 @@ protected RequestBuilderCallback addAuth() {
6766 .addHeader ("nonce" , nonce )
6867 .addHeader ("t" , time );
6968 } catch (NoSuchAlgorithmException | InvalidKeyException e ) {
70- logger .warn ("exception with auth: " , e );
69+ log .warn ("exception with auth: " , e );
7170 }
7271 return builder ;
7372 };
@@ -83,13 +82,13 @@ protected boolean checkForError(Response response, Optional<IApiResponse> apiRes
8382 return apiResponse
8483 .map (api -> {
8584 if (api .getStatusCode () != 100 ) {
86- logger .error ("error code: " + api .getStatusCode () + " : " + api .getMessage ());
85+ log .error ("error code: " + api .getStatusCode () + " : " + api .getMessage ());
8786 return false ;
8887 }
8988 return true ;
9089 })
9190 .orElseGet (() -> {
92- logger .error ("Error calling switchbot api: " + response .code () + " " + response .message ());
91+ log .error ("Error calling switchbot api: " + response .code () + " " + response .message ());
9392 return false ;
9493 });
9594 }
0 commit comments