get contacts endpoint

This commit is contained in:
Juan Marulanda De Los Rios 2025-08-30 01:10:27 -04:00
parent 5ba6dcedf3
commit d481981395

View File

@ -49,6 +49,7 @@ class ApiService {
return [];
}
}
Future<List<GetThreadResponse>> fetchEmailsFromFolderReversed(
String folder, int pagenitaion) async {
try {
@ -57,7 +58,7 @@ class ApiService {
'limit': '50',
'offset': pagenitaion.toString(),
});
var response = await http.get(url);
List<GetThreadResponse> allEmails = [];
@ -82,6 +83,7 @@ class ApiService {
return [];
}
}
Future<void> fetchThreads(
//populates allEmails, which is the List that contains all the emails in a thread
int threadId,
@ -214,7 +216,6 @@ class ApiService {
// SerializableMessage firstMail = mailsInSerializable[0];
try {
for (SerializableMessage mail in mailsInSerializable) {
Map<String, String> requestBody = {
@ -223,18 +224,19 @@ class ApiService {
'to': "Deleted Crabmail",
};
var response = await http.post(
url,
headers: {
'Content-Type': 'application/json',
},
body: jsonEncode(requestBody),
);
if (response.statusCode == 200) {
print('response body ${response.body}');
return true;
} else {
print('error ${response.statusCode} ${response.body}');
}}
url,
headers: {
'Content-Type': 'application/json',
},
body: jsonEncode(requestBody),
);
if (response.statusCode == 200) {
print('response body ${response.body}');
return true;
} else {
print('error ${response.statusCode} ${response.body}');
}
}
} catch (e) {
print("failed trying to post move_email, with error: $e");
}
@ -251,6 +253,17 @@ class ApiService {
return [];
}
}
Future<List<String>> fetchContacts() async {
try {
var url = Uri.http('$ip:$port', 'get_contacts');
var response = await http.get(url);
return List<String>.from(json.decode(response.body));
} catch (e) {
print('fetchFolders caught error: $e');
return [];
}
}
Future<void> createFolder(String folderName) async {
var url = Uri.http('$ip:$port', 'create_folder');
@ -416,6 +429,7 @@ class ApiService {
try {
var url = Uri.http(
'$ip:$port', 'post_seen_thread', {'id': thread_id.toString()});
print("url: $url");
var response = await http.get(url);
if (response.statusCode == 200) {
var result = response.body;
@ -430,6 +444,7 @@ class ApiService {
try {
var url = Uri.http(
'$ip:$port', 'post_unseen_thread', {'id': thread_id.toString()});
print("url: $url");
var response = await http.get(url);
if (response.statusCode == 200) {
var result = response.body;