File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/python3
2
+ """get all information about all user and their completed task
3
+ and get all the information about the user and the todo taska and
4
+ the todos task which the user have not done.
5
+ You cannot kill me with documentation"""
6
+ import json
7
+ import requests
8
+
9
+ if __name__ == "__main__" :
10
+ data = {}
11
+ for i in range (1 , 11 ):
12
+ id = i
13
+ url = "https://jsonplaceholder.typicode.com"
14
+ res = requests .get ('{}/users/{}' .format (url , id )).json ()
15
+ res_todo = requests .get ("{}/todos" .format (url ),
16
+ params = {"userId" : id }).json ()
17
+ name = res .get ("username" )
18
+ user_data = list (map (
19
+ lambda x : {
20
+ "task" : x .get ("title" ),
21
+ "completed" : x .get ("completed" ),
22
+ "username" : name
23
+ },
24
+ res_todo
25
+ ))
26
+ data ["{}" .format (id )] = user_data
27
+ with open ('todo_all_employees.json' , 'w' ) as apidata :
28
+ json .dump (data , apidata )
You can’t perform that action at this time.
0 commit comments