*/
public class CreateCompanies {
public static void runExample(DfpServices dfpServices, DfpSession session) throws Exception {
// Get the CompanyService.
CompanyServiceInterface companyService =
dfpServices.get(session, CompanyServiceInterface.class);
// Create an advertiser.
Company company1 = new Company();
company1.setName("Advertiser #" + new Random().nextLong());
company1.setType(CompanyType.ADVERTISER);
// Create an agency.
Company company2 = new Company();
company2.setName("Agency #" + new Random().nextLong());
company2.setType(CompanyType.AGENCY);
// Create the companies on the server.
Company[] companies = companyService.createCompanies(new Company[] {company1, company2});
for (Company company : companies) {
System.out.printf("A company with ID \"%d\", name \"%s\", and type \"%s\" was created.\n",
company.getId(), company.getName(), company.getType());
}