import uuid


def CreateShoppingCampaign(client, budget_id, merchant_id):
  """Creates a shopping campaign with the given budget and merchant IDs.

  Args:
    client: an AdWordsClient instance.
    budget_id: the str ID of the budget to be associated with the shopping
      campaign.
    merchant_id: the str ID of the merchant account to be associated with the
      shopping campaign.

  Returns:
    The created Shopping Campaign as a sudsobject.
  """
  campaign_service = client.GetService('CampaignService', 'v201809')

  campaign = {
      'name': 'Shopping campaign #%s' % uuid.uuid4(),
      # The advertisingChannelType is what makes this a shopping campaign
      'advertisingChannelType': 'SHOPPING',
      # Recommendation: Set the campaign to PAUSED when creating it to stop the
      # ads from immediately serving. Set to ENABLED once you've added targeting
      # and the ads are ready to serve.
      'status': 'PAUSED',
      # Set portfolio budget (required)
      'budget': {
          'budgetId': budget_id
      },
      'biddingStrategyConfiguration': {
          'biddingStrategyType': 'MANUAL_CPC'
      },
      'settings': [
          # All shopping campaigns need a ShoppingSetting
          {
              'xsi_type': 'ShoppingSetting',
              'salesCountry': 'US',
              'campaignPriority': '0',
              'merchantId': merchant_id,
              # Set to "True" to enable Local Inventory Ads in your campaign.
              'enableLocal': True
          }
      ]
  }

  campaign_operations = [{
      'operator': 'ADD',
      'operand': campaign
  }]

  campaign = campaign_service.mutate(campaign_operations)['value'][0]
  print ('Campaign with name "%s" and ID "%s" was added.'
         % (campaign['name'], campaign['id']))

  return campaign