Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 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);
        }