コード例 #1
0
        public void GetCallsWithGetByIdAndBatchIdRequest()
        {
            var expectedJson = GetJsonPayload("/campaigns/callBroadcastsApi/response/getCalls.json");
            var restRequest  = MockRestResponse(expectedJson);

            var request = new GetBroadcastCallsTextsRequest
            {
                Offset  = 5,
                Fields  = FIELDS,
                Id      = 11,
                batchId = 13
            };
            var calls = Client.CallBroadcastsApi.GetCalls(request);

            Assert.That(Serializer.Serialize(calls), 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.Resource, Is.StringEnding("/11/calls"));
            Assert.That(restRequest.Value.Parameters, Has.No.Some.Matches <Parameter>(p => p.Name.Equals("id")));
            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("batchId") && p.Value.Equals("13")));
        }
コード例 #2
0
        public void GetBroadcastTexts()
        {
            var broadcast = new TextBroadcast
            {
                Name       = "text_broadcast_1",
                Message    = "test_msg",
                Recipients = new List <TextRecipient>
                {
                    new TextRecipient {
                        PhoneNumber = "14246525473"
                    }
                }
            };
            var broadcastId = Client.TextBroadcastsApi.Create(broadcast, false);

            var request = new GetByIdRequest {
                Id = broadcastId.Id
            };
            var texts = Client.TextBroadcastsApi.GetTexts(request);

            Console.WriteLine(texts);
            Assert.That(texts.Items, Is.Not.Empty);

            long testBatchId = (long)texts.Items[0].BatchId;

            request = new GetBroadcastCallsTextsRequest {
                Id = broadcastId.Id, BatchId = testBatchId
            };
            texts = Client.TextBroadcastsApi.GetTexts(request);
            Assert.AreEqual(texts.Items[0].BatchId, testBatchId);
        }
コード例 #3
0
 public static void Main(string[] args)
 {
     var client  = new CallfireClient("api_login", "api_password");
     var request = new GetBroadcastCallsTextsRequest
     {
         Id      = 11646003,
         BatchId = 5500030002,
         Offset  = 0,
         Limit   = 10,
         Fields  = "items(fromNumber,toNumber,state,modified)"
     };
     var calls = client.CallBroadcastsApi.GetCalls(request);
 }
        public void GetBroadcastCalls()
        {
            var broadcast = new CallBroadcast
            {
                Name = "call_broadcast",
                AnsweringMachineConfig = AnsweringMachineConfig.AM_AND_LIVE,
                Sounds = new CallBroadcastSounds
                {
                    LiveSoundText         = "Hello! This is a live answer text to speech recording",
                    LiveSoundTextVoice    = Voice.MALE1,
                    MachineSoundText      = "This is an answering machine text to speech recording",
                    MachineSoundTextVoice = Voice.MALE1
                },
                Recipients = new List <CallRecipient>
                {
                    new CallRecipient {
                        PhoneNumber = "12132041238"
                    },
                    new CallRecipient {
                        PhoneNumber = "14246525473"
                    }
                }
            };
            var id = Client.CallBroadcastsApi.Create(broadcast, false);

            var getCallsRequest = new GetByIdRequest {
                Id = id.Id
            };
            var calls = Client.CallBroadcastsApi.GetCalls(getCallsRequest);

            System.Console.WriteLine(calls);
            Assert.That(calls.Items, Is.Not.Empty);

            long testBatchId = (long)calls.Items[0].BatchId;

            var getCallsRequestNew = new GetBroadcastCallsTextsRequest {
                Id = id.Id, BatchId = testBatchId
            };

            calls = Client.CallBroadcastsApi.GetCalls(getCallsRequestNew);
            System.Console.WriteLine(calls);
            Assert.AreEqual(calls.Items[0].BatchId, testBatchId);
        }
        public void GetBroadcastCalls()
        {
            var getCallsRequest = new GetByIdRequest {
                Id = 1
            };
            var calls = Client.CallBroadcastsApi.GetCalls(getCallsRequest);

            Console.WriteLine(calls);
            Assert.That(calls.Items, Is.Not.Empty);

            long testBatchId = (long)calls.Items[0].BatchId;

            getCallsRequest = new GetBroadcastCallsTextsRequest {
                Id = 1, batchId = testBatchId
            };
            calls = Client.CallBroadcastsApi.GetCalls(getCallsRequest);
            Console.WriteLine(calls);
            Assert.AreEqual(calls.Items[0].BatchId, testBatchId);
        }
コード例 #6
0
        /// <summary>
        /// Get texts associated with text broadcast ordered by date
        /// </summary>
        /// <param name="request">request with properties to filter</param>
        /// <returns>texts assosiated with broadcast</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 <Text> GetTexts(GetBroadcastCallsTextsRequest request)
        {
            String path = TB_ITEM_TEXTS_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, request.Id.ToString());

            return(Client.Get <Page <Text> >(path, request));
        }