Ejemplo n.º 1
0
        /// <summary>
        /// Updates an incoming phone number data
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="incomingPhoneNumberSid">34 characters long unique incoming phone number identifier</param>
        /// <param name="friendlyName">User generated name for the incoming number.</param>
        /// <param name="voiceUrl">The URL returning InboundXML incoming calls should execute when connected.</param>
        /// <param name="voiceMethod">Specifies the HTTP method used to request the VoiceUrl once incoming call connects.</param>
        /// <param name="voiceFallbackUrl">URL used if any errors occur during execution of InboundXML on a call or at initial request of the VoiceUrl.</param>
        /// <param name="voiceFallbackMethod">Specifies the HTTP method used to request the VoiceFallbackUrl once incoming call connects.</param>
        /// <param name="voiceCallerIdLookup">Look up the caller’s caller-ID name from the CNAM database(additional charges apply).</param>
        /// <param name="smsUrl">The URL returning InboundXML incoming phone numbers should execute when receiving an SMS.</param>
        /// <param name="smsMethod">Specifies the HTTP method used to request the SmsUrl once an incoming SMS is received.</param>
        /// <param name="smsFallbackUrl">URL used if any errors occur during execution of InboundXML from an SMS or at initial request of the SmsUrl.</param>
        /// <param name="smsFallbackMethod">Specifies the HTTP method used to request the SmsFallbackUrl.</param>
        /// <param name="heartbeatUrl">URL that can be used to monitor the phone number.</param>
        /// <param name="heartbeatMethod">The HTTP method Avaya CPaaS will use when requesting the HeartbeatURL.</param>
        /// <param name="statusCallback">URL that can be requested to receive notification when and how incoming call has ended.</param>
        /// <param name="statusCallbackMethod">The HTTP method Avaya CPaaS will use when requesting the HangupCallback URL.</param>
        /// <param name="hangupCallback">This is a StatusCallback clone that will be phased out in future versions.</param>
        /// <param name="hangupCallbackMethod">This is a StatusCallbackMethod clone that will be phased out in future versions.</param>
        /// <returns>Returns updated incoming number</returns>
        public IncomingPhoneNumber UpdateIncomingNumber(string accountSid, string incomingPhoneNumberSid,
                                                        string friendlyName            = null, string voiceUrl = null,
                                                        HttpMethod voiceMethod         = HttpMethod.POST, string voiceFallbackUrl  = null,
                                                        HttpMethod voiceFallbackMethod = HttpMethod.POST, bool voiceCallerIdLookup = false, string smsUrl = null,
                                                        HttpMethod smsMethod           = HttpMethod.POST, string smsFallbackUrl = null,
                                                        HttpMethod smsFallbackMethod   = HttpMethod.POST, string heartbeatUrl   = null,
                                                        HttpMethod heartbeatMethod     = HttpMethod.POST,
                                                        string statusCallback          = null, HttpMethod statusCallbackMethod = HttpMethod.POST,
                                                        string hangupCallback          = null, HttpMethod hangupCallbackMethod = HttpMethod.POST)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create POST request
            var request = RestRequestHelper.CreateRestRequest(Method.POST,
                                                              $"Accounts/{accountSid}/IncomingPhoneNumbers/{incomingPhoneNumberSid}.json");

            // Add UpdateIncomingNumber query and body parameters
            this.SetParamsForUpdatingIncomingNumber(request, friendlyName, voiceUrl, voiceMethod, voiceFallbackUrl,
                                                    voiceFallbackMethod, voiceCallerIdLookup, smsUrl, smsMethod,
                                                    smsFallbackUrl, smsFallbackMethod, heartbeatUrl, heartbeatMethod, statusCallback, statusCallbackMethod,
                                                    hangupCallback, hangupCallbackMethod);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <IncomingPhoneNumber>(response));
        }
        /// <summary>
        /// Extends a destinations authorization expiration by 30 days
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="countryCode">Country code.</param>
        /// <returns>Returns fraud contorl rule</returns>
        public FraudControlRule ExtendDestinationAuthorization(string accountSid, string countryCode)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create POST request
            var request = RestRequestHelper.CreateRestRequest(Method.POST,
                                                              $"Accounts/{accountSid}/Fraud/Extend/{countryCode}.json");

            // Send request
            var response = client.Execute(request);

            var fraudControlRuleElement = this.ReturnOrThrowException <FraudControlRuleElement>(response);

            // If authorized part of a fraud control rule element is null return null
            if (fraudControlRuleElement.Authorized == null)
            {
                return(null);
            }

            // Get authorized part of fraud control rule element and set type
            var fraudControlRuleAuthorized = fraudControlRuleElement.Authorized;

            fraudControlRuleAuthorized.Type = FraudControlType.AUTHORIZED;

            return(fraudControlRuleAuthorized);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Records a call
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="callSid">Call SID.</param>
        /// <param name="record">Specifies if a call recording should start or end. Allowed values are "true" to start recording and "false" to end recording. Any number of simultaneous, separate recordings can be initiated.</param>
        /// <param name="direction">Specifies which audio stream to record. Allowed values are "in" to record the incoming caller's audio, "out" to record the outgoing caller's audio, and "both" to record both.</param>
        /// <param name="timeLimit">The maximum duration of the recording.Allowed value is an integer greater than 0.</param>
        /// <param name="callbackUrl">A URL that will be requested when the recording ends, sending information about the recording. The longer the recording, the longer the delay in processing the recording and requesting the CallbackUrl. Url length is limited to 200 characters.</param>
        /// <param name="fileFormat">Specifies the file format of the recording. Allowed values are "mp3" or "wav" - any other value will default to "mp3".</param>
        /// <param name="trimSilence">Trims all silence from the beginning of the recording. Allowed values are "true" or "false" - any other value will default to "false".</param>
        /// <param name="transcribe">Specifies if this recording should be transcribed. Allowed values are "true" and "false" - all other values will default to "false".</param>
        /// <param name="transcribeQuality">Specifies the quality of the transcription. Allowed values are "auto" for automated transcriptions and "hybrid" for human-reviewed transcriptions - all other values will default to "auto".</param>
        /// <param name="transcribeCallback">A URL that will be requested when the call ends, sending information about the transcription. The longer the recording, the longer the delay in processing the transcription and requesting the TranscribeCallback. URL length is limited to 200 characters.</param>
        /// <returns>Returns created recording</returns>
        public Recording RecordCall(string accountSid, string callSid, bool record,
                                    RecordingAudioDirection direction = RecordingAudioDirection.BOTH, int?timeLimit = null,
                                    string callbackUrl = null, RecordingFileFormat fileFormat = RecordingFileFormat.MP3,
                                    bool trimSilence   = false, bool transcribe = false,
                                    TranscribeQuality transcribeQuality = TranscribeQuality.AUTO,
                                    string transcribeCallback           = null)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create POST request
            var request = RestRequestHelper.CreateRestRequest(Method.POST,
                                                              $"Accounts/{accountSid}/Calls/{callSid}/Recordings.json");

            // Mark obligatory parameters
            Require.Argument("Record", record);

            // Add RecordCall query and body parameters
            this.SetParamsForRecordCall(request, record, direction, timeLimit, callbackUrl, fileFormat, trimSilence,
                                        transcribe, transcribeQuality, transcribeCallback);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <Recording>(response));
        }
        /// <summary>
        /// Authorizes previously blocked destination for outbound calls and sms messages
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="countryCode">Country code.</param>
        /// <param name="mobileEnabled">Mobile status for the destination. If false, all mobile call activity will be rejected or disabled. Allowed values are "true" and "false".</param>
        /// <param name="landlineEnabled">Landline status for the destination. If false, all landline call activity will be rejected or disabled. Allowed values are "true" and "false".</param>
        /// <param name="smsEnabled">SMS status for the destination. If false, all SMS activity will be rejected or disabled. Allowed values are "true" and "false".</param>
        /// <returns>Returns fraud control rule</returns>
        public FraudControlRule AuthorizeDestination(string accountSid, string countryCode,
                                                     bool mobileEnabled = true, bool landlineEnabled = true, bool smsEnabled = true)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create POST request
            var request = RestRequestHelper.CreateRestRequest(Method.POST,
                                                              $"Accounts/{accountSid}/Fraud/Authorize/{countryCode}.json");

            // Add AuthorizeDestination query and body parameters
            this.SetParamsForBlockOrAuthorizeDestination(request, mobileEnabled, landlineEnabled, smsEnabled);

            // Send request
            var response = client.Execute(request);

            var fraudControlRuleElement = this.ReturnOrThrowException <FraudControlRuleElement>(response);

            // If authorized part of a fraud control rule element is null return null
            if (fraudControlRuleElement.Authorized == null)
            {
                return(null);
            }

            // Get authorized part of fraud control rule element and set type
            var fraudControlRuleAuthorized = fraudControlRuleElement.Authorized;

            fraudControlRuleAuthorized.Type = FraudControlType.AUTHORIZED;

            return(fraudControlRuleAuthorized);
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Create new SIP domain
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="domainName">An address on Avaya CPaaS uniquely associated with your account and through which all your SIP traffic is routed.</param>
        /// <param name="friendlyName">A human-readable name associated with this domain.</param>
        /// <param name="voiceUrl">The URL requested when a call is received by your domain.</param>
        /// <param name="voiceMethod">The HTTP method used when requesting the VoiceUrl.</param>
        /// <param name="voiceFallbackUrl">The URL requested if the VoiceUrl fails.</param>
        /// <param name="voiceFallbackMethod">The HTTP method used when requesting the VoiceFallbackUrl.</param>
        /// <param name="hearbeatUrl">URL that can be requested every 60 seconds during the call to notify of elapsed time and pass other general information.</param>
        /// <param name="hearbeatMethod">Specifies the HTTP method used to request HeartbeatUrl.</param>
        /// <param name="voiceStatusCallback">The URL that Avaya CPaaS will use to send you status notifications regarding your SIP call.</param>
        /// <param name="voiceStatusCallbackMethod">The HTTP method used when requesting the VoiceStatusCallback.</param>
        /// <returns>Returns created domain</returns>
        public Domain CreateDomain(string accountSid, string domainName,
                                   string friendlyName        = null, string voiceUrl = null, HttpMethod voiceMethod = HttpMethod.POST,
                                   string voiceFallbackUrl    = null, HttpMethod voiceFallbackMethod       = HttpMethod.POST,
                                   string hearbeatUrl         = null, HttpMethod hearbeatMethod            = HttpMethod.POST,
                                   string voiceStatusCallback = null, HttpMethod voiceStatusCallbackMethod = HttpMethod.POST)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create POST request
            var request = RestRequestHelper.CreateRestRequest(Method.POST, $"Accounts/{accountSid}/SIP/Domains.json");

            // Mark obligatory parameters
            Require.Argument("DomainName", domainName);

            // Add CreateDomain query and body parameters
            request.AddParameter("DomainName", domainName);

            this.SetParamsForCreateOrUpdateDomain(request, friendlyName, voiceUrl, voiceMethod, voiceFallbackUrl,
                                                  voiceFallbackMethod, hearbeatUrl,
                                                  hearbeatMethod, voiceStatusCallback, voiceStatusCallbackMethod);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <Domain>(response));
        }
        /// <summary>
        /// Shows information on all fraud control resources associated with some account
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="page">Used to return a particular page within the list.</param>
        /// <param name="pageSize">Used to specify the amount of list items to return per page.</param>
        /// <returns>Returns fraud control rules list</returns>
        public FraudControlRulesList ListFraudControlResources(string accountSid, int?page = null, int?pageSize = null)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create GET request
            var request = RestRequestHelper.CreateRestRequest(Method.GET, $"Accounts/{accountSid}/Fraud.json");

            // Add ListFraudControlResources query and body parameters
            this.SetParamsForListFraudControlResources(request, page, pageSize);

            // Send request
            var response = client.Execute(request);

            var fraudControlRules = this.ReturnOrThrowException <FraudControlRulesList>(response);

            // If fraud control rules are null return null
            if (fraudControlRules == null)
            {
                return(null);
            }

            fraudControlRules.Authorized  = new List <FraudControlRule>();
            fraudControlRules.Blocked     = new List <FraudControlRule>();
            fraudControlRules.Whitelisted = new List <FraudControlRule>();

            foreach (var element in fraudControlRules.Elements)
            {
                // Determine which type of rule is the rule and add it to appropriate list
                var authorizedRule  = element.Authorized;
                var blockedRule     = element.Blocked;
                var whitelistedRule = element.Whitelisted;

                if (authorizedRule != null)
                {
                    authorizedRule.Type = FraudControlType.AUTHORIZED;
                    fraudControlRules.Authorized.Add(authorizedRule);
                }
                else if (blockedRule != null)
                {
                    blockedRule.Type = FraudControlType.BLOCKED;
                    fraudControlRules.Blocked.Add(blockedRule);
                }
                else if (whitelistedRule != null)
                {
                    whitelistedRule.Type = FraudControlType.WHITELISTED;
                    fraudControlRules.Whitelisted.Add(whitelistedRule);
                }
            }

            return(fraudControlRules);
        }
Ejemplo n.º 7
0
        /// <summary>
        /// See all the information associated with an account
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <returns>Returns account</returns>
        public Account ViewAccount(string accountSid)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create GET request
            var request = RestRequestHelper.CreateRestRequest(Method.GET, $"Accounts/{accountSid}.json");

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <Account>(response));
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Shows info on an incoming phone number
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="incomingNumberSid">Incoming number SID.</param>
        /// <returns>Returns incoming phone number</returns>
        public IncomingPhoneNumber ViewIncomingNumber(string accountSid, string incomingNumberSid)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create GET request
            var request = RestRequestHelper.CreateRestRequest(Method.GET,
                                                              $"Accounts/{accountSid}/IncomingPhoneNumbers/{incomingNumberSid}.json");

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <IncomingPhoneNumber>(response));
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Deletes SIP domain credentials list
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="clSid">Credentials list SID.</param>
        /// <returns>Returns deleted credentials list</returns>
        public CredentialList DeleteCredentialsList(string accountSid, string clSid)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create DELETE request
            var request = RestRequestHelper.CreateRestRequest(Method.DELETE,
                                                              $"Accounts/{accountSid}/SIP/CredentialLists/{clSid}.json");

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <CredentialList>(response));
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Shows info on credential lists attached to a SIP domain
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="domainSid">Domain SID.</param>
        /// <returns>Returns mapped credential lists list</returns>
        public CredentialListsList ListMappedCredentialsLists(string accountSid, string domainSid)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create GET request
            var request = RestRequestHelper.CreateRestRequest(Method.GET,
                                                              $"Accounts/{accountSid}/SIP/Domains/{domainSid}/CredentialListMappings.json");

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <CredentialListsList>(response));
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Deletes a recording
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="recordingSid">Recording SID.</param>
        /// <returns>Returns deleted recording</returns>
        public Recording DeleteRecording(string accountSid, string recordingSid)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create DELETE request
            var request = RestRequestHelper.CreateRestRequest(Method.DELETE,
                                                              $"Accounts/{accountSid}/Recordings/{recordingSid}.json");

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <Recording>(response));
        }
        /// <summary>
        /// Deletes IP address from IP access control list
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="aclSid">IP access control list SID.</param>
        /// <param name="ipSid">Access control list IP address SID.</param>
        /// <returns>Returns deleted access control list IP address</returns>
        public IpAddress DeleteAccessControlListIp(string accountSid, string aclSid, string ipSid)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create DELETE request
            var request = RestRequestHelper.CreateRestRequest(Method.DELETE,
                                                              $"Accounts/{accountSid}/SIP/IpAccessControlLists/{aclSid}/IpAddresses/{ipSid}.json");

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <IpAddress>(response));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Hangs up a conference participant
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="conferenceSid">Conference SID.</param>
        /// <param name="participantSid">Participant SID.</param>
        /// <returns>Returns participant</returns>
        public Participant HangupParticipant(string accountSid, string conferenceSid, string participantSid = null)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create DELETE request
            var request = RestRequestHelper.CreateRestRequest(Method.DELETE,
                                                              $"Accounts/{accountSid}/Conferences/{conferenceSid}/Participants/{participantSid}.json");

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <Participant>(response));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Detaches an IP access control list from a SIP domain
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="domainSid">Domain SID.</param>
        /// <param name="alSid">IP access control list SID.</param>
        /// <returns>Returns deleted IP access control list</returns>
        public IpAccessControlList DeleteMappedIpAccessControlList(string accountSid, string domainSid, string alSid)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create DELETE request
            var request = RestRequestHelper.CreateRestRequest(Method.DELETE,
                                                              $"Accounts/{accountSid}/SIP/Domains/{domainSid}/IpAccessControlListMappings/{alSid}.json");

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <IpAccessControlList>(response));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// Shows info on all carrier lookups associated with some account
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="page">Used to return a particular page within the list.</param>
        /// <param name="pageSize">Used to specify the amount of list items to return per page.</param>
        /// <returns>Returns carrier lookup list</returns>
        public CarrierLookupsList CarrierLookupList(string accountSid, int?page = null, int?pageSize = null)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create GET request
            var request = RestRequestHelper.CreateRestRequest(Method.GET, $"Accounts/{accountSid}/Lookups/Carrier.json");

            // Add CarrierLookupList query and body parameters
            this.SetParamsForListLookups(request, page, pageSize);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <CarrierLookupsList>(response));
        }
Ejemplo n.º 16
0
        /// <summary>
        /// Shows info on all notifications associated with some account
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="log">Specifies that only notifications with the given log level value should be listed. Allowed values are 1,2 or 3, where 2=INFO, 1=WARNING, 0=ERROR.</param>
        /// <param name="page">Used to return a particular page within the list.</param>
        /// <param name="pageSize">Used to specify the amount of list items to return per page.</param>
        /// <returns>Returns notification list</returns>
        public NotificationsList ListNotifications(string accountSid, Log?log = null, int?page = null,
                                                   int?pageSize = null)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create GET request
            var request = RestRequestHelper.CreateRestRequest(Method.GET, $"Accounts/{accountSid}/Notifications.json");

            // Add ListNotifications query and body parameters
            this.SetParamsForListNotifications(request, log, page, pageSize);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <NotificationsList>(response));
        }
Ejemplo n.º 17
0
        /// <summary>
        /// Complete list of all usages of your account
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="day">Filters usage by day of month. If no month is specified then defaults to current month. Allowed values are integers between 1 and 31 depending on the month. Leading 0s will be ignored.</param>
        /// <param name="month">Filters usage by month. Allowed values are integers between 1 and 12. Leading 0s will be ignored.</param>
        /// <param name="year">Filters usage by year. Allowed values are valid years in integer form such as "2014".</param>
        /// <param name="product">Filters usage by a specific “product” of Avaya Cloud. Each product is uniquely identified by an integer. For example: Product=1, would return all outbound call usage. The integer assigned to each product is listed below.</param>
        /// <param name="page">Used to return a particular page within the list.</param>
        /// <param name="pageSize">Used to specify the amount of list items to return per page.</param>
        /// <returns>Returns usage list</returns>
        public UsagesList ListUsages(string accountSid, int?day = null, int?month = null, int?year     = null,
                                     Product?product            = null, int?page  = null, int?pageSize = null)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create GET request
            var request = RestRequestHelper.CreateRestRequest(Method.GET, $"Accounts/{accountSid}/Usages.json");

            // Add ListUsages query and body parameters
            this.SetParamsForListUsages(request, day, month, year, product, page, pageSize);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <UsagesList>(response));
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Shows info on all SMS messages associated with some account
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="to">List all SMS sent to this number.The value does not have to be in any specific format.</param>
        /// <param name="from">List all SMS sent from this number. The value does not have to be in any specific format.</param>
        /// <param name="dateSentGte">Filter by date sent greater or equal than.</param>
        /// <param name="dateSentLt">Filter by date sent less than.</param>
        /// <param name="page">Used to return a particular page within the list.</param>
        /// <param name="pageSize">Used to specify the amount of list items to return per page.</param>
        /// <returns>Returns sms list</returns>
        public SmsMessagesList ListSmsMessages(string accountSid, string to = null, string from = null,
                                               DateTime dateSentGte         = default(DateTime), DateTime dateSentLt = default(DateTime), int?page = null,
                                               int?pageSize = null)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create GET request
            var request = RestRequestHelper.CreateRestRequest(Method.GET, $"Accounts/{accountSid}/SMS/Messages.json");

            // Add ListSmsMessages query and body parameters
            this.SetParamsForListSmsMessages(request, to, from, dateSentGte, dateSentLt, page, pageSize);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <SmsMessagesList>(response));
        }
        /// <summary>
        /// Updates IP address for IP access control list
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="aclSid">IP access control list SID.</param>
        /// <param name="ipSid">Access control list IP address SID.</param>
        /// <param name="friendlyName">A human-readable name associated with this IP ACL.</param>
        /// <param name="ipAddress">An IP address from which you wish to accept traffic. At this time, only IPv4 supported.</param>
        /// <returns>Returns updated access control list IP address</returns>
        public IpAddress UpdateAccessControlListIp(string accountSid, string aclSid, string ipSid,
                                                   string friendlyName = null, string ipAddress = null)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create POST request
            var request = RestRequestHelper.CreateRestRequest(Method.POST,
                                                              $"Accounts/{accountSid}/SIP/IpAccessControlLists/{aclSid}/IpAddresses/{ipSid}.json");

            // Add UpdateAccessControlListIp query and body parameters
            this.SetParamsForAddOrUpdateAccessControlListIp(request, friendlyName, ipAddress);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <IpAddress>(response));
        }
Ejemplo n.º 20
0
        /// <summary>
        /// Shows info on all recordings associated with some account
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="callSid">Filters by recordings associated with a given CallSid.</param>
        /// <param name="dateCreatedGte">Filter by date created greater or equal than.</param>
        /// <param name="dateCreatedLt">Filter by date created less than.</param>
        /// <param name="page">Used to return a particular page within the list.</param>
        /// <param name="pageSize">Used to specify the amount of list items to return per page.</param>
        /// <returns>Returns recording list</returns>
        public RecordingsList ListRecordings(string accountSid, string callSid = null,
                                             DateTime dateCreatedGte           = default(DateTime),
                                             DateTime dateCreatedLt            = default(DateTime), int?page = null, int?pageSize = null)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create GET request
            var request = RestRequestHelper.CreateRestRequest(Method.GET, $"Accounts/{accountSid}/Recordings.json");

            // Add ListRecordings query and body parameters
            this.SetParamsForListRecordings(request, callSid, dateCreatedGte, dateCreatedLt, page, pageSize);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <RecordingsList>(response));
        }
Ejemplo n.º 21
0
        /// <summary>
        /// The Carrier Lookup API allows you to retrieve additional information about a phone number.
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="phoneNumber">Phone number to do a lookup for.</param>
        /// <returns>Returns carrier lookup</returns>
        public CarrierLookup CarrierLookup(string accountSid, string phoneNumber)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create POST request
            var request = RestRequestHelper.CreateRestRequest(Method.POST, $"Accounts/{accountSid}/Lookups/Carrier.json");

            // Add CarrierLookup query and body parameters
            request.AddParameter("PhoneNumber", phoneNumber);

            // Send request
            var response = client.Execute(request);

            var lookups = this.ReturnOrThrowException <CarrierLookups>(response);

            return(lookups != null && lookups.LookupArray != null && lookups.LookupArray.Length > 0 ? lookups.LookupArray[0] : null);
        }
Ejemplo n.º 22
0
        /// <summary>
        /// Sets participant in conference to mute or deaf
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="conferenceSid">Conference SID.</param>
        /// <param name="participantSid">Participant SID.</param>
        /// <param name="muted">Specifies whether the participant should be muted. Allowed values are "true" and "false".</param>
        /// <param name="deaf">Specifies whether the participant should be deaf. Allowed values are "true" and "false".</param>
        /// <returns>Returns participant</returns>
        public Participant MuteOrDeafParticipant(string accountSid, string conferenceSid, string participantSid,
                                                 bool muted = false, bool deaf = false)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create POST request
            var request = RestRequestHelper.CreateRestRequest(Method.POST,
                                                              $"Accounts/{accountSid}/Conferences/{conferenceSid}/Participants/{participantSid}.json");

            // Add MuteOrDeafParticipant query and body parameters
            this.SetParamsForMuteOrDeafParticipant(request, muted, deaf);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <Participant>(response));
        }
Ejemplo n.º 23
0
        /// <summary>
        /// Options include filtering by muted or deaf.
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="conferenceSid">Conference SID.</param>
        /// <param name="muted">Filter by participants that are muted. Allowed values are "true" or "false".</param>
        /// <param name="deaf">Filter by participants that are deaf. Allowed values are "true" or "false".</param>
        /// <param name="page">Used to return a particular page within the list.</param>
        /// <param name="pageSize">Used to specify the amount of list items to return per page.</param>
        /// <returns>Returns participant list</returns>
        public ParticipantsList ListParticipants(string accountSid, string conferenceSid,
                                                 bool muted = false, bool deaf = false, int?page = null, int?pageSize = null)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create GET request
            var request = RestRequestHelper.CreateRestRequest(Method.GET,
                                                              $"Accounts/{accountSid}/Conferences/{conferenceSid}/Participants.json");

            // Add ListParticipants query and body parameters
            this.SetParamsForListParticipants(request, muted, deaf, page, pageSize);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <ParticipantsList>(response));
        }
        /// <summary>
        /// Transcribes some recording
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="recordingSid">Recording SID.</param>
        /// <param name="transcribeCallback">The URL some parameters regarding the transcription will be passed to once it is completed. The longer the recording time, the longer the process delay in returning the transcription information. If no TranscribeCallback is given, the recording will still be saved to the system and available either in your Transcriptions Logs or via a REST List Transcriptions (ADD URL LINK) request. URL length is limited to 200 characters.</param>
        /// <param name="callbackMethod">The HTTP method used to request the TranscribeCallback. Valid parameters are GET and POST - any other value will default to POST.</param>
        /// <param name="sliceStart">Start point for slice transcription(in seconds).</param>
        /// <param name="sliceDuration">Duration of slice transcription (in seconds).</param>
        /// <param name="quality">Specifies the transcription quality.Transcription price differs for each quality tier.See pricing page for details.Allowed values are "auto", "hybrid" and "keywords", where "auto" is a machine-generated transcription, "hybrid" is reviewed by a human for accuracy and "keywords" returns topics and keywords for given audio file.</param>
        /// <returns>Returns created transcription</returns>
        public Transcription TranscribeRecording(string accountSid, string recordingSid,
                                                 string transcribeCallback = null, HttpMethod callbackMethod = HttpMethod.POST, int?sliceStart = null,
                                                 int?sliceDuration         = null, TranscribeQuality quality = TranscribeQuality.AUTO)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create POST request
            var request = RestRequestHelper.CreateRestRequest(Method.POST, $"Accounts/{accountSid}/Transcriptions.json");

            // Add TranscribeRecording query and body parameters
            this.SetParamsForTranscribeRecordingOrAudioUrl(request, transcribeCallback, callbackMethod, sliceStart,
                                                           sliceDuration, quality);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <Transcription>(response));
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Updates account information.
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="friendlyName">The custom alias for your account.</param>
        /// <returns>Returns updated account</returns>
        public Account UpdateAccount(string accountSid, string friendlyName = null)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create POST request
            var request = RestRequestHelper.CreateRestRequest(Method.POST, $"Accounts/{accountSid}.json");

            // Set body parameter
            if (friendlyName.HasValue())
            {
                request.AddParameter("FriendlyName", friendlyName);
            }

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <Account>(response));
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Shows info on all incoming numbers associated with some account
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="contains">List numbers containing certain digits.</param>
        /// <param name="friendlyName">Specifies that only IncomingPhoneNumber resources matching the input FriendlyName should be returned in the list request.</param>
        /// <param name="page">Used to return a particular page within the list.</param>
        /// <param name="pageSize">Used to specify the amount of list items to return per page.</param>
        /// <returns>Returns incoming phone number list</returns>
        public IncomingPhoneNumbersList ListIncomingNumbers(string accountSid, string contains = null,
                                                            string friendlyName = null,
                                                            int?page            = null, int?pageSize = null)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create GET request
            var request = RestRequestHelper.CreateRestRequest(Method.GET,
                                                              $"Accounts/{accountSid}/IncomingPhoneNumbers.json");

            // Add ListIncomingNumbers query and body parameters
            this.SetParamsForListIncomingNumbers(request, contains, friendlyName, page, pageSize);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <IncomingPhoneNumbersList>(response));
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Updates SIP domain credentials
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="clSid">Credentials list SID.</param>
        /// <param name="credentialSid">Credential SID.</param>
        /// <param name="password">The password used to authenticate this credential.</param>
        /// <returns>Returns updated credential</returns>
        public Credential UpdateCredential(string accountSid, string clSid, string credentialSid, string password)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create POST request
            var request = RestRequestHelper.CreateRestRequest(Method.POST,
                                                              $"Accounts/{accountSid}/SIP/CredentialLists/{clSid}/Credentials/{credentialSid}.json");

            // Mark obligatory parameters
            Require.Argument("Password", password);

            // Add UpdateCredential query and body parameters
            request.AddParameter("Password", password);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <Credential>(response));
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Creates SIP domain credentials list
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="friendlyName">A human readable name for this credential list.</param>
        /// <returns>Returns created credentials list</returns>
        public CredentialList CreateCredentialsList(string accountSid, string friendlyName)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create POST request
            var request = RestRequestHelper.CreateRestRequest(Method.POST,
                                                              $"Accounts/{accountSid}/SIP/CredentialLists.json");

            // Mark obligatory parameters
            Require.Argument("FriendlyName", friendlyName);

            // Add CreateCredential query and body parameters
            request.AddParameter("FriendlyName", friendlyName);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <CredentialList>(response));
        }
Ejemplo n.º 29
0
        /// <summary>
        /// Creates a new application client for your application
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="applicationSid">Application SID.</param>
        /// <param name="nickname">The name used to identify this application client.</param>
        /// <returns>Returns created application client</returns>
        public ApplicationClient CreateApplicationClient(string accountSid, string applicationSid, string nickname)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create POST request
            var request = RestRequestHelper.CreateRestRequest(Method.POST,
                                                              $"Accounts/{accountSid}/Applications/{applicationSid}/Tokens.json");

            // Mark obligatory parameters
            Require.Argument("Nickname", nickname);

            // Add CreateApplicationClient parameter
            request.AddParameter("Nickname", nickname);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <ApplicationClient>(response));
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Maps credentials list to a SIP domain
        /// </summary>
        /// <param name="accountSid">The account sid.</param>
        /// <param name="domainSid">Domain SID.</param>
        /// <param name="credentialListSid">The SID of the credential list that you wish to associate with this domain.</param>
        /// <returns>Returns mapped credentials list</returns>
        public CredentialList MapCredentialsList(string accountSid, string domainSid, string credentialListSid)
        {
            // Get client to make request
            var client = HttpProvider.GetHttpClient();

            // Create POST request
            var request = RestRequestHelper.CreateRestRequest(Method.POST,
                                                              $"Accounts/{accountSid}/SIP/Domains/{domainSid}/CredentialListMappings.json");

            // Mark obligatory parameters
            Require.Argument("CredentialListSid", credentialListSid);

            // Add MapCredentialsList query and body parameters
            request.AddParameter("CredentialListSid", credentialListSid);

            // Send request
            var response = client.Execute(request);

            return(this.ReturnOrThrowException <CredentialList>(response));
        }