/// <summary> /// Run the code example. /// </summary> /// <param name="service">An initialized Dfa Reporting service object /// </param> public override void Run(DfareportingService service) { long advertiserId = long.Parse(_T("INSERT_ADVERTISER_ID_HERE")); long remarketingListId = long.Parse(_T("INSERT_REMARKETING_LIST_ID_HERE")); long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE")); // Load the existing share info. RemarketingListShare share = service.RemarketingListShares.Get(profileId, remarketingListId).Execute(); if (share.SharedAdvertiserIds == null) { share.SharedAdvertiserIds = new List <long?> { }; } if (!share.SharedAdvertiserIds.Contains(advertiserId)) { share.SharedAdvertiserIds.Add(advertiserId); // Update the share info with the newly added advertiser ID. RemarketingListShare result = service.RemarketingListShares.Update(share, profileId).Execute(); Console.WriteLine( "Remarketing list with ID {0} is now shared to advertiser ID(s): {1}.\n", result.RemarketingListId, string.Join(", ", result.SharedAdvertiserIds)); } else { Console.WriteLine( "Remarketing list with ID {0} is already shared to advertiser ID {1}.\n", remarketingListId, advertiserId); } }
/// <summary> /// Updates an existing remarketing list share. This method supports patch semantics. /// Documentation https://developers.google.com/dfareporting/v2.8/reference/remarketingListShares/patch /// Generation Note: This does not always build corectly. Google needs to standardise things I need to figuer out which ones are wrong. /// </summary> /// <param name="service">Authenticated Dfareporting service.</param> /// <param name="profileId">User profile ID associated with this request.</param> /// <param name="remarketingListId">Remarketing list ID.</param> /// <param name="body">A valid Dfareporting v2.8 body.</param> /// <returns>RemarketingListShareResponse</returns> public static RemarketingListShare Patch(DfareportingService service, string profileId, string remarketingListId, RemarketingListShare body) { try { // Initial validation. if (service == null) { throw new ArgumentNullException("service"); } if (body == null) { throw new ArgumentNullException("body"); } if (profileId == null) { throw new ArgumentNullException(profileId); } if (remarketingListId == null) { throw new ArgumentNullException(remarketingListId); } // Make the request. return(service.RemarketingListShares.Patch(body, profileId, remarketingListId).Execute()); } catch (Exception ex) { throw new Exception("Request RemarketingListShares.Patch failed.", ex); } }