def create(self, list_id, data): """ Create a new webhook for a specific list. The documentation does not include any required request body parameters but the url parameter is being listed here as a required parameter in documentation and error-checking based on the description of the method :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "url": string* } """ self.list_id = list_id try: test = data['url'] except KeyError as error: error.message += ' The list webhook must have a url' raise check_url(data['url']) response = self._mc_client._post(url=self._build_path(list_id, 'webhooks'), data=data) self.webhook_id = response['id'] return response
def create(self, list_id, data): """ Create a new webhook for a specific list. The documentation does not include any required request body parameters but the url parameter is being listed here as a required parameter in documentation and error-checking based on the description of the method :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "url": string* } """ self.list_id = list_id try: test = data['url'] except KeyError as error: new_msg = 'The list webhook must have a url, {}'.format(error) six.reraise(KeyError, KeyError(new_msg), sys.exc_info()[2]) check_url(data['url']) response = self._mc_client._post(url=self._build_path( list_id, 'webhooks'), data=data) if response is not None: self.webhook_id = response['id'] else: self.webhook_id = None return response
async def create(self, list_id, data): """ Create a new webhook for a specific list. The documentation does not include any required request body parameters but the url parameter is being listed here as a required parameter in documentation and error-checking based on the description of the method :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "url": string* } """ self.list_id = list_id if 'url' not in data: raise KeyError('The list webhook must have a url') check_url(data['url']) response = await self._mc_client._post(url=self._build_path( list_id, 'webhooks'), data=data) if response is not None: self.webhook_id = response['id'] else: self.webhook_id = None return response
def create(self, list_id, data): """ Create a new Twitter Lead Generation Card for a specific list. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "name": string*, "title": string*, "cta_text": string*, "privacy_policy_url": string*, "image_url": string*, "twitter_account_id": string* } """ self.list_id = list_id try: data['name'] except KeyError as error: error.message += ' The twitter lead generation card must have a name' raise try: data['title'] except KeyError as error: error.message += ' The twitter lead generation card must have a title' raise try: data['cta_text'] except KeyError as error: error.message += ' The twitter lead generation card must have a cta_text' raise if len(data['cta_text']) > 20: raise ValueError('The twitter lead generation card cta_text must be 20 characters or less') try: data['privacy_policy_url'] except KeyError as error: error.message += ' The twitter lead generation card must have a privacy_policy_url' raise check_url(data['privacy_policy_url']) try: data['image_url'] except KeyError as error: error.message += ' The twitter lead generation card must have a image_url' raise check_url(data['image_url']) try: data['twitter_account_id'] except KeyError as error: error.message += ' The twitter lead generation card must have a twitter_account_id' raise response = self._mc_client._post(url=self._build_path(list_id, 'twitter-lead-gen-cards'), data=data) self.twitter_card_id = response['id'] return response
def create(self, list_id, data): """ Create a new Twitter Lead Generation Card for a specific list. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "name": string*, "title": string*, "cta_text": string*, "privacy_policy_url": string*, "image_url": string*, "twitter_account_id": string* } """ self.list_id = list_id if 'name' not in data: raise KeyError('The twitter lead generation card must have a name') if 'title' not in data: raise KeyError( 'The twitter lead generation card must have a title') if 'cta_text' not in data: raise KeyError( 'The twitter lead generation card must have a cta_text') if len(data['cta_text']) > 20: raise ValueError( 'The twitter lead generation card cta_text must be 20 characters or less' ) if 'privacy_policy_url' not in data: raise KeyError( 'The twitter lead generation card must have a privacy_policy_url' ) check_url(data['privacy_policy_url']) if 'image_url' not in data: raise KeyError( 'The twitter lead generation card must have a image_url') check_url(data['image_url']) if 'twitter_account_id' not in data: raise KeyError( 'The twitter lead generation card must have a twitter_account_id' ) response = self._mc_client._post(url=self._build_path( list_id, 'twitter-lead-gen-cards'), data=data) if response is not None: self.twitter_card_id = response['id'] else: self.twitter_card_id = None return response
def create(self, list_id, data): """ Create a new Twitter Lead Generation Card for a specific list. :param list_id: The unique id for the list. :type list_id: :py:class:`str` :param data: The request body parameters :type data: :py:class:`dict` data = { "name": string*, "title": string*, "cta_text": string*, "privacy_policy_url": string*, "image_url": string*, "twitter_account_id": string* } """ self.list_id = list_id try: data['name'] except KeyError as error: new_msg = 'The twitter lead generation card must have a name, {}'.format( error) six.reraise(KeyError, KeyError(new_msg), sys.exc_info()[2]) try: data['title'] except KeyError as error: new_msg = 'The twitter lead generation card must have a title, {}'.format( error) six.reraise(KeyError, KeyError(new_msg), sys.exc_info()[2]) try: data['cta_text'] except KeyError as error: new_msg = 'The twitter lead generation card must have a cta_text, {}'.format( error) six.reraise(KeyError, KeyError(new_msg), sys.exc_info()[2]) if len(data['cta_text']) > 20: raise ValueError( 'The twitter lead generation card cta_text must be 20 characters or less' ) try: data['privacy_policy_url'] except KeyError as error: new_msg = 'The twitter lead generation card must have a privacy_policy_url, {}'.format( error) six.reraise(KeyError, KeyError(new_msg), sys.exc_info()[2]) check_url(data['privacy_policy_url']) try: data['image_url'] except KeyError as error: new_msg = 'The twitter lead generation card must have a image_url, {}'.format( error) six.reraise(KeyError, KeyError(new_msg), sys.exc_info()[2]) check_url(data['image_url']) try: data['twitter_account_id'] except KeyError as error: new_msg = 'The twitter lead generation card must have a twitter_account_id, {}'.format( error) six.reraise(KeyError, KeyError(new_msg), sys.exc_info()[2]) response = self._mc_client._post(url=self._build_path( list_id, 'twitter-lead-gen-cards'), data=data) if response is not None: self.twitter_card_id = response['id'] else: self.twitter_card_id = None return response