def marketingCloud(bases, event1):
        stubObj = ET_Client.ET_Client(
            False, False, {
                'clientid': os.environ['clientid'],
                'clientsecret': os.environ['clientsecret'],
                'defaultwsdl':
                'https://webservice.exacttarget.com/etframework.wsdl',
                'authenticationurl': os.environ['authenticationurl'],
                'baseapiurl': os.environ['baseapiurl'],
                'soapendpoint': os.environ['soapendpoint'],
                'wsdl_file_local_loc': r'/tmp/ExactTargetWSDL.xml',
                'useOAuth2Authentication': 'True',
                'accountId': os.environ['accountId']
            })
        de = ET_Client.ET_DataExtension_Row()
        de.CustomerKey = bases
        de.auth_stub = stubObj
        de.props = props1 if de.CustomerKey == os.environ[
            'basesLeads_Gerais'] else props2
        postResponse = de.post()
        # Mensagens de error para debugar depois! Caso necessário:
        ## print("Post Status: " + str(postResponse.status))
        ## print("Code: " + str(postResponse.code))
        ## print("Message: " + str(postResponse.message))
        ## print("Results: " + str(postResponse.results))

        if postResponse.status:
            return True
예제 #2
0
 def get_all_rows_from_data_extension(self, data_extension_customer_key,
                                      fields_list):
     der = ET_Client.ET_DataExtension_Row()
     der.auth_stub = self.auth_stub
     der.CustomerKey = data_extension_customer_key
     der.props = fields_list
     return der.get()
예제 #3
0
 def add_row_to_data_extension(self, data_extension_name,
                               fields_dictionary):
     der = ET_Client.ET_DataExtension_Row()
     der.auth_stub = self.auth_stub
     der.Name = data_extension_name
     der.props = fields_dictionary
     return der.post()
예제 #4
0
 def __init__(self):
     client_config = {
         "clientid": app.config['FUELSDK_CLIENT_ID'],
         "clientsecret": app.config['FUELSDK_CLIENT_SECRET'],
         "appsignature": app.config['FUELSDK_APP_SIGNATURE'],
         "defaultwsdl": app.config['FUELSDK_DEFAULT_WSDL'],
         "authenticationurl": app.config['FUELSDK_AUTH_URL']
     }
     self.auth_stub = ET_Client.ET_Client(False, True, client_config)
예제 #5
0
 def get_data_extension_by_customer_key(self, data_extension_customer_key):
     de = ET_Client.ET_DataExtension()
     de.auth_stub = self.auth_stub
     de.props = ["CustomerKey", "Name"]
     de.search_filter = {
         'Property': 'CustomerKey',
         'SimpleOperator': 'like',
         'Value': data_extension_customer_key
     }
     return de.get()
예제 #6
0
 def get_fields_from_data_extension(self, data_extension_customer_key):
     dec = ET_Client.ET_DataExtension_Column()
     dec.auth_stub = self.auth_stub
     dec.props = ["Name"]
     dec.search_filter = {
         'Property': 'CustomerKey',
         'SimpleOperator': 'like',
         'Value': data_extension_customer_key
     }
     return dec.get()
예제 #7
0
 def get_client(self):
     client: ET_Client = ET_Client.ET_Client(
         False,
         False,
         {
             "clientid": settings.SF_CLIENT_ID,
             "clientsecret": settings.SF_CLIENT_SECRET,
             "authenticationurl":
             f"https://{settings.SF_ACCOUNT_ID}.auth.marketingcloudapis.com/",
             "baseapiurl":
             f"https://{settings.SF_ACCOUNT_ID}.rest.marketingcloudapis.com/",
             "soapendpoint":
             f"https://{settings.SF_ACCOUNT_ID}.soap.marketingcloudapis.com/",
             "useOAuth2Authentication": "True",
         },
     )
     return client
예제 #8
0
 def update_row(self, message: Dict[str, str], extension_key: str) -> bool:
     """
     :param message: the list of dict wiht the data
     :param extension_key: it is the customer key or 'table name'
     """
     logger.info("Adding a row to a data extension")
     row = ET_Client.ET_DataExtension_Row()
     row.CustomerKey = extension_key
     row.auth_stub = self.get_client()
     row.props = message
     response = row.patch()
     logger.info(
         f"patch_tatus: {str(response.status)}, code: {str(response.code)}, message: {str(response.message)}"
     )
     logger.info("Results: " + str(response.results))
     if int(response.status) == 200:
         return True
     return False
예제 #9
0
    def create_data_extension(self, table_name: str, customer_key: str,
                              message: List[Dict[str, str]]):
        """
         [{"Name" : "Name", "FieldType" : "Text",  "MaxLength" : "255"},
         {"Name" : "phone_number", "FieldType" : "Text",  "MaxLength" : "13"},
         {"Name" : "email", "FieldType" : "EmailAddress", "IsPrimaryKey" : "true", "IsRequired" : "true"}]
        """
        logger.info(f'Creating new {table_name} Data Extension')
        data_extension = ET_Client.ET_DataExtension()
        data_extension.auth_stub = self.get_client()

        data_extension.props = {
            "Name": table_name,
            "CustomerKey": customer_key
        }
        data_extension.columns = message
        response = data_extension.post()
        logger.info(
            f"post_tatus: {str(response.status)}, code: {str(response.code)}, message: {str(response.message)}"
        )
        logger.info("Results: " + str(response.results))
        if int(response.status) == 200:  # HTTPStatus.OK
            return True
        return False
import ET_Client
from MarketingCloudSDK.client import ET_Client
from MarketingCloudSDK.objects import ET_CreateOptions, ET_DeleteOptions, ET_DataExtension

RequestType = "Asynchronous"
QueuePriority = "High" / "Medium" / "Low"
myClient = ET_Client()
try:
    debug = False
    stubObj = ET_Client.ET_Client(False, debug)

    ## Example using CreateDataExtensions() method

    # Declare a Python dict which contain all of the details for a DataExtension
    deOne = {"Name": "HelperDEOne", "CustomerKey": "HelperDEOne"}
    deOne['columns'] = [{
        "Name": "Name",
        "FieldType": "Text",
        "IsPrimaryKey": "true",
        "MaxLength": "100",
        "IsRequired": "true"
    }, {
        "Name": "OtherField",
        "FieldType": "Text"
    }]

    # Declare a 2nd Python dict which contain all of the details for a DataExtension
    deTwo = {"Name": "HelperDETwo", "CustomerKey": "HelperDETwo"}
    deTwo['columns'] = [{
        "Name": "Name",
        "FieldType": "Text",
예제 #11
0
from __future__ import print_function

import ET_Client

try:
    debug = False
    stubObj = ET_Client.ET_Client(False, debug)

    # Modify the date below to reduce the number of results returned from the request
    # Setting this too far in the past could result in a very large response size
    retrieveDate = '2013-01-15T13:00:00.000'

    print('>>> Retrieve Filtered OpenEvents with GetMoreResults')
    getOpenEvent = ET_Client.ET_OpenEvent()
    getOpenEvent.auth_stub = stubObj
    getOpenEvent.props = [
        "SendID", "SubscriberKey", "EventDate", "Client.ID", "EventType",
        "BatchID", "TriggeredSendDefinitionObjectID", "PartnerKey"
    ]
    getOpenEvent.search_filter = {
        'Property': 'EventDate',
        'SimpleOperator': 'greaterThan',
        'DateValue': retrieveDate
    }
    getResponse = getOpenEvent.get()
    print('Retrieve Status: ' + str(getResponse.status))
    print('Code: ' + str(getResponse.code))
    print('Message: ' + str(getResponse.message))
    print('MoreResults: ' + str(getResponse.more_results))
    print('RequestID: ' + str(getResponse.request_id))
    print('Results Length: ' + str(len(getResponse.results)))
예제 #12
0
import ET_Client

try:
    debug = False
    stubObj = ET_Client.ET_Client(False, debug)

    # Retrieve All Folder with GetMoreResults
    print('>>> Retrieve All Folder with GetMoreResults')
    getFolder = ET_Client.ET_Folder()
    getFolder.auth_stub = stubObj
    getFolder.props = [
        "ID", "Client.ID", "ParentFolder.ID", "ParentFolder.CustomerKey",
        "ParentFolder.ObjectID", "ParentFolder.Name",
        "ParentFolder.Description", "ParentFolder.ContentType",
        "ParentFolder.IsActive", "ParentFolder.IsEditable",
        "ParentFolder.AllowChildren", "Name", "Description", "ContentType",
        "IsActive", "IsEditable", "AllowChildren", "CreatedDate",
        "ModifiedDate", "Client.ModifiedBy", "ObjectID", "CustomerKey",
        "Client.EnterpriseID", "Client.CreatedBy"
    ]
    getResponse = getFolder.get()
    print('Retrieve Status: ' + str(getResponse.status))
    print('Code: ' + str(getResponse.code))
    print('Message: ' + str(getResponse.message))
    print('MoreResults: ' + str(getResponse.more_results))
    print('Results Length: ' + str(len(getResponse.results)))
    #print 'Results: ' + str(getResponse.results)

    while getResponse.more_results:
        print('>>> Continue Retrieve All Folder with GetMoreResults')
        getResponse = getFolder.getMoreResults()
예제 #13
0
import ET_Client

try:
    debug = False
    stubObj = ET_Client.ET_Client(False, debug)

    # In order for this sample to run, it needs to have an asset that it can associate the campaign to
    ExampleAssetType = "LIST"
    ExampleAssetItemID = "1953114"

    # Retrieve all Campaigns
    print('>>> Retrieve all Campaigns')
    getCamp = ET_Client.ET_Campaign()
    getCamp.auth_stub = stubObj
    getResponse = getCamp.get()
    print('Retrieve Status: ' + str(getResponse.status))
    print('Code: ' + str(getResponse.code))
    print('Message: ' + str(getResponse.message))
    print('MoreResults: ' + str(getResponse.more_results))
    if 'count' in getResponse.results:
        print('Results(Items) Length: ' +
              str(len(getResponse.results['items'])))
    # print 'Results(Items): ' + str(getResponse.results)
    print('-----------------------------')

    while getResponse.more_results:
        print('>>> Continue Retrieve all Campaigns with GetMoreResults')
        getResponse = getCamp.getMoreResults()
        print(str(getResponse))
        print('Retrieve Status: ' + str(getResponse.status))
        print('Code: ' + str(getResponse.code))
예제 #14
0
import ET_Client

try:
    debug = False
    stubObj = ET_Client.ET_Client(False, debug)
    
    ## Modify the date below to reduce the number of results returned from the request
    ## Setting this too far in the past could result in a very large response size
    retrieveDate = '2013-01-15T13:00:00.000'
    
    print '>>> Retrieve Filtered UnsubEvents with GetMoreResults'
    getUnsubEvent = ET_Client.ET_UnsubEvent()
    getUnsubEvent.auth_stub = stubObj
    getUnsubEvent.props = ["SendID","SubscriberKey","EventDate","Client.ID","EventType","BatchID","TriggeredSendDefinitionObjectID","PartnerKey"]
    getUnsubEvent.search_filter = {'Property' : 'EventDate','SimpleOperator' : 'greaterThan','DateValue' : retrieveDate}
    getResponse = getUnsubEvent.get()
    print 'Retrieve Status: ' + str(getResponse.status)
    print 'Code: ' + str(getResponse.code)
    print 'Message: ' + str(getResponse.message)
    print 'MoreResults: ' + str(getResponse.more_results)
    print 'RequestID: ' + str(getResponse.request_id)
    print 'Results Length: ' + str(len(getResponse.results))
    print 'results: ' + str(getResponse.results)
    # Since this could potentially return a large number of results, we do not want to print the results
    #print 'Results: ' + str(getResponse.results)
    
    while getResponse.more_results: 
        print '>>> Continue Retrieve Filtered UnsubEvents with GetMoreResults'
        getResponse = getUnsubEvent.getMoreResults()
        print 'Retrieve Status: ' + str(getResponse.status)
        print 'Code: ' + str(getResponse.code)
예제 #15
0
    def run(self):
        '''
        Main execution code
        '''
        output = []
        output_title = []

        params = self.cfg_params  # noqac

        # Get proper list of tables
        client_id = params.get(CLIENT_ID)
        client_secret = params.get(CLIENT_SECRET)
        subdomain = params.get(SUBDOMAIN)
        sub_id = params.get(MID)
        scope = params.get(SCOPE)

        stubObj = ET_Client.ET_Client(
            False, False, {
                'clientid': client_id,
                'clientsecret': client_secret,
                'wsdl_file_local_loc':
                DEFAULT_FILE_INPUT + '/ExactTargetWSDL.xml',
                'authenticationurl':
                'https://' + subdomain + '.auth.marketingcloudapis.com/',
                'useOAuth2Authentication': 'True',
                'accountId': sub_id
            })

        if scope == ('Subscribers').lower():
            getSub = ET_Client.ET_Subscriber()
            getSub.props = ["SubscriberKey", "EmailAddress", "Status"]
            getSub.auth_stub = stubObj
            getResponse = getSub.get()
            result = getResponse.results
            output = [(x['EmailAddress'], x['SubscriberKey'], x['Status'])
                      for x in result]
            output_title = ['email', 'subscriber_key', 'status']
        elif scope == ('DataExtensions').lower():
            de = ET_Client.ET_DataExtension()
            de.auth_stub = stubObj
            de.props = ["CustomerKey", "Name", "Description"]
            getResponse = de.get()
            result = getResponse.results
            output = [(x['CustomerKey'], x['Name'], x['Description'])
                      for x in result]
            output_title = ['customerkey', 'name', 'description']
        elif scope == ('Folders').lower():
            getFolder = ET_Client.ET_Folder()
            getFolder.auth_stub = stubObj
            getFolder.props = [
                "ID", "Client.ID", "ParentFolder.ID",
                "ParentFolder.CustomerKey", "ParentFolder.ObjectID",
                "ParentFolder.Name", "ParentFolder.Description",
                "ParentFolder.ContentType", "ParentFolder.IsActive",
                "ParentFolder.IsEditable", "ParentFolder.AllowChildren",
                "Name", "Description", "ContentType", "IsActive", "IsEditable",
                "AllowChildren", "CreatedDate", "ModifiedDate",
                "Client.ModifiedBy", "ObjectID", "CustomerKey",
                "Client.EnterpriseID", "Client.CreatedBy"
            ]
            getResponse = getFolder.get()
            result = getResponse.results
            output = [(x['Name'], x['ID'], x['CustomerKey'], x['ObjectID'])
                      for x in result]
            output_title = ['name', 'id', 'customerkey', 'objectid']

        output_file = DEFAULT_TABLE_DESTINATION + scope + '.csv'
        logging.info(output_file)

        with open(output_file, 'w') as out:
            csv_out = csv.writer(out)
            csv_out.writerow(output_title)
            for row in output:
                csv_out.writerow(row)
예제 #16
0
import ET_Client

try:
    debug = False
    stubObj = ET_Client.ET_Client(False, debug)

    # NOTE: These examples only work in accounts where the SubscriberKey functionality is not enabled
    #       SubscriberKey will need to be included in the props if that feature is enabled

    SubscriberTestEmail = "*****@*****.**"

    # Create Subscriber
    print '>>> Create Subscriber'
    postSub = ET_Client.ET_Subscriber()
    postSub.auth_stub = stubObj
    postSub.props = {"EmailAddress": SubscriberTestEmail}
    postResponse = postSub.post()
    print 'Post Status: ' + str(postResponse.status)
    print 'Code: ' + str(postResponse.code)
    print 'Message: ' + str(postResponse.message)
    print 'Result Count: ' + str(len(postResponse.results))
    print 'Results: ' + str(postResponse.results)

    # Retrieve newly created Subscriber
    print '>>> Retrieve newly created Subscriber'
    getSub = ET_Client.ET_Subscriber()
    getSub.auth_stub = stubObj
    getSub.props = ["SubscriberKey", "EmailAddress", "Status"]
    getSub.search_filter = {
        'Property': 'SubscriberKey',
        'SimpleOperator': 'equals',
from __future__ import print_function

import ET_Client

try:
    debug = False
    stubObj = ET_Client.ET_Client(False, debug)

    # Example using CreateDataExtensions() method

    # Declare a Python dict which contain all of the details for a DataExtension
    deOne = {"Name": "HelperDEOne", "CustomerKey": "HelperDEOne"}
    deOne['columns'] = [{"Name": "Name", "FieldType": "Text", "IsPrimaryKey": "true", "MaxLength": "100", "IsRequired": "true"}, {"Name": "OtherField", "FieldType": "Text"}]

    # Declare a 2nd Python dict which contain all of the details for a DataExtension
    deTwo = {"Name": "HelperDETwo", "CustomerKey": "HelperDETwo"}
    deTwo['columns'] = [{"Name": "Name", "FieldType": "Text", "IsPrimaryKey": "true", "MaxLength": "100", "IsRequired": "true"}, {"Name": "OtherField", "FieldType": "Text"}]

    # Call CreateDataExtensions passing in both DataExtension Hashes as an Array
    createDEResponse = stubObj.CreateDataExtensions([deOne, deTwo])
    print('CreateDataExtensions Status: ' + str(createDEResponse.status))
    print('Code: ' + str(createDEResponse.code))
    print('Message: ' + str(createDEResponse.message))
    print('Results Length: ' + str(len(createDEResponse.results)))
    print('Results: ' + str(createDEResponse.results))

    # Cleaning uprint the newly created DEs
    # Delete deOne
    print('>>> Delete deOne')
    de5 = ET_Client.ET_DataExtension()
    de5.auth_stub = stubObj
예제 #18
0
from __future__ import print_function

import ET_Client

try:
    debug = False
    stubObj = ET_Client.ET_Client(False, debug)

    # Get all of the DataExtensions in an Account
    print('>>> Get all of the DataExtensions in an Account')
    de = ET_Client.ET_DataExtension()
    de.auth_stub = stubObj
    de.props = ["CustomerKey", "Name"]
    getResponse = de.get()
    print(('Retrieve Status: ' + str(getResponse.status)))
    print(('Code: ' + str(getResponse.code)))
    print(('Message: ' + str(getResponse.message)))
    print(('MoreResults: ' + str(getResponse.more_results)))
    print(('RequestID: ' + str(getResponse.request_id)))
    print(('Results Length: ' + str(len(getResponse.results))))
    # print('Results: ' + str(getResponse.results))

    # Get all of the DataExtensions in an Account belonging to a specific sub account
    print(
        '>>> Get all of the DataExtensions in an Account belonging to a specific sub account'
    )
    de = ET_Client.ET_DataExtension()
    de.auth_stub = stubObj
    de.props = ["CustomerKey", "Name"]
    de.options = {"Client": {"ID": "1234567"}}
    getResponse = de.get()
예제 #19
0
 def get_subscribers(self):
     subscribers = ET_Client.ET_Subscriber()
     subscribers.auth_stub = self.auth_stub
     subscribers.props = ["ID", "EmailAddress", "Status"]
     return subscribers.get()
예제 #20
0
import ET_Client
from MarketingCloudSDK.objects import ET_List, ET_CreateOptions, ET_UpdateOptions, ET_DeleteOptions
from MarketingCloudSDK.client import ET_Client
RequestType = "Asynchronus"
QueuePriority = "High" / "Low" / "Medium"
myClient = ET_Client()
try:
    debug = False   
    stubObj = ET_Client.ET_Client(False, debug) 
    
    NewListName = "PythonSDKList"

    # Create List 
    print '>>> Create List'
    postList = ET_Client.ET_List()
    postList.auth_stub = stubObj
    postList.props = {"ListName" : NewListName, "Description" : "This list was created with the PythonSDK", "Type" : "Private" }        
    postResponse = postList.post()
    print 'Post Status: ' + str(postResponse.status)
    print 'Code: ' + str(postResponse.code)
    print 'Message: ' + str(postResponse.message)
    print 'Result Count: ' + str(len(postResponse.results))
    print 'Results: ' + str(postResponse.results)
    
    
    # Make sure the list created correctly and the 1st dict in it has a NewID...
    if postResponse.status and 'NewID' in postResponse.results[0]:
        
        newListID = postResponse.results[0]['NewID']

        # Retrieve newly created List by ID
예제 #21
0
from __future__ import print_function

import ET_Client

try:
    debug = False
    stubObj = ET_Client.ET_Client(False, debug)

    # Retrieve All ContentArea with GetMoreResults
    print('>>> Retrieve All ContentArea with GetMoreResults')
    getContent = ET_Client.ET_ContentArea()
    getContent.auth_stub = stubObj
    getContent.props = [
        "RowObjectID", "ObjectID", "ID", "CustomerKey", "Client.ID",
        "ModifiedDate", "CreatedDate", "CategoryID", "Name", "Layout",
        "IsDynamicContent", "Content", "IsSurvey", "IsBlank", "Key"
    ]
    getResponse = getContent.get()
    print('Retrieve Status: ' + str(getResponse.status))
    print('Code: ' + str(getResponse.code))
    print('Message: ' + str(getResponse.message))
    print('MoreResults: ' + str(getResponse.more_results))
    print('Results Length: ' + str(len(getResponse.results)))
    # print 'Results: ' + str(getResponse.results)

    while getResponse.more_results:
        print('>>> Continue Retrieve All ContentArea with GetMoreResults')
        getResponse = getContent.getMoreResults()
        print('Retrieve Status: ' + str(getResponse.status))
        print('Code: ' + str(getResponse.code))
        print('Message: ' + str(getResponse.message))
예제 #22
0
import ET_Client

try:
    debug = False
    stubObj = ET_Client.ET_Client(False, debug)

    ## Modify the date below to reduce the number of results returned from the request
    ## Setting this too far in the past could result in a very large response size
    retrieveDate = '2013-01-15T13:00:00.000'

    print '>>> Retrieve Filtered ClickEvents with GetMoreResults'
    getClickEvent = ET_Client.ET_ClickEvent()
    getClickEvent.auth_stub = stubObj
    getClickEvent.props = [
        "SendID", "SubscriberKey", "EventDate", "Client.ID", "EventType",
        "BatchID", "TriggeredSendDefinitionObjectID", "PartnerKey"
    ]
    getClickEvent.search_filter = {
        'Property': 'EventDate',
        'SimpleOperator': 'greaterThan',
        'DateValue': retrieveDate
    }
    getResponse = getClickEvent.get()
    print 'Retrieve Status: ' + str(getResponse.status)
    print 'Code: ' + str(getResponse.code)
    print 'Message: ' + str(getResponse.message)
    print 'MoreResults: ' + str(getResponse.more_results)
    print 'RequestID: ' + str(getResponse.request_id)
    print 'Results Length: ' + str(len(getResponse.results))
    # Since this could potentially return a large number of results, we do not want to print the results
    #print 'Results: ' + getResponse.results.to_s
import ET_Client

try:
    debug = True
    stubObj = ET_Client.ET_Client(False, debug)

    NameOfAttribute = "PythonSDKEmail"

    # Create Profile Attribute
    print '>>> Create Profile Attribute'
    postAttribute = ET_Client.ET_ProfileAttribute()
    postAttribute.auth_stub = stubObj
    postAttribute.props = {"Name": NameOfAttribute, "PropertyType": "string"}
    postResponse = postAttribute.post()
    print 'Post Status: ' + str(postResponse.status)
    print 'Code: ' + str(postResponse.code)
    print 'Message: ' + str(postResponse.message)
    print 'Result Count: ' + str(len(postResponse.results))
    print 'Results: ' + str(postResponse.results)

except Exception as e:
    print 'Caught exception: ' + e.message
    print e
from __future__ import print_function

import ET_Client

try:
    debug = False
    stubObj = ET_Client.ET_Client(False, debug)

    # Modify the date below to reduce the number of results returned from the request
    # Setting this too far in the past could result in a very large response size
    retrieveDate = '2011-01-15T13:00:00.000'

    print('>>> Retrieve Filtered BounceEvents with GetMoreResults')
    getBounceEvent = ET_Client.ET_BounceEvent()
    getBounceEvent.auth_stub = stubObj
    getBounceEvent.props = [
        "SendID", "SubscriberKey", "EventDate", "Client.ID", "EventType",
        "BatchID", "TriggeredSendDefinitionObjectID", "PartnerKey"
    ]
    getBounceEvent.search_filter = {
        'Property': 'EventDate',
        'SimpleOperator': 'greaterThan',
        'DateValue': retrieveDate
    }
    getResponse = getBounceEvent.get()
    print('Retrieve Status: ' + str(getResponse.status))
    print('Code: ' + str(getResponse.code))
    print('Message: ' + str(getResponse.message))
    print('MoreResults: ' + str(getResponse.more_results))
    print('RequestID: ' + str(getResponse.request_id))
    print('Results Length: ' + str(len(getResponse.results)))
import ET_Client
import uuid
from MarketingCloudSDK.objects import ET_TriggeredSend, ET_CreateOptions, ET_UpdateOptions, ET_DeleteOptions
from MarketingCloudSDK.client import ET_Client
RequestType = "Asynchronus"
QueuePriority = "High" / "Low" / "Medium"
myClient = ET_Client()

try:
    debug = False
    stubObj = ET_Client.ET_Client(False, debug)

    # Get all TriggeredSendDefinitions
    print '>>> Get all TriggeredSendDefinitions'
    getTS = ET_Client.ET_TriggeredSend()
    getTS.auth_stub = stubObj
    getTS.props = ["CustomerKey", "Name", "TriggeredSendStatus"]
    getResponse = getTS.get()
    print 'Retrieve Status: ' + str(getResponse.status)
    print 'Code: ' + str(getResponse.code)
    print 'Message: ' + str(getResponse.message)
    print 'MoreResults: ' + str(getResponse.more_results)
    print 'Results Count: ' + str(len(getResponse.results))
    #print 'Results: ' + str(getResponse.results)

    # Specify the name of a TriggeredSend that was setuprint for testing
    # Do not use a production Triggered Send Definition

    NameOfTestTS = "TEXTEXT"

    # Pause a TriggeredSend
예제 #26
0
 def send_email(self, key, subscriber_email, subscriber_key):
     ts = ET_Client.ET_TriggeredSend()
     ts.auth_stub = self.auth_stub
     ts.props = {"CustomerKey" : key}
     ts.subscribers = [{"EmailAddress": subscriber_email, "SubscriberKey" : subscriber_key}]
     return ts.send()
import ET_Client

try:
    debug = False
    stubObj = ET_Client.ET_Client(False, debug)

    NewListName = "PythonSDKList"

    ## Example using AddSubscriberToList() method
    ## Typically this method will be used with a pre-existing list but for testing purposes one is being created.

    # Create List
    print('>>> Create List')
    postList = ET_Client.ET_List()
    postList.auth_stub = stubObj
    postList.props = {
        "ListName": NewListName,
        "Description": "This list was created with the PythonSDK",
        "Type": "Private"
    }
    postResponse = postList.post()
    print('Post Status: ' + str(postResponse.status))
    print('Code: ' + str(postResponse.code))
    print('Message: ' + str(postResponse.message))
    print('Result Count: ' + str(len(postResponse.results)))
    print('Results: ' + str(postResponse.results))

    if postResponse.status:

        newListID = postResponse.results[0]['NewID']
        # Adding Subscriber To a List
예제 #28
0
import ET_Client

try:
    debug = False
    stubObj = ET_Client.ET_Client(False, debug)

    ## Modify the date below to reduce the number of results returned from the request
    ## Setting this too far in the past could result in a very large response size
    retrieveDate = '2013-01-15T13:00:00.000'

    print('>>> Retrieve Filtered SentEvents with GetMoreResults')
    getSentEvent = ET_Client.ET_SentEvent()
    getSentEvent.auth_stub = stubObj
    getSentEvent.props = [
        "SendID", "SubscriberKey", "EventDate", "Client.ID", "EventType",
        "BatchID", "TriggeredSendDefinitionObjectID", "ListID", "PartnerKey",
        "SubscriberID"
    ]
    getSentEvent.search_filter = {
        'Property': 'EventDate',
        'SimpleOperator': 'greaterThan',
        'DateValue': retrieveDate
    }
    getResponse = getSentEvent.get()
    print('Retrieve Status: ' + str(getResponse.status))
    print('Code: ' + str(getResponse.code))
    print('Message: ' + str(getResponse.message))
    print('MoreResults: ' + str(getResponse.more_results))
    print('RequestID: ' + str(getResponse.request_id))
    print('Results Length: ' + str(len(getResponse.results)))
    print('Results: ' + str(getResponse.results))
예제 #29
0
import ET_Client

try:
    debug = False
    stubObj = ET_Client.ET_Client(False, debug)

    # Retrieve All Email with GetMoreResults
    print('>>> Retrieve All Email with GetMoreResults')
    getHTMLBody = ET_Client.ET_Email()
    getHTMLBody.auth_stub = stubObj
    getHTMLBody.props = [
        "ID", "PartnerKey", "CreatedDate", "ModifiedDate", "Client.ID", "Name",
        "Folder", "CategoryID", "HTMLBody", "TextBody", "Subject", "IsActive",
        "IsHTMLPaste", "ClonedFromID", "Status", "EmailType", "CharacterSet",
        "HasDynamicSubjectLine", "ContentCheckStatus",
        "Client.PartnerClientKey", "ContentAreas", "CustomerKey"
    ]
    getResponse = getHTMLBody.get()
    print('Retrieve Status: ' + str(getResponse.status))
    print('Code: ' + str(getResponse.code))
    print('Message: ' + str(getResponse.message))
    print('MoreResults: ' + str(getResponse.more_results))
    print('Results Length: ' + str(len(getResponse.results)))
    #print 'Results: ' + str(getResponse.results)

    while getResponse.more_results:
        print('>>> Continue Retrieve All Email with GetMoreResults')
        getResponse = getHTMLBody.getMoreResults()
        print('Retrieve Status: ' + str(getResponse.status))
        print('Code: ' + str(getResponse.code))
        print('Message: ' + str(getResponse.message))
예제 #30
0
 def start_triggered_send_definition(self, key):
     ts = ET_Client.ET_TriggeredSend()
     ts.auth_stub = self.auth_stub
     ts.props = {"CustomerKey" key: , "TriggeredSendStatus" :"Active"}
     return ts.patch()