public void ShouldAddContactsToList()
        {
            var contactId1 = 12345;
            var contactId2 = 23456;
            var contactId3 = 34567;

            IRestRequest savedRequest = null;
            mockClient.Setup(trc => trc.Execute<LinkResult>(It.IsAny<IRestRequest>()))
                .Callback<IRestRequest>((request) => savedRequest = request)
                .Returns(new LinkResult());
            var client = mockClient.Object;

            var contact1 = new Contact() { Id = contactId1 };
            var contact2 = new Contact() { Id = contactId2 };
            var contact3 = new Contact() { Id = contactId3 };
            int[] contactIds = { contactId1, contactId2, contactId3 };
            var contacts = new System.Collections.Generic.List<Contact> { contact1, contact2, contact3 };
            var list = new ContactList() { Id = listId };
            client.AddContactsToList(list, contacts);

            mockClient.Verify(trc => trc.Execute<LinkResult>(It.IsAny<IRestRequest>()), Times.Once);
            Assert.IsNotNull(savedRequest);
            Assert.AreEqual("lists/{id}/contacts", savedRequest.Resource);
            Assert.AreEqual(Method.PUT, savedRequest.Method);
            Assert.AreEqual(2, savedRequest.Parameters.Count);
            Assert.AreEqual(listId.ToString(), savedRequest.Parameters.Find(x => x.Name == "id").Value);
            Assert.AreEqual(string.Join(",", contactIds), savedRequest.Parameters.Find(x => x.Name == "contacts").Value);

            var content = "{ \"id\": \"31337\", \"href\": \"/api/v2/lists/31337/contacts\"}";

            var testClient = Common.CreateClient<LinkResult>(content, null, null);
            client = new Client(testClient);

            var link = client.AddContactsToList(list, contacts);

            Assert.IsTrue(link.Success);
            Assert.AreEqual(31337, link.Id);
            Assert.AreEqual("/api/v2/lists/31337/contacts", link.Href);
        }
 /// <summary>
 /// Delete a single contact.
 /// </summary>
 /// <param name="contact">Contact object</param>
 /// <returns></returns>
 public DeleteResult DeleteContact(Contact contact)
 {
     return DeleteContact(contact.Id);
 }
        /// <summary>
        /// Update existing contact.
        /// </summary>
        /// <param name="contact">Contact object</param>
        /// <param name="listIds">List IDs</param>
        /// <returns></returns>
        public LinkResult UpdateContact(Contact contact, int[] listIds)
        {
            var request = new RestRequest(Method.PUT);
            request.Resource = "contacts/{id}";
            request.AddUrlSegment("id", contact.Id.ToString());
            request.AddParameter("phone", contact.Phone);
            request.AddParameter("lists", string.Join(",", listIds));
            request.AddParameter("firstName", contact.FirstName);
            request.AddParameter("lastName", contact.LastName);
            request.AddParameter("companyName", contact.CompanyName);
            request.AddParameter("email", contact.Email);

            var result = Execute<LinkResult>(request);

            if (contact.CustomFields != null)
            {
                foreach (var customField in contact.CustomFields)
                {
                    SetCustomFieldValue(customField.Id, contact.Id, customField.Value);
                }
            }

            return result;
        }
 /// <summary>
 /// Unsubscribe contact from your communication.
 /// </summary>
 /// <param name="phone">Contact object</param>
 /// <returns></returns>
 public LinkResult UnsubscribeContact(Contact contact)
 {
     return UnsubscribeContact(contact.Phone);
 }