Exemplo n.º 1
0
 public static void Main(string[] args)
 {
     var client          = new CallfireClient("api_login", "api_password");
     var callCreateSound = new CallCreateSound
     {
         Name     = "Sound 1",
         ToNumber = "12135551122"
     };
     ResourceId resourceId = client.CampaignSoundsApi.RecordViaPhone(callCreateSound);
 }
        public void TestCallInToRecord()
        {
            CallCreateSound callCreateSound = new CallCreateSound
            {
                Name = "call_in_sound_" + new DateTime().Millisecond,
                ToNumber = "12132212384"
            };

            ResourceId resourceId = Client.CampaignSoundsApi.RecordViaPhone(callCreateSound);

            Assert.NotNull(resourceId.Id);

            CampaignSound sound = Client.CampaignSoundsApi.RecordViaPhoneAndGetSoundDetails(callCreateSound, "id,name");
            Assert.NotNull(sound.Id);
            Assert.NotNull(sound.Name);
            Assert.Null(sound.Status);
        }
Exemplo n.º 3
0
        public void TestCallInToRecord()
        {
            CallCreateSound callCreateSound = new CallCreateSound
            {
                Name     = "call_in_sound_" + new DateTime().Millisecond,
                ToNumber = "12132212384"
            };

            ResourceId resourceId = Client.CampaignSoundsApi.RecordViaPhone(callCreateSound);

            Assert.NotNull(resourceId.Id);

            CampaignSound sound = Client.CampaignSoundsApi.RecordViaPhoneAndGetSoundDetails(callCreateSound, "id,name");

            Assert.NotNull(sound.Id);
            Assert.NotNull(sound.Name);
            Assert.Null(sound.Status);
        }
        public void TestRecordViaPhone()
        {
            string responseJson = GetJsonPayload("/campaigns/campaignSoundsApi/response/uploadSound.json");
            string requestJson  = GetJsonPayload("/campaigns/campaignSoundsApi/request/recordViaPhone.json");
            var    restRequest  = MockRestResponse(responseJson);

            CallCreateSound callCreateSound = new CallCreateSound
            {
                Name     = "My sound file",
                ToNumber = "12135551122"
            };

            ResourceId id = Client.CampaignSoundsApi.RecordViaPhone(callCreateSound);

            Assert.That(Serializer.Serialize(id), Is.EqualTo(responseJson));
            Assert.AreEqual(Method.POST, restRequest.Value.Method);
            var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);

            Assert.That(requestBodyParam.Value, Is.EqualTo(requestJson));
        }
        public void TestRecordViaPhoneAndGetSoundDetails()
        {
            string responseJson = GetJsonPayload("/campaigns/campaignSoundsApi/response/uploadSoundWithDetails.json");
            string requestJson  = GetJsonPayload("/campaigns/campaignSoundsApi/request/recordViaPhone.json");
            var    restRequest  = MockRestResponse(responseJson);

            CallCreateSound callCreateSound = new CallCreateSound
            {
                Name     = "My sound file",
                ToNumber = "12135551122"
            };

            CampaignSound sound = Client.CampaignSoundsApi.RecordViaPhoneAndGetSoundDetails(callCreateSound, FIELDS);

            Assert.That(Serializer.Serialize(sound), Is.EqualTo(responseJson));
            Assert.AreEqual(Method.POST, restRequest.Value.Method);
            var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);

            Assert.That(requestBodyParam.Value, Is.EqualTo(requestJson));
            Assert.That(restRequest.Value.Parameters, Has.None.Matches <Parameter>(p => p.Name.Equals("FIELDS") && p.Value.Equals(FIELDS)));
        }
        /// <summary>
        /// Use this API to create a sound via phone call. Supply the required phone number in
        /// the CallCreateSound object inside of the request, and the user will receive a call
        /// shortly after with instructions on how to record a sound over the phone.
        /// </summary>
        /// <param name="callCreateSound"> request object to create campaign sound</param>
        /// <param name="fields">Limit text fields returned. Example fields=limit,offset,items(id,message)</param>
        /// <returns>CampaignSound object with sound details</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 CampaignSound RecordViaPhoneAndGetSoundDetails(CallCreateSound callCreateSound, string fields)
        {
            var queryParams = ClientUtils.BuildQueryParams("fields", fields);

            return(Client.Post <CampaignSound>(SOUNDS_CALLS_PATH, callCreateSound, queryParams));
        }
 public ResourceId RecordViaPhone(CallCreateSound callCreateSound)
 {
     return(Client.Post <ResourceId>(SOUNDS_CALLS_PATH, callCreateSound));
 }
 /// <summary>
 /// Use this API to create a sound via phone call. Supply the required phone number in
 /// the CallCreateSound object inside of the request, and the user will receive a call
 /// shortly after with instructions on how to record a sound over the phone.
 /// </summary>
 /// <param name="callCreateSound"> request object to create campaign sound</param>
 /// <param name="fields">Limit text fields returned. Example fields=limit,offset,items(id,message)</param>
 /// <returns>CampaignSound object with sound details</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 CampaignSound RecordViaPhoneAndGetSoundDetails(CallCreateSound callCreateSound, string fields)
 {
     var queryParams = ClientUtils.BuildQueryParams("fields", fields);
     return Client.Post<CampaignSound>(SOUNDS_CALLS_PATH, callCreateSound, queryParams);
 }
 public ResourceId RecordViaPhone(CallCreateSound callCreateSound)
 {
     return Client.Post<ResourceId>(SOUNDS_CALLS_PATH, callCreateSound);
 }
        public void TestRecordViaPhoneAndGetSoundDetails()
        {
            string responseJson = GetJsonPayload("/campaigns/campaignSoundsApi/response/uploadSoundWithDetails.json");
            string requestJson = GetJsonPayload("/campaigns/campaignSoundsApi/request/recordViaPhone.json");
            var restRequest = MockRestResponse(responseJson);

            CallCreateSound callCreateSound = new CallCreateSound
            {
                Name = "My sound file",
                ToNumber = "12135551122"
            };

            CampaignSound sound = Client.CampaignSoundsApi.RecordViaPhoneAndGetSoundDetails(callCreateSound, FIELDS);

            Assert.That(Serializer.Serialize(sound), Is.EqualTo(responseJson));
            Assert.AreEqual(Method.POST, restRequest.Value.Method);
            var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);
            Assert.That(requestBodyParam.Value, Is.EqualTo(requestJson));
            Assert.That(restRequest.Value.Parameters, Has.None.Matches<Parameter>(p => p.Name.Equals("FIELDS") && p.Value.Equals(FIELDS)));
        }
        public void TestRecordViaPhone()
        {
            string responseJson = GetJsonPayload("/campaigns/campaignSoundsApi/response/uploadSound.json");
            string requestJson = GetJsonPayload("/campaigns/campaignSoundsApi/request/recordViaPhone.json");
            var restRequest = MockRestResponse(responseJson);

            CallCreateSound callCreateSound = new CallCreateSound
            {
                Name = "My sound file",
                ToNumber = "12135551122"
            };

            ResourceId id = Client.CampaignSoundsApi.RecordViaPhone(callCreateSound);

            Assert.That(Serializer.Serialize(id), Is.EqualTo(responseJson));
            Assert.AreEqual(Method.POST, restRequest.Value.Method);
            var requestBodyParam = restRequest.Value.Parameters.FirstOrDefault(p => p.Type == ParameterType.RequestBody);
            Assert.That(requestBodyParam.Value, Is.EqualTo(requestJson));
        }