get contacts endpoint
This commit is contained in:
parent
5ba6dcedf3
commit
d481981395
@ -49,6 +49,7 @@ class ApiService {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<List<GetThreadResponse>> fetchEmailsFromFolderReversed(
|
Future<List<GetThreadResponse>> fetchEmailsFromFolderReversed(
|
||||||
String folder, int pagenitaion) async {
|
String folder, int pagenitaion) async {
|
||||||
try {
|
try {
|
||||||
@ -82,6 +83,7 @@ class ApiService {
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> fetchThreads(
|
Future<void> fetchThreads(
|
||||||
//populates allEmails, which is the List that contains all the emails in a thread
|
//populates allEmails, which is the List that contains all the emails in a thread
|
||||||
int threadId,
|
int threadId,
|
||||||
@ -214,7 +216,6 @@ class ApiService {
|
|||||||
|
|
||||||
// SerializableMessage firstMail = mailsInSerializable[0];
|
// SerializableMessage firstMail = mailsInSerializable[0];
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (SerializableMessage mail in mailsInSerializable) {
|
for (SerializableMessage mail in mailsInSerializable) {
|
||||||
Map<String, String> requestBody = {
|
Map<String, String> requestBody = {
|
||||||
@ -223,18 +224,19 @@ class ApiService {
|
|||||||
'to': "Deleted Crabmail",
|
'to': "Deleted Crabmail",
|
||||||
};
|
};
|
||||||
var response = await http.post(
|
var response = await http.post(
|
||||||
url,
|
url,
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: jsonEncode(requestBody),
|
body: jsonEncode(requestBody),
|
||||||
);
|
);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
print('response body ${response.body}');
|
print('response body ${response.body}');
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
print('error ${response.statusCode} ${response.body}');
|
print('error ${response.statusCode} ${response.body}');
|
||||||
}}
|
}
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
print("failed trying to post move_email, with error: $e");
|
print("failed trying to post move_email, with error: $e");
|
||||||
}
|
}
|
||||||
@ -252,6 +254,17 @@ class ApiService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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 {
|
Future<void> createFolder(String folderName) async {
|
||||||
var url = Uri.http('$ip:$port', 'create_folder');
|
var url = Uri.http('$ip:$port', 'create_folder');
|
||||||
|
|
||||||
@ -416,6 +429,7 @@ class ApiService {
|
|||||||
try {
|
try {
|
||||||
var url = Uri.http(
|
var url = Uri.http(
|
||||||
'$ip:$port', 'post_seen_thread', {'id': thread_id.toString()});
|
'$ip:$port', 'post_seen_thread', {'id': thread_id.toString()});
|
||||||
|
print("url: $url");
|
||||||
var response = await http.get(url);
|
var response = await http.get(url);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
var result = response.body;
|
var result = response.body;
|
||||||
@ -430,6 +444,7 @@ class ApiService {
|
|||||||
try {
|
try {
|
||||||
var url = Uri.http(
|
var url = Uri.http(
|
||||||
'$ip:$port', 'post_unseen_thread', {'id': thread_id.toString()});
|
'$ip:$port', 'post_unseen_thread', {'id': thread_id.toString()});
|
||||||
|
print("url: $url");
|
||||||
var response = await http.get(url);
|
var response = await http.get(url);
|
||||||
if (response.statusCode == 200) {
|
if (response.statusCode == 200) {
|
||||||
var result = response.body;
|
var result = response.body;
|
||||||
|
Loading…
Reference in New Issue
Block a user