99
1010
1111@app .route ('/api/customer/list' )
12- def list_customers (): # put application's code here
12+ def list_customers ():
1313 db_cursor .execute ("SELECT * FROM customer" )
1414 records = db_cursor .fetchall ()
1515 return {"data" : records }
1616
1717
18- @app .route ('/api/customer/list/<int:pk >' )
19- def get_customer (pk ): # put application's code here
20- db_cursor .execute (f"SELECT * FROM customer WHERE id = { pk } " )
18+ @app .route ('/api/customer/list/<int:customer_id >' )
19+ def get_customer (customer_id ):
20+ db_cursor .execute (f"SELECT * FROM customer WHERE id = { customer_id } " )
2121 record = db_cursor .fetchone ()
2222 return {"data" : record }
2323
@@ -31,15 +31,10 @@ def create_customer():
3131 db_connection .commit ()
3232 return {"message" : "Customer created successfully." }
3333
34- def call_log_for_num (phn_num ):
35- db_cursor .execute (f"SELECT * "
36- f"FROM call"
37- f"INNER JOIN WHERE phone_id IN (SELECT id FROM phone WHERE mobile_number = { phn_num } )" )
38- call_log = db_cursor .fetchall ()
39- return call_log
40-
4134# plan (phone number)
4235
36+
37+ @app .route ('/api/phone/plan/<int:phn_num>' )
4338def plan_for_num (phn_num ):
4439 db_cursor .execute (f"SELECT * "
4540 f"FROM plan "
@@ -48,6 +43,7 @@ def plan_for_num(phn_num):
4843 plan = db_cursor .fetchone ()
4944 return plan
5045
46+ @app .route ('/api/phone/customer/<int:phn_num>' )
5147def profile_of_customer (phn_num ):
5248 db_cursor .execute (f"SELECT * "
5349 f"FROM customer "
@@ -56,13 +52,70 @@ def profile_of_customer(phn_num):
5652 profile = db_cursor .fetchone ()
5753 return profile
5854
55+ @app .route ('/api/phone/sms/<int:phn_num>' )
5956def sms_log_for_num (phn_num ):
6057 db_cursor .execute (f"SELECT * "
6158 f"FROM sms "
62- f"INNER JOIN phone ON sms.phone_id IN (SELECT id FROM phone WHERE mobile_number = { phn_num } )" )
59+ f"INNER JOIN phone ON sms.from_id=phone.id OR sms.to_id=phone.id "
60+ f"WHERE phone.id IN (SELECT id FROM phone WHERE mobile_number = { phn_num } )" )
6361 sms_log = db_cursor .fetchall ()
6462 return sms_log
6563
64+ @app .route ('/api/phone/call/<int:phn_num>' )
65+ def call_log_for_num (phn_num ):
66+ db_cursor .execute (f"SELECT * "
67+ f"FROM call "
68+ f"INNER JOIN phone "
69+ f"ON call.from_id=phone.id OR call.to_id=phone.id "
70+ f"WHERE phone.id IN (SELECT id FROM phone WHERE mobile_number = { phn_num } )" )
71+ call_log = db_cursor .fetchall ()
72+ return call_log
73+
74+ @app .route ('/api/plan/list' )
75+ def get_all_plans ():
76+ db_cursor .execute ("SELECT * FROM plan" )
77+ plans = db_cursor .fetchall ()
78+ return plans
79+
80+ @app .route ('/api/phone/data/<int:phn_num>' )
81+ def data_log_for_num (phn_num ):
82+ db_cursor .execute (f"SELECT * "
83+ f"FROM data_log "
84+ f"INNER JOIN phone "
85+ f"ON data_log.phone_data=phone.id "
86+ f"WHERE phone.id IN (SELECT id FROM phone WHERE mobile_number = { phn_num } )" )
87+ data_log = db_cursor .fetchall ()
88+ return data_log
89+
90+ @app .route ('/api/phone/mms/<int:phn_num>' )
91+ def mms_log_for_num (phn_num ):
92+ db_cursor .execute (f"SELECT * "
93+ f"FROM mms "
94+ f"INNER JOIN phone "
95+ f"ON mms.from_id=phone.id OR mms.to_id=phone.id "
96+ f"WHERE phone.id IN (SELECT id FROM phone WHERE mobile_number = { phn_num } )" )
97+ mms_log = db_cursor .fetchall ()
98+ return mms_log
99+
100+ @app .route ('/api/employee/list/<int:phn_num>' )
101+ def employee_profile (emp_id ):
102+ db_cursor .execute (f"SELECT * FROM employee WHERE id = { emp_id } " )
103+ profile = db_cursor .fetchone ()
104+ return profile
105+
106+ @app .route ('/api/plan/create' , methods = ['POST' ])
107+ def create_plan (plan_validity , plan_value , plan_type , plan_cost ):
108+ db_cursor .execute (f"INSERT INTO plan (validity, value, type, cost) VALUES ({ plan_validity } , { plan_value } , { plan_type } , { plan_cost } )" )
109+ db_connection .commit ()
110+ return {"message" : "Plan created successfully." }
111+
112+ @app .route ('/api/tickets/list/<int:phn_num>' )
113+ def return_all_active_tickets ():
114+ db_cursor .execute ("SELECT * FROM ticket WHERE status = false" )
115+ tickets = db_cursor .fetchall ()
116+ return tickets
117+
118+
66119if __name__ == '__main__' :
67120 port = os .getenv ('PORT' , '8000' )
68121 app .run (debug = False , host = '0.0.0.0' , port = int (port ))
@@ -72,14 +125,14 @@ def sms_log_for_num(phn_num):
72125# // kyc checker/signup and login
73126# // customer features
74127# // ticket radio for tower or phone
75- # //call log for a particular customer (phone number)
76- # //plan (phone number)
128+ # //call log for a particular customer (phone number)(done)
129+ # //plan (phone number)(done)
77130# //payment(no sense)
78- # //profile(every detail about the customer holding the phone number)(phone number)
79- # //sms that a phone number has received or sent (phone number)
80- # //call (from ka number, to ka number, duration)
81- # //data log (from ka number, to ka number, duration)
82- # //mms log (from ka number, to ka number, duration)
131+ # //profile(every detail about the customer holding the phone number)(phone number)(done but I need all the number related to that person)
132+ # //sms that a phone number has received or sent (phone number)(done)
133+ # //call (from ka number, to ka number, duration)(phone number)(done)
134+ # //data log (from ka number, to ka number, duration)(phone number)(done)
135+ # //mms log (from ka number, to ka number, duration)(phone number)(done)
83136#
84137# // employee features
85138# //create plan(all except id)
0 commit comments