Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/improvement/push-notification'…
Browse files Browse the repository at this point in the history
… into improvement/push-notification
  • Loading branch information
vvlladd28 committed Feb 20, 2024
2 parents 4c8144b + 578b3a5 commit ed55c6f
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions lib/src/service/user_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import 'dart:convert';

import 'package:dio/dio.dart';

import '../thingsboard_client_base.dart';
import '../http/http_utils.dart';
import '../model/model.dart';
import '../thingsboard_client_base.dart';

PageData<User> parseUserPageData(Map<String, dynamic> json) {
return PageData.fromJson(json, (json) => User.fromJson(json));
Expand Down Expand Up @@ -228,11 +228,12 @@ class UserService {

Future<MobileSessionInfo?> getMobileSession(String mobileToken,
{RequestConfig? requestConfig}) async {
var options = defaultHttpOptionsFromConfig(requestConfig);
final options = defaultHttpOptionsFromConfig(requestConfig);
options.headers?[MOBILE_TOKEN_HEADER] = mobileToken;
var response = await _tbClient.get<Map<String, dynamic>>(
'/api/user/mobile/session',
options: options);
final response = await _tbClient.get(
'/api/user/mobile/session',
options: options,
);
return response.data != null
? MobileSessionInfo.fromJson(response.data!)
: null;
Expand All @@ -241,16 +242,22 @@ class UserService {
Future<void> saveMobileSession(
String mobileToken, MobileSessionInfo sessionInfo,
{RequestConfig? requestConfig}) async {
var options = defaultHttpOptionsFromConfig(requestConfig);
final options = defaultHttpOptionsFromConfig(requestConfig);
options.headers?[MOBILE_TOKEN_HEADER] = mobileToken;
await _tbClient.post<void>('/api/user/mobile/session',
data: jsonEncode(sessionInfo), options: options);
await _tbClient.post<void>(
'/api/user/mobile/session',
data: jsonEncode(sessionInfo),
options: options,
);
}

Future<void> removeMobileSession(String mobileToken,
{RequestConfig? requestConfig}) async {
var options = defaultHttpOptionsFromConfig(requestConfig);
final options = defaultHttpOptionsFromConfig(requestConfig);
options.headers?[MOBILE_TOKEN_HEADER] = mobileToken;
await _tbClient.delete<void>('/api/user/mobile/session', options: options);
await _tbClient.delete<void>(
'/api/user/mobile/session',
options: options,
);
}
}

0 comments on commit ed55c6f

Please sign in to comment.