public void TestContactListItemsCRUD() { Contact c1 = new Contact { FirstName = "name1", HomePhone = "12345678901" }; Contact c2 = new Contact { FirstName = "name2", HomePhone = "12345678902" }; CreateContactListRequest<Contact> request = new CreateContactListRequest<Contact> { Contacts = new List<Contact> { c1, c2 }, Name = "listFromContacts" }; ResourceId id = Client.ContactListsApi.Create(request); AddContactListContactsRequest<string> addItemsRequest = new AddContactListContactsRequest<string> { ContactListId = id.Id, Contacts = new List<string> { "12345543211" } }; Client.ContactListsApi.AddListItems(addItemsRequest); GetByIdRequest getItemsRequest = new GetByIdRequest { Id = id.Id }; Page<Contact> contactListItems = Client.ContactListsApi.GetListItems(getItemsRequest); IList<Contact> items = contactListItems.Items; Assert.AreEqual(3, items.Count); Client.ContactListsApi.RemoveListItem(id.Id, (long)items[0].Id); contactListItems = Client.ContactListsApi.GetListItems(getItemsRequest); items = contactListItems.Items; Assert.AreEqual(2, items.Count); Client.ContactListsApi.RemoveListItems(id.Id, new List<long> { (long)items[0].Id, (long)items[1].Id }); contactListItems = Client.ContactListsApi.GetListItems(getItemsRequest); Assert.True(contactListItems.Items.Count == 0); Assert.AreEqual(0, contactListItems.TotalCount); Client.ContactListsApi.Delete(id.Id); }
public void Create() { string responseJson = GetJsonPayload("/contacts/contactsApi/response/createContactList.json"); var restRequest = MockRestResponse(responseJson); Contact c1 = new Contact { HomePhone = "123456" }; Contact c2 = new Contact { HomePhone = "123457" }; CreateContactListRequest <Contact> requestContact = new CreateContactListRequest <Contact> { Name = "listFromContacts", Contacts = new List <Contact> { c1, c2 }, UseCustomFields = true }; ResourceId res = Client.ContactListsApi.Create(requestContact); Assert.That(Serializer.Serialize(res), Is.EqualTo(responseJson)); Assert.AreEqual(Method.POST, restRequest.Value.Method); }
public void TestContactListItemsCRUD() { Contact c1 = new Contact { FirstName = "name1", HomePhone = "12345678901" }; Contact c2 = new Contact { FirstName = "name2", HomePhone = "12345678902" }; CreateContactListRequest <Contact> request = new CreateContactListRequest <Contact> { Contacts = new List <Contact> { c1, c2 }, Name = "listFromContacts", UseCustomFields = true }; ResourceId id = Client.ContactListsApi.Create(request); AddContactListContactsRequest <string> addItemsRequest = new AddContactListContactsRequest <string> { ContactListId = id.Id, Contacts = new List <string> { "12345543211" }, UseCustomFields = true }; Client.ContactListsApi.AddListItems(addItemsRequest); GetByIdRequest getItemsRequest = new GetByIdRequest { Id = id.Id }; Page <Contact> contactListItems = Client.ContactListsApi.GetListItems(getItemsRequest); IList <Contact> items = contactListItems.Items; Assert.AreEqual(3, items.Count); Client.ContactListsApi.RemoveListItem(id.Id, (long)items[0].Id); System.Threading.Thread.Sleep(5000); contactListItems = Client.ContactListsApi.GetListItems(getItemsRequest); items = contactListItems.Items; Assert.AreEqual(2, items.Count); Client.ContactListsApi.RemoveListItems(id.Id, new List <long> { (long)items[0].Id, (long)items[1].Id }); System.Threading.Thread.Sleep(5000); contactListItems = Client.ContactListsApi.GetListItems(getItemsRequest); Assert.True(contactListItems.Items.Count == 0); Assert.AreEqual(0, contactListItems.TotalCount); Client.ContactListsApi.Delete(id.Id); }
public void TestContactListCRUD() { // create from numbers CreateContactListRequest<string> request = new CreateContactListRequest<string> { Contacts = new List<string> { "12135543211", "12135678882" }, Name = "listFromNumbers" }; ResourceId numbersListId = Client.ContactListsApi.Create(request); ContactList contactList = Client.ContactListsApi.Get(numbersListId.Id); Assert.AreEqual(2, contactList.Size); Assert.AreEqual(contactList.Name, "listFromNumbers"); // get items GetByIdRequest getItemsRequest = new GetByIdRequest { Id = contactList.Id }; Page<Contact> contactListItems = Client.ContactListsApi.GetListItems(getItemsRequest); IList<Contact> items = contactListItems.Items; Assert.AreEqual(2, items.Count); // create from ids var request2 = new CreateContactListRequest<long> { Contacts = new List<long> { (long)items[0].Id, (long)items[1].Id }, Name = "listFromExistingContacts" }; ResourceId idsListId = Client.ContactListsApi.Create(request2); contactList = Client.ContactListsApi.Get(idsListId.Id); Assert.AreEqual(2, contactList.Size); Assert.AreEqual(contactList.Name, "listFromExistingContacts"); // find by name FindContactListsRequest findRequest = new FindContactListsRequest { Name = "listFrom" }; Page<ContactList> contactLists = Client.ContactListsApi.Find(findRequest); Assert.Greater(contactLists.TotalCount, 1); // update UpdateContactListRequest updateListRequest = new UpdateContactListRequest { Id = idsListId.Id, Name = "new_name" }; Client.ContactListsApi.Update(updateListRequest); ContactList updatedList = Client.ContactListsApi.Get((long)updateListRequest.Id); Assert.AreEqual("new_name", updatedList.Name); // delete Client.ContactListsApi.Delete((long)numbersListId.Id); Client.ContactListsApi.Delete((long)idsListId.Id); }
public void TestDynamicPropertiesSerializationStringNumbers() { CreateContactListRequest <string> requestString = new CreateContactListRequest <string> { Name = "listFromNumbers", Contacts = new List <string> { "12345678881", "12345678882" } }; String serialized = Serializer.Serialize(requestString); Assert.That(serialized, Does.Contain("\"contactNumbers\":")); }
public void TestDynamicPropertiesSerializationContactIds() { var requestLong = new CreateContactListRequest <long> { Name = "listFromIds", Contacts = new List <long> { 1, 2 } }; String serialized = Serializer.Serialize(requestLong); Assert.That(serialized, Does.Contain("\"contactIds\":")); Assert.That(serialized, Does.Contain("\"listFromIds\"")); }
public static void Main(string[] args) { var client = new CallfireClient("api_login", "api_password"); var request1 = new CreateContactListRequest <Contact> { Contacts = new List <Contact> { new Contact { FirstName = "Alice", LastName = "Moore", HomePhone = "12135551126" }, new Contact { FirstName = "Bob", LastName = "Smith", HomePhone = "12135551127", Properties = new Dictionary <string, string> { { "age", "30" } } } }, Name = "My Contact List" }; ResourceId resourceId1 = client.ContactListsApi.Create(request1); var request2 = new CreateContactListRequest <string> { Contacts = new List <string> { "12132212384", "12136612355", "12133312300" }, ContactNumbersField = "workPhone", Name = "My Contact List" }; ResourceId resourceId2 = client.ContactListsApi.Create(request2); var request3 = new CreateContactListRequest <long> { Contacts = new List <long> { 800634185003, 800734186003, 800834187003, 800984185003 }, Name = "My Contact List" }; ResourceId resourceId3 = client.ContactListsApi.Create(request3); }
public void Create() { string responseJson = GetJsonPayload("/contacts/contactsApi/response/createContactList.json"); var restRequest = MockRestResponse(responseJson); Contact c1 = new Contact { HomePhone = "123456" }; Contact c2 = new Contact { HomePhone = "123457" }; CreateContactListRequest<Contact> requestContact = new CreateContactListRequest<Contact> { Name = "listFromContacts", Contacts = new List<Contact> { c1, c2 } }; ResourceId res = Client.ContactListsApi.Create(requestContact); Assert.That(Serializer.Serialize(res), Is.EqualTo(responseJson)); Assert.AreEqual(Method.POST, restRequest.Value.Method); }
public void TestDynamicPropertiesSerializationContactPojos() { Contact c1 = new Contact { FirstName = "name1" }; Contact c2 = new Contact { FirstName = "name1" }; CreateContactListRequest <Contact> requestContact = new CreateContactListRequest <Contact>(); requestContact.Name = "listFromContacts"; requestContact.Contacts = new List <Contact> { c1, c2 }; String serialized = Serializer.Serialize(requestContact); Assert.That(serialized, Does.Contain("\"contacts\":")); Assert.That(serialized, Does.Contain("\"listFromContacts\"")); }
public void TestDynamicPropertiesSerializationStringNumbers() { CreateContactListRequest<string> requestString = new CreateContactListRequest<string> { Name = "listFromNumbers", Contacts = new List<string> { "12345678881", "12345678882" } }; String serialized = Serializer.Serialize(requestString); Assert.That(serialized, Is.StringContaining("\"contactNumbers\":")); }
public void TestDynamicPropertiesSerializationContactPojos() { Contact c1 = new Contact { FirstName = "name1" }; Contact c2 = new Contact { FirstName = "name1" }; CreateContactListRequest<Contact> requestContact = new CreateContactListRequest<Contact>(); requestContact.Name = "listFromContacts"; requestContact.Contacts = new List<Contact> { c1, c2 }; String serialized = Serializer.Serialize(requestContact); Assert.That(serialized, Is.StringContaining("\"contacts\":")); Assert.That(serialized, Is.StringContaining("\"listFromContacts\"")); }
public void TestDynamicPropertiesSerializationContactIds() { var requestLong = new CreateContactListRequest<long> { Name = "listFromIds", Contacts = new List<long> { 1, 2 } }; String serialized = Serializer.Serialize(requestLong); Assert.That(serialized, Is.StringContaining("\"contactIds\":")); Assert.That(serialized, Is.StringContaining("\"listFromIds\"")); }
/// <summary> /// Creates a contact list for use with campaigns using 1 of 3 inputs. A List of Contact objects, /// a list of String E.164 numbers, or a list of CallFire contactIds can be used as the data source /// for the created contact list.After staging these contacts into the CallFire system, contact lists /// go through seven system safeguards that check the accuracy and consistency of the data. For example, /// our system checks if a number is formatted correctly, is invalid, is duplicated in another /// contact list, or is on a specific DNC list.The default resolution in these safeguards will be /// to remove contacts that are against these rules. If contacts are not being added to a list, /// this means the data needs to be properly formatted and correct before calling this API. /// </summary> /// <example> /// <code> /// var request = new CreateContactListRequest<Contact> /// { /// Contacts = new List<Contact> /// { /// new Contact /// { /// FirstName = "Name1", /// HomePhone = "16506190257" /// }, /// new Contact /// { /// FirstName = "Name2", /// HomePhone = "18778973473" /// } /// }, /// Name = "Name" /// }; /// </code> /// </example> /// <param name="request">request object with provided contacts, list name and other values</param> /// <returns>newly created contact list id</returns> /// <exception cref="BadRequestException"> in case HTTP response code is 400 - Bad request, the request was formatted improperly.</exception> /// <exception cref="UnauthorizedException"> in case HTTP response code is 401 - Unauthorized, API Key missing or invalid.</exception> /// <exception cref="AccessForbiddenException"> in case HTTP response code is 403 - Forbidden, insufficient permissions.</exception> /// <exception cref="ResourceNotFoundException"> in case HTTP response code is 404 - NOT FOUND, the resource requested does not exist.</exception> /// <exception cref="InternalServerErrorException"> in case HTTP response code is 500 - Internal Server Error.</exception> /// <exception cref="CallfireApiException"> in case HTTP response code is something different from codes listed above.</exception> /// <exception cref="CallfireClientException"> in case error has occurred in client.</exception> public ResourceId Create <T>(CreateContactListRequest <T> request) { return(Client.Post <ResourceId>(LISTS_PATH, request)); }
public void TestContactListCRUD() { // create from numbers CreateContactListRequest <string> request = new CreateContactListRequest <string> { Contacts = new List <string> { "12135543211", "12135678882" }, Name = "listFromNumbers" }; ResourceId numbersListId = Client.ContactListsApi.Create(request); ContactList contactList = Client.ContactListsApi.Get(numbersListId.Id); Assert.AreEqual(2, contactList.Size); Assert.AreEqual(contactList.Name, "listFromNumbers"); // get items GetByIdRequest getItemsRequest = new GetByIdRequest { Id = contactList.Id }; Page <Contact> contactListItems = Client.ContactListsApi.GetListItems(getItemsRequest); IList <Contact> items = contactListItems.Items; Assert.AreEqual(2, items.Count); // create from ids var request2 = new CreateContactListRequest <long> { Contacts = new List <long> { (long)items[0].Id, (long)items[1].Id }, Name = "listFromExistingContacts" }; ResourceId idsListId = Client.ContactListsApi.Create(request2); contactList = Client.ContactListsApi.Get(idsListId.Id); Assert.AreEqual(2, contactList.Size); Assert.AreEqual(contactList.Name, "listFromExistingContacts"); // find by name FindContactListsRequest findRequest = new FindContactListsRequest { Name = "listFrom" }; Page <ContactList> contactLists = Client.ContactListsApi.Find(findRequest); Assert.Greater(contactLists.TotalCount, 1); // update UpdateContactListRequest updateListRequest = new UpdateContactListRequest { Id = idsListId.Id, Name = "new_name" }; Client.ContactListsApi.Update(updateListRequest); ContactList updatedList = Client.ContactListsApi.Get((long)updateListRequest.Id); Assert.AreEqual("new_name", updatedList.Name); // delete Client.ContactListsApi.Delete((long)numbersListId.Id); Client.ContactListsApi.Delete((long)idsListId.Id); }