本文整理匯總了Python中models.Customer.find_by_contact_number方法的典型用法代碼示例。如果您正苦於以下問題:Python Customer.find_by_contact_number方法的具體用法?Python Customer.find_by_contact_number怎麽用?Python Customer.find_by_contact_number使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models.Customer
的用法示例。
在下文中一共展示了Customer.find_by_contact_number方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get
# 需要導入模塊: from models import Customer [as 別名]
# 或者: from models.Customer import find_by_contact_number [as 別名]
def get(self, request):
"""
summary: This endpoint is called by the ASMX server. It then publishes a push notification of
the concerned agent on their cogent_agent_id
Auth: Doesn't require the auth token in request headers
---
serializer: CustomerDetailSerializer
parameters:
- name: contact_number
required: true
type: string
- name: forwarded_for
required: true
type: string
- name: agent_id
required: true
type: integer
"""
client, order = None, False
print "request from asmx server", request.query_params
# TODO Check for a B2B customer
try:
forwarded_for = request.query_params["forwarded_for"]
if forwarded_for in B2BCall.keys():
print forwarded_for
# client = PhoneNumber.objects.filter(number= forwarded_for, number_type=NUMBER_TYPE[0][0])[0]
from restaurant.models import Restaurant
restaurant = Restaurant.objects.get(id=B2BCall[forwarded_for])
client = ClientSerializer(instance=restaurant).data
except (KeyError, IndexError):
pass
try:
contact_number = request.query_params["contact_number"]
customer = Customer.find_by_contact_number(contact_number=contact_number)
customer_info = {"primary_number": contact_number, "name": "New Customer", "call_count": 1}
if customer:
customer.call_count += 1
customer.save()
customer_info = CustomerDetailSerializer(instance=customer).data
order = customer.get_pending_order()
if order:
order = OrderDetailViewSerializer(instance=order).data
CallLog.log_call(customer, request.query_params["agent_id"])
pusher = PushMessage(channel=request.query_params["agent_id"])
print "pusher order ", order
pusher.push(
json.dumps({"client": client, "customer": customer_info, "order": order}, default=self.date_handler)
)
return JSONResponse({"customer": customer_info}, status=200)
except Exception as e:
print traceback.format_exc(e)
beam(e, request)
return JSONResponse({"Success": False}, status=200)