refreshToken method

  1. @override
Future<bool> refreshToken(
  1. String? deviceIp
)
override

Implementation

@override
Future<bool> refreshToken(String? deviceIp) async {
  final fullPath = await rebuildUrl(deviceIp, "/api/user/v1.0/refresh_token.cgi", null);
  var rawResponse = await getResponse(false, fullPath, null, null);
  if (rawResponse is Map<String, dynamic> && isResponseSuccess(rawResponse)) {
    final data = (rawResponse as Map<String, dynamic>?)?["data"];
    DeviceRequestManager.resetTokenFromDeviceData(data);
    return true;
  } else {
    String code = rawResponse["code"] ?? ErrorCode.refreshTokenError.code;
    debugPrint(
      "refresh token failed, code: $code rawResponse: ${rawResponse.toString()}",
    );
    return false;
  }
}