/// <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="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 searchString = _T("INSERT_SEARCH_STRING_CRITERIA_HERE"); // Create advertiser group search criteria structure. AdvertiserGroupSearchCriteria advGroupSearchCriteria = new AdvertiserGroupSearchCriteria(); advGroupSearchCriteria.pageSize = 10; advGroupSearchCriteria.searchString = searchString; try { // Get advertiser group record set. AdvertiserGroupRecordSet advertiserGroupRecordSet = service.getAdvertiserGroups(advGroupSearchCriteria); // Display advertiser group names, ids and advertiser count. if (advertiserGroupRecordSet != null && advertiserGroupRecordSet.records != null) { foreach (AdvertiserGroup advertiserGroup in advertiserGroupRecordSet.records) { Console.WriteLine("Advertiser Group with name \"{0}\", id \"{1}\", containing \"{2}\"" + " advertisers was found.", advertiserGroup.name, advertiserGroup.id, advertiserGroup.advertiserCount); } } else { Console.WriteLine("No advertiser groups found for your search criteria."); } } catch (Exception e) { Console.WriteLine("Failed to retrieve advertiser groups. Exception says \"{0}\"", e.Message); } }
/// <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); long[] advertiserIds = new long[] { long.Parse(_T("INSERT_ADVERTISER_ID1_HERE")), long.Parse(_T("INSERT_ADVERTISER_ID2_HERE")) }; long advertiserGroupId = long.Parse(_T("INSERT_ADVERTISER_GROUP_ID_HERE")); try { // Assign the advertisers to the advertiser group. service.assignAdvertisersToAdvertiserGroup(advertiserGroupId, advertiserIds); Console.WriteLine("Assigned advertisers to advertiser group successfully."); } catch (Exception e) { Console.WriteLine("Failed to add advertisers to advertiser group. Exception says \"{0}\"", e.Message); } }