Пример #1
0
        public void TestSubaccountCreate()
        {
            var data = new Dictionary <string, object>()
            {
                { "name", "naam" },
                { "enabled", true }
            };

            var request =
                new PlivoRequest(
                    "POST",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Subaccount/",
                    "",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"Mocks/subaccountCreateResponse.json"
                    );

            Setup <SubaccountCreateResponse>(
                201,
                response
                );
            Assert.IsEmpty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Subaccount.Create("naam", true)));
            AssertRequest(request);
        }
Пример #2
0
        public void TestCallList()
        {
            var request =
                new PlivoRequest(
                    "GET",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Call/",
                    "",
                    new Dictionary <string, object>()
            {
                { "end_time__gt", "2017-06-07 00:00:00.000000" }
            });

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"../Mocks/callListResponse.json"
                    );

            Setup <ListResponse <Call> >(200, response);

            Assert.Empty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Call.List(endTime_Gt: DateTime.Parse("2017-06-07"))
                    )
                );

            AssertRequest(request);
        }
Пример #3
0
        public void TestEndpointGet()
        {
            var id   = "abcabcabc";
            var data = new Dictionary <string, object>()
            {
                { "is_voice_request", true }
            };
            var request =
                new PlivoRequest(
                    "GET",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Endpoint/" + id + "/",
                    "",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"../Mocks/endpointGetResponse.json"
                    );

            Setup <Endpoint>(
                200,
                response
                );
            Assert.Empty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Endpoint.Get(id)));

            AssertRequest(request);
        }
Пример #4
0
        public void TestCallRecord()
        {
            var id = "abcabcabc";

            var data = new Dictionary <string, object>()
            {
                { "time_limit", 120 },
                { "file_format", "wav" },
                { "callback_method", "http://a.a" },
                { "callback_url", "http://s.s" }
            };

            var request =
                new PlivoRequest(
                    "POST",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Call/" + id + "/Record/",
                    "",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"../Mocks/liveCallRecordCreateResponse.json"
                    );

            Setup <UpdateResponse <Call> >(202, response);

            Assert.Empty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Call.StartRecording(id, 120, "wav", callbackMethod: "http://a.a", callbackUrl: "http://s.s")
                    )
                );

            AssertRequest(request);
        }
Пример #5
0
        public void TestCallPlay()
        {
            var id = "abcabcabc";

            var data = new Dictionary <string, object>()
            {
                { "urls", "http://wewewe.ewewew,http:/second.url" },
            };

            var request =
                new PlivoRequest(
                    "POST",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Call/" + id + "/Play/",
                    "",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"../Mocks/liveCallPlayCreateResponse.json"
                    );

            Setup <UpdateResponse <Call> >(202, response);

            Assert.Empty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Call.StartPlaying(id, new List <string>()
            {
                "http://wewewe.ewewew", "http:/second.url"
            })
                    )
                );

            AssertRequest(request);
        }
Пример #6
0
        public void TestMessageGet()
        {
            var id      = "abcabcabc";
            var request =
                new PlivoRequest(
                    "GET",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Message/" + id + "/",
                    "");

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"Mocks/messageGetResponse.json"
                    );

            Setup <Message>(
                200,
                response
                );
            Assert.IsEmpty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Message.Get(id)));

            AssertRequest(request);
        }
Пример #7
0
        public void TestLiveCallGet()
        {
            var id      = "abcabcabc";
            var request =
                new PlivoRequest(
                    "GET",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Call/" + id + "/",
                    "",
                    new Dictionary <string, object>()
            {
                { "status", "live" }
            });

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"../Mocks/liveCallGetResponse.json"
                    );

            Assert.NotEmpty(response);

            Setup <LiveCall>(200, response);

            Assert.Empty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Call.GetLive(id)
                    )
                );

            AssertRequest(request);
        }
Пример #8
0
        public void TestPowerpackCreate()
        {
            var data = new Dictionary <string, object> ()
            {
                { "name", "vishnu" }, { "StickySender", True }
            };

            var request =
                new PlivoRequest(
                    "POST",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Powerpack/",
                    "",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"Mocks/powerpack.json"
                    );

            Setup <Powerpack> (
                201,
                response
                );
            Assert.IsEmpty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Powerpacks.Create(new List <string> ()
            {
                name = "vishnu", sticky_sender = True
            })));
            AssertRequest(request);
        }
Пример #9
0
        public void TestPowerpackDelete()
        {
            var id   = "d35f2e82-d387-427f-8594-6fa07613c43a";
            var data = new Dictionary <string, object> ()
            {
                { "unrent_numbers", true }
            };
            var request =
                new PlivoRequest(
                    "Delete",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Powerpack/" + id + "/",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"Mocks/powerpackDeleteResponse.json"
                    );

            Setup <Powerpack> (
                200,
                response
                );
            var powerpack = Api.Powerpack.Get(id);

            Assert.IsEmpty(
                ComparisonUtilities.Compare(
                    response,
                    powerpack.Delete(unrent_numbers = True)));

            AssertRequest(request);
        }
Пример #10
0
        public void TestRentedNumberGet()
        {
            var id      = "abcabcabc";
            var request =
                new PlivoRequest(
                    "GET",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Number/" + id + "/",
                    "");

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"../Mocks/numberGetResponse.json"
                    );

            Setup <RentedNumber>(
                200,
                response
                );
            Assert.Empty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Number.Get(id)));

            AssertRequest(request);
        }
Пример #11
0
        public void TestPowerpackUpdate()
        {
            var id   = "5ec4c8c9-cd74-42b5-9e41-0d7670d6bb46";
            var data = new Dictionary <string, object> ()
            {
                { "name", "vishnu123" }
            };
            var request =
                new PlivoRequest(
                    "POST",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Powerpack/" + id + "/",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"Mocks/powerpack.json"
                    );

            Setup <Powerpack> (
                200,
                response
                );
            var powerpack = Api.Powerpack.Get(id);

            Assert.IsEmpty(
                ComparisonUtilities.Compare(
                    response,
                    powerpack.Update(name = "vishnu123")));

            AssertRequest(request);
        }
Пример #12
0
        public void TestRentedNumberList()
        {
            var data = new Dictionary <string, object>()
            {
                { "limit", 10 }
            };
            var request =
                new PlivoRequest(
                    "GET",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Number/",
                    "",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"../Mocks/numberListResponse.json"
                    );

            Setup <ListResponse <RentedNumber> >(
                200,
                response
                );
            Assert.Empty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Number.List(limit: 10)));

            AssertRequest(request);
        }
Пример #13
0
        public void TestNumberUpdate()
        {
            var id   = "abcabcabc";
            var data = new Dictionary <string, object>()
            {
                { "alias", "alalaalalala" }
            };

            var request =
                new PlivoRequest(
                    "POST",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Number/" + id + "/",
                    "",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"../Mocks/endpointUpdateResponse.json"
                    );

            Setup <UpdateResponse <RentedNumber> >(
                202,
                response
                );
            Assert.Empty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Number.Update(id, alias: "alalaalalala")));
            AssertRequest(request);
        }
Пример #14
0
        public void TestAccountModifyResponse()
        {
            var id   = "abcabcabc";
            var data = new Dictionary <string, object>()
            {
                { "enabled", true },
                { "name", "naam" }
            };
            var request =
                new PlivoRequest(
                    "POST",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Subaccount/" + id + "/",
                    "",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"Mocks/subaccountModifyResponse.json"
                    );

            Setup <UpdateResponse <Account> >(
                202,
                response
                );
            Assert.IsEmpty(ComparisonUtilities.Compare(response, Api.Subaccount.Update(id, "naam", true)));

            CompareRequests(request, ((TestClient)Api.Client._client).Request);
        }
Пример #15
0
        public void TestMessageCreate()
        {
            var data = new Dictionary <string, object>()
            {
                { "src", "+919999999999" },
                { "dst", "+919898989898<+919090909090" },
                { "text", "textext" }
            };

            var request =
                new PlivoRequest(
                    "POST",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Message/",
                    "",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"Mocks/messageSendResponse.json"
                    );

            Setup <MessageCreateResponse>(
                201,
                response
                );
            Assert.IsEmpty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Message.Create("+919999999999", new List <string>()
            {
                "+919898989898", "+919090909090"
            },
                                       "textext")));
            AssertRequest(request);
        }
Пример #16
0
        public void TestAddNumbers()
        {
            var id     = "d35f2e82-d387-427f-8594-6fa07613c43a";
            var number = "15799140336";

            var request =
                new PlivoRequest(
                    "POST",
                    "Account/MAXXXXXXXXXXXXXXXXXX/NumberPool/ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f/Number/" + number + "/",
                    "");

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"Mocks/numberpoolSingleNoResponse.json"
                    );

            Setup <NumberPool> (
                200,
                response
                );
            var powerpack = Api.Powerpack.Get(id);

            Assert.IsEmpty(
                ComparisonUtilities.Compare(
                    response,
                    powerpack.Add_Number(number)));

            AssertRequest(request);
        }
Пример #17
0
        public void TestMessageList()
        {
            var data = new Dictionary <string, object>()
            {
                { "limit", 10 }
            };
            var request =
                new PlivoRequest(
                    "GET",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Message/",
                    "",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"Mocks/messageListResponse.json"
                    );

            Setup <ListResponse <Message> >(
                200,
                response
                );
            Assert.IsEmpty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Message.List(limit: 10)));

            AssertRequest(request);
        }
Пример #18
0
        public void TestFindShortcode()
        {
            var id        = "d35f2e82-d387-427f-8594-6fa07613c43a";
            var shortcode = "444444";

            var request =
                new PlivoRequest(
                    "GET",
                    "Account/MAXXXXXXXXXXXXXXXXXX/NumberPool/ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f/Shortcode/" + shortcode + "/",
                    "");

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"Mocks/numberpoolSingleShortcodeResponse.json"
                    );

            Setup <NumberPool> (
                200,
                response
                );
            var powerpack = Api.Powerpack.Get(id);

            Assert.IsEmpty(
                ComparisonUtilities.Compare(
                    response,
                    powerpack.Find_Shortcode(shortcode)));

            AssertRequest(request);
        }
Пример #19
0
        public void TestCallGet()
        {
            var id      = "abcabcabc";
            var request =
                new PlivoRequest(
                    "GET",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Call/" + id + "/",
                    "");

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"../Mocks/callGetResponse.json"
                    );

            Assert.NotEmpty(response);

            Setup <Call>(200, response);

            Assert.Empty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Call.Get(id)
                    )
                );

            AssertRequest(request);
        }
Пример #20
0
        public void TestListShortcode()
        {
            var id     = "d35f2e82-d387-427f-8594-6fa07613c43a";
            var number = "444444";
            var id     = "d35f2e82-d387-427f-8594-6fa07613c43a";
            var data   = new Dictionary <string, object> ()
            {
                { "limit", 1 }
            };
            var request =
                new PlivoRequest(
                    "GET",
                    "Account/MAXXXXXXXXXXXXXXXXXX/NumberPool/ca5fd1f2-26c0-43e9-a7e4-0dc426e9dd2f/Shortcode/",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"Mocks/numberpoolShortcodeResponse.json"
                    );

            Setup <Shortcode> (
                200,
                response
                );
            var powerpack = Api.Powerpack.Get(id);

            Assert.IsEmpty(
                ComparisonUtilities.Compare(
                    response,
                    powerpack.List_Shortcode(limit: 1)));

            AssertRequest(request);
        }
Пример #21
0
        public void TestCallTranfer()
        {
            var id = "abcabcabc";

            var data = new Dictionary <string, object>()
            {
                { "legs", "aleg" },
                { "aleg_url", "http://asdsa.asdsa" }
            };

            var request =
                new PlivoRequest(
                    "POST",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Call/" + id + "/",
                    "",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"../Mocks/callUpdateResponse.json"
                    );

            Setup <UpdateResponse <Call> >(202, response);

            Assert.Empty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Call.Transfer(id, "aleg", "http://asdsa.asdsa")
                    )
                );

            AssertRequest(request);
        }
Пример #22
0
        public void TestPowerpackGet()
        {
            var id      = "5ec4c8c9-cd74-42b5-9e41-0d7670d6bb46";
            var request =
                new PlivoRequest(
                    "GET",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Powerpack/" + id + "/",
                    "");

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"Mocks/powerpack.json"
                    );

            Setup <Powerpack> (
                200,
                response
                );
            Assert.IsEmpty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Powerpacks.Get(id)));

            AssertRequest(request);
        }
Пример #23
0
        public void TestCallSpeak()
        {
            var id = "abcabcabc";

            var data = new Dictionary <string, object>()
            {
                { "text", "120" },
                { "voice", "WOMAN" }
            };

            var request =
                new PlivoRequest(
                    "POST",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Call/" + id + "/Speak/",
                    "",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"../Mocks/liveCallSpeakCreateResponse.json"
                    );

            Setup <UpdateResponse <Call> >(202, response);

            Assert.Empty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Call.StartSpeaking(id, "120", voice: "WOMAN")
                    )
                );

            AssertRequest(request);
        }
Пример #24
0
        public void TestAccountModifyResponse()
        {
            var data = new Dictionary <string, object>()
            {
                { "city", "delhi" },
                { "name", "name name name" },
            };
            var request =
                new PlivoRequest(
                    "POST",
                    "Account/MAXXXXXXXXXXXXXXXXXX/",
                    "",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"../Mocks/accountModifyResponse.json"
                    );

            Setup <UpdateResponse <Account> >(
                202,
                response
                );
            Assert.Empty(ComparisonUtilities.Compare(response, Api.Account.Update("name name name", "delhi")));

            CompareRequests(request, ((TestClient)Api.Client._client).Request);
        }
Пример #25
0
        public void TestCallStopSpeaking()
        {
            var id = "abcabcabc";

            var data = new Dictionary <string, object>();

            var request =
                new PlivoRequest(
                    "DELETE",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Call/" + id + "/Speak/",
                    "",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"../Mocks/liveCallSpeakDeleteResponse.json"
                    );

            Setup <DeleteResponse <Call> >(204, response);

            Assert.Empty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Call.StopSpeaking(id)));

            AssertRequest(request);
        }
Пример #26
0
        public void TestQueuedCallList()
        {
            var request =
                new PlivoRequest(
                    "GET",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Call/",
                    "",
                    new Dictionary <string, object>()
            {
                { "status", "queued" }
            });

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"Mocks/liveCallListGetResponse.json"
                    );

            Setup <QueuedCallListResponse>(200, response);

            Assert.IsEmpty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Call.ListQueued()
                    )
                );

            AssertRequest(request);
        }
Пример #27
0
        public void TestEndpointCreate()
        {
            var data = new Dictionary <string, object>()
            {
                { "username", "user" },
                { "password", "pass" },
                { "alias", "alias" },
                { "is_voice_request", true }
            };

            var request =
                new PlivoRequest(
                    "POST",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Endpoint/",
                    "",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"../Mocks/endpointCreateResponse.json"
                    );

            Setup <EndpointCreateResponse>(
                201,
                response
                );
            Assert.Empty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Endpoint.Create("user", "pass", "alias")));
            AssertRequest(request);
        }
Пример #28
0
        public void TestCallStopSpeaking()
        {
            var id = "abcabcabc";

            var data = new Dictionary <string, object>();

            var request =
                new PlivoRequest(
                    "DELETE",
                    "Account/MAXXXXXXXXXXXXXXXXXX/Call/" + id + "/Speak/",
                    "",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"Mocks/liveCallSpeakDeleteResponse.json"
                    );

            Setup <DeleteResponse <Call> >(204, response);

            // Console.WriteLine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));

            Assert.IsEmpty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Call.StopSpeaking(id)));

            AssertRequest(request);
        }
Пример #29
0
        public void TestLookupGet()
        {
            var number  = "14154305555";
            var request =
                new PlivoRequest(
                    "GET",
                    "Number/" + number + "?type=carrier",
                    "");

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"../Mocks/lookupGetResponse.json"
                    );

            Setup <Number>(
                200,
                response
                );
            Assert.IsEmpty(
                ComparisonUtilities.Compare(
                    response,
                    Api.Lookup.Get(number)));

            AssertRequest(request);
        }
Пример #30
0
        public void TestPhoneNumberBuy()
        {
            var id   = "abcabcabc";
            var data = new Dictionary <string, object>()
            {
                { "app_id", "123" }
            };
            var request =
                new PlivoRequest(
                    "POST",
                    "Account/MAXXXXXXXXXXXXXXXXXX/PhoneNumber/" + id + "/",
                    "",
                    data);

            var response =
                System.IO.File.ReadAllText(
                    SOURCE_DIR + @"Mocks/phoneNumberCreateResponse.json"
                    );

            Setup <PhoneNumberBuyResponse>(
                201,
                response
                );
            Assert.IsEmpty(
                ComparisonUtilities.Compare(
                    response,
                    Api.PhoneNumber.Buy(id, "123")));

            AssertRequest(request);
        }