/// <summary> /// Receive SMS message. Make GET request /// </summary> /// <param name="smsMessageSid">An alphanumeric string used for identification of sms messages.</param> /// <returns></returns> public async Task<SmsMessage> GetSmsMessage(string smsMessageSid) { var request = new RestRequest(); request.Resource = RequestUri.GetSmsMessageUri; request.AddUrlSegment(RequestUriParams.SmsMessageSid, smsMessageSid); return await Execute<SmsMessage>(request); }
/// <summary> /// Retrive Call details. Make GET request /// </summary> /// <param name="callSid"></param> /// <returns></returns> public async Task<Call> GetCall(string callSid) { var request = new RestRequest(); request.Resource = RequestUri.GetCallUri; request.AddUrlSegment(RequestUriParams.CallSid, callSid); return await Execute<Call>(request); }
/// <summary> /// Return transcription content in textual format /// </summary> /// <param name="transcriptionSid">An alphanumeric string used for identification of transcriptions.</param> /// <returns></returns> public string GetTranscriptionText(string transcriptionSid) { Require.Argument("TranscriptionSid", transcriptionSid); var request = new RestRequest(); request.Resource = RequestUri.TranscriptionTextUri; request.AddUrlSegment(RequestUriParams.TranscriptionSid, transcriptionSid); return Execute(request).Result.RawData; }
/// <summary> /// Return resource properties about conference call /// </summary> /// <param name="conferenceSid">Conference sid</param> /// <returns></returns> public async Task<Conference> GetConference(string conferenceSid) { Require.Argument("ConferenceSid", conferenceSid); var request = new RestRequest(); request.Resource = RequestUri.ConferenceUri; request.AddUrlSegment(RequestUriParams.ConferenceSid, conferenceSid); return await Execute<Conference>(request); }
/// <summary> /// Get a single recording resource /// </summary> /// <param name="recordingSid">An alphanumeric string used to identify each recording.</param> /// <returns></returns> public async Task<Recording> GetRecording(string recordingSid) { Require.Argument("RecordingSid", recordingSid); var request = new RestRequest(); request.Resource = RequestUri.RecordingUri; request.AddUrlSegment(RequestUriParams.RecordingSid, recordingSid); return await Execute<Recording>(request); }
/// <summary> /// Return application details /// </summary> /// <param name="applicationSid">An alphanumeric string used for identification of the application.</param> /// <returns></returns> public async Task<Application> GetApplication(string applicationSid) { Require.Argument("ApplicationSid", applicationSid); var request = new RestRequest(); request.Resource = RequestUri.ApplicationUri; request.AddUrlSegment(RequestUriParams.ApplicationSid, applicationSid); return await Execute<Application>(request); }
/// <summary> /// Gets TelAPI phone number associated with an account /// </summary> /// <param name="phoneNumberSid">An alphanumeric string used for identification of incoming phone numbers.</param> /// <returns></returns> public async Task<IncomingPhoneNumber> GetIncomingPhoneNumber(string phoneNumberSid) { Require.Argument("IncomingPhoneNumberSid", phoneNumberSid); var request = new RestRequest(); request.Resource = RequestUri.IncomingPhoneNumberUri; request.AddUrlSegment(RequestUriParams.IncomingPhoneNumberSid, phoneNumberSid); return await Execute<IncomingPhoneNumber>(request); }
/// <summary> /// Return transcription /// </summary> /// <param name="transcriptionSid">An alphanumeric string used for identification of transcriptions.</param> /// <returns></returns> public async Task<Transcription> GetTranscription(string transcriptionSid) { Require.Argument("TranscriptionSid", transcriptionSid); var request = new RestRequest(); request.Resource = RequestUri.TranscriptionUri; request.AddUrlSegment(RequestUriParams.TranscriptionSid, transcriptionSid); return await Execute<Transcription>(request); }
/// <summary> /// /// </summary> /// <param name="notificationSid"></param> /// <returns></returns> public async Task<Notification> GetNotification(string notificationSid) { Require.Argument("NotificationsSid", notificationSid); var request = new RestRequest(); request.Resource = RequestUri.NotificationUri; request.AddUrlSegment(RequestUriParams.NotificationSid, notificationSid); return await Execute<Notification>(request); }
/// <summary> /// Used to authorize destinations for outbound calls and sms messages. /// </summary> /// <param name="countryCode">Two letter country code being whitelisted, authorized or blocked.</param> /// <param name="mobileBreakout">Mobile breakout status for the destination.</param> /// <param name="Landlinebreakout">Landline breakout status for the destination.</param> /// <param name="smsEnabled">SMS status for the destination.</param> /// <returns></returns> public async Task<FraudResult> AuthorizeDestination(string countryCode, bool? mobileBreakout, bool? landlinebreakout, bool? smsEnabled) { Require.Argument("CountryCode", countryCode); var request = new RestRequest(System.Net.Http.HttpMethod.Post); request.Resource = RequestUri.FraudAuthorizeDestination; request.AddUrlSegment(RequestUriParams.CountryCode, countryCode); if (mobileBreakout.HasValue) request.AddParameter("MobileBreakout", mobileBreakout); if (landlinebreakout.HasValue) request.AddParameter("LandlineBreakout", landlinebreakout); if (smsEnabled.HasValue) request.AddParameter("SmsEnabled", smsEnabled); return await Execute<FraudResult>(request); }
/// <summary> /// A list of only notifications associated with a given CallSid /// </summary> /// <param name="callSid">An alphanumeric string used for identification of calls.</param> /// <param name="log">Specifies that only notifications with the given log level value should be listed.</param> /// <param name="page">Used to return a particular page withing the list.</param> /// <param name="pageSize">Used to specify the amount of list items to return per page.</param> /// <returns></returns> public async Task<NotificationResult> GetCallNotifications(string callSid, NotificationLog? log, int? page, int? pageSize) { Require.Argument("CallSid", callSid); var request = new RestRequest(); request.Resource = RequestUri.CallNotificationUri; request.AddUrlSegment("CallSid", callSid); if (log.HasValue) request.AddParameter("Log", (int)log); if (page.HasValue) request.AddParameter("Page", page); if (pageSize.HasValue) request.AddParameter("PageSize", pageSize); return await Execute<NotificationResult>(request); }
/// <summary> /// Request a list of available numbers /// </summary> /// <param name="isoCountryCode">Two letter country code of the available phone number.</param> /// <param name="areaCode">Code used to identify the phone numbers geographic origin. Found at the beginning of the number.</param> /// <param name="contains">Specifies the desired characters contained within the available numbers to list.</param> /// <param name="inRegion">Specifies the desired region of the available numbers to be listed.</param> /// <param name="inPostalCode">Specifies the desired postal code of the available numbers to be listed.</param> /// <param name="type">Search for local (default) or toll free nubmers.</param> /// <returns></returns> public async Task<AvailablePhoneNumberResult> GetAvailablePhoneNumbers(string isoCountryCode, string areaCode, string contains, string inRegion, string inPostalCode, AvaliablePhoneNumberType type) { Require.Argument("IsoCountryCode", isoCountryCode); var request = new RestRequest(); request.Resource = type == AvaliablePhoneNumberType.Local ? RequestUri.AvailablePhoneNumbersUri : RequestUri.AvailableTollFreePhoneNumbersUri; request.AddUrlSegment(RequestUriParams.IsoCountryCode, isoCountryCode); if (areaCode != null) request.AddParameter("AreaCode", areaCode); if (contains != null) request.AddParameter("Contains", contains); if (inRegion != null) request.AddParameter("InRegion", inRegion); if (inPostalCode != null) request.AddParameter("InPostalCode", inPostalCode); return await Execute<AvailablePhoneNumberResult>(request); }
/// <summary> /// Update existing Incoming Phone number /// </summary> /// <param name="phoneNumber">Desired Incoming phone number to update</param> /// <returns></returns> public async Task<IncomingPhoneNumber> UpdateIncomingPhoneNumber(IncomingPhoneNumber phoneNumber) { var request = new RestRequest(System.Net.Http.HttpMethod.Post); request.Resource = RequestUri.UpdateIncomingPhoneNumberUri; request.AddUrlSegment(RequestUriParams.IncomingPhoneNumberSid, phoneNumber.Sid); CreateIncomingPhoneNumberParams(phoneNumber, request); return await Execute<IncomingPhoneNumber>(request); }
/// <summary> /// DTMFs, aka touch tone signals, can be sent to a call /// </summary> /// <param name="callSid">An alphanumeric string used for identification of calls</param> /// <param name="playDtmf">Specifies which touch tone signals to send to a call. W or w can be used to include half second pauses within the digit transmission. For example: wwww1234 waits two seconds before sending the digits and 12wwww34 waits two seconds in between the sending of 12 and 34. Allowed Value: the digits 0-9, W, or w</param> /// <param name="dtmfLeg">Specifies which leg of the call digits will be sent to. 'aleg' leg is the originator of the call, 'bleg' is the recipient of the call.</param> /// <returns></returns> public async Task<Call> SendDigits(string callSid, string playDtmf, PlayDtmfLeg? dtmfLeg) { Require.Argument("CallSid", callSid); Require.Argument("PlayDtmf", playDtmf); var request = new RestRequest(System.Net.Http.HttpMethod.Post); request.Resource = RequestUri.SendDigitsUri; request.AddUrlSegment(RequestUriParams.CallSid, callSid); request.AddParameter("PlayDtmf", playDtmf); if (dtmfLeg.HasValue) request.AddParameter("PlayDtmfLeg", dtmfLeg.ToString().ToLower()); return await Execute<Call>(request); }
/// <summary> /// To change the behavior of live calls, TelAPI provides the ability to interrupt calls in real time and end or redirect them to InboundXML for execution. /// </summary> /// <param name="callSid">An alphanumeric string used for identification of calls</param> /// <param name="url">The URL in-progress calls can be forwarded to.</param> /// <param name="httpMethod">Specifies the HTTP method used to request forwarding URL. Allowed Value: POST or GET. Default Value: POST</param> /// <param name="status">The status used to end the call. canceled only ends queued/ringing calls while completed ends in-progress calls as well as queued/ringing calls. Allowed Value: canceled or completed</param> /// <returns></returns> public async Task<Call> InterruptLiveCall(string callSid, string url, HttpMethod? httpMethod, HangupCallStatus? status) { Require.Argument("CallSid", callSid); var request = new RestRequest(System.Net.Http.HttpMethod.Post); request.Resource = RequestUri.InterruptLiveCallUri; request.AddUrlSegment(RequestUriParams.CallSid, callSid); if(url != null) request.AddParameter("Url", url); if(httpMethod != null) request.AddParameter("Method", httpMethod.ToString().ToLower()); if(status != null) request.AddParameter("Status", status.ToString().ToLower()); return await Execute<Call>(request); }
/// <summary> /// Update application data /// </summary> /// <param name="application">Application object</param> /// <returns></returns> public async Task<Application> UpdateApplication(Application application) { Require.Argument("ApplicationSid", application.Sid); var request = new RestRequest(System.Net.Http.HttpMethod.Post); request.Resource = RequestUri.UpdateApplicationUri; request.AddUrlSegment(RequestUriParams.ApplicationSid, application.Sid); CreateApplicationParams(application, request); return await Execute<Application>(request); }
/// <summary> /// Start transcribe of recording /// </summary> /// <param name="recordingSid">An alphanumeric string used for identification of recording.</param> /// <param name="quality">Specifies the transcription quality.</param> /// <param name="transcribeCallback">URL that will be requested when the transcription has finished processing.</param> /// <param name="callbackMethod">Specifies the HTTP method to use when requesting the TranscribeCallback URL.</param> /// <returns></returns> public async Task<Transcription> TranscribeRecording(string recordingSid, TranscriptionType? quality, string transcribeCallback, string callbackMethod) { Require.Argument("RecordingSid", recordingSid); var request = new RestRequest(System.Net.Http.HttpMethod.Post); request.Resource = RequestUri.TranscribeRecordingUri; request.AddUrlSegment("RecordingSid", recordingSid); if (quality.HasValue) request.AddParameter("Quality", quality.ToString().ToLower()); if (transcribeCallback != null) request.AddParameter("TranscribeCallback", transcribeCallback); if (callbackMethod != null) request.AddParameter("CallbackMethod", callbackMethod); return await Execute<Transcription>(request); }
/// <summary> /// TelAPI offers a way to both initiate or end a call recording /// </summary> /// <param name="callSid">An alphanumeric string used for identification of calls</param> /// <param name="isRecording">Specifies if call recording should beging or end. To start recording a call, value must be true. To stop recording a call, value must be false.</param> /// <param name="timeLimit">The time in seconds the duration a call recording should not exceed. If no value specified, recordings are 60 seconds by default.</param> /// <param name="callbackUrl">URL where recording information will be relayed to after it has completed.</param> /// <returns></returns> public async Task<RecordingResult> RecordCall(string callSid, bool isRecording, int? timeLimit, string callbackUrl) { Require.Argument("CallSid", callSid); Require.Argument("Record", isRecording); var request = new RestRequest(System.Net.Http.HttpMethod.Post); request.Resource = RequestUri.RecordCallUri; request.AddUrlSegment(RequestUriParams.CallSid, callSid); request.AddParameter("Record", isRecording); if (timeLimit.HasValue) request.AddParameter("TimeLimit", timeLimit); if (callbackUrl != null) request.AddParameter("CallbackUrl", callbackUrl); return await Execute<RecordingResult>(request); }
/// <summary> /// Get call recordings /// </summary> /// <param name="callSid">An alphanumeric string used to identify each call</param> /// <param name="dateCreated">Lists all recordings created on or after a certain date</param> /// <param name="dateCreatedComparasion">Date created comparasion</param> /// <param name="page">Used to return a particular page withing the list.</param> /// <param name="pageSize">Used to specify the amount of list items to return per page.</param> /// <returns></returns> public async Task<RecordingResult> GetCallRecordings(string callSid, DateTime? dateCreated, ComparisonType? dateCreatedComparasion, int? page, int? pageSize) { Require.Argument("CallSid", callSid); var request = new RestRequest(); request.Resource = RequestUri.CallRecordingsUri; request.AddUrlSegment(RequestUriParams.CallSid, callSid); var dateCreatedParameterName = GetParameterNameWithEquality(dateCreatedComparasion, "DateCreated"); if (dateCreated.HasValue) request.AddParameter(dateCreatedParameterName, dateCreated.Value.ToString("yyyy-MM-dd")); if (page.HasValue) request.AddParameter("Page", page); if (pageSize.HasValue) request.AddParameter("PageSize", pageSize); return await Execute<RecordingResult>(request); }
/// <summary> /// Return list of all conference participants /// </summary> /// <param name="conferenceSid">Conference sid</param> /// <param name="muted">Only list participants that are muted.</param> /// <param name="deafed">Only list participants that are deaf.</param> /// <param name="page">Used to return a particular page withing the list.</param> /// <param name="pageSize">Used to specify the amount of list items to return per page.</param> /// <returns></returns> public async Task<List<Participant>> GetConferenceParticipants(string conferenceSid, bool? muted, bool? deafed, int? page, int? pageSize) { Require.Argument("ConferenceSid", conferenceSid); var request = new RestRequest(); request.Resource = RequestUri.ConferenceParticipantsUri; request.AddUrlSegment(RequestUriParams.ConferenceSid, conferenceSid); if (muted.HasValue) request.AddParameter("Muted", muted); if (deafed.HasValue) request.AddParameter("Deafed", deafed); if (page.HasValue) request.AddParameter("Page", page); if (pageSize.HasValue) request.AddParameter("PageSize", pageSize); return await Execute<List<Participant>>(request); }
/// <summary> /// Delete existing Incoming Phone number from account /// </summary> /// <param name="phoneNumber">Desired phone number to delete from account</param> /// <returns></returns> public async Task<IncomingPhoneNumber> DeleteIncomingPhoneNumber(string phoneNumberSid) { Require.Argument("IncomingPhoneNumberSid", phoneNumberSid); var request = new RestRequest(System.Net.Http.HttpMethod.Delete); request.Resource = RequestUri.DeleteIncomingPhoneNumberUri; request.AddUrlSegment(RequestUriParams.IncomingPhoneNumberSid, phoneNumberSid); return await Execute<IncomingPhoneNumber>(request); }
/// <summary> /// Return list of recording transcriptions /// </summary> /// <param name="recordingSid">An alphanumeric string used for identification of recording.</param> /// <param name="page">Used to return a particular page withing the list.</param> /// <param name="pageSize">Used to specify the amount of list items to return per page.</param> /// <returns></returns> public async Task<TranscriptionResult> GetRecordingTranscriptions(string recordingSid, int? page, int? pageSize) { Require.Argument("RecordingSid", recordingSid); var request = new RestRequest(); request.Resource = RequestUri.RecordingTranscriptionsUri; request.AddUrlSegment("RecordingSid", RequestUriParams.RecordingSid); if (page.HasValue) request.AddParameter("Page", page); if (pageSize.HasValue) request.AddParameter("PageSize", pageSize); return await Execute<TranscriptionResult>(request); }
/// <summary> /// Hangup participant of conference call /// </summary> /// <param name="conferenceSid">Conference sid</param> /// <param name="participant">Specifies the participant to hangup.</param> /// <returns></returns> public async Task<Participant> HangupParticipant(string conferenceSid, Participant participant) { Require.Argument("ConferenceSid", conferenceSid); Require.Argument("CallSid", participant.CallSid); var request = new RestRequest(System.Net.Http.HttpMethod.Delete); request.Resource = RequestUri.ConferenceParticipantActionUri; request.AddUrlSegment(RequestUriParams.ConferenceSid, conferenceSid); request.AddUrlSegment(RequestUriParams.CallSid, participant.CallSid); return await Execute<Participant>(request); }
/// <summary> /// Play audio to participant of conference call /// </summary> /// <param name="conferenceSid">Conference sid</param> /// <param name="participant">Specifies the participant to play audio.</param> /// <param name="url">Url where audio is located</param> /// <returns></returns> public async Task<Participant> PlayAudioToParticipant(string conferenceSid, Participant participant, string url) { Require.Argument("ConferenceSid", conferenceSid); Require.Argument("CallSid", participant.CallSid); Require.Argument("Url", url); var request = new RestRequest(System.Net.Http.HttpMethod.Post); request.Resource = RequestUri.ConferencePlayAudioToParticipantUri; request.AddUrlSegment(RequestUriParams.ConferenceSid, conferenceSid); request.AddUrlSegment(RequestUriParams.CallSid, participant.CallSid); request.AddParameter("AudioUrl", url); return await Execute<Participant>(request); }
/// <summary> /// TelAPI allows you to play an audio file during a call. This is useful for playing hold music, providing IVR prompts, etc. /// </summary> /// <param name="callSid">An alphanumeric string used for identification of calls</param> /// <param name="audioOptions">Audio options</param> /// <returns></returns> public async Task<Call> PlayAudio(string callSid, PlayAudioOptions audioOptions) { Require.Argument("CallSid", callSid); Require.Argument("AudioUrl", audioOptions.AudioUrl); var request = new RestRequest(System.Net.Http.HttpMethod.Post); request.Resource = RequestUri.PlayAudioUri; request.AddUrlSegment(RequestUriParams.CallSid, callSid); CreatePlayAudioOptions(audioOptions, request); return await Execute<Call>(request); }
/// <summary> /// Delete application from TelApi account /// </summary> /// <param name="applicationSid">An alphanumeric string used for identification of the application.</param> /// <returns></returns> public async Task<Application> DeleteApplication(string applicationSid) { Require.Argument("ApplicationSid", applicationSid); var request = new RestRequest(System.Net.Http.HttpMethod.Delete); request.Resource = RequestUri.DeleteApplicationUri; request.AddUrlSegment(RequestUriParams.ApplicationSid, applicationSid); return await Execute<Application>(request); }
/// <summary> /// With TelAPI you can modify the way a callers voice sounds by changing things such as speed and pitch of the audio. /// </summary> /// <param name="callSid">An alphanumeric string used for identification of calls</param> /// <param name="effectOptions">Voice effect options</param> /// <returns></returns> public async Task<Call> VoiceEffects(string callSid, VoiceEffectOptions effectOptions) { Require.Argument("CallSid", callSid); var request = new RestRequest(System.Net.Http.HttpMethod.Post); request.Resource = RequestUri.VoiceEffectsUri; request.AddUrlSegment(RequestUriParams.CallSid, callSid); CreateVoiceEffectsOptions(effectOptions, request); return await Execute<Call>(request); }
/// <summary> /// Individual usage resources are assigned a Sid which can be used to access them. /// In addition to the name and price of the feature used, usage resources also provide the date the usage occurred. /// </summary> /// <param name="sid">Usage sid</param> /// <returns></returns> public async Task<Usage> GetUsage(string sid) { Require.Argument(RequestUriParams.UsageSid, sid); var request = new RestRequest(); request.Resource = RequestUri.GetUsageUri; request.AddUrlSegment(RequestUriParams.UsageSid, sid); return await Execute<Usage>(request); }
/// <summary> /// Hangup up current active call. Make POST request /// </summary> /// <param name="callSid">An alphanumeric string used for identification of calls.</param> /// <returns></returns> public async Task<Call> HangupCall(string callSid) { Require.Argument("CallSid", callSid); var request = new RestRequest(System.Net.Http.HttpMethod.Post); request.Resource = RequestUri.HangupCallUri; request.AddUrlSegment(RequestUriParams.CallSid, callSid); request.AddParameter("Status", HangupCallStatus.Completed.ToString().ToLower()); return await Execute<Call>(request); }
/// <summary> /// Participants of a conference are identified by the CallSid created when they dial into the conference. /// </summary> /// <param name="conferenceSid"></param> /// <param name="callSid">The CallSid identifying this participant.</param> /// <returns></returns> public async Task<Participant> GetConferenceParticipant(string conferenceSid, string callSid) { Require.Argument("ConferenceSid", conferenceSid); Require.Argument("CallSid", callSid); var request = new RestRequest(); request.Resource = RequestUri.ConferenceParticipantActionUri; request.AddUrlSegment(RequestUriParams.ConferenceSid, conferenceSid); request.AddUrlSegment(RequestUriParams.CallSid, callSid); return await Execute<Participant>(request); }