private InfusionsoftWebService InfusionsoftWebService() { var service = new InfusionsoftWebService(AccessToken, DeveloperAppKey, ServiceUrl); return service; }
public ActionResult FindContact() { //var accessToken = Request.QueryString["AccessToken"]; //var email = Request.QueryString["Email"]; //var viewData = new List<ContactInfo>(); //if (!string.IsNullOrEmpty(accessToken)) //{ // var contactService = XmlRpcProxyGen.Create<IInfusionsoftAPI>(); // contactService.Url = "https://api.infusionsoft.com/crm/xmlrpc/v1?access_token=" + accessToken; // var contacts = contactService.LookupByEmail(DeveloperAppKey, email, new[] { "Id", "FirstName", "LastName" }); // foreach (var contact in contacts) // { // viewData.Add(new ContactInfo { Id = (int)contact["Id"], FirstName = (string)contact["FirstName"], LastName = (string)contact["LastName"]}); // } //} var service = new InfusionsoftWebService(AccessToken, DeveloperAppKey, ServiceUrl); var client = service.Connect(); //client.MethodListener = new NullMethodListener(); const string email = "*****@*****.**"; var contacts = client.ContactService.FindByEmail(email, p => p.Include(c => c.Id) .Include(c => c.Email) .Include(c => c.FirstName) .Include(c => c.LastName) .Include(c => c.LeadSourceId) ); //Email opt in var emailOptinResponse = client.EmailService.OptIn(email, "Customer email opt-in from booker"); var emailOptOutResponse = client.EmailService.OptOut(email, "Customer email opt-out from booker"); //var deleteRecordResponse = client.DataService.Delete("Contact", contacts.FirstOrDefault().Id); var viewData = new List<ContactInfo>(); foreach (var contact in contacts) { viewData.Add(new ContactInfo {Id = contact.Id, FirstName = contact.FirstName, LastName = contact.LastName}); } return View(viewData); }