def create(self, list_id, subscriber_hash, data): """ Add a new note for a specific subscriber. The documentation lists only the note request body parameter so it is being documented and error-checked as if it were required based on the description of the method. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "note": string* } """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash if 'note' not in data: raise KeyError('The list member note must have a note') response = self._mc_client._post(url=self._build_path( list_id, 'members', subscriber_hash, 'notes'), data=data) if response is not None: self.note_id = response['id'] else: self.note_id = None return response
def all(self, list_id, subscriber_hash, get_all=False, **queryparams): """ Get events for a contact :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param get_all: Should the query get all results :type get_all: :py:class:`bool` :param queryparams: The query string parameters queryparams['count'] = integer queryparams['offset'] = integer queryparams['fields'] = [] queryparams['exclude_fields'] = [] """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash if get_all: return self._iterate(url=self._build_path(list_id, 'members', subscriber_hash, 'events'), **queryparams) else: return self._mc_client._get(url=self._build_path( list_id, 'members', subscriber_hash, 'events'), **queryparams)
def create(self, list_id, subscriber_hash, data): """ Add an event for a list member. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "name": string*, (Must be 2-30 characters in length) } """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash if 'name' not in data: raise KeyError('The list member events must have a name') if len(data['name']) < 2 or len(data['name']) > 30: raise ValueError( 'The list member events name must be 2-30 in length') return self._mc_client._post(url=self._build_path( list_id, 'members', subscriber_hash, 'events'), data=data)
def create_or_update(self, list_id, subscriber_hash, data): """ Add or update a list member. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "email_address": string*, "status_if_new": string* (Must be one of 'subscribed', 'unsubscribed', 'cleaned' or 'pending') } """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash if 'email_address' not in data: raise KeyError('The list member must have an email_address') check_email(data['email_address']) if 'status_if_new' not in data: raise KeyError('The list member must have a status_if_new') if data['status_if_new'] not in ['subscribed', 'unsubscribed', 'cleaned', 'pending']: raise ValueError('The list member status_if_new must be one of "subscribed", "unsubscribed", "cleaned", ' 'or "pending"') return self._mc_client._put(url=self._build_path(list_id, 'members', subscriber_hash), data=data)
def create(self, list_id, subscriber_hash, data): """ Add a new note for a specific subscriber. The documentation lists only the note request body parameter so it is being documented and error-checked as if it were required based on the description of the method. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "note": string* } """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash try: test = data['note'] except KeyError as error: error.message += ' The list member note must have a note' raise response = self._mc_client._post(url=self._build_path(list_id, 'members', subscriber_hash, 'notes'), data=data) self.note_id = response['id'] return response
async def create_or_update(self, list_id, subscriber_hash, data): """ Add or update a list member. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "email_address": string*, "status_if_new": string* (Must be one of 'subscribed', 'unsubscribed', 'cleaned', 'pending', or 'transactional') } """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash if 'email_address' not in data: raise KeyError('The list member must have an email_address') check_email(data['email_address']) if 'status_if_new' not in data: raise KeyError('The list member must have a status_if_new') if data['status_if_new'] not in [ 'subscribed', 'unsubscribed', 'cleaned', 'pending', 'transactional' ]: raise ValueError( 'The list member status_if_new must be one of "subscribed", "unsubscribed", "cleaned", ' '"pending", or "transactional"') return await self._mc_client._put(url=self._build_path( list_id, 'members', subscriber_hash), data=data)
def all(self, list_id, subscriber_hash, get_all=False, **queryparams): """ Get recent notes for a specific list member. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param get_all: Should the query get all results :type get_all: :py:class:`bool` :param queryparams: The query string parameters queryparams['fields'] = [] queryparams['exclude_fields'] = [] queryparams['count'] = integer queryparams['offset'] = integer """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash self.note_id = None if get_all: return self._iterate(url=self._build_path(list_id, 'members', subscriber_hash, 'notes'), **queryparams) else: return self._mc_client._get(url=self._build_path(list_id, 'members', subscriber_hash, 'notes'), **queryparams)
def update(self, list_id, subscriber_hash, note_id, data): """ Update a specific note for a specific list member. The documentation lists only the note request body parameter so it is being documented and error-checked as if it were required based on the description of the method. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param note_id: The id for the note. :type note_id: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "note": string* } """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash self.note_id = note_id if 'note' not in data: raise KeyError('The list member note must have a note') return self._mc_client._patch( url=self._build_path(list_id, 'members', subscriber_hash, 'notes', note_id), data=data )
async def update(self, list_id, subscriber_hash, note_id, data): """ Update a specific note for a specific list member. The documentation lists only the note request body parameter so it is being documented and error-checked as if it were required based on the description of the method. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param note_id: The id for the note. :type note_id: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "note": string* } """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash self.note_id = note_id if 'note' not in data: raise KeyError('The list member note must have a note') return await self._mc_client._patch(url=self._build_path( list_id, 'members', subscriber_hash, 'notes', note_id), data=data)
def update(self, list_id, subscriber_hash, note_id, data): """ Update a specific note for a specific list member. The documentation lists only the note request body parameter so it is being documented and error-checked as if it were required based on the description of the method. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param note_id: The id for the note. :type note_id: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "note": string* } """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash self.note_id = note_id try: test = data['note'] except KeyError as error: new_msg = 'The list member note must have a note, {}'.format(error) six.reraise(KeyError, KeyError(new_msg), sys.exc_info()[2]) return self._mc_client._patch( url=self._build_path(list_id, 'members', subscriber_hash, 'notes', note_id), data=data )
def get(self, list_id, subscriber_hash): """Get the tags for a specified list subscriber. :param list_id: The unique id for the list. :param subscriber_hash: The MD5 hash of the lowercase version of the member’s email """ subscriber_hash = check_subscriber_hash(subscriber_hash) # noinspection PyProtectedMember return self._mc_client._get( url=self._build_path(list_id, "members", subscriber_hash, "tags"))
def delete(self, list_id, subscriber_hash): """ Delete a member from a list. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash return self._mc_client._delete(url=self._build_path(list_id, 'members', subscriber_hash))
def all(self, list_id, subscriber_hash, **queryparams): """ Get all tags for a specific list member. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash return self._mc_client._get(url=self._build_path(list_id, 'members', subscriber_hash, 'tags'), **queryparams)
async def delete(self, list_id, subscriber_hash): """ Delete a member from a list. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash return await self._mc_client._delete( url=self._build_path(list_id, 'members', subscriber_hash))
def delete_permanent(self, list_id, subscriber_hash): """ Delete permanently a member from a list. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash return self._mc_client._post( url=self._build_path(list_id, 'members', subscriber_hash, 'actions', 'delete-permanent'))
def update(self, list_id, subscriber_hash, data): """ Update information for a specific list member. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash return self._mc_client._patch(url=self._build_path(list_id, 'members', subscriber_hash), data=data)
def get(self, campaign_id, subscriber_hash, **queryparams): """ Get information about a specific campaign recipient. :param campaign_id: The unique id for the campaign. :type campaign_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param queryparams: The query string parameters queryparams['fields'] = [] queryparams['exclude_fields'] = [] """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.campaign_id = campaign_id self.subscriber_hash = subscriber_hash return self._mc_client._get(url=self._build_path(campaign_id, 'sent-to', subscriber_hash), **queryparams)
async def get(self, campaign_id, subscriber_hash, **queryparams): """ Get information about a specific campaign recipient. :param campaign_id: The unique id for the campaign. :type campaign_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param queryparams: The query string parameters queryparams['fields'] = [] queryparams['exclude_fields'] = [] """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.campaign_id = campaign_id self.subscriber_hash = subscriber_hash return await self._mc_client._get(url=self._build_path(campaign_id, 'sent-to', subscriber_hash), **queryparams)
def delete(self, list_id, subscriber_hash, note_id): """ Delete a specific note for a specific list member. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param note_id: The id for the note. :type note_id: :py:class:`str` """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash self.note_id = note_id return self._mc_client._delete(url=self._build_path(list_id, 'members', subscriber_hash, 'notes', note_id))
def all(self, list_id, subscriber_hash, **queryparams): """ Get the last 50 Goal events for a member on a specific list. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param queryparams: The query string parameters queryparams['fields'] = [] queryparams['exclude_fields'] = [] """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash return self._mc_client._get(url=self._build_path(list_id, 'members', subscriber_hash, 'goals'), **queryparams)
async def update(self, list_id, subscriber_hash, data): """ Update information for a specific list member. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash return await self._mc_client._patch(url=self._build_path( list_id, 'members', subscriber_hash), data=data)
def delete(self, list_id, segment_id, subscriber_hash): """ Remove a member from the specified static segment. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param segment_id: The unique id for the segment. :type segment_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.segment_id = segment_id self.subscriber_hash = subscriber_hash return self._mc_client._delete(url=self._build_path( list_id, 'segments', segment_id, 'members', subscriber_hash))
def get(self, workflow_id, email_id, subscriber_hash): """ Get information about a specific subscriber in an Automation email queue. :param workflow_id: The unique id for the Automation workflow. :type workflow_id: :py:class:`str` :param email_id: The unique id for the Automation workflow email. :type email_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.workflow_id = workflow_id self.email_id = email_id self.subscriber_hash = subscriber_hash return self._mc_client._get(url=self._build_path(workflow_id, "emails", email_id, "queue", subscriber_hash))
def get(self, workflow_id, email_id, subscriber_hash): """ Get information about a specific subscriber in an Automation email queue. :param workflow_id: The unique id for the Automation workflow. :type workflow_id: :py:class:`str` :param email_id: The unique id for the Automation workflow email. :type email_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.workflow_id = workflow_id self.email_id = email_id self.subscriber_hash = subscriber_hash return self._mc_client._get(url=self._build_path(workflow_id, 'emails', email_id, 'queue', subscriber_hash))
def get(self, list_id, subscriber_hash, **queryparams): """ Get information about a specific list member, including a currently subscribed, unsubscribed, or bounced member. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param queryparams: The query string parameters queryparams['fields'] = [] queryparams['exclude_fields'] = [] """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash return self._mc_client._get(url=self._build_path(list_id, 'members', subscriber_hash), **queryparams)
def all(self, list_id, subscriber_hash, **queryparams): """ Get the last 50 Goal events for a member on a specific list. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param queryparams: The query string parameters queryparams['fields'] = [] queryparams['exclude_fields'] = [] """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash return self._mc_client._get(url=self._build_path( list_id, 'members', subscriber_hash, 'goals'), **queryparams)
async def get(self, list_id, subscriber_hash, **queryparams): """ Get information about a specific list member, including a currently subscribed, unsubscribed, or bounced member. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param queryparams: The query string parameters queryparams['fields'] = [] queryparams['exclude_fields'] = [] """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash return await self._mc_client._get(url=self._build_path( list_id, 'members', subscriber_hash), **queryparams)
async def all(self, list_id, subscriber_hash, **queryparams): """ Get the last 50 events of a member’s activity on a specific list, including opens, clicks, and unsubscribes. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param queryparams: The query string parameters queryparams['fields'] = [] queryparams['exclude_fields'] = [] """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash return await self._mc_client._get(url=self._build_path( list_id, 'members', subscriber_hash, 'activity'), **queryparams)
async def get(self, campaign_id, subscriber_hash, **queryparams): """ Get a specific list member’s activity in a campaign including opens, clicks, and bounces. :param campaign_id: The unique id for the campaign. :type campaign_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param queryparams: The query string parameters queryparams['fields'] = [] queryparams['exclude_fields'] = [] """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.campaign_id = campaign_id self.subscriber_hash = subscriber_hash return await self._mc_client._get(url=self._build_path( campaign_id, 'email-activity', subscriber_hash), **queryparams)
def create_or_update(self, list_id, subscriber_hash, data): """ Add or update a list member. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "email_address": string*, "status_if_new": string* (Must be one of 'subscribed', 'unsubscribed', 'cleaned' or 'pending') } """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash try: test = data['email_address'] except KeyError as error: new_msg = 'The list member must have an email_address, {}'.format( error) six.reraise(KeyError, KeyError(new_msg), sys.exc_info()[2]) check_email(data['email_address']) try: test = data['status_if_new'] except KeyError as error: new_msg = 'The list member must have a status_if_new, {}'.format( error) six.reraise(KeyError, KeyError(new_msg), sys.exc_info()[2]) if data['status_if_new'] not in [ 'subscribed', 'unsubscribed', 'cleaned', 'pending' ]: raise ValueError( 'The list member status_if_new must be one of "subscribed", "unsubscribed", "cleaned", ' 'or "pending"') return self._mc_client._put(url=self._build_path( list_id, 'members', subscriber_hash), data=data)
def get(self, campaign_id, subscriber_hash, **queryparams): """ Get a specific list member’s activity in a campaign including opens, clicks, and bounces. :param campaign_id: The unique id for the campaign. :type campaign_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param queryparams: The query string parameters queryparams['fields'] = [] queryparams['exclude_fields'] = [] """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.campaign_id = campaign_id self.subscriber_hash = subscriber_hash return self._mc_client._get( url=self._build_path(campaign_id, 'email-activity', subscriber_hash), **queryparams )
def feed(self, list_id, subscriber_hash, **queryparams): """ Get the last 10 events of a member’s activity on a specific list, including opens, clicks, and unsubscribes. With count parameter, get as many past events as you would like. Returns many more fields not accessible by all endpoint. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param queryparams: The query string parameters queryparams['fields'] = [] queryparams['exclude_fields'] = [] """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash return self._mc_client._get(url=self._build_path( list_id, 'members', subscriber_hash, 'activity-feed'), **queryparams)
def get(self, list_id, subscriber_hash, note_id, **queryparams): """ Get a specific note for a specific list member. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param note_id: The id for the note. :type note_id: :py:class:`str` :param queryparams: The query string parameters queryparams['fields'] = [] queryparams['exclude_fields'] = [] """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash self.note_id = note_id return self._mc_client._get(url=self._build_path( list_id, 'members', subscriber_hash, 'notes', note_id), **queryparams)
def get(self, list_id, subscriber_hash, note_id, **queryparams): """ Get a specific note for a specific list member. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param note_id: The id for the note. :type note_id: :py:class:`str` :param queryparams: The query string parameters queryparams['fields'] = [] queryparams['exclude_fields'] = [] """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash self.note_id = note_id return self._mc_client._get( url=self._build_path(list_id, 'members', subscriber_hash, 'notes', note_id), **queryparams )
def delete(self, list_id, subscriber_hash, data): """Remove one or more tags from a specified list subscriber. :param list_id: The unique id for the list. :param subscriber_hash: The MD5 hash of the lowercase version of the member’s email :param data: The tag(s) to remove, as either a string or list of strings """ subscriber_hash = check_subscriber_hash(subscriber_hash) if isinstance(data, str): tag_names = [dict(name=data, status="inactive")] elif isinstance(data, list): tag_names = list( map(lambda t: dict(name=t, status="inactive"), data)) else: raise ValueError( "Tags must be given as a string or list of strings") # noinspection PyProtectedMember return self._mc_client._post(url=self._build_path( list_id, "members", subscriber_hash, "tags"), data=dict(tags=tag_names))
def get(self, campaign_id, link_id, subscriber_hash, **queryparams): """ Get information about a specific subscriber who clicked a link in a specific campaign. :param campaign_id: The unique id for the campaign. :type campaign_id: :py:class:`str` :param link_id: The id for the link. :type link_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param queryparams: The query string parameters queryparams['fields'] = [] queryparams['exclude_fields'] = [] """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.campaign_id = campaign_id self.link_id = link_id self.subscriber_hash = subscriber_hash return self._mc_client._get(url=self._build_path( campaign_id, 'click-details', link_id, 'members', subscriber_hash), **queryparams)
def update(self, list_id, subscriber_hash, data): """ Update tags for a specific subscriber. The documentation lists only the tags request body parameter so it is being documented and error-checked as if it were required based on the description of the method. The data list needs to include a "status" key. This determines if the tag should be added or removed from the user: data = { 'tags': [ {'name': 'foo', 'status': 'active'}, {'name': 'bar', 'status': 'inactive'} ] } :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param subscriber_hash: The MD5 hash of the lowercase version of the list member’s email address. :type subscriber_hash: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "tags": list* } """ subscriber_hash = check_subscriber_hash(subscriber_hash) self.list_id = list_id self.subscriber_hash = subscriber_hash if 'tags' not in data: raise KeyError('The list member tags must have a tag') response = self._mc_client._post(url=self._build_path(list_id, 'members', subscriber_hash, 'tags'), data=data) return response