init
This commit is contained in:
@@ -16,24 +16,23 @@ class ApiService {
|
||||
if (_token != null) 'Authorization': 'Bearer $_token',
|
||||
};
|
||||
|
||||
Future<String> login(String username, String password) async {
|
||||
Future<bool> verifyToken(String token) async {
|
||||
final res = await http.post(
|
||||
Uri.parse('$_baseUrl/api/auth/login'),
|
||||
Uri.parse('$_baseUrl/api/auth/verify'),
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: jsonEncode({'username': username, 'password': password}),
|
||||
body: jsonEncode({'token': token}),
|
||||
);
|
||||
if (res.statusCode != 200) throw Exception(_error(res));
|
||||
return jsonDecode(res.body)['token'];
|
||||
return res.statusCode == 200;
|
||||
}
|
||||
|
||||
Future<String> register(String username, String password) async {
|
||||
final res = await http.post(
|
||||
Uri.parse('$_baseUrl/api/auth/register'),
|
||||
headers: {'Content-Type': 'application/json'},
|
||||
body: jsonEncode({'username': username, 'password': password}),
|
||||
Future<List<Map<String, dynamic>>> fetchServerSms() async {
|
||||
final res = await http.get(
|
||||
Uri.parse('$_baseUrl/api/sms?limit=999999'),
|
||||
headers: _headers,
|
||||
);
|
||||
if (res.statusCode != 201) throw Exception(_error(res));
|
||||
return jsonDecode(res.body)['token'];
|
||||
if (res.statusCode != 200) throw Exception(_error(res));
|
||||
final data = jsonDecode(res.body);
|
||||
return List<Map<String, dynamic>>.from(data['messages']);
|
||||
}
|
||||
|
||||
Future<int> uploadSms(List<SmsMessage> messages) async {
|
||||
|
||||
Reference in New Issue
Block a user