get contacts endpoint
This commit is contained in:
		
							parent
							
								
									5ba6dcedf3
								
							
						
					
					
						commit
						d481981395
					
				
					 1 changed files with 29 additions and 14 deletions
				
			
		| 
						 | 
				
			
			@ -49,6 +49,7 @@ class ApiService {
 | 
			
		|||
      return [];
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  Future<List<GetThreadResponse>> fetchEmailsFromFolderReversed(
 | 
			
		||||
      String folder, int pagenitaion) async {
 | 
			
		||||
    try {
 | 
			
		||||
| 
						 | 
				
			
			@ -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 = {
 | 
			
		||||
| 
						 | 
				
			
			@ -234,7 +235,8 @@ class ApiService {
 | 
			
		|||
          return true;
 | 
			
		||||
        } else {
 | 
			
		||||
          print('error ${response.statusCode} ${response.body}');
 | 
			
		||||
      }}
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    } catch (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 {
 | 
			
		||||
    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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue