def schedule_using_mailchimp(self, schedule_datetime=None): mc = MailchimpAPIClient() if not schedule_datetime: schedule_datetime = timezone.now() response = mc.campaign_schedule( self.mailchimp_list.mailchimp_list_campaign, time=schedule_datetime, ) return response
def create_mailchimp_campaign(self): mc = MailchimpAPIClient() response = mc.create_campaign(self.template, self.mailchimp_list) if response['id']: MailChimpCampaign.objects.get_or_create( external_id=response['id'], mailing_list=self.mailchimp_list, raw_response=json.dumps(response), ) return response
def create_mailchimp_list(self): mc = MailchimpAPIClient() response = mc.create_list(self.template.subject) if response['id']: list_obj = MailChimpList.objects.get_or_create( external_id=response['id'], mailing=self, raw_response=json.dumps(response), ) # TODO: Remove hardcoded merge field creation eventlink_data = { 'name': 'Event Invitation Link', 'tag': 'EVENTLINK', 'type': 'url', } mc.create_list_merge_field(response['id'], eventlink_data) activity_list_data = { 'name': 'Activity List', 'tag': 'ACTIVITIES', 'type': 'text', } mc.create_list_merge_field(response['id'], activity_list_data) userlink_data = { 'name': 'User password Link', 'tag': 'RECOVER_PA', 'type': 'url', } mc.create_list_merge_field(response['id'], userlink_data) return list_obj
def create_mailchimp_campaign_content(self): mc = MailchimpAPIClient() template = self.template campaign = self.mailchimp_list.mailchimp_list_campaign response = mc.create_campaign_content( template, campaign, ) return response
def sub_target_users_to_list(self, update_existing=False): list_id = self.mailchimp_list.external_id mc = MailchimpAPIClient() def extra_data(fields, user): if self.event: fields['EVENTLINK'] = self.event.get_invitation_link(user) fields['ACTIVITY_LIST'] = \ self.event.get_activities_list_html(user) fields['RECOVER_PA'] = user.get_recover_password_url() response = mc.sub_users_to_list( self.get_users(), list_id, extra_data, update_existing=update_existing, ) return response
def get_mailchimp_data(self): list_id = self.external_id mc = MailchimpAPIClient() return mc.get_list(list_id)
def send_using_mailchimp(self): mc = MailchimpAPIClient() response = mc.campaign_send( self.mailchimp_list.mailchimp_list_campaign ) return response