*/
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 advertiser = new Company();
advertiser.setName("Advertiser #" + new Random().nextInt(Integer.MAX_VALUE));
advertiser.setType(CompanyType.ADVERTISER);
// Create an agency.
Company agency = new Company();
agency.setName("Agency #" + new Random().nextInt(Integer.MAX_VALUE));
agency.setType(CompanyType.AGENCY);
// Create the companies on the server.
Company[] companies = companyService.createCompanies(new Company[] {advertiser, agency});
for (Company createdCompany : companies) {
System.out.printf("A company with ID \"%d\", name \"%s\", and type \"%s\" was created.\n",
createdCompany.getId(), createdCompany.getName(), createdCompany.getType());
}