| Line 19... |
Line 19... |
| 19 |
import urllib2
|
19 |
import urllib2
|
| 20 |
import urlparse
|
20 |
import urlparse
|
| 21 |
from Crypto.Hash import MD5
|
21 |
from Crypto.Hash import MD5
|
| 22 |
from Crypto.Cipher import DES
|
22 |
from Crypto.Cipher import DES
|
| 23 |
import string
|
23 |
import string
|
| - |
|
24 |
from shop2020.clients.CRMClient import CRMClient
|
| - |
|
25 |
from shop2020.clients.UserClient import UserClient
|
| - |
|
26 |
from shop2020.thriftpy.crm.ttypes import SearchFilter, TicketCategory, Ticket, \
|
| - |
|
27 |
Activity, TicketPriority, TicketStatus, ActivityType
|
| 24 |
#TODO Need to add messy stuff to conf.
|
28 |
#TODO Need to add messy stuff to conf.
|
| 25 |
|
29 |
|
| 26 |
|
30 |
|
| 27 |
SENDER = "cnc.center@shop2020.in"
|
31 |
SENDER = "cnc.center@shop2020.in"
|
| 28 |
PASSWORD = "5h0p2o2o"
|
32 |
PASSWORD = "5h0p2o2o"
|
| Line 411... |
Line 415... |
| 411 |
def sendCrmProjectMail(userId,disposition_description,disposition_comments):
|
415 |
def sendCrmProjectMail(userId,disposition_description,disposition_comments):
|
| 412 |
parameters = ("user_id", userId),("subject", disposition_description),("message",disposition_comments)
|
416 |
parameters = ("user_id", userId),("subject", disposition_description),("message",disposition_comments)
|
| 413 |
parameters = urllib.urlencode(parameters)
|
417 |
parameters = urllib.urlencode(parameters)
|
| 414 |
emailpushrequest = urllib2.Request(EMAIL_CRM_PUSH_URL, parameters, headers=headers)
|
418 |
emailpushrequest = urllib2.Request(EMAIL_CRM_PUSH_URL, parameters, headers=headers)
|
| 415 |
emailpushrequest.add_header("Authorization", "Basic %s" % DTR_API_BASIC_AUTH)
|
419 |
emailpushrequest.add_header("Authorization", "Basic %s" % DTR_API_BASIC_AUTH)
|
| 416 |
urllib2.urlopen(emailpushrequest).read()
|
- |
|
| 417 |
|
420 |
urllib2.urlopen(emailpushrequest).read()
|
| - |
|
421 |
|
| - |
|
422 |
def generateCrmTicket(customerFeedBack):
|
| - |
|
423 |
crmServiceClient = CRMClient().get_client()
|
| - |
|
424 |
userServiceClient = UserClient().get_client()
|
| - |
|
425 |
ticket = Ticket()
|
| - |
|
426 |
activity = Activity()
|
| - |
|
427 |
ticket.creatorId = 1
|
| - |
|
428 |
user = userServiceClient.getUserByEmail(customerFeedBack.get('email'))
|
| - |
|
429 |
if 'Return or replacement pending' in customerFeedBack.get('subject'):
|
| - |
|
430 |
ticket.category = TicketCategory.PROFITMANDI_REFUND_PROBLEM
|
| - |
|
431 |
ticket.priority = TicketPriority.HIGH
|
| - |
|
432 |
elif 'Product Quality issue' in customerFeedBack.get('subject'):
|
| - |
|
433 |
ticket.category = TicketCategory.PROFITMANDI_PRODUCT_ISSUE
|
| - |
|
434 |
ticket.priority = TicketPriority.HIGH
|
| - |
|
435 |
elif 'Delayed Delivery' in customerFeedBack.get('subject'):
|
| - |
|
436 |
ticket.category = TicketCategory.PROFITMANDI_DELAYED_DELIVERY
|
| - |
|
437 |
ticket.priority = TicketPriority.HIGH
|
| - |
|
438 |
elif 'Technical issue at Profitmandi' in customerFeedBack.get('subject'):
|
| - |
|
439 |
ticket.category = TicketCategory.PROFITMANDI_TECHNICAL_PROBLEM
|
| - |
|
440 |
ticket.priority = TicketPriority.HIGH
|
| - |
|
441 |
else:
|
| - |
|
442 |
ticket.category = TicketCategory.PROFITMANDI_OTHER
|
| - |
|
443 |
ticket.priority = TicketPriority.MEDIUM
|
| - |
|
444 |
|
| - |
|
445 |
ticket.description = 'User Specified Subject :- '+ customerFeedBack.get('subject') + ' | ' + customerFeedBack.get('message')
|
| - |
|
446 |
ticket.customerEmailId = customerFeedBack.get('email')
|
| - |
|
447 |
if user is not None and user.userId !=-1:
|
| - |
|
448 |
ticket.customerId = user.userId
|
| - |
|
449 |
ticket.status = TicketStatus.OPEN
|
| - |
|
450 |
ticket.openDate = customerFeedBack.get('created')
|
| - |
|
451 |
ticket.customerMobileNumber = customerFeedBack.get('mobile_number')
|
| - |
|
452 |
ticket.customerName = customerFeedBack.get('customer_name')
|
| - |
|
453 |
activity.creatorId = 1
|
| - |
|
454 |
activity.ticketAssigneeId = ticket.assigneeId
|
| - |
|
455 |
activity.type = ActivityType.PROFITMANDI_CRM_APP_TICKET
|
| - |
|
456 |
activity.description = 'User Specified Subject :- '+ customerFeedBack.get('subject') + ' | ' + customerFeedBack.get('message')
|
| - |
|
457 |
|
| - |
|
458 |
activity.ticketCategory = ticket.category
|
| - |
|
459 |
activity.ticketDescription = ticket.description
|
| - |
|
460 |
activity.ticketPriority = ticket.priority
|
| - |
|
461 |
activity.ticketStatus = ticket.status
|
| - |
|
462 |
activity.customerEmailId = customerFeedBack.get('email')
|
| - |
|
463 |
if user is not None and user.userId !=-1:
|
| - |
|
464 |
activity.customerId = user.userId
|
| - |
|
465 |
activity.customerName = customerFeedBack.get('customer_name')
|
| - |
|
466 |
activity.customerMobileNumber = customerFeedBack.get('mobile_number')
|
| - |
|
467 |
activity.creationTimestamp = customerFeedBack.get('created')
|
| - |
|
468 |
activity.customerEmailId= customerFeedBack.get('email')
|
| - |
|
469 |
|
| - |
|
470 |
if not crmServiceClient.isAlive():
|
| - |
|
471 |
crmServiceClient = CRMClient().get_client()
|
| - |
|
472 |
|
| - |
|
473 |
ticketId = crmServiceClient.insertTicket(ticket, activity)
|
| - |
|
474 |
|
| - |
|
475 |
if ticketId > 0:
|
| - |
|
476 |
return True
|
| - |
|
477 |
else:
|
| - |
|
478 |
return False
|
| - |
|
479 |
|
| 418 |
|
480 |
|