public void Update()
        {
            string requestJson = GetJsonPayload("/contacts/dncApi/request/updateDnc.json");
            var    restRequest = MockRestResponse();

            DoNotContact dnc = new DoNotContact
            {
                Call   = true,
                ListId = TEST_LONG,
                Number = TEST_LONG.ToString(),
                Text   = true
            };

            Client.DncApi.Update(dnc);

            Assert.AreEqual(Method.PUT, restRequest.Value.Method);
            var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);

            Assert.That(requestBodyParam.Value, Is.EqualTo(requestJson));
        }
Ejemplo n.º 2
0
        public void AddDncItems()
        {
            string requestJson = GetJsonPayload("/contacts/dncApi/request/addDncItems.json");
            var    restRequest = MockRestResponse();

            var dncs = new List <DoNotContact>();
            var dnc  = new DoNotContact {
                ListId = TEST_LONG, Number = TEST_LONG.ToString()
            };

            dncs.Add(dnc);
            var request = new AddDncListItemsRequest <DoNotContact>();

            request.ContactListId = TEST_LONG;
            request.Contacts      = dncs;

            Client.DncListsApi.AddListItems(request);

            Assert.AreEqual(Method.POST, restRequest.Value.Method);
            Assert.That(restRequest.Value.Resource, Is.StringContaining("/" + TEST_LONG));
            var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);

            Assert.That(requestBodyParam.Value, Is.EqualTo(requestJson));
        }
Ejemplo n.º 3
0
        public void GetUniversalDncNumbers()
        {
            string expectedJson = GetJsonPayload("/contacts/dncApi/response/getUniversalDncNumbers.json");
            var    restRequest  = MockRestResponse(expectedJson);

            IList <UniversalDnc> universalDncNumbers = Client.DncListsApi.GetUniversalDncNumber(TEST_LONG.ToString(), TEST_LONG.ToString(), FIELDS);

            Assert.NotNull(universalDncNumbers);
            Assert.That(Serializer.Serialize(new ListHolder <UniversalDnc>(universalDncNumbers)), Is.EqualTo(expectedJson));
            Assert.AreEqual(Method.GET, restRequest.Value.Method);
            Assert.That(restRequest.Value.Parameters, Has.Some.Matches <Parameter>(p => p.Name.Equals("fromNumber") && p.Value.Equals(TEST_LONG.ToString())));
            Assert.That(restRequest.Value.Parameters, Has.Some.Matches <Parameter>(p => p.Name.Equals("fields") && p.Value.Equals(FIELDS)));
        }
Ejemplo n.º 4
0
        public void Find()
        {
            string expectedJson = GetJsonPayload("/contacts/dncApi/response/findDncLists.json");
            var    restRequest  = MockRestResponse(expectedJson);

            FindDncListsRequest request = new FindDncListsRequest
            {
                Limit      = 1,
                Offset     = 5,
                Fields     = FIELDS,
                CampaignId = TEST_LONG,
                Name       = TEST_STRING
            };

            Page <DncList> dncList = Client.DncListsApi.Find(request);

            Assert.NotNull(dncList);
            Assert.That(Serializer.Serialize(dncList), Is.EqualTo(expectedJson));
            Assert.AreEqual(Method.GET, restRequest.Value.Method);
            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("fields") && p.Value.Equals(FIELDS)));
            Assert.That(restRequest.Value.Parameters, Has.Some.Matches <Parameter>(p => p.Name.Equals("campaignId") && p.Value.Equals(TEST_LONG.ToString())));
            Assert.That(restRequest.Value.Parameters, Has.Some.Matches <Parameter>(p => p.Name.Equals("name") && p.Value.Equals(TEST_STRING)));
        }