Beispiel #1
0
def createBulkImportJob(file,
                        partitionName=None,
                        listId=None,
                        format='csv',
                        lookupField=fieldNames.id):

    # creates dictionary to pass with csv file to API call
    files = {'file': ('leads.' + format, file)}

    # defining a data json for the parameters to be sent to the API
    data = {
        'access_token': identity.getAccessToken(),
        'format': format,
        'lookupField': lookupField
    }

    #checks to add values to request if not none type
    if listId is not None:
        data['listId'] = listId

    if partitionName is not None:
        data['partitionName'] = partitionName

    # sending post request.
    r = requests.post(url=identity.baseBulk + "/v1/leads.json",
                      files=files,
                      data=data).json()

    return r
Beispiel #2
0
def describe2Lead():
    # defining a params dict for the parameters to be sent to the API.
    PARAMS = {'access_token': identity.getAccessToken()}

    # sending get request
    data = requests.get(url=identity.baseRest + "/v1/leads/describe2.json",
                        params=PARAMS).json()

    return data
Beispiel #3
0
def getBulkExtractJobs(status=bulkStatusAll):
    # defining a params dict for the parameters to be sent to the API.
    PARAMS = {'access_token': identity.getAccessToken(), 'status': status}

    # sending get request
    data = requests.get(url=identity.baseBulk + "/v1/leads/export.json",
                        params=PARAMS).json()

    return data
Beispiel #4
0
def listCustomObjects():
    # defining a params dict for the parameters to be sent to the API.
    PARAMS = {'access_token': identity.getAccessToken()}

    # sending get request
    data = requests.get(url=identity.baseRest + "/v1/customobjects.json",
                        params=PARAMS).json()

    return data
Beispiel #5
0
def getStaticList(id):
    # defining a params dict for the parameters to be sent to the API.
    PARAMS = {'access_token': identity.getAccessToken()}

    # sending get request
    data = requests.get(url=identity.baseRest +
                        "/asset/v1/staticList/{:d}.json".format(id),
                        params=PARAMS).json()

    return data
Beispiel #6
0
def getBulkImportWarnings(batchId):
    # defining a params dict for the parameters to be sent to the API.
    PARAMS = {'access_token': identity.getAccessToken()}

    # sending get request
    data = requests.get(url=identity.baseBulk + "/v1/leads/batch/" + batchId +
                        "/warnings.json",
                        params=PARAMS).json()

    return data
Beispiel #7
0
def retrieveBulkExtractData(exportId):
    # defining a params dict for the parameters to be sent to the API.
    PARAMS = {'access_token': identity.getAccessToken()}

    # sending get request. Doesn't return json as it returns csv which is parsed with .text
    data = requests.get(url=identity.baseBulk + "/v1/leads/export/" +
                        exportId + "/file.json",
                        params=PARAMS).text

    return data
Beispiel #8
0
def pollBulkExtractJob(exportId):
    # defining a params dict for the parameters to be sent to the API.
    PARAMS = {'access_token': identity.getAccessToken()}

    # sending get request
    data = requests.get(url=identity.baseBulk + "/v1/leads/export/" +
                        exportId + "/status.json",
                        params=PARAMS).json()

    return data
Beispiel #9
0
def getLeads(type, value, fields=[]):
    # defining a params dict for the parameters to be sent to the API.
    PARAMS = {
        'access_token': identity.getAccessToken(),
        'filterType': type,
        'filterValues': value,
        'fields': fields
    }

    # sending get request
    data = requests.get(url=identity.baseRest + "/v1/leads.json",
                        params=PARAMS).json()

    return data
Beispiel #10
0
def deleteLead(id):
    # defining a data json for the parameters to be sent to the API
    data = json.dumps({'input': [{fieldNames.id: id}]})

    # sending delete request
    r = requests.delete(url=identity.baseRest + "/v1/leads.json",
                        headers={
                            'Content-type':
                            'application/json',
                            'Authorization':
                            'Bearer ' + str(identity.getAccessToken())
                        },
                        data=data).json()

    return r
Beispiel #11
0
def createLead(type, input, action='createOrUpdate'):
    # defining a data json for the parameters to be sent to the API
    data = json.dumps({'action': action, 'lookupField': type, 'input': input})

    # sending post request.
    r = requests.post(url=identity.baseRest + "/v1/leads.json",
                      headers={
                          'Content-type':
                          'application/json',
                          'Authorization':
                          'Bearer ' + str(identity.getAccessToken())
                      },
                      data=data).json()

    return r
Beispiel #12
0
def createBulkExtractJob(fields, filter, format='CSV'):
    # defining a data json for the parameters to be sent to the API
    data = json.dumps({'fields': fields, 'format': format, 'filter': filter})

    # sending post request.
    r = requests.post(url=identity.baseBulk + "/v1/leads/export/create.json",
                      headers={
                          'Content-type':
                          'application/json',
                          'Authorization':
                          'Bearer ' + str(identity.getAccessToken())
                      },
                      data=data).json()

    return r
Beispiel #13
0
def getCustomObjects(apiName, value, fields=[]):
    # defining a params dict for the parameters to be sent to the API.
    PARAMS = {
        'access_token': identity.getAccessToken(),
        'filterType': 'dedupeFields',
        'filterValues': value,
        'fields': fields
    }

    # sending get request
    data = requests.get(url=identity.baseRest + "/v1/customobjects/" +
                        apiName + ".json",
                        params=PARAMS).json()

    return data
Beispiel #14
0
def cancelBulkExtractJob(exportId):
    # defining a data json for the parameters to be sent to the API
    data = json.dumps({})

    # sending post request
    r = requests.post(url=identity.baseBulk + "/v1/leads/export/" + exportId +
                      "/cancel.json",
                      headers={
                          'Content-type':
                          'application/json',
                          'Authorization':
                          'Bearer ' + str(identity.getAccessToken())
                      },
                      data=data).json()

    return r
Beispiel #15
0
def deleteCustomObjects(apiName, input):
    # defining a data json for the parameters to be sent to the API
    data = json.dumps({'deleteBy': 'dedupeFields', 'input': input})

    # sending post request.
    r = requests.post(url=identity.baseRest + "/v1/customobjects/" + apiName +
                      "/delete.json",
                      headers={
                          'Content-type':
                          'application/json',
                          'Authorization':
                          'Bearer ' + str(identity.getAccessToken())
                      },
                      data=data).json()

    return r