예제 #1
0
 def setUp(self):
     """Prepare unittest."""
     client = AdWordsClient(headers={
         'authToken': ' ',
         'userAgent': ' ',
         'developerToken': ' '
     })
     self.service = client.GetReportDownloader()
예제 #2
0
 def setUp(self):
     """Prepare unittest."""
     client = AdWordsClient(headers={
         'oauth2credentials': 'cr3d3n7i415',
         'userAgent': 'USER AGENT',
         'developerToken': 'DEV TOKEN'
     },
                            path='/tmp/')
     self.service = client.GetReportDownloader()
  def setUp(self):
    """Prepare unittest."""
    with mock.patch('adspygoogle.adwords.util.XsdToWsdl.CreateWsdlFromXsdUrl'):
      credentials = OAuth2Credentials(
          'ACCESS_TOKEN', 'client_id', 'client_secret', 'refresh_token', None,
          'uri', 'user_agent')

      self.oauth2_headers = {
          'oauth2credentials': credentials,
          'userAgent': 'USER AGENT',
          'developerToken': 'DEV TOKEN',
          'clientCustomerId': 'client customer id'
      }
      client = AdWordsClient(self.oauth2_headers, path='/tmp/')
      self.service_v201402 = client.GetReportDownloader(
          version='v201402')

      self.service = client.GetReportDownloader()
예제 #4
0
    def setUp(self):
        """Prepare unittest."""
        with mock.patch(
                'adspygoogle.adwords.util.XsdToWsdl.CreateWsdlFromXsdUrl'):
            client = AdWordsClient(
                headers={
                    'authToken': 'AUTH TOKEN',
                    'userAgent': 'USER AGENT',
                    'developerToken': 'DEV TOKEN',
                    'email': '*****@*****.**',
                    'password': '******'
                })
            self.service = client.GetReportDownloader()

            credentials = OAuth2Credentials('ACCESS_TOKEN', 'client_id',
                                            'client_secret', 'refresh_token',
                                            None, 'uri', 'user_agent')
            client_oauth2 = AdWordsClient(
                headers={
                    'oauth2credentials': credentials,
                    'userAgent': 'USER AGENT',
                    'developerToken': 'DEV TOKEN'
                })
            self.service_oauth2 = client_oauth2.GetReportDownloader()
예제 #5
0
    # Get all campaigns.
    # Construct selector and get all campaigns.
    selector = {'fields': ['Id', 'Name', 'Status']}
    campaigns = campaign_service.Get(selector)[0]

    # Display results.
    if 'entries' in campaigns:
        for campaign in campaigns['entries']:
            print(
                'Campaign with id \'%s\', name \'%s\' and status \'%s\' was found.'
                % (campaign['id'], campaign['name'], campaign['status']))
    else:
        print 'No campaigns were found.'

    # Initialize appropriate service.
    report_downloader = client.GetReportDownloader(version='v201402')

    # Create report definition.
    report = {
        'reportName': 'Last 7 days CRITERIA_PERFORMANCE_REPORT',
        'dateRangeType': 'LAST_7_DAYS',
        'reportType': 'CRITERIA_PERFORMANCE_REPORT',
        'downloadFormat': 'CSV',
        'selector': {
            'fields': [
                'CampaignId', 'AdGroupId', 'Id', 'CriteriaType', 'Criteria',
                'Impressions', 'Clicks', 'Cost'
            ]
        },
        # Enable to get rows with zero impressions.
        'includeZeroImpressions': 'false'