Example #1
0
	def get(self, request, pk_1=None):
		phone_no = str(pk_1)
		otp_recv = request.GET.get('token','0')
		if verify_otp(phone_no, otp_recv):
			return Response (getProducts())
		else:
			return Response({'data' : 'Unauthorized'}, status=status.HTTP_401_UNAUTHORIZED)
Example #2
0
	def get(self, request):
		phone_no = request.GET.get('phone_number','0')
		otp_recv = request.GET.get('token','0')
		if verify_otp(phone_no, otp_recv):
			user_info = getUser(phone_no)
			for key in user_info.keys():
				user_info[key] = str(user_info[key])
			return Response (user_info)
		else:
			return Response({'data' : 'Unauthorized'}, status=status.HTTP_401_UNAUTHORIZED)
Example #3
0
	def post(self,request,pk_1=None):
		group_json  = request.data
		otp_recv = group_json['token']
		if verify_otp(str(pk_1), otp_recv):
			if createGroup(pk_1, group_json['name']):
				return Response({'data': 'Group Saved'})
			else:
				return Response ({'data' : 'Group Data error'}, status=status.HTTP_400_BAD_REQUEST)
		else:
			return Response({'data' : 'Unauthorized'}, status=status.HTTP_401_UNAUTHORIZED)
Example #4
0
	def post(self,request,pk_1 = None):
		product_json  = request.data
		otp_recv = product_json['token']
		if verify_otp(str(pk_1), otp_recv):
			if createOrder(pk_1, product_json):
				return Response({'data': 'Order Saved'})
			else:
				return Response ({'data' : 'Order Data error'}, status=status.HTTP_400_BAD_REQUEST)
		else:
			return Response({'data' : 'Unauthorized'}, status=status.HTTP_401_UNAUTHORIZED)
Example #5
0
	def post(self,request,pk_1 = None, pk_2=None):
		order_json  = request.data
		print (order_json)
		otp_recv = order_json['token']
		order_json['order_id'] = pk_2
		if verify_otp(str(pk_1), otp_recv):
			if editOrder(pk_1, order_json):
				return Response({'data': 'Order Edited'})
			else:
				return Response ({'data' : 'Order Data error'}, status=status.HTTP_400_BAD_REQUEST)
		else:
			return Response({'data' : 'Unauthorized'}, status=status.HTTP_401_UNAUTHORIZED)
Example #6
0
	def post(self,request,pk_1 = None):
		customer_json  = request.data
		otp_recv = customer_json['token']
		if verify_otp(str(pk_1), otp_recv):
			customer_json['creator_id']=str(pk_1)
			customer_json['group_id'] = getGroupId(str(pk_1))
			if createCustomer(customer_json):
				return Response ({'data' : 'Customer Added'})

			else:
				return Response ({'data' : 'Customer with this Phone no. already exists'}, status=status.HTTP_400_BAD_REQUEST)
		else:
			return Response({'data' : 'Unauthorized'}, status=status.HTTP_401_UNAUTHORIZED)
Example #7
0
	def post(self,request,pk_1 = None,pk_2 = None):
		recv_json  = request.data
		otp_recv = recv_json['token']
		recv_json['data'] = user_json
		user_json['phone_number']=str(pk_2)
		user_json['created_by'] = str(pk_1)
		if verify_otp(str(pk_1), otp_recv):
			if createUser(user_json):
				return Response ({'data' : 'User Added'})

			else:
				return Response ({'data' : 'User Already Exists'})
		else:
			return Response({'data' : 'Unauthorized'}, status=status.HTTP_401_UNAUTHORIZED)