/// <summary> /// Run the code example. /// </summary> /// <param name="user">The DFP user object running the code example.</param> public override void Run(DfpUser user) { // Get the ContactService. ContactService contactService = (ContactService) user.GetService(DfpService.v201311.ContactService); // Set the IDs of the companies for the contacts. long advertiserCompanyId = long.Parse(_T("INSERT_ADVERTISER_COMPANY_ID_HERE")); long agencyCompanyId = long.Parse(_T("INSERT_AGENCY_COMPANY_ID_HERE")); // Create an advertiser contact. Contact advertiserContact = new Contact(); advertiserContact.name = "Mr. Advertiser #" + GetTimeStamp(); advertiserContact.email = "*****@*****.**"; advertiserContact.companyId = advertiserCompanyId; // Create an agency contact. Contact agencyContact = new Contact(); agencyContact.name = "Ms. Agency #" + GetTimeStamp(); agencyContact.email = "*****@*****.**"; agencyContact.companyId = agencyCompanyId; try { // Create the contacts on the server. Contact[] contacts = contactService.createContacts(new Contact[] {advertiserContact, agencyContact}); foreach (Contact contact in contacts) { Console.WriteLine("A contact with ID \"{0}\" and name \"{1}\" was created.", contact.id, contact.name); } } catch (Exception ex) { Console.WriteLine("Failed to create contacts. Exception says \"{0}\"", ex.Message); } }
public virtual Contact updateContact(Contact contact) { object[] results = this.Invoke("updateContact", new object[] { contact }); return ((Contact) (results[0])); }