本文整理匯總了Python中mailsnake.MailSnake.listBatchSubscribe方法的典型用法代碼示例。如果您正苦於以下問題:Python MailSnake.listBatchSubscribe方法的具體用法?Python MailSnake.listBatchSubscribe怎麽用?Python MailSnake.listBatchSubscribe使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類mailsnake.MailSnake
的用法示例。
在下文中一共展示了MailSnake.listBatchSubscribe方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: update_ticketholders_list
# 需要導入模塊: from mailsnake import MailSnake [as 別名]
# 或者: from mailsnake.MailSnake import listBatchSubscribe [as 別名]
def update_ticketholders_list(self):
ms = MailSnake(app.config['MAILCHIMP_KEY'])
list_id = '5f939ca32a' # Ticketholders 2016
tix = Ticket.query.filter_by(paid=True).join(User).\
group_by(User).with_entities(User).order_by(User.id)
list_members = {member['email'] for member in ms.listMembers(id=list_id, limit=10000)['data']}
current_users = {ticket.email for ticket in tix}
to_remove = list_members - current_users
to_add = current_users - list_members
app.logger.info("Ticketholders list: adding %s addresses, removing %s addresses",
len(to_add), len(to_remove))
res = ms.listBatchUnsubscribe(id=list_id, emails=list(to_remove), send_goodbye=False)
print(res)
to_add_data = [{'EMAIL': email, 'EMAIL_TYPE': 'html'} for email in to_add]
res = ms.listBatchSubscribe(id=list_id, batch=to_add_data,
double_optin=False, update_existing=True)
print(res)