/// <summary>
        /// Get webhook by id.
        /// </summary>
        /// <param name="id">id of webhook</param>
        /// <param name="fields">limit fields returned. Example fields=id,name</param>
        /// <returns>webhook object</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 Webhook Get(long id, string fields = null)
        {
            var queryParams = ClientUtils.BuildQueryParams("fields", fields);
            var path        = WEBHOOKS_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString());

            return(Client.Get <Webhook>(path, queryParams));
        }
        public void BuildQueryParams()
        {
            var now = DateTime.Now;
            var mms = new MmsMessage
            {
                FileId  = 123,
                Subject = "test subject",
                Message = "this is mms message",
                Groups  = new List <string> {
                    "group1", "group2", "group3"
                },
                PhoneNumbers = new List <string> {
                    "1234567890", "2345678900", "3456789000"
                },
                StampToSend = now
            };

            var queryParams = ClientUtils.BuildQueryParams(mms).ToString();

            Console.WriteLine("params: " + queryParams);

            Assert.That(queryParams, Is.StringContaining("FileID=123"));
            Assert.That(queryParams, Is.StringContaining("Groups[]=group1"));
            Assert.That(queryParams, Is.StringContaining("Groups[]=group2"));
            Assert.That(queryParams, Is.StringContaining("Groups[]=group3"));
            Assert.That(queryParams, Is.StringContaining("PhoneNumbers[]=1234567890"));
            Assert.That(queryParams, Is.StringContaining("PhoneNumbers[]=2345678900"));
            Assert.That(queryParams, Is.StringContaining("PhoneNumbers[]=3456789000"));
            Assert.That(queryParams, Is.StringContaining("Subject=" + "test subject".UrlEncode()));
            Assert.That(queryParams, Is.StringContaining("Message=" + "this is mms message".UrlEncode()));
            Assert.That(queryParams, Is.StringContaining("MessageTypeID=3"));
            Assert.That(queryParams, Is.StringContaining("StampToSend=" + ClientUtils.ToUnixTime(now) / 1000));
        }
        /// <summary>
        /// Get subscription by id.
        /// </summary>
        /// <param name="id">id of subscription</param>
        /// <param name="fields">limit fields returned. Example fields=id,name</param>
        /// <returns>subscription object</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 Subscription Get(long id, string fields = null)
        {
            var queryParams = ClientUtils.BuildQueryParams("fields", fields);
            var path        = SUBSCRIPTIONS_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString());

            return(Client.Get <Subscription>(path, queryParams));
        }
Exemple #4
0
        /// <summary>
        /// Get keyword lease by keyword
        /// </summary>
        /// <param name="keyword">leased keyword</param>
        /// <param name="fields">Limit fields returned. Example fields=id,name</param>
        /// <returns>keyword lease object</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 KeywordLease Get(string keyword, string fields = null)
        {
            Validate.NotBlank(keyword, "keyword cannot be blank");
            var queryParams = ClientUtils.BuildQueryParams("fields", fields);

            return(Client.Get <KeywordLease>(KEYWORD_LEASES_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, keyword.ToString()), queryParams));
        }
        /// <summary>
        /// Update broadcast
        /// </summary>
        /// <param name="broadcast">broadcast to update</param>
        /// <param name="strictValidation">apply strict validation for contacts</param>
        /// <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 void Update(TextBroadcast broadcast, bool?strictValidation = null)
        {
            Validate.NotNull(broadcast.Id, "broadcast.id cannot be null");
            var queryParams = ClientUtils.BuildQueryParams("strictValidation", strictValidation.ToString());

            Client.Put <object>(TB_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, broadcast.Id.ToString()), broadcast, queryParams);
        }
        /// <summary>
        /// Use this API to add recipients to an already created text broadcast. Post a list of Recipient
        /// objects for them to be immediately added to the text broadcast campaign. These contacts do not
        /// go through validation process, and will be acted upon as they are added. Recipients may be added
        /// as a list of contact ids, or list of numbers.
        /// </summary>
        /// <param name="id">id of text broadcast</param>
        /// <param name="recipients">recipients to add</param>
        /// <param name="fields">limit fields returned. E.g. fields=id,name or fields=items(id,name)</param>
        /// <returns>Text objects</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 IList <Text> AddRecipients(long id, IList <TextRecipient> recipients, String fields = null)
        {
            var    queryParams = ClientUtils.BuildQueryParams("fields", fields);
            string path        = TB_ITEM_RECIPIENTS_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString());

            return(Client.Post <ListHolder <Text> >(path, recipients, queryParams).Items);
        }
        /// <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());
            var    queryParams = ClientUtils.BuildQueryParams("strictValidation", request.StrictValidation.ToString());

            return(Client.Post <ResourceId>(path, request, queryParams));
        }
        /// <summary>
        /// Returns a single CampaignSound instance for a given campaign sound id. This is the meta
        /// data to the sounds only.No audio data is returned from this API.
        /// </summary>
        /// <param name="id">id of campaign sound</param>
        /// <param name="fields">Limit text fields returned. Example fields=limit,offset,items(id,message)</param>
        /// <returns>CampaignSound meta object</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 Get(long id, string fields = null)
        {
            string path        = SOUNDS_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString());
            var    queryParams = ClientUtils.BuildQueryParams("fields", fields);

            return(Client.Get <CampaignSound>(path, queryParams));
        }
        /// <summary>
        /// Get text broadcast by id
        /// </summary>
        /// <param name="id">id of broadcast</param>
        /// <param name="fields">limit fields returned. Example fields=id,message</param>
        /// <returns>broadcast object</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 TextBroadcast Get(long id, string fields = null)
        {
            var    queryParams = ClientUtils.BuildQueryParams("fields", fields);
            string path        = TB_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString());

            return(Client.Get <TextBroadcast>(path, queryParams));
        }
        /// <summary>
        /// Send texts to recipients through existing campaign, if null default campaign will be used
        /// Use the /texts API to quickly send individual texts.A verified Caller ID and sufficient
        /// credits are required to make a call.
        /// </summary>
        /// <param name="request">request object with different fields to filter</param>
        /// <returns>list with created text objects</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 IList <Text> Send(SendTextsRequest request)
        {
            Validate.NotBlank(request.Recipients.ToString(), "recipients cannot be blank");
            var queryParams = ClientUtils.BuildQueryParams(request);

            return(Client.Post <ListHolder <Text> >(TEXTS_PATH, request.Recipients, queryParams).Items);
        }
        ///
        /// Get text auto reply
        /// <param name="id">id of text auto reply object</param>
        /// <param name="fields">limit fields returned. Example fields=id,message</param>
        /// <returns>text auto reply object</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 TextAutoReply Get(long id, string fields = null)
        {
            var    queryParams = ClientUtils.BuildQueryParams("fields", fields);
            string path        = TEXT_AUTO_REPLIES_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString());

            return(Client.Get <TextAutoReply>(path, queryParams));
        }
        /// <summary>
        /// Get number lease by number
        /// </summary>
        /// <param name="number">leased phone number</param>
        /// <param name="fields">Limit fields returned. Example fields=id,name</param>
        /// <returns>object which represents number lease</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 NumberLease Get(string number, string fields = null)
        {
            Validate.NotBlank(number, "number cannot be blank");
            var queryParams = ClientUtils.BuildQueryParams("fields", fields);

            return(Client.Get <NumberLease>(NUMBER_LEASES_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, number), queryParams));
        }
        /// <summary>
        /// Returns call recording by id
        /// </summary>
        /// <param name="id">id of call recording</param>
        /// <param name="fields">limit fields returned. Example fields=id,name</param>
        /// <returns>CallRecording objects list</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 CallRecording GetCallRecording(long id, string fields = null)
        {
            Validate.NotBlank(id.ToString(), "id cannot be blank");
            string path        = CALLS_ITEM_RECORDING_BY_ID_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString());
            var    queryParams = ClientUtils.BuildQueryParams("fields", fields);

            return(Client.Get <CallRecording>(path, queryParams));
        }
        /// <summary>
        /// Get text by id
        /// </summary>
        /// <param name="id">id of text</param>
        /// <param name="fields">limit fields returned. Example fields=id,name</param>
        /// <returns>text object</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 Text Get(long id, string fields = null)
        {
            Validate.NotBlank(id.ToString(), "id cannot be blank");
            string path        = TEXTS_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString());
            var    queryParams = ClientUtils.BuildQueryParams("fields", fields);

            return(Client.Get <Text>(path, queryParams));
        }
        /// <summary>
        /// Returns call recording by name
        /// </summary>
        /// <param name="callId">id of call</param>
        /// <param name="recordingName">name of call recording</param>
        /// <param name="fields">limit fields returned. Example fields=id,name</param>
        /// <returns>CallRecording object</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 CallRecording GetCallRecordingByName(long callId, string recordingName, string fields = null)
        {
            Validate.NotBlank(callId.ToString(), "callId cannot be blank");
            Validate.NotBlank(recordingName, "recordingName cannot be blank");
            string path        = CALLS_ITEM_RECORDING_BY_NAME_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, callId.ToString()).ReplaceFirst(ClientConstants.PLACEHOLDER, recordingName);
            var    queryParams = ClientUtils.BuildQueryParams("fields", fields);

            return(Client.Get <CallRecording>(path, queryParams));
        }
        public void BuildQueryParamsWithBooleanAsNumber()
        {
            var contact = new Contact
            {
                Email  = "*****@*****.**",
                OptOut = true
            };

            var queryParams = ClientUtils.BuildQueryParams(contact).ToString();

            Console.WriteLine("contact: " + queryParams);
            Assert.That(queryParams, Is.StringContaining("Email=" + "*****@*****.**".UrlEncode()));
            Assert.That(queryParams, Is.StringContaining("OptOut=1"));
        }
        public void BuildQueryParamsFromGetRequest()
        {
            var request = new GetGroupsRequest
            {
                SortBy       = SortProperty.Name,
                SortType     = SortType.Asc,
                ItemsPerPage = 10,
                Page         = 5
            };
            var queryParams = ClientUtils.BuildQueryParams(request).ToString();

            Console.WriteLine("get request: " + queryParams);

            Assert.That(queryParams, Is.StringContaining("sortBy=Name"));
            Assert.That(queryParams, Is.StringContaining("sortDir=asc"));
            Assert.That(queryParams, Is.StringContaining("itemsPerPage=10"));
            Assert.That(queryParams, Is.StringContaining("page=5"));
        }
        /// <summary>
        /// Get order for keyword and/or number orders
        /// GET /me/account
        /// </summary>
        /// <param name="id">id of order</param>
        /// <param name="fields">limit fields returned. Example fields=id,name</param>
        /// <returns>ResourceId with id of created order</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 NumberOrder GetOrder(long id, string fields = null)
        {
            var queryParams = ClientUtils.BuildQueryParams("fields", fields);

            return(Client.Get <NumberOrder>(ORDERS_GET_ORDER.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString()), queryParams));
        }
        /// <summary>
        /// Returns a single Batch instance for a given batch id.
        /// This API is useful for determining the state of a validating batch.
        /// </summary>
        /// <param name="id">id of batch</param>
        /// <param name="fields">limit fields returned. Example fields=id,name</param>
        /// <returns>requested 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 Batch Get(long id, string fields = null)
        {
            var queryParams = ClientUtils.BuildQueryParams("fields", fields);

            return(Client.Get <Batch>(BATCH_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString()), queryParams));
        }
        /// <summary>
        /// Upload a MP3 or WAV file to account
        /// </summary>
        /// <param name="name">file name</param>
        /// <param name="pathToFile">path to MP3 or WAV file</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 UploadAndGetSoundDetails(string pathToFile, string name, string fields = null)
        {
            var queryParams = ClientUtils.BuildQueryParams("fields", fields);

            return(Client.PostFile <CampaignSound>(SOUNDS_FILES_PATH, name, pathToFile, queryParams));
        }
        /// <summary>
        /// Upload a MP3 or WAV file to account
        /// </summary>
        /// <param name="fileData">binary file data to upload</param>
        /// <param name="name">file name</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 UploadAndGetSoundDetails(byte[] fileData, string name = null, string fields = null)
        {
            var queryParams = ClientUtils.BuildQueryParams("fields", fields);

            return(Client.PostFile <CampaignSound>(SOUNDS_FILES_PATH, fileData, name, null, queryParams));
        }
        /// <summary>
        /// Create a text broadcast campaign using the Text Broadcast API. A campaign can be created with
        /// no contacts and bare minimum configuration, but contacts will have to be added further on to use the campaign.
        /// If start set to true campaign starts immediately
        /// </summary>
        /// <param name="broadcast">text broadcast to create</param>
        /// <param name="start">if set to true then broadcast will start immediately, by default it set to false</param>
        /// <returns>ResourceId object with id of created 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 ResourceId Create(TextBroadcast broadcast, bool start = false)
        {
            var queryParams = ClientUtils.BuildQueryParams("start", start.ToString());

            return(Client.Post <ResourceId>(TB_PATH, broadcast, queryParams));
        }
        /// <summary>
        /// Get API credentials by id
        /// </summary>
        /// <param name="id">id of credentials</param>
        /// <param name="fields">limit fields returned. Example fields=id,name</param>
        /// <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 ApiCredentials GetApiCredentials(long id, string fields = null)
        {
            var queryParams = ClientUtils.BuildQueryParams("fields", fields);

            return(Client.Get <ApiCredentials>(ME_API_CREDS_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString()), queryParams));
        }
        /// <summary>
        /// Find specific webhook resource
        /// </summary>
        /// <param name="resource">resource type object</param>
        /// <returns>WebhookResource object</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 WebhookResource FindWebhookResource(ResourceType resource, string fields)
        {
            var queryParams = ClientUtils.BuildQueryParams("fields", fields);

            return(Client.Get <WebhookResource>(WEBHOOKS_RESOURCE_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, resource.ToString()), queryParams));
        }
        /// <summary>
        /// Find webhook resources
        /// </summary>
        /// <param name="fields">limit fields returned. Example fields=id,name</param>
        /// <returns>List of WebhookResource objects</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 IList <WebhookResource> FindWebhookResources(string fields)
        {
            var queryParams = ClientUtils.BuildQueryParams("fields", fields);

            return(Client.Get <ListHolder <WebhookResource> >(WEBHOOKS_RESOURCES_PATH, queryParams).Items);
        }
        /// <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));
        }
        /// <summary>
        /// Use this API to create a sound file via a supplied string of text.
        /// </summary>
        /// <param name="textToSpeech">TTS object to create</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 CreateFromTtsAndGetSoundDetails(TextToSpeech textToSpeech, string fields)
        {
            var queryParams = ClientUtils.BuildQueryParams("fields", fields);

            return(Client.Post <CampaignSound>(SOUNDS_TTS_PATH, textToSpeech, queryParams));
        }
Exemple #28
0
        /// <summary>
        /// Get contact by id. Deleted contacts can still be retrieved but will be marked deleted
        /// and will not show up when quering contacts.
        /// </summary>
        /// <param name="id">id of contact</param>
        /// <param name="fields">limit fields returned. Example fields=id,name</param>
        /// <returns>contact object</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 Contact Get(long id, String fields = null)
        {
            var queryParams = ClientUtils.BuildQueryParams("fields", fields);

            return(Client.Get <Contact>(CONTACTS_ITEM_PATH.ReplaceFirst(ClientConstants.PLACEHOLDER, id.ToString()), queryParams));
        }