/// <summary> /// Run the code example. /// </summary> /// <param name="user">The Dfa user object running the code example. /// </param> public override void Run(DfaUser user) { // Create AdvertiserGroupRemoteService instance. AdvertiserGroupRemoteService service = (AdvertiserGroupRemoteService)user.GetService( DfaService.v1_20.AdvertiserGroupRemoteService); string advertiserGroupName = _T("INSERT_ADVERTISER_GROUP_NAME_HERE"); // Create advertiser group structure. AdvertiserGroup advertiserGroup = new AdvertiserGroup(); advertiserGroup.id = 0; advertiserGroup.name = advertiserGroupName; try { // Create advertiser group. AdvertiserGroupSaveResult advertiserGroupSaveResult = service.saveAdvertiserGroup(advertiserGroup); // Display advertiser group id. Console.WriteLine("Advertiser Group with id \"{0}\" was created.", advertiserGroupSaveResult.id); } catch (Exception ex) { Console.WriteLine("Failed to create advertiser group. Exception says \"{0}\"", ex.Message); } }
/// <summary> /// Run the code example. /// </summary> /// <param name="service">An initialized Dfa Reporting service object /// </param> public override void Run(DfareportingService service) { long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE")); String advertiserGroupName = _T("INSERT_ADVERTISER_GROUP_NAME_HERE"); // Create advertiser group structure. AdvertiserGroup advertiserGroup = new AdvertiserGroup(); advertiserGroup.Name = advertiserGroupName; // Create advertiser group. AdvertiserGroup result = service.AdvertiserGroups.Insert(advertiserGroup, profileId).Execute(); // Display advertiser group ID. Console.WriteLine("Advertiser Group with ID {0} was created.", result.Id); }
/// <summary> /// Run the code example. /// </summary> /// <param name="service">An initialized Dfa Reporting service object /// </param> public override void Run(DfareportingService service) { long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE")); String advertiserGroupName = _T("INSERT_ADVERTISER_GROUP_NAME_HERE"); // Create advertiser group structure. AdvertiserGroup advertiserGroup = new AdvertiserGroup(); advertiserGroup.Name = advertiserGroupName; // Create advertiser group. AdvertiserGroup result = service.AdvertiserGroups.Insert(advertiserGroup, profileId).Execute(); // Display advertiser group ID. Console.WriteLine("Advertiser Group with ID {0} was created.", result.Id); }
/// <summary> /// Updates an existing advertiser group. /// Documentation https://developers.google.com/dfareporting/v2.7/reference/advertiserGroups/update /// 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="body">A valid Dfareporting v2.7 body.</param> /// <returns>AdvertiserGroupResponse</returns> public static AdvertiserGroup Update(DfareportingService service, string profileId, AdvertiserGroup 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); } // Make the request. return(service.AdvertiserGroups.Update(body, profileId).Execute()); } catch (Exception ex) { throw new Exception("Request AdvertiserGroups.Update failed.", ex); } }