Esempio n. 1
0
def apply_updates(target_et, record):
    """Send the record data to ET to update the database named
    target_et.

    :param str target_et: Target database, e.g. settings.EXACTTARGET_DATA
        or settings.EXACTTARGET_CONFIRMATION.
    :param dict record: Data to send
    """
    et = ExactTarget(settings.EXACTTARGET_USER, settings.EXACTTARGET_PASS)
    et.data_ext().add_record(target_et, record.keys(), record.values())
Esempio n. 2
0
def update_phonebook(data, email, token):
    record = {
        'EMAIL_ADDRESS': email,
        'TOKEN': token,
    }
    if 'city' in data:
        record['CITY'] = data['city']
    if 'country' in data:
        record['COUNTRY'] = data['country']

    record.update((k, v) for k, v in data.items() if k in PHONEBOOK_GROUPS)

    et = ExactTarget(settings.EXACTTARGET_USER, settings.EXACTTARGET_PASS)
    et.data_ext().add_record('PHONEBOOK', record.keys(), record.values())
Esempio n. 3
0
def send_message(message_id, email, token, format):
    """
    Ask ET to send a message.

    :param str message_id: ID of the message in ET
    :param str email: email to send it to
    :param str token: token of the email user
    :param str format: 'H' or 'T' - whether to send in HTML or Text
       (message_id should also be for a message in matching format)

    :raises: NewsletterException for retryable errors, BasketError for
        fatal errors.
    """

    if BAD_MESSAGE_ID_CACHE.get(message_id, False):
        return
    log.debug("Sending message %s to %s %s in %s" %
              (message_id, email, token, format))
    et = ExactTarget(settings.EXACTTARGET_USER, settings.EXACTTARGET_PASS)
    try:
        et.trigger_send(
            message_id,
            {
                'EMAIL_ADDRESS_': email,
                'TOKEN': token,
                'EMAIL_FORMAT_': format,
            }
        )
    except NewsletterException as e:
        # Better error messages for some cases. Also there's no point in
        # retrying these
        if 'Invalid Customer Key' in e.message:
            # remember it's a bad message ID so we don't try again during this process.
            BAD_MESSAGE_ID_CACHE.set(message_id, True)
            return
        # we should retry
        raise
Esempio n. 4
0
def update_student_ambassadors(data, email, token):
    data['EMAIL_ADDRESS'] = email
    data['TOKEN'] = token
    et = ExactTarget(settings.EXACTTARGET_USER, settings.EXACTTARGET_PASS)
    et.data_ext().add_record('Student_Ambassadors', data.keys(), data.values())