Inheritance: CallfireApiClient.Api.Common.Model.CallfireModel
        public void AddBatch()
        {
            var requestJson = GetJsonPayload("/campaigns/callBroadcastsApi/request/addBatch.json");
            var responseJson = GetJsonPayload("/campaigns/callBroadcastsApi/response/addBatch.json");
            var restRequest = MockRestResponse(responseJson);

            var request = new AddBatchRequest
            {
                CampaignId = 15,
                Name = "batch name",
                Recipients = new List<Recipient>
                {
                    new Recipient { PhoneNumber = "12135551100" },
                    new Recipient { PhoneNumber = "12135551101" },
                }
            };
            var id = Client.CallBroadcastsApi.AddBatch(request);
            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));
            Assert.That(restRequest.Value.Parameters, Has.No.Some.Matches<Parameter>(p => p.Name.Equals("campaignId")));
            Assert.That(restRequest.Value.Resource, Is.StringEnding("/15/batches"));
        }
        public void AddRecipientsAndAddRemoveBatches()
        {
            var findRequest = new FindBroadcastsRequest
            {
                Name = "updated_name",
                Limit = 1
            };
            var broadcasts = Client.TextBroadcastsApi.Find(findRequest);
            Console.WriteLine(broadcasts);
            Assert.That(broadcasts.Items, Is.Not.Empty);
            var id = broadcasts.Items[0].Id;

            // add recipients
            var recipients = new List<TextRecipient>
            {
                new TextRecipient { PhoneNumber = "14246525473" },
                new TextRecipient { PhoneNumber = "12132041238" }
            };
            var texts = Client.TextBroadcastsApi.AddRecipients((long)id, recipients);
            Console.WriteLine(texts);
            Assert.AreEqual(2, texts.Count);
            Assert.That(texts[0].Message, Is.StringStarting("test_msg"));

            // get batches
            var getBatchesRequest = new GetByIdRequest { Id = id };
            var batches = Client.TextBroadcastsApi.GetBatches(getBatchesRequest);
            Console.WriteLine(batches);

            // add batch
            var addBatchRequest = new AddBatchRequest
            {
                CampaignId = (long)id,
                Name = "new_batch",
                Recipients = new List<Recipient>
                {
                    new TextRecipient { PhoneNumber = "14246525473" },
                    new TextRecipient { PhoneNumber = "12132041238" }
                }
            };
            ResourceId addedBatchId = Client.TextBroadcastsApi.AddBatch(addBatchRequest);

            var addedBatch = Client.BatchesApi.Get(addedBatchId.Id);
            Console.WriteLine(batches);
            Assert.AreEqual(addedBatch.BroadcastId, id);
            Assert.True((bool)addedBatch.Enabled);
            Assert.AreEqual(addBatchRequest.Name, addedBatch.Name);

            addedBatch.Enabled = false;
            Client.BatchesApi.Update(addedBatch);
            Batch updatedBatch = Client.BatchesApi.Get(addedBatchId.Id);
            Assert.False((bool)updatedBatch.Enabled);
        }
        public void AddRecipientsAndAddRemoveBatches()
        {
            var findRequest = new FindBroadcastsRequest
            {
                Name = "updated_name",
                Limit = 1
            };
            var broadcasts = Client.CallBroadcastsApi.Find(findRequest);
            Console.WriteLine(broadcasts);
            Assert.That(broadcasts.Items, Is.Not.Empty);
            var id = broadcasts.Items[0].Id;

            var calls = Client.CallBroadcastsApi.AddRecipients((long)id, new List<Recipient>
                {
                    new Recipient { PhoneNumber = "12132212384" },
                    new Recipient { PhoneNumber = "12132212385" }
                });
            Console.WriteLine(calls);
            Assert.AreEqual(2, calls.Count);

            // get batches
            var getBatchesRequest = new GetByIdRequest { Id = id };
            var batches = Client.CallBroadcastsApi.GetBatches(getBatchesRequest);
            Console.WriteLine(batches);

            // add batch
            var addBatchRequest = new AddBatchRequest
            {
                CampaignId = (long)id,
                Name = "new_batch",
                Recipients = new List<Recipient>
                {
                    new Recipient { PhoneNumber = "12132212386" },
                    new Recipient { PhoneNumber = "12132212387" }
                }
            };
            ResourceId addedBatchId = Client.CallBroadcastsApi.AddBatch(addBatchRequest);

            var addedBatch = Client.BatchesApi.Get(addedBatchId.Id);
            Assert.AreEqual(addedBatch.BroadcastId, id);
        }
 /// <summary>
 /// Add batch to text broadcast.
 /// The add batch API allows the user to add additional batches to an already created text broadcast
 /// campaign. The added batch will go through the CallFire validation process, unlike in the
 /// recipients version of this API. Because of this, use the scrubDuplicates flag to remove duplicates
 /// from your batch. Batches may be added as a contact list id, a list of contact ids, or a list of numbers.
 /// </summary>
 /// <param name="request">request with contacts</param>
 /// <returns>id of created batch</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 ResourceId AddBatch(AddBatchRequest request)
 {
     String path = TB_ITEM_BATCHES_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, request.CampaignId.ToString());
     return Client.Post<ResourceId>(path, request);
 }