public void Find() { var expectedJson = GetJsonPayload("/contacts/contactsApi/response/findContacts.json"); var restRequest = MockRestResponse(expectedJson); var request = new FindContactsRequest { Number = new List <string> { "123", "456" }, Id = new List <long> { 124, 457 }, Limit = 1, Offset = 5 }; var contacts = Client.ContactsApi.Find(request); Assert.That(Serializer.Serialize(contacts), Is.EqualTo(expectedJson)); Assert.AreEqual(Method.GET, restRequest.Value.Method); var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody); Assert.IsNull(requestBodyParam); Assert.That(restRequest.Value.Parameters, Has.Some.Matches <Parameter>(p => p.Name.Equals("limit") && p.Value.Equals("1"))); Assert.That(restRequest.Value.Parameters, Has.Some.Matches <Parameter>(p => p.Name.Equals("offset") && p.Value.Equals("5"))); Assert.That(restRequest.Value.Parameters, Has.Some.Matches <Parameter>(p => p.Name.Equals("number") && p.Value.Equals("123"))); Assert.That(restRequest.Value.Parameters, Has.Some.Matches <Parameter>(p => p.Name.Equals("number") && p.Value.Equals("456"))); Assert.That(restRequest.Value.Parameters, Has.Some.Matches <Parameter>(p => p.Name.Equals("id") && p.Value.Equals("124"))); Assert.That(restRequest.Value.Parameters, Has.Some.Matches <Parameter>(p => p.Name.Equals("id") && p.Value.Equals("457"))); }
public void Find() { var request = new FindContactsRequest { Number = new List <string> { "16506190257", "18778973473" }, Id = new List <long> { 1, 2 } }; var contacts = Client.ContactsApi.Find(request); Console.WriteLine(String.Join(",", contacts)); Assert.AreEqual(1, contacts.Items.Count); Assert.AreEqual("18088395900", contacts.Items[0].WorkPhone); }
public void Find() { var request = new FindContactsRequest { }; var contacts = Client.ContactsApi.Find(request); Console.WriteLine(String.Join(",", contacts)); Assert.AreEqual(100, contacts.Items.Count); string numberToFilter; numberToFilter = null; if (contacts.Items[0].HomePhone != null) { numberToFilter = contacts.Items[0].HomePhone; } else if (contacts.Items[0].WorkPhone != null) { numberToFilter = contacts.Items[0].WorkPhone; } else if (contacts.Items[0].MobilePhone != null) { numberToFilter = contacts.Items[0].MobilePhone; } if (numberToFilter != null) { request = new FindContactsRequest { Number = new List <string> { numberToFilter } }; contacts = Client.ContactsApi.Find(request); Assert.True(numberToFilter.Equals(contacts.Items[0].WorkPhone) || numberToFilter.Equals(contacts.Items[0].MobilePhone) || numberToFilter.Equals(contacts.Items[0].HomePhone)); } }
public static void Main(string[] args) { var client = new CallfireClient("api_login", "api_password"); var request = new FindContactsRequest { Id = new List <long> { 11646003, 12646003, 13776003 }, Number = new List <string> { "12135551126", "12136666123" }, ContactListId = 14400809003, PropertyName = "14400809003", PropertyValue = "14400809003", Offset = 0, Limit = 10, Fields = "items(id,name,size)" }; Page <Contact> contacts = client.ContactsApi.Find(request); }
/// <summary> /// Find contacts by id, contact list, or on any property name. Returns a paged list of contacts. /// </summary> /// <param name="request">request object with different fields to filter</param> /// <returns>paged list with contact objects</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 Page <Contact> Find(FindContactsRequest request) { return(Client.Get <Page <Contact> >(CONTACTS_PATH, request)); }