Пример #1
0
 def update(self, file_path, list_type, operation=TA_OPERATIONS.ADD):
     """
     Updates the current tailored audience instance.
     """
     upload = TONUpload(self.account.client, file_path)
     getattr(self, '__update_audience__')(upload.perform(), list_type, operation)
     return self.reload()
Пример #2
0
 def opt_out(klass, account, file_path, list_type):
     """
     Updates the global opt-out list for the specified advertiser account.
     """
     upload = TONUpload(account.client, file_path)
     params = {'input_file_path': upload.perform(), 'list_type': list_type}
     resource = klass.OPT_OUT.format(account_id=account.id)
     Request(account.client, 'put', resource, params=params).perform()
     return True
Пример #3
0
 def create(klass, account, file_path, name, list_type):
     """
     Uploads and creates a new tailored audience.
     """
     upload = TONUpload(account.client, file_path)
     audience = klass(account)
     getattr(audience, '__create_audience__')(name, list_type)
     try:
         getattr(audience, '__update_audience__')(upload.perform(), list_type, TA_OPERATIONS.ADD)
         return audience.reload()
     except BadRequest as e:
         audience.delete()
         raise e