/// <summary>
    /// Attaches a shared set to a campaign.
    /// </summary>
    /// <param name="user">The AdWords user.</param>
    /// <param name="campaignId">The campaign id.</param>
    /// <param name="sharedSetId">The shared set id.</param>
    /// <returns>A CampaignSharedSet object that represents a binding between
    /// the specified campaign and the shared set.</returns>
    public CampaignSharedSet AttachSharedSetToCampaign(AdWordsUser user, long campaignId,
        long sharedSetId) {
      // Get the CampaignSharedSetService.
      CampaignSharedSetService campaignSharedSetService = (CampaignSharedSetService)
          user.GetService(AdWordsService.v201506.CampaignSharedSetService);

      CampaignSharedSet campaignSharedSet = new CampaignSharedSet();
      campaignSharedSet.campaignId = campaignId;
      campaignSharedSet.sharedSetId = sharedSetId;

      CampaignSharedSetOperation operation = new CampaignSharedSetOperation();
      operation.@operator = Operator.ADD;
      operation.operand = campaignSharedSet;

      CampaignSharedSetReturnValue retval = campaignSharedSetService.mutate(
          new CampaignSharedSetOperation[] {operation});
      return retval.value[0];
    }
Пример #2
0
    /// <summary>
    /// Detaches the shared set from campaign.
    /// </summary>
    /// <param name="user">The user.</param>
    /// <param name="campaignId">The campaign identifier.</param>
    /// <param name="sharedSetId">The shared set identifier.</param>
    public void DetachSharedSetFromCampaign(AdWordsUser user, long campaignId, long sharedSetId) {
      // Get the CampaignSharedSetService.
      CampaignSharedSetService campaignSharedSetService = (CampaignSharedSetService)
          user.GetService(AdWordsService.v201506.CampaignSharedSetService);

      CampaignSharedSet campaignSharedSet = new CampaignSharedSet();
      campaignSharedSet.campaignId = campaignId;
      campaignSharedSet.sharedSetId = sharedSetId;

      CampaignSharedSetOperation operation = new CampaignSharedSetOperation();
      operation.@operator = Operator.REMOVE;
      operation.operand = campaignSharedSet;

      campaignSharedSetService.mutate(new CampaignSharedSetOperation[] { operation });
    }