2022-02-15 11:06:39 +00:00
|
|
|
import 'dart:convert';
|
|
|
|
import 'package:http/http.dart' as http;
|
|
|
|
import 'package:leg_barkr_app/utils/endpoints.dart' as Endpoints;
|
|
|
|
|
|
|
|
class AuthService{
|
2022-03-01 11:07:52 +00:00
|
|
|
Future<List<String>> getUserDevices(String uid) async {
|
2022-02-15 11:06:39 +00:00
|
|
|
final response = await http.get(
|
|
|
|
Uri.parse(Endpoints.getUserDevices),
|
|
|
|
headers: <String, String>{
|
|
|
|
'Content-Type': 'application/json; charset=UTF-8',
|
2022-03-01 11:07:52 +00:00
|
|
|
'UID': uid,
|
2022-02-15 11:06:39 +00:00
|
|
|
},
|
|
|
|
);
|
2022-02-15 11:52:19 +00:00
|
|
|
if (response.statusCode == 200){
|
|
|
|
List<dynamic> list = jsonDecode(response.body)['devices'];
|
|
|
|
List<String> res = [];
|
|
|
|
for (final l in list) {
|
|
|
|
res.add(l.toString());
|
|
|
|
}
|
|
|
|
return res;
|
|
|
|
} else{
|
|
|
|
return [];
|
2022-02-15 11:06:39 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|