-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmerge.py
39 lines (32 loc) · 1.35 KB
/
merge.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import os
import suds_marketo
import urllib3
from flask import Flask, request, json
from flask.ext import restful
from flask.ext.jsonpify import jsonify
app = Flask(__name__)
api = restful.Api(app)
class merge(restful.Resource):
def get(self, ID):
#Establish Connection to OpenTable Marketo Endpoint
client = suds_marketo.Client(soap_endpoint='YOUR KEY HERE',
user_id='Your key here',
encryption_key='Your key here')
NewContactFromSFDC = str(ID)
#get the leads from Marketo
lead = client.get_lead_IDNUM(NewContactFromSFDC)
for i in range(0,len(lead.leadRecordList.leadRecord[0].leadAttributeList[0])):
if 'mKTOLeadID' == lead.leadRecordList.leadRecord[0].leadAttributeList[0][i].attrName:
originalmarketoid = lead.leadRecordList.leadRecord[0].leadAttributeList[0][i].attrValue
try:
#Try and merge leads if they both exist in marketo. One will be the new SFDC contact
#One will be the marketo lead that was a lead before it was an SFDC contact.
client.merge_leads(NewContactFromSFDC,originalmarketoid)
except:
pass
return None
api.add_resource(merge, '/<int:ID>')
if __name__ == '__main__':
#app.run(debug=True)
#for debugging
print 'lol'