/// <summary> /// Run the code example. /// </summary> /// <param name="service">An initialized Dfa Reporting service object /// </param> public override void Run(DfareportingService service) { long accountId = long.Parse(_T("INSERT_ACCOUNT_ID_HERE")); long permissionOneId = long.Parse(_T("INSERT_FIRST_PERMISSION_ID_HERE")); long permissionTwoId = long.Parse(_T("INSERT_SECOND_PERMISSION_ID_HERE")); long profileId = long.Parse(_T("INSERT_USER_PROFILE_ID_HERE")); String subaccountName = _T("INSERT_SUBACCOUNT_NAME_HERE"); // Create subaccount structure. Subaccount subaccount = new Subaccount(); subaccount.Name = subaccountName; subaccount.AccountId = accountId; // Create a collection of all permissions assigned to this subaccount and add it to the // subaccount structure. To get list of available permissions, run GetUserRolePermissions.cs. subaccount.AvailablePermissionIds = new List<long?> { permissionOneId, permissionTwoId }; // Create subaccount. Subaccount result = service.Subaccounts.Insert(subaccount, profileId).Execute(); // Display subaccount ID. Console.WriteLine("Subaccount with ID {0} was created.", result.Id); }
/// <summary> /// Inserts a new subaccount. /// Documentation https://developers.google.com/dfareporting/v2.5beta1/reference/subaccounts/insert /// 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.5beta1 body.</param> /// <returns>SubaccountResponse</returns> public static Subaccount Insert(dfareportingService service, string profileId, Subaccount 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.Subaccounts.Insert(body, profileId).Execute()); } catch (Exception ex) { throw new Exception("Request Subaccounts.Insert failed.", ex); } }
public void Status() { var subaccount = new Subaccount { Status = SubaccountStatus.Terminated }; dataMapper.ToDictionary(subaccount)["status"].ShouldEqual(SubaccountStatus.Terminated.ToString().ToLowerInvariant()); }
public void Name() { var subaccount = new Subaccount { Name = Guid.NewGuid().ToString() }; dataMapper.ToDictionary(subaccount)["name"].ShouldEqual(subaccount.Name); }
public void IpPool() { var subaccount = new Subaccount { IpPool = Guid.NewGuid().ToString() }; dataMapper.ToDictionary(subaccount)["ip_pool"].ShouldEqual(subaccount.IpPool); }
public void Id() { var subaccount = new Subaccount { Id = 432 }; dataMapper.ToDictionary(subaccount)["id"].ShouldEqual(subaccount.Id); }
public void ComplianceStatus() { var subaccount = new Subaccount { ComplianceStatus = Guid.NewGuid().ToString() }; dataMapper.ToDictionary(subaccount)["compliance_status"].ShouldEqual(subaccount.ComplianceStatus); }