move_email endpoint
This commit is contained in:
		
							parent
							
								
									b5cb5b99fb
								
							
						
					
					
						commit
						b2fd9d16cc
					
				
					 1 changed files with 27 additions and 5 deletions
				
			
		|  | @ -143,10 +143,32 @@ class ApiService { | |||
|     return content; | ||||
|   } | ||||
| 
 | ||||
|   // void _addMailBox async(BuildContext context){ | ||||
|   //   //add email folder | ||||
|   //   showDialog(context: context, builder: builder) | ||||
|   // } | ||||
|   Future<bool> moveEmail(String fromFolder, String uID, String toFolder) async { | ||||
|     var url = Uri.http('$ip:$port', 'move_email'); | ||||
|     Map<String, String> requestBody = { | ||||
|       'from': fromFolder, | ||||
|       'uid': uID, | ||||
|       'to': toFolder, | ||||
|     }; | ||||
|     try { | ||||
|       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 '); | ||||
|       } | ||||
|     } catch (e) { | ||||
|       print(e); | ||||
|     } | ||||
|     return false; | ||||
|   } | ||||
| 
 | ||||
|   Future<List<String>> fetchFolders() async { | ||||
|     try { | ||||
|  | @ -176,7 +198,7 @@ class ApiService { | |||
|         print('response body: ${response.body}'); | ||||
|       } else { | ||||
|         print('Error: ${response.statusCode}, response body: ${response.body}'); | ||||
|       }  | ||||
|       } | ||||
|     } catch (e) { | ||||
|       print('error making post req: $e'); | ||||
|     } | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue