Skip to content
Browse files

Twilio.WinRT

Initial Checkin
  • Loading branch information...
1 parent 4aaaae3 commit a65e9ae87c58a3e1b49ea25c65db96d80000d09b @devinrader devinrader committed May 10, 2013
Showing with 6,162 additions and 0 deletions.
  1. +19 −0 Twilio.WinRT.nuspec
  2. +20 −0 build.WinRT.bat
  3. +38 −0 src/Twilio.2012.sln
  4. +132 −0 src/Twilio.WinRT/Accounts.cs
  5. +164 −0 src/Twilio.WinRT/Applications.cs
  6. +63 −0 src/Twilio.WinRT/AuthorizedConnectApps.cs
  7. +96 −0 src/Twilio.WinRT/AvailablePhoneNumbers.cs
  8. +223 −0 src/Twilio.WinRT/Calls.cs
  9. +216 −0 src/Twilio.WinRT/Conference.cs
  10. +105 −0 src/Twilio.WinRT/ConnectApps.cs
  11. +160 −0 src/Twilio.WinRT/Core.cs
  12. +177 −0 src/Twilio.WinRT/IncomingPhoneNumbers.cs
  13. +45 −0 src/Twilio.WinRT/Model/Account.cs
  14. +71 −0 src/Twilio.WinRT/Model/AccountResult.cs
  15. +26 −0 src/Twilio.WinRT/Model/AccountStatus.cs
  16. +93 −0 src/Twilio.WinRT/Model/Application.cs
  17. +59 −0 src/Twilio.WinRT/Model/ApplicationOptions.cs
  18. +68 −0 src/Twilio.WinRT/Model/ApplicationResult.cs
  19. +58 −0 src/Twilio.WinRT/Model/AuthorizedConnectApp.cs
  20. +59 −0 src/Twilio.WinRT/Model/AuthorizedConnectAppResult.cs
  21. +57 −0 src/Twilio.WinRT/Model/AvailablePhoneNumber.cs
  22. +47 −0 src/Twilio.WinRT/Model/AvailablePhoneNumberListRequest.cs
  23. +60 −0 src/Twilio.WinRT/Model/AvailablePhoneNumberResult.cs
  24. +88 −0 src/Twilio.WinRT/Model/Call.cs
  25. +51 −0 src/Twilio.WinRT/Model/CallListRequest.cs
  26. +63 −0 src/Twilio.WinRT/Model/CallOptions.cs
  27. +70 −0 src/Twilio.WinRT/Model/CallResult.cs
  28. +23 −0 src/Twilio.WinRT/Model/ComparisonType.cs
  29. +45 −0 src/Twilio.WinRT/Model/Conference.cs
  30. +43 −0 src/Twilio.WinRT/Model/ConferenceListRequest.cs
  31. +61 −0 src/Twilio.WinRT/Model/ConferenceResult.cs
  32. +70 −0 src/Twilio.WinRT/Model/ConnectApp.cs
  33. +61 −0 src/Twilio.WinRT/Model/ConnectAppResult.cs
  34. +22 −0 src/Twilio.WinRT/Model/DeleteStatus.cs
  35. +22 −0 src/Twilio.WinRT/Model/DequeueStatus.cs
  36. +19 −0 src/Twilio.WinRT/Model/HangupStyle.cs
  37. +12 −0 src/Twilio.WinRT/Model/IDirectlyAddressable.cs
  38. +101 −0 src/Twilio.WinRT/Model/IncomingPhoneNumber.cs
  39. +68 −0 src/Twilio.WinRT/Model/IncomingPhoneNumberResult.cs
  40. +93 −0 src/Twilio.WinRT/Model/Notification.cs
  41. +61 −0 src/Twilio.WinRT/Model/NotificationResult.cs
  42. +45 −0 src/Twilio.WinRT/Model/OutgoingCallerId.cs
  43. +38 −0 src/Twilio.WinRT/Model/OutgoingCallerIdOptions.cs
  44. +68 −0 src/Twilio.WinRT/Model/OutgoingCallerIdResult.cs
  45. +53 −0 src/Twilio.WinRT/Model/Participant.cs
  46. +61 −0 src/Twilio.WinRT/Model/ParticipantResult.cs
  47. +18 −0 src/Twilio.WinRT/Model/Permission.cs
  48. +79 −0 src/Twilio.WinRT/Model/PhoneNumberOptions.cs
  49. +54 −0 src/Twilio.WinRT/Model/Queue.cs
  50. +40 −0 src/Twilio.WinRT/Model/QueueMember.cs
  51. +60 −0 src/Twilio.WinRT/Model/QueueMemberResult.cs
  52. +61 −0 src/Twilio.WinRT/Model/QueueResult.cs
  53. +48 −0 src/Twilio.WinRT/Model/Recording.cs
  54. +71 −0 src/Twilio.WinRT/Model/RecordingResult.cs
  55. +27 −0 src/Twilio.WinRT/Model/RestException.cs
  56. +57 −0 src/Twilio.WinRT/Model/Sandbox.cs
  57. +69 −0 src/Twilio.WinRT/Model/SmsMessage.cs
  58. +68 −0 src/Twilio.WinRT/Model/SmsMessageResult.cs
  59. +68 −0 src/Twilio.WinRT/Model/SmsShortCode.cs
  60. +61 −0 src/Twilio.WinRT/Model/SmsShortCodeResult.cs
  61. +57 −0 src/Twilio.WinRT/Model/Transcription.cs
  62. +60 −0 src/Twilio.WinRT/Model/TranscriptionResult.cs
  63. +19 −0 src/Twilio.WinRT/Model/TwilioBase.cs
  64. +52 −0 src/Twilio.WinRT/Model/TwilioListBase.cs
  65. +76 −0 src/Twilio.WinRT/Model/UsageRecord.cs
  66. +61 −0 src/Twilio.WinRT/Model/UsageResult.cs
  67. +90 −0 src/Twilio.WinRT/Model/UsageTrigger.cs
  68. +43 −0 src/Twilio.WinRT/Model/UsageTriggerOptions.cs
  69. +61 −0 src/Twilio.WinRT/Model/UsageTriggerResult.cs
  70. +70 −0 src/Twilio.WinRT/Model/ValidationRequest.cs
  71. +90 −0 src/Twilio.WinRT/Notifications.cs
  72. +171 −0 src/Twilio.WinRT/OutgoingCallerIds.cs
  73. +21 −0 src/Twilio.WinRT/Properties/AssemblyInfo.cs
  74. +288 −0 src/Twilio.WinRT/Queues.cs
  75. +109 −0 src/Twilio.WinRT/Recordings.cs
  76. +14 −0 src/Twilio.WinRT/SharedAssemblyInfo.cs
  77. +195 −0 src/Twilio.WinRT/Sms.cs
  78. +107 −0 src/Twilio.WinRT/Transcriptions.cs
  79. +203 −0 src/Twilio.WinRT/Twilio.WinRT.csproj
  80. +17 −0 src/Twilio.WinRT/UnderscoreMappingResolver.cs
  81. +278 −0 src/Twilio.WinRT/Usage.cs
  82. +4 −0 src/Twilio.WinRT/packages.config
  83. +1 −0 src/packages/repositories.config
View
19 Twilio.WinRT.nuspec
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8"?>
+<package>
+ <metadata>
+ <id>Twilio.WinRT</id>
+ <version>0.0.1-alpha</version>
+ <authors>Twilio</authors>
+ <description>Twilio REST API helper library for Windows Store Apps</description>
+ <language>en-US</language>
+ <projectUrl>http://github.com/twilio/twilio-csharp</projectUrl>
+ <iconUrl>http://www.twilio.com/packages/company/img/logos_downloadable_round.png</iconUrl>
+ <licenseUrl>https://github.com/twilio/twilio-csharp/blob/master/LICENSE.txt</licenseUrl>
+ <tags>REST SMS voice telephony phone twilio twiml Windows8 WinRT WinJS</tags>
+ <dependencies>
+ <dependency id="RestRT" />
+ </dependencies>
+ <releaseNotes>
+ </releaseNotes>
+ </metadata>
+</package>
View
20 build.WinRT.bat
@@ -0,0 +1,20 @@
+REM tools\nuget.exe update -self
+
+C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe /nologo /maxcpucount /nr:true /verbosity:minimal /p:BuildInParallel=true /p:Configuration=Release /p:RestorePackages=true /t:Rebuild src/Twilio.2012.sln
+
+rd download /s /q
+
+if not exist download mkdir download
+if not exist download\package mkdir download\package
+if not exist download\package\twilio.winrt mkdir download\package\twilio.winrt
+
+if not exist download\package\twilio.winrt\lib mkdir download\package\twilio.winrt\lib
+if not exist download\package\twilio.winrt\lib\windows8 mkdir download\package\twilio.winrt\lib\windows8
+
+copy LICENSE.txt download
+
+copy src\Twilio.WinRT\bin\Release\Twilio.winmd download\package\twilio.winrt\lib\windows8\
+copy src\Twilio.WinRT\bin\Release\Twilio.pri download\package\twilio.winrt\lib\windows8\
+
+
+tools\nuget.exe pack Twilio.WinRT.nuspec -BasePath download\package\twilio.winrt -o download
View
38 src/Twilio.2012.sln
@@ -0,0 +1,38 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Twilio.WinRT", "Twilio.WinRT\Twilio.WinRT.csproj", "{B73FB286-30FD-48A5-B022-CC5FC5D6F27F}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|ARM = Debug|ARM
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|ARM = Release|ARM
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {B73FB286-30FD-48A5-B022-CC5FC5D6F27F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {B73FB286-30FD-48A5-B022-CC5FC5D6F27F}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {B73FB286-30FD-48A5-B022-CC5FC5D6F27F}.Debug|ARM.ActiveCfg = Debug|ARM
+ {B73FB286-30FD-48A5-B022-CC5FC5D6F27F}.Debug|ARM.Build.0 = Debug|ARM
+ {B73FB286-30FD-48A5-B022-CC5FC5D6F27F}.Debug|x64.ActiveCfg = Debug|x64
+ {B73FB286-30FD-48A5-B022-CC5FC5D6F27F}.Debug|x64.Build.0 = Debug|x64
+ {B73FB286-30FD-48A5-B022-CC5FC5D6F27F}.Debug|x86.ActiveCfg = Debug|x86
+ {B73FB286-30FD-48A5-B022-CC5FC5D6F27F}.Debug|x86.Build.0 = Debug|x86
+ {B73FB286-30FD-48A5-B022-CC5FC5D6F27F}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {B73FB286-30FD-48A5-B022-CC5FC5D6F27F}.Release|Any CPU.Build.0 = Release|Any CPU
+ {B73FB286-30FD-48A5-B022-CC5FC5D6F27F}.Release|ARM.ActiveCfg = Release|ARM
+ {B73FB286-30FD-48A5-B022-CC5FC5D6F27F}.Release|ARM.Build.0 = Release|ARM
+ {B73FB286-30FD-48A5-B022-CC5FC5D6F27F}.Release|x64.ActiveCfg = Release|x64
+ {B73FB286-30FD-48A5-B022-CC5FC5D6F27F}.Release|x64.Build.0 = Release|x64
+ {B73FB286-30FD-48A5-B022-CC5FC5D6F27F}.Release|x86.ActiveCfg = Release|x86
+ {B73FB286-30FD-48A5-B022-CC5FC5D6F27F}.Release|x86.Build.0 = Release|x86
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
View
132 src/Twilio.WinRT/Accounts.cs
@@ -0,0 +1,132 @@
+using System;
+using RestRT;
+using Windows.Foundation;
+using System.Runtime.InteropServices.WindowsRuntime;
+using System.Threading.Tasks;
+
+namespace Twilio
+{
+ public sealed partial class TwilioRestClient
+ {
+ /// <summary>
+ /// Retrieve the account details for the currently authenticated account. Makes a GET request to an Account Instance resource.
+ /// </summary>
+ public IAsyncOperation<Account> GetAccountAsync()
+ {
+ return (IAsyncOperation<Account>)AsyncInfo.Run((System.Threading.CancellationToken ct) => GetAccountAsyncInternal());
+ }
+ private async Task<Account> GetAccountAsyncInternal()
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}.json";
+
+ var result = await ExecuteAsync(request, typeof(Account));
+ return (Account)result;
+ }
+
+ /// <summary>
+ /// Retrieve the account details for a subaccount. Makes a GET request to an Account Instance resource.
+ /// </summary>
+ /// <param name="accountSid">The Sid of the subaccount to retrieve</param>
+ public IAsyncOperation<Account> GetAccountAsync(string accountSid)
+ {
+ return (IAsyncOperation<Account>)AsyncInfo.Run((System.Threading.CancellationToken ct) => GetAccountAsyncInternal(accountSid));
+ }
+ private async Task<Account> GetAccountAsyncInternal(string accountSid)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}.json";
+
+ request.AddUrlSegment("AccountSid", accountSid);
+
+ var result = await ExecuteAsync(request, typeof(Account));
+ return (Account)result;
+ }
+
+ /// <summary>
+ /// List all subaccounts created for the authenticated account. Makes a GET request to the Account List resource.
+ /// </summary>
+ public IAsyncOperation<AccountResult> ListSubAccountsAsync()
+ {
+ return (IAsyncOperation<AccountResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListSubAccountsAsyncInternal());
+ }
+ private async Task<AccountResult> ListSubAccountsAsyncInternal()
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts.json";
+
+ var result = await ExecuteAsync(request, typeof(AccountResult));
+ return (AccountResult)result;
+ }
+
+ /// <summary>
+ /// Creates a new subaccount under the authenticated account. Makes a POST request to the Account List resource.
+ /// </summary>
+ /// <param name="friendlyName">Name associated with this account for your own reference (can be empty string)</param>
+ public IAsyncOperation<Account> CreateSubAccountAsync(string friendlyName)
+ {
+ return (IAsyncOperation<Account>)AsyncInfo.Run((System.Threading.CancellationToken ct) => CreateSubAccountAsyncInternal(friendlyName));
+ }
+ private async Task<Account> CreateSubAccountAsyncInternal(string friendlyName)
+ {
+ var request = new RestRequest();
+ request.Method = Method.POST;
+ request.Resource = "Accounts.json";
+
+ request.AddParameter("FriendlyName", friendlyName);
+
+ var result = await ExecuteAsync(request, typeof(Account));
+ return (Account)result;
+ }
+
+ /// <summary>
+ /// Changes the status of a subaccount. You must be authenticated as the master account to call this method on a subaccount.
+ /// WARNING: When closing an account, Twilio will release all phone numbers assigned to it and shut it down completely.
+ /// You can't ever use a closed account to make and receive phone calls or send and receive SMS messages.
+ /// It's closed, gone, kaput. It will still appear in your accounts list, and you will still have access to historical
+ /// data for that subaccount, but you cannot reopen a closed account.
+ /// </summary>
+ /// <param name="subAccountSid">The subaccount to change the status on</param>
+ /// <param name="status">The status to change the subaccount to</param>
+ public IAsyncOperation<Account> ChangeSubAccountStatusAsync(string subAccountSid, AccountStatus status)
+ {
+ return (IAsyncOperation<Account>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ChangeSubAccountStatusAsyncInternal(subAccountSid, status));
+ }
+ private async Task<Account> ChangeSubAccountStatusAsyncInternal(string subAccountSid, AccountStatus status)
+ {
+ if (subAccountSid == AccountSid)
+ {
+ throw new InvalidOperationException("Subaccount status can only be changed when authenticated from the master account.");
+ }
+
+ var request = new RestRequest();
+ request.Method = Method.POST;
+ request.Resource = "Accounts/{AccountSid}.json";
+
+ request.AddParameter("Status", status.ToString().ToLower());
+ request.AddUrlSegment("AccountSid", subAccountSid);
+
+ var result = await ExecuteAsync(request, typeof(Account));
+ return (Account)result;
+ }
+
+ /// <summary>
+ /// Update the friendly name associated with the currently authenticated account. Makes a POST request to an Account Instance resource.
+ /// </summary>
+ /// <param name="friendlyName">Name to use when updating</param>
+ public IAsyncOperation<Account> UpdateAccountNameAsync(string friendlyName)
+ {
+ return (IAsyncOperation<Account>)AsyncInfo.Run((System.Threading.CancellationToken ct) => UpdateAccountNameAsyncInternal(friendlyName));
+ }
+ private async Task<Account> UpdateAccountNameAsyncInternal(string friendlyName)
+ {
+ var request = new RestRequest();
+ request.Method = Method.POST;
+ request.Resource = "Accounts/{AccountSid}.json";
+ request.AddParameter("FriendlyName", friendlyName);
+
+ var result = await ExecuteAsync(request, typeof(Account));
+ return (Account)result;
+ }
+ }
+}
View
164 src/Twilio.WinRT/Applications.cs
@@ -0,0 +1,164 @@
+using System;
+using RestRT;
+using RestRT.Extensions;
+using RestRT.Validation;
+using System.Threading.Tasks;
+using Windows.Foundation;
+using System.Runtime.InteropServices.WindowsRuntime;
+
+namespace Twilio
+{
+ public sealed partial class TwilioRestClient
+ {
+ /// <summary>
+ /// Retrieve the details for an application instance. Makes a GET request to an Application Instance resource.
+ /// </summary>
+ /// <param name="applicationSid">The Sid of the application to retrieve</param>
+ public IAsyncOperation<Application> GetApplicationAsync(string applicationSid)
+ {
+ return (IAsyncOperation<Application>)AsyncInfo.Run((System.Threading.CancellationToken ct) => GetApplicationAsyncInternal(applicationSid));
+ }
+ private async Task<Application> GetApplicationAsyncInternal(string applicationSid)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/Applications/{ApplicationSid}.json";
+
+ request.AddUrlSegment("ApplicationSid", applicationSid);
+
+ var result = await ExecuteAsync(request, typeof(Application));
+ return (Application)result;
+ }
+
+ /// <summary>
+ /// List applications on current account
+ /// </summary>
+ public IAsyncOperation<ApplicationResult> ListApplicationsAsync()
+ {
+ return (IAsyncOperation<ApplicationResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListApplicationsAsyncInternal(null, null, null));
+ }
+
+ /// <summary>
+ /// List applications on current account with filters
+ /// </summary>
+ /// <param name="friendlyName">Optional friendly name to match</param>
+ /// <param name="pageNumber">Page number to start retrieving results from</param>
+ /// <param name="count">How many results to return</param>
+ public IAsyncOperation<ApplicationResult> ListApplicationsAsync(string friendlyName, int? pageNumber, int? count)
+ {
+ return (IAsyncOperation<ApplicationResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListApplicationsAsyncInternal(friendlyName, pageNumber, count));
+ }
+ private async Task<ApplicationResult> ListApplicationsAsyncInternal(string friendlyName, int? pageNumber, int? count)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/Applications.json";
+
+ if (friendlyName.HasValue()) request.AddParameter("FriendlyName", friendlyName);
+ if (pageNumber.HasValue) request.AddParameter("Page", pageNumber.Value);
+ if (count.HasValue) request.AddParameter("PageSize", count.Value);
+
+ //return Execute<ApplicationResult>(request);
+ var result = await ExecuteAsync(request, typeof(ApplicationResult));
+ return (ApplicationResult)result;
+
+ }
+
+ /// <summary>
+ /// Create a new application
+ /// </summary>
+ /// <param name="friendlyName">The friendly name to name the application</param>
+ /// <param name="options">Optional parameters to use when purchasing number</param>
+ public IAsyncOperation<Application> AddApplicationAsync(string friendlyName, ApplicationOptions options)
+ {
+ return (IAsyncOperation<Application>)AsyncInfo.Run((System.Threading.CancellationToken ct) => AddApplicationAsyncInternal(friendlyName, options));
+ }
+ private async Task<Application> AddApplicationAsyncInternal(string friendlyName, ApplicationOptions options)
+ {
+ var request = new RestRequest();
+ request.Method = Method.POST;
+ request.Resource = "Accounts/{AccountSid}/Applications.json";
+
+ Require.Argument("FriendlyName", friendlyName);
+ Validate.IsValidLength(friendlyName, 64);
+ request.AddParameter("FriendlyName", friendlyName);
+
+ // some check for null. in those cases an empty string is a valid value (to remove a URL assignment)
+ if (options != null)
+ {
+ if (options.VoiceUrl != null) request.AddParameter("VoiceUrl", options.VoiceUrl);
+ if (options.VoiceMethod.HasValue()) request.AddParameter("VoiceMethod", options.VoiceMethod.ToString());
+ if (options.VoiceFallbackUrl != null) request.AddParameter("VoiceFallbackUrl", options.VoiceFallbackUrl);
+ if (options.VoiceFallbackMethod.HasValue()) request.AddParameter("VoiceFallbackMethod", options.VoiceFallbackMethod.ToString());
+ if (options.VoiceCallerIdLookup.HasValue) request.AddParameter("VoiceCallerIdLookup", options.VoiceCallerIdLookup.Value);
+ if (options.StatusCallback.HasValue()) request.AddParameter("StatusCallback", options.StatusCallback);
+ if (options.StatusCallbackMethod.HasValue()) request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod.ToString());
+ if (options.SmsUrl != null) request.AddParameter("SmsUrl", options.SmsUrl);
+ if (options.SmsMethod.HasValue()) request.AddParameter("SmsMethod", options.SmsMethod.ToString());
+ if (options.SmsFallbackUrl != null) request.AddParameter("SmsFallbackUrl", options.SmsFallbackUrl);
+ if (options.SmsFallbackMethod.HasValue()) request.AddParameter("SmsFallbackMethod", options.SmsFallbackMethod.ToString());
+ }
+
+ var result = await ExecuteAsync(request, typeof(Application));
+ return (Application)result;
+ }
+
+ /// <summary>
+ /// Tries to update the application's properties, and returns the updated resource representation if successful.
+ /// </summary>
+ /// <param name="applicationSid">The Sid of the application to update</param>
+ /// <param name="friendlyName">The friendly name to rename the application to (optional, null to leave as-is)</param>
+ /// <param name="options">Which settings to update. Only properties with values set will be updated.</param>
+ public IAsyncOperation<Application> UpdateApplicationAsync(string applicationSid, string friendlyName, ApplicationOptions options)
+ {
+ return (IAsyncOperation<Application>)AsyncInfo.Run((System.Threading.CancellationToken ct) => UpdateApplicationAsyncInternal(applicationSid, friendlyName, options));
+ }
+ private async Task<Application> UpdateApplicationAsyncInternal(string applicationSid, string friendlyName, ApplicationOptions options)
+ {
+ Require.Argument("ApplicationSid", applicationSid);
+
+ var request = new RestRequest();
+ request.Method = Method.POST;
+ request.Resource = "Accounts/{AccountSid}/Applications/{ApplicationSid}.json";
+ request.AddUrlSegment("ApplicationSid", applicationSid);
+
+ if (friendlyName.HasValue()) request.AddParameter("FriendlyName", friendlyName);
+ if (options != null)
+ {
+ if (options.VoiceUrl != null) request.AddParameter("VoiceUrl", options.VoiceUrl);
+ if (options.VoiceMethod.HasValue()) request.AddParameter("VoiceMethod", options.VoiceMethod.ToString());
+ if (options.VoiceFallbackUrl != null) request.AddParameter("VoiceFallbackUrl", options.VoiceFallbackUrl);
+ if (options.VoiceFallbackMethod.HasValue()) request.AddParameter("VoiceFallbackMethod", options.VoiceFallbackMethod.ToString());
+ if (options.VoiceCallerIdLookup.HasValue) request.AddParameter("VoiceCallerIdLookup", options.VoiceCallerIdLookup.Value);
+ if (options.StatusCallback.HasValue()) request.AddParameter("StatusCallback", options.StatusCallback);
+ if (options.StatusCallbackMethod.HasValue()) request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod.ToString());
+ if (options.SmsUrl != null) request.AddParameter("SmsUrl", options.SmsUrl);
+ if (options.SmsMethod.HasValue()) request.AddParameter("SmsMethod", options.SmsMethod.ToString());
+ if (options.SmsFallbackUrl != null) request.AddParameter("SmsFallbackUrl", options.SmsFallbackUrl);
+ if (options.SmsFallbackMethod.HasValue()) request.AddParameter("SmsFallbackMethod", options.SmsFallbackMethod.ToString());
+ }
+
+ var result = await ExecuteAsync(request, typeof(Application));
+ return (Application)result;
+ }
+
+ /// <summary>
+ /// Delete this application. If this application's sid is assigned to any IncomingPhoneNumber resources as a VoiceApplicationSid or SmsApplicationSid it will be removed.
+ /// </summary>
+ /// <param name="applicationSid">The Sid of the number to remove</param>
+ public IAsyncOperation<DeleteStatus> DeleteApplicationAsync(string applicationSid)
+ {
+ return (IAsyncOperation<DeleteStatus>)AsyncInfo.Run((System.Threading.CancellationToken ct) => DeleteApplicationAsyncInternal(applicationSid));
+ }
+ private async Task<DeleteStatus> DeleteApplicationAsyncInternal(string applicationSid)
+ {
+ Require.Argument("ApplicationSid", applicationSid);
+ var request = new RestRequest();
+ request.Method = Method.DELETE;
+ request.Resource = "Accounts/{AccountSid}/Applications/{ApplicationSid}.json";
+
+ request.AddUrlSegment("ApplicationSid", applicationSid);
+
+ var response = (RestResponse)await ExecuteAsync(request);
+ return response.StatusCode == (int)System.Net.HttpStatusCode.NoContent ? DeleteStatus.Success : DeleteStatus.Failed;
+ }
+ }
+}
View
63 src/Twilio.WinRT/AuthorizedConnectApps.cs
@@ -0,0 +1,63 @@
+using RestRT;
+using RestRT.Extensions;
+using RestRT.Validation;
+using System;
+using System.Runtime.InteropServices.WindowsRuntime;
+using System.Threading.Tasks;
+using Windows.Foundation;
+
+namespace Twilio
+{
+ public partial class TwilioRestClient
+ {
+ /// <summary>
+ /// Retrieve the details for an AuthorizedConnectApp instance. Makes a GET request to an AuthorizedConnectApp Instance resource.
+ /// </summary>
+ /// <param name="authorizedConnectAppSid">The Sid of the AuthorizedConnectApp to retrieve</param>
+ public IAsyncOperation<AuthorizedConnectApp> GetAuthorizedConnectAppAsync(string authorizedConnectAppSid)
+ {
+ return (IAsyncOperation<AuthorizedConnectApp>)AsyncInfo.Run((System.Threading.CancellationToken ct) => GetAuthorizedConnectAppAsyncInternal(authorizedConnectAppSid));
+ }
+ private async Task<AuthorizedConnectApp> GetAuthorizedConnectAppAsyncInternal(string authorizedConnectAppSid)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/AuthorizedConnectApps/{AuthorizedConnectAppSid}.json";
+
+ request.AddUrlSegment("AuthorizedConnectAppSid", authorizedConnectAppSid);
+
+ var result = await ExecuteAsync(request, typeof(AuthorizedConnectApp));
+ return (AuthorizedConnectApp)result;
+
+ }
+
+ /// <summary>
+ /// List AuthorizedConnectApps on current account
+ /// </summary>
+ public IAsyncOperation<AuthorizedConnectAppResult> ListAuthorizedConnectAppsAsync()
+ {
+ return (IAsyncOperation<AuthorizedConnectAppResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListAuthorizedConnectAppsAsyncInternal(null, null));
+ }
+
+ /// <summary>
+ /// List AuthorizedConnectApps on current account with filters
+ /// </summary>
+ /// <param name="pageNumber">Page number to start retrieving results from</param>
+ /// <param name="count">How many results to return</param>
+ public IAsyncOperation<AuthorizedConnectAppResult> ListAuthorizedConnectAppsAsync(int? pageNumber, int? count)
+ {
+ return (IAsyncOperation<AuthorizedConnectAppResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListAuthorizedConnectAppsAsyncInternal(pageNumber, count));
+ }
+ private async Task<AuthorizedConnectAppResult> ListAuthorizedConnectAppsAsyncInternal(int? pageNumber, int? count)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/AuthorizedConnectApps.json";
+
+ if (pageNumber.HasValue) request.AddParameter("Page", pageNumber.Value);
+ if (count.HasValue) request.AddParameter("PageSize", count.Value);
+
+ var result = await ExecuteAsync(request, typeof(AuthorizedConnectAppResult));
+ return (AuthorizedConnectAppResult)result;
+
+ }
+ }
+}
View
96 src/Twilio.WinRT/AvailablePhoneNumbers.cs
@@ -0,0 +1,96 @@
+using RestRT;
+using RestRT.Extensions;
+using RestRT.Validation;
+using System;
+using System.Runtime.InteropServices.WindowsRuntime;
+using System.Threading.Tasks;
+using Windows.Foundation;
+
+namespace Twilio
+{
+ public partial class TwilioRestClient
+ {
+ /// <summary>
+ /// Search available local phone numbers. Makes a GET request to the AvailablePhoneNumber List resource.
+ /// </summary>
+ /// <param name="isoCountryCode">Two-character ISO country code (US or CA)</param>
+ /// <param name="options">Search filter options. Only properties with values set will be used.</param>
+ public IAsyncOperation<AvailablePhoneNumberResult> ListAvailableLocalPhoneNumbersAsync(string isoCountryCode, AvailablePhoneNumberListRequest options)
+ {
+ return (IAsyncOperation<AvailablePhoneNumberResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListAvailableLocalPhoneNumbersAsyncInternal(isoCountryCode, options));
+ }
+ private async Task<AvailablePhoneNumberResult> ListAvailableLocalPhoneNumbersAsyncInternal(string isoCountryCode, AvailablePhoneNumberListRequest options)
+ {
+ Require.Argument("isoCountryCode", isoCountryCode);
+
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/AvailablePhoneNumbers/{IsoCountryCode}/Local.json";
+ request.AddUrlSegment("IsoCountryCode", isoCountryCode);
+
+ AddNumberSearchParameters(options, request);
+
+ var result = await ExecuteAsync(request, typeof(AvailablePhoneNumberResult));
+ return (AvailablePhoneNumberResult)result;
+
+ }
+
+ /// <summary>
+ /// Search available toll-free phone numbers. Makes a GET request to the AvailablePhoneNumber List resource.
+ /// </summary>
+ /// <param name="isoCountryCode">Two-character ISO country code (US or CA)</param>
+ public IAsyncOperation<AvailablePhoneNumberResult> ListAvailableTollFreePhoneNumbersAsync(string isoCountryCode)
+ {
+ return (IAsyncOperation<AvailablePhoneNumberResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListAvailableTollFreePhoneNumbersAsyncInternal(isoCountryCode));
+ }
+ private async Task<AvailablePhoneNumberResult> ListAvailableTollFreePhoneNumbersAsyncInternal(string isoCountryCode)
+ {
+ Require.Argument("isoCountryCode", isoCountryCode);
+
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/AvailablePhoneNumbers/{IsoCountryCode}/TollFree.json";
+ request.AddUrlSegment("IsoCountryCode", isoCountryCode);
+
+ var result = await ExecuteAsync(request, typeof(AvailablePhoneNumberResult));
+ return (AvailablePhoneNumberResult)result;
+
+ }
+
+ /// <summary>
+ /// Search available toll-free phone numbers. Makes a GET request to the AvailablePhoneNumber List resource.
+ /// </summary>
+ /// <param name="isoCountryCode">Two-character ISO country code (US or CA)</param>
+ /// <param name="contains">Value to use when filtering search. Accepts numbers or characters.</param>
+ public IAsyncOperation<AvailablePhoneNumberResult> ListAvailableTollFreePhoneNumbersAsync(string isoCountryCode, string contains)
+ {
+ return (IAsyncOperation<AvailablePhoneNumberResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListAvailableTollFreePhoneNumbersAsyncInternal(isoCountryCode, contains));
+ }
+ private async Task<AvailablePhoneNumberResult> ListAvailableTollFreePhoneNumbersAsyncInternal(string isoCountryCode, string contains)
+ {
+ Require.Argument("isoCountryCode", isoCountryCode);
+ Require.Argument("contains", contains);
+
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/AvailablePhoneNumbers/{IsoCountryCode}/TollFree.json";
+ request.AddUrlSegment("IsoCountryCode", isoCountryCode);
+
+ request.AddParameter("Contains", contains);
+
+ var result = await ExecuteAsync(request, typeof(AvailablePhoneNumberResult));
+ return (AvailablePhoneNumberResult)result;
+
+ }
+
+ private void AddNumberSearchParameters(AvailablePhoneNumberListRequest options, RestRequest request)
+ {
+ if (options.AreaCode.HasValue()) request.AddParameter("AreaCode", options.AreaCode);
+ if (options.Contains.HasValue()) request.AddParameter("Contains", options.Contains);
+ if (options.Distance.HasValue) request.AddParameter("Distance", options.Distance);
+ if (options.InLata.HasValue()) request.AddParameter("InLata", options.InLata);
+ if (options.InPostalCode.HasValue()) request.AddParameter("InPostalCode", options.InPostalCode);
+ if (options.InRateCenter.HasValue()) request.AddParameter("InRateCenter", options.InRateCenter);
+ if (options.InRegion.HasValue()) request.AddParameter("InRegion", options.InRegion);
+ if (options.NearLatLong.HasValue()) request.AddParameter("NearLatLong", options.NearLatLong);
+ if (options.NearNumber.HasValue()) request.AddParameter("NearNumber", options.NearNumber);
+ }
+ }
+}
View
223 src/Twilio.WinRT/Calls.cs
@@ -0,0 +1,223 @@
+using RestRT;
+using RestRT.Extensions;
+using RestRT.Validation;
+using System;
+using System.Runtime.InteropServices.WindowsRuntime;
+using System.Threading.Tasks;
+using Windows.Foundation;
+
+namespace Twilio
+{
+ public partial class TwilioRestClient
+ {
+ /// <summary>
+ /// Returns a paged list of phone calls made to and from the account.
+ /// Sorted by DateUpdated with most-recent calls first.
+ /// Makes a GET request to the Calls List resource.
+ /// </summary>
+ public IAsyncOperation<CallResult> ListCallsAsync()
+ {
+ return (IAsyncOperation<CallResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListCallsAsyncInternal());
+ }
+ private async Task<CallResult> ListCallsAsyncInternal()
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/Calls.json";
+
+ var result = await ExecuteAsync(request, typeof(CallResult));
+ return (CallResult)result;
+ }
+
+ /// <summary>
+ /// Returns a paged list of phone calls made to and from the account.
+ /// Sorted by DateUpdated with most-recent calls first.
+ /// Makes a GET request to the Calls List resource.
+ /// </summary>
+ /// <param name="options">List filter options. If an property is set the list will be filtered by that value.</param>
+ public IAsyncOperation<CallResult> ListCallsAsync(CallListRequest options)
+ {
+ return (IAsyncOperation<CallResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListCallsAsyncInternal(options));
+ }
+ private async Task<CallResult> ListCallsAsyncInternal(CallListRequest options)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/Calls.json";
+
+ AddCallListOptions(options, request);
+
+ var result = await ExecuteAsync(request, typeof(CallResult));
+ return (CallResult)result;
+ }
+
+ /// <summary>
+ /// Returns the single Call resource identified by {CallSid}
+ /// Makes a GET request to a Call Instance resource.
+ /// </summary>
+ /// <param name="callSid">The Sid of the Call resource to retrieve</param>
+ public IAsyncOperation<Call> GetCallAsync(string callSid)
+ {
+ return (IAsyncOperation<Call>)AsyncInfo.Run((System.Threading.CancellationToken ct) => GetCallAsyncInternal(callSid));
+ }
+ private async Task<Call> GetCallAsyncInternal(string callSid)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/Calls/{CallSid}.json";
+
+ request.AddParameter("CallSid", callSid, ParameterType.UrlSegment);
+
+ var result = await ExecuteAsync(request, typeof(Call));
+ return (Call)result;
+
+ }
+
+ /// <summary>
+ /// Initiates a new phone call. Makes a POST request to the Calls List resource.
+ /// </summary>
+ /// <param name="from">The phone number to use as the caller id. Format with a '+' and country code e.g., +16175551212 (E.164 format). Must be a Twilio number or a valid outgoing caller id for your account.</param>
+ /// <param name="to">The number to call formatted with a '+' and country code e.g., +16175551212 (E.164 format). Twilio will also accept unformatted US numbers e.g., (415) 555-1212, 415-555-1212.</param>
+ /// <param name="url">The fully qualified URL that should be consulted when the call connects. Just like when you set a URL for your inbound calls. URL should return TwiML.</param>
+ public IAsyncOperation<Call> InitiateOutboundCallAsync(string from, string to, string url)
+ {
+ return InitiateOutboundCallAsync(from, to, url, string.Empty);
+ }
+
+ /// <summary>
+ /// Initiates a new phone call. Makes a POST request to the Calls List resource.
+ /// </summary>
+ /// <param name="from">The phone number to use as the caller id. Format with a '+' and country code e.g., +16175551212 (E.164 format). Must be a Twilio number or a valid outgoing caller id for your account.</param>
+ /// <param name="to">The number to call formatted with a '+' and country code e.g., +16175551212 (E.164 format). Twilio will also accept unformatted US numbers e.g., (415) 555-1212, 415-555-1212.</param>
+ /// <param name="url">The fully qualified URL that should be consulted when the call connects. Just like when you set a URL for your inbound calls. URL should return TwiML.</param>
+ /// <param name="statusCallback">A URL that Twilio will request when the call ends to notify your app.</param>
+ public IAsyncOperation<Call> InitiateOutboundCallAsync(string from, string to, string url, string statusCallback)
+ {
+ return (IAsyncOperation<Call>)AsyncInfo.Run((System.Threading.CancellationToken ct) => InitiateOutboundCallAsyncInternal(new CallOptions
+ {
+ From = from,
+ To = to,
+ Url = url,
+ StatusCallback = statusCallback
+ }));
+ }
+
+ /// <summary>
+ /// Initiates a new phone call. Makes a POST request to the Calls List resource.
+ /// </summary>
+ /// <param name="options">Call settings. Only properties with values set will be used.</param>
+ public IAsyncOperation<Call> InitiateOutboundCallAsync(CallOptions options)
+ {
+ return (IAsyncOperation<Call>)AsyncInfo.Run((System.Threading.CancellationToken ct) => InitiateOutboundCallAsyncInternal(options));
+ }
+ private async Task<Call> InitiateOutboundCallAsyncInternal(CallOptions options)
+ {
+ Require.Argument("From", options.From);
+ Require.Argument("To", options.To);
+
+ var request = new RestRequest();
+ request.Method = Method.POST;
+ request.Resource = "Accounts/{AccountSid}/Calls.json";
+
+ AddCallOptions(options, request);
+
+ var result = await ExecuteAsync(request, typeof(Call));
+ return (Call)result;
+
+ }
+
+ /// <summary>
+ /// Hangs up a call in progress. Makes a POST request to a Call Instance resource.
+ /// </summary>
+ /// <param name="callSid">The Sid of the call to hang up.</param>
+ /// <param name="style">'Canceled' will attempt to hangup calls that are queued or ringing but not affect calls already in progress. 'Completed' will attempt to hang up a call even if it's already in progress.</param>
+ public IAsyncOperation<Call> HangupCallAsync(string callSid, HangupStyle style)
+ {
+ return (IAsyncOperation<Call>)AsyncInfo.Run((System.Threading.CancellationToken ct) => HangupCallAsyncInternal(callSid, style));
+ }
+ private async Task<Call> HangupCallAsyncInternal(string callSid, HangupStyle style)
+ {
+ Require.Argument("CallSid", callSid);
+
+ var request = new RestRequest();
+ request.Method = Method.POST;
+ request.Resource = "Accounts/{AccountSid}/Calls/{CallSid}.json";
+
+ request.AddUrlSegment("CallSid", callSid);
+ request.AddParameter("Status", style.ToString().ToLower());
+
+ var result = await ExecuteAsync(request, typeof(Call));
+ return (Call)result;
+ }
+
+ /// <summary>
+ /// Redirect a call in progress to a new TwiML URL. Makes a POST request to a Call Instance resource.
+ /// </summary>
+ /// <param name="callSid">The Sid of the call to redirect</param>
+ /// <param name="redirectUrl">The URL to redirect the call to.</param>
+ /// <param name="redirectMethod">The HTTP method to use when requesting the redirectUrl</param>
+ public IAsyncOperation<Call> RedirectCallAsync(string callSid, string redirectUrl, string redirectMethod)
+ {
+ return (IAsyncOperation<Call>)AsyncInfo.Run((System.Threading.CancellationToken ct) => RedirectCallAsyncInternal(callSid, redirectUrl, redirectMethod));
+ }
+ private async Task<Call> RedirectCallAsyncInternal(string callSid, string redirectUrl, string redirectMethod)
+ {
+ Require.Argument("CallSid", callSid);
+ Require.Argument("Url", redirectUrl);
+
+ var request = new RestRequest();
+ request.Method = Method.POST;
+ request.Resource = "Accounts/{AccountSid}/Calls/{CallSid}.json";
+
+ request.AddParameter("CallSid", callSid, ParameterType.UrlSegment);
+ request.AddParameter("Url", redirectUrl);
+ if (redirectMethod.HasValue()) request.AddParameter("Method", redirectMethod);
+
+ var result = await ExecuteAsync(request, typeof(Call));
+ return (Call)result;
+
+ }
+
+ private void AddCallOptions(CallOptions options, RestRequest request)
+ {
+ request.AddParameter("From", options.From);
+ request.AddParameter("To", options.To);
+
+ if (options.ApplicationSid.HasValue())
+ {
+ request.AddParameter("ApplicationSid", options.ApplicationSid);
+ }
+ else
+ {
+ request.AddParameter("Url", options.Url);
+ }
+
+ if (options.StatusCallback.HasValue()) request.AddParameter("StatusCallback", options.StatusCallback);
+ if (options.StatusCallbackMethod.HasValue()) request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod);
+ if (options.FallbackUrl.HasValue()) request.AddParameter("FallbackUrl", options.FallbackUrl);
+ if (options.FallbackMethod.HasValue()) request.AddParameter("FallbackMethod", options.FallbackMethod);
+ if (options.Method.HasValue()) request.AddParameter("Method", options.Method);
+ if (options.SendDigits.HasValue()) request.AddParameter("SendDigits", options.SendDigits);
+ if (options.IfMachine.HasValue()) request.AddParameter("IfMachine", options.IfMachine);
+ if (options.Timeout.HasValue) request.AddParameter("Timeout", options.Timeout.Value);
+ if (options.Record) request.AddParameter("Record", "true");
+ }
+
+ private void AddCallListOptions(CallListRequest options, RestRequest request)
+ {
+ if (options.From.HasValue()) request.AddParameter("From", options.From);
+ if (options.To.HasValue()) request.AddParameter("To", options.To);
+ if (options.Status.HasValue()) request.AddParameter("Status", options.Status);
+ // if (options.StartTime.HasValue) request.AddParameter("StartTime", options.StartTime.Value.ToString("yyyy-MM-dd"));
+ // if (options.EndTime.HasValue) request.AddParameter("EndTime", options.EndTime.Value.ToString("yyyy-MM-dd"));
+
+ var startTimeParameterName = GetParameterNameWithEquality(options.StartTimeComparison, "StartTime");
+ var endTimeParameterName = GetParameterNameWithEquality(options.EndTimeComparison, "EndTime");
+
+ if (options.StartTime.HasValue) request.AddParameter(startTimeParameterName, options.StartTime.Value.ToString("yyyy-MM-dd"));
+ if (options.EndTime.HasValue) request.AddParameter(endTimeParameterName, options.EndTime.Value.ToString("yyyy-MM-dd"));
+
+ if (options.Count.HasValue) request.AddParameter("PageSize", options.Count.Value);
+ if (options.PageNumber.HasValue) request.AddParameter("Page", options.PageNumber.Value);
+
+ if (options.ParentCallSid.HasValue()) request.AddParameter("ParentCallSid", options.ParentCallSid);
+ }
+ }
+}
View
216 src/Twilio.WinRT/Conference.cs
@@ -0,0 +1,216 @@
+using RestRT;
+using RestRT.Extensions;
+using System;
+using System.Runtime.InteropServices.WindowsRuntime;
+using System.Threading.Tasks;
+using Windows.Foundation;
+
+namespace Twilio
+{
+ public partial class TwilioRestClient
+ {
+ /// <summary>
+ /// Returns a list of conferences within an account.
+ /// The list includes paging information and is sorted by DateUpdated, with most recent conferences first.
+ /// Makes a GET request to the Conferences List resource.
+ /// </summary>
+ public IAsyncOperation<ConferenceResult> ListConferencesAsync()
+ {
+ return (IAsyncOperation<ConferenceResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListConferencesAsyncInternal());
+ }
+ private async Task<ConferenceResult> ListConferencesAsyncInternal()
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/Conferences.json";
+
+ var result = await ExecuteAsync(request, typeof(ConferenceResult));
+ return (ConferenceResult)result;
+
+ }
+
+ /// <summary>
+ /// Returns a list of conferences within an account.
+ /// The list includes paging information and is sorted by DateUpdated, with most recent conferences first.
+ /// Makes a POST request to the Conferences List resource.
+ /// </summary>
+ /// <param name="options">List filter options. Only properties with values are included in request.</param>
+ public IAsyncOperation<ConferenceResult> ListConferencesAsync(ConferenceListRequest options)
+ {
+ return (IAsyncOperation<ConferenceResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListConferencesAsyncInternal(options));
+ }
+ private async Task<ConferenceResult> ListConferencesAsyncInternal(ConferenceListRequest options)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/Conferences.json";
+
+ AddConferenceListOptions(options, request);
+
+ var result = await ExecuteAsync(request, typeof(ConferenceResult));
+ return (ConferenceResult)result;
+
+ }
+
+ /// <summary>
+ /// Retrieve details for specific conference. Makes a GET request to a Conference Instance resource.
+ /// </summary>
+ /// <param name="conferenceSid">The Sid of the conference to retrieve</param>
+ public IAsyncOperation<Conference> GetConferenceAsync(string conferenceSid)
+ {
+ return (IAsyncOperation<Conference>)AsyncInfo.Run((System.Threading.CancellationToken ct) => GetConferenceAsyncInternal(conferenceSid));
+ }
+ private async Task<Conference> GetConferenceAsyncInternal(string conferenceSid)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/Conferences/{ConferenceSid}.json";
+
+ request.AddUrlSegment("ConferenceSid", conferenceSid);
+
+ var result = await ExecuteAsync(request, typeof(Conference));
+ return (Conference)result;
+
+ }
+
+ /// <summary>
+ /// Retrieve a list of conference participants. Makes a GET request to a Conference Participants List resource.
+ /// </summary>
+ /// <param name="conferenceSid">The Sid of the conference</param>
+ /// <param name="muted">Set to null to retrieve all, true to retrieve muted, false to retrieve unmuted</param>
+ public IAsyncOperation<ParticipantResult> ListConferenceParticipantsAsync(string conferenceSid, bool? muted)
+ {
+ return (IAsyncOperation<ParticipantResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListConferenceParticipantsAsyncInternal(conferenceSid, muted, null, null));
+ }
+
+ /// <summary>
+ /// Retrieve a list of conference participants. Makes a GET request to a Conference Participants List resource.
+ /// </summary>
+ /// <param name="conferenceSid">The Sid of the conference</param>
+ /// <param name="muted">Set to null to retrieve all, true to retrieve muted, false to retrieve unmuted</param>
+ /// <param name="pageNumber">Which page number to start retrieving from</param>
+ /// <param name="count">How many participants to retrieve</param>
+ public IAsyncOperation<ParticipantResult> ListConferenceParticipantsAsync(string conferenceSid, bool? muted, int? pageNumber, int? count)
+ {
+ return (IAsyncOperation<ParticipantResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListConferenceParticipantsAsyncInternal(conferenceSid, muted, pageNumber, count));
+ }
+ private async Task<ParticipantResult> ListConferenceParticipantsAsyncInternal(string conferenceSid, bool? muted, int? pageNumber, int? count)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants.json";
+
+ request.AddUrlSegment("ConferenceSid", conferenceSid);
+
+ if (muted.HasValue) request.AddParameter("Muted", muted.Value);
+ if (pageNumber.HasValue) request.AddParameter("Page", pageNumber.Value);
+ if (count.HasValue) request.AddParameter("PageSize", count.Value);
+
+ var result = await ExecuteAsync(request, typeof(ParticipantResult));
+ return (ParticipantResult)result;
+
+ }
+
+ /// <summary>
+ /// Retrieve a single conference participant by their CallSid. Makes a GET request to a Conference Participant Instance resource.
+ /// </summary>
+ /// <param name="conferenceSid">The Sid of the conference</param>
+ /// <param name="callSid">The Sid of the call instance</param>
+ public IAsyncOperation<Participant> GetConferenceParticipantAsync(string conferenceSid, string callSid)
+ {
+ return (IAsyncOperation<Participant>)AsyncInfo.Run((System.Threading.CancellationToken ct) => GetConferenceParticipantAsyncInternal(conferenceSid, callSid));
+ }
+ private async Task<Participant> GetConferenceParticipantAsyncInternal(string conferenceSid, string callSid)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}.json";
+
+ request.AddUrlSegment("ConferenceSid", conferenceSid);
+ request.AddUrlSegment("CallSid", callSid);
+
+ var result = await ExecuteAsync(request, typeof(Participant));
+ return (Participant)result;
+
+ }
+
+ /// <summary>
+ /// Change a participant of a conference to be muted. Makes a GET request to a Conference Participant Instance resource.
+ /// </summary>
+ /// <param name="conferenceSid">The Sid of the conference</param>
+ /// <param name="callSid">The Sid of the call to mute</param>
+ public IAsyncOperation<Participant> MuteConferenceParticipantAsync(string conferenceSid, string callSid)
+ {
+ return (IAsyncOperation<Participant>)AsyncInfo.Run((System.Threading.CancellationToken ct) => MuteConferenceParticipantAsyncInternal(conferenceSid, callSid));
+ }
+ private async Task<Participant> MuteConferenceParticipantAsyncInternal(string conferenceSid, string callSid)
+ {
+ var request = new RestRequest();
+ request.Method = Method.POST;
+ request.Resource = "Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}.json";
+
+ request.AddUrlSegment("ConferenceSid", conferenceSid);
+ request.AddUrlSegment("CallSid", callSid);
+ request.AddParameter("Muted", true);
+
+ var result = await ExecuteAsync(request, typeof(Participant));
+ return (Participant)result;
+
+ }
+
+ /// <summary>
+ /// Change a participant of a conference to be unmuted. Makes a GET request to a Conference Participant Instance resource.
+ /// </summary>
+ /// <param name="conferenceSid">The Sid of the conference</param>
+ /// <param name="callSid">The Sid of the call to unmute</param>
+ public IAsyncOperation<Participant> UnmuteConferenceParticipantAsync(string conferenceSid, string callSid)
+ {
+ return (IAsyncOperation<Participant>)AsyncInfo.Run((System.Threading.CancellationToken ct) => UnmuteConferenceParticipantAsyncInternal(conferenceSid, callSid));
+ }
+ private async Task<Participant> UnmuteConferenceParticipantAsyncInternal(string conferenceSid, string callSid)
+ {
+ var request = new RestRequest();
+ request.Method = Method.POST;
+ request.Resource = "Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}.json";
+
+ request.AddUrlSegment("ConferenceSid", conferenceSid);
+ request.AddUrlSegment("CallSid", callSid);
+ request.AddParameter("Muted", false);
+
+ var result = await ExecuteAsync(request, typeof(Participant));
+ return (Participant)result;
+
+ }
+
+ /// <summary>
+ /// Remove a caller from a conference. Makes a DELETE request to a Conference Participant Instance resource.
+ /// </summary>
+ /// <param name="conferenceSid">The Sid of the conference</param>
+ /// <param name="callSid">The Sid of the call to remove</param>
+ public IAsyncOperation<bool> KickConferenceParticipantAsync(string conferenceSid, string callSid)
+ {
+ return (IAsyncOperation<bool>)AsyncInfo.Run((System.Threading.CancellationToken ct) => KickConferenceParticipantAsyncInternal(conferenceSid, callSid));
+ }
+ private async Task<bool> KickConferenceParticipantAsyncInternal(string conferenceSid, string callSid)
+ {
+ var request = new RestRequest();
+ request.Method = Method.DELETE;
+ request.Resource = "Accounts/{AccountSid}/Conferences/{ConferenceSid}/Participants/{CallSid}.json";
+ request.AddUrlSegment("ConferenceSid", conferenceSid);
+ request.AddUrlSegment("CallSid", callSid);
+
+ var response = (RestResponse)await ExecuteAsync(request);
+ return response.StatusCode == (int)System.Net.HttpStatusCode.NoContent;
+ }
+
+ private void AddConferenceListOptions(ConferenceListRequest options, RestRequest request)
+ {
+ if (options.Status.HasValue) request.AddParameter("Status", options.Status);
+ if (options.FriendlyName.HasValue()) request.AddParameter("FriendlyName", options.FriendlyName);
+
+ var dateCreatedParameterName = GetParameterNameWithEquality(options.DateCreatedComparison, "DateCreated");
+ var dateUpdatedParameterName = GetParameterNameWithEquality(options.DateUpdatedComparison, "DateUpdated");
+
+ if (options.DateCreated.HasValue) request.AddParameter(dateCreatedParameterName, options.DateCreated.Value.ToString("yyyy-MM-dd"));
+ if (options.DateUpdated.HasValue) request.AddParameter(dateUpdatedParameterName, options.DateUpdated.Value.ToString("yyyy-MM-dd"));
+
+ if (options.Count.HasValue) request.AddParameter("PageSize", options.Count.Value);
+ if (options.PageNumber.HasValue) request.AddParameter("Page", options.PageNumber.Value);
+ }
+ }
+}
View
105 src/Twilio.WinRT/ConnectApps.cs
@@ -0,0 +1,105 @@
+using System;
+using RestRT;
+using RestRT.Extensions;
+using RestRT.Validation;
+using Windows.Foundation;
+using System.Runtime.InteropServices.WindowsRuntime;
+using System.Threading.Tasks;
+
+namespace Twilio
+{
+ public partial class TwilioRestClient
+ {
+ /// <summary>
+ /// Retrieve the details for an ConnectApp instance. Makes a GET request to an ConnectApp Instance resource.
+ /// </summary>
+ /// <param name="connectAppSid">The Sid of the ConnectApp to retrieve</param>
+ public IAsyncOperation<ConnectApp> GetConnectAppAsync(string connectAppSid)
+ {
+ return (IAsyncOperation<ConnectApp>)AsyncInfo.Run((System.Threading.CancellationToken ct) => GetConnectAppAsyncInternal(connectAppSid));
+ }
+ private async Task<ConnectApp> GetConnectAppAsyncInternal(string connectAppSid)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/ConnectApps/{ConnectAppSid}.json";
+
+ request.AddUrlSegment("ConnectAppSid", connectAppSid);
+
+ var result = await ExecuteAsync(request, typeof(ConnectApp));
+ return (ConnectApp)result;
+
+ }
+
+ /// <summary>
+ /// List ConnectApps on current account
+ /// </summary>
+ public IAsyncOperation<ConnectAppResult> ListConnectAppsAsync()
+ {
+ return (IAsyncOperation<ConnectAppResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListConnectAppsAsyncInternal(null,null));
+ }
+
+ /// <summary>
+ /// List ConnectApps on current account with filters
+ /// </summary>
+ /// <param name="pageNumber">Page number to start retrieving results from</param>
+ /// <param name="count">How many results to return</param>
+ public IAsyncOperation<ConnectAppResult> ListConnectAppsAsync(int? pageNumber, int? count)
+ {
+ return (IAsyncOperation<ConnectAppResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListConnectAppsAsyncInternal(pageNumber, count));
+ }
+ private async Task<ConnectAppResult> ListConnectAppsAsyncInternal(int? pageNumber, int? count)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/ConnectApps.json";
+
+ if (pageNumber.HasValue) request.AddParameter("Page", pageNumber.Value);
+ if (count.HasValue) request.AddParameter("PageSize", count.Value);
+
+ var result = await ExecuteAsync(request, typeof(ConnectAppResult));
+ return (ConnectAppResult)result;
+
+ }
+
+ /// <summary>
+ /// Tries to update the ConnectApp's properties, and returns the updated resource representation if successful.
+ /// </summary>
+ /// <param name="connectAppSid">The Sid of the ConnectApp to update</param>
+ /// <param name="friendlyName">A human readable description of the Connect App, with maximum length 64 characters. (optional, null to leave as-is)</param>
+ /// <param name="authorizeRedirectUrl">The URL the user's browser will redirect to after Twilio authenticates the user and obtains authorization for this Connect App. (optional, null to leave as-is)</param>
+ /// <param name="deauthorizeCallbackUrl">The URL to which Twilio will send a request when a user de-authorizes this Connect App. (optional, null to leave as-is)</param>
+ /// <param name="deauthorizeCallbackMethod">The HTTP method to be used when making a request to the DeauthorizeCallbackUrl. Either GET or POST. (optional, null to leave as-is)</param>
+ /// <param name="permissions">A comma-separated list of permssions you will request from users of this ConnectApp. Valid permssions are get-all or post-all. (optional, null to leave as-is)</param>
+ /// <param name="description">A more detailed human readable description of the Connect App. (optional, null to leave as-is)</param>
+ /// <param name="companyName">The company name for this Connect App. (optional, null to leave as-is)</param>
+ /// <param name="homepageUrl">The public URL where users can obtain more information about this Connect App. (optional, null to leave as-is)</param>
+ public IAsyncOperation<ConnectApp> UpdateConnectAppAsync(string connectAppSid, string friendlyName, string authorizeRedirectUrl, string deauthorizeCallbackUrl,
+ string deauthorizeCallbackMethod, string permissions, string description, string companyName, string homepageUrl)
+ {
+ return (IAsyncOperation<ConnectApp>)AsyncInfo.Run((System.Threading.CancellationToken ct) => UpdateConnectAppAsyncInternal(connectAppSid, friendlyName, authorizeRedirectUrl, deauthorizeCallbackUrl,
+ deauthorizeCallbackMethod, permissions, description, companyName, homepageUrl));
+ }
+ private async Task<ConnectApp> UpdateConnectAppAsyncInternal(string connectAppSid, string friendlyName, string authorizeRedirectUrl, string deauthorizeCallbackUrl,
+ string deauthorizeCallbackMethod, string permissions, string description, string companyName, string homepageUrl)
+ {
+ Require.Argument("ConnectAppSid", connectAppSid);
+
+ var request = new RestRequest();
+ request.Method = Method.POST;
+ request.Resource = "Accounts/{AccountSid}/ConnectApps/{ConnectAppSid}.json";
+ request.AddUrlSegment("ConnectAppSid", connectAppSid);
+
+ if (friendlyName.HasValue()) request.AddParameter("FriendlyName", friendlyName);
+ if (authorizeRedirectUrl.HasValue()) request.AddParameter("AuthorizeRedirectUrl", authorizeRedirectUrl);
+ if (deauthorizeCallbackUrl.HasValue()) request.AddParameter("DeauthorizeCallbackUrl", deauthorizeCallbackUrl);
+ if (deauthorizeCallbackMethod.HasValue()) request.AddParameter("DeauthorizeCallbackMethod", deauthorizeCallbackMethod);
+ if (permissions.HasValue()) request.AddParameter("Permissions", permissions);
+ if (description.HasValue()) request.AddParameter("Description", description);
+ if (companyName.HasValue()) request.AddParameter("CompanyName", companyName);
+ if (homepageUrl.HasValue()) request.AddParameter("HomepageUrl", homepageUrl);
+
+ var result = await ExecuteAsync(request, typeof(ConnectApp));
+ return (ConnectApp)result;
+
+ }
+ }
+}
View
160 src/Twilio.WinRT/Core.cs
@@ -0,0 +1,160 @@
+using RestRT;
+using RestRT.Extensions;
+using System.Reflection;
+using RestRT.Deserializers;
+using System.Text;
+using System;
+using System.Threading.Tasks;
+using Windows.Foundation;
+using System.Runtime.InteropServices.WindowsRuntime;
+using RestRT.Authenticators;
+
+namespace Twilio
+{
+ /// <summary>
+ /// REST API wrapper.
+ /// </summary>
+ public sealed partial class TwilioRestClient
+ {
+ /// <summary>
+ /// Twilio API version to use when making requests
+ /// </summary>
+ public string ApiVersion { get; set; }
+ /// <summary>
+ /// Base URL of API (defaults to https://api.twilio.com)
+ /// </summary>
+ public string BaseUrl { get; set; }
+ private string AccountSid { get; set; }
+ private string AuthToken { get; set; }
+
+ private RestClient _client;
+
+ /// <summary>
+ /// Initializes a new client with the specified credentials.
+ /// </summary>
+ /// <param name="accountSid">The AccountSid to authenticate with</param>
+ /// <param name="authToken">The AuthToken to authenticate with</param>
+ public TwilioRestClient(string accountSid, string authToken)
+ {
+ ApiVersion = "2010-04-01";
+ BaseUrl = "https://api.twilio.com/";
+ AccountSid = accountSid;
+ AuthToken = authToken;
+
+ // silverlight friendly way to get current version
+ //var assembly = Assembly.GetExecutingAssembly();
+ //AssemblyName assemblyName = new AssemblyName(assembly.FullName);
+ //var version = assemblyName.Version;
+
+ var asmName = this.GetType().AssemblyQualifiedName;
+ var versionExpression = new System.Text.RegularExpressions.Regex("Version=(?<version>[0-9.]*)");
+ var m = versionExpression.Match(asmName);
+ string version = String.Empty;
+ if (m.Success)
+ {
+ version = m.Groups["version"].Value;
+ }
+
+ _client = new RestClient();
+ _client.UserAgent = "twilio-csharp/" + version;
+ _client.Authenticator = new HttpBasicAuthenticator(AccountSid, AuthToken);
+ _client.BaseUrl = string.Format("{0}{1}", BaseUrl, ApiVersion);
+
+ // if acting on a subaccount, use request.AddUrlSegment("AccountSid", "value")
+ // to override for that request.
+ _client.AddDefaultUrlSegment("AccountSid", AccountSid);
+ }
+
+ /// <summary>
+ /// Execute a manual REST request
+ /// </summary>
+ /// <typeparam name="T">The type of object to create and populate with the returned data.</typeparam>
+ /// <param name="request">The RestRequest to execute (will use client credentials)</param>
+ //public T Execute<T>(RestRequest request) where T : new()
+ //{
+ // request.OnBeforeDeserialization = (resp) =>
+ // {
+ // // for individual resources when there's an error to make
+ // // sure that RestException props are populated
+ // if (((int)resp.StatusCode) >= 400)
+ // {
+ // // have to read the bytes so .Content doesn't get populated
+ // var content = resp.RawBytes.AsString();
+ // var json = JObject.Parse(content);
+ // var newJson = new JObject();
+ // newJson["RestException"] = json;
+ // resp.Content = null;
+ // resp.RawBytes = Encoding.UTF8.GetBytes(newJson.ToString());
+ // }
+ // };
+
+ // request.DateFormat = "ddd, dd MMM yyyy HH:mm:ss '+0000'";
+
+ // var response = _client.Execute<T>(request);
+ // return response.Data;
+ //}
+
+ public IAsyncOperation<object> ExecuteAsync(IRestRequest request)
+ {
+ return (IAsyncOperation<object>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ExecuteAsyncInternal(request));
+ }
+ private async Task<object> ExecuteAsyncInternal(IRestRequest request)
+ {
+ var result = await _client.ExecuteAsync(request);
+
+ return result;
+ }
+
+ /// <summary>
+ /// Execute a manual REST request
+ /// </summary>
+ /// <param name="request">The RestRequest to execute (will use client credentials)</param>
+ public IAsyncOperation<object> ExecuteAsync(IRestRequest request, Type type)
+ {
+ return (IAsyncOperation<object>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ExecuteAsyncInternal(request, type));
+ }
+ private async Task<object> ExecuteAsyncInternal(IRestRequest request, Type type)
+ {
+ var result = await _client.ExecuteAsync(request);
+
+ if (result.StatusCode >= 400)
+ {
+ // have to read the bytes so .Content doesn't get populated
+ //var content = result.RawBytes.AsString();
+ //var json = JObject.Parse(content);
+ //var newJson = new JObject();
+ //newJson["RestException"] = json;
+ //result.Content = null;
+ //result.RawBytes = Encoding.UTF8.GetBytes(newJson.ToString());
+
+ // have to read the bytes so .Content doesn't get populated
+ string restException = "{{ \"RestException\" : {0} }}";
+ var content = result.RawBytes.AsString(); //get the response content
+ var newJson = string.Format(restException, content);
+
+ result.Content = null;
+ result.RawBytes = Encoding.UTF8.GetBytes(newJson.ToString());
+ }
+
+ var deserializer = new RestRT.Deserializers.JsonDeserializer();
+ return deserializer.Deserialize(result, type);
+ }
+
+ private string GetParameterNameWithEquality(ComparisonType? comparisonType, string parameterName)
+ {
+ if (comparisonType.HasValue)
+ {
+ switch (comparisonType)
+ {
+ case ComparisonType.GreaterThanOrEqualTo:
+ parameterName += ">";
+ break;
+ case ComparisonType.LessThanOrEqualTo:
+ parameterName += "<";
+ break;
+ }
+ }
+ return parameterName;
+ }
+ }
+}
View
177 src/Twilio.WinRT/IncomingPhoneNumbers.cs
@@ -0,0 +1,177 @@
+using RestRT;
+using RestRT.Extensions;
+using RestRT.Validation;
+using System;
+using System.Runtime.InteropServices.WindowsRuntime;
+using System.Threading.Tasks;
+using Windows.Foundation;
+
+namespace Twilio
+{
+ public partial class TwilioRestClient
+ {
+ /// <summary>
+ /// Retrieve the details for an incoming phone number
+ /// </summary>
+ /// <param name="incomingPhoneNumberSid">The Sid of the number to retrieve</param>
+ public IAsyncOperation<IncomingPhoneNumber> GetIncomingPhoneNumberAsync(string incomingPhoneNumberSid)
+ {
+ return (IAsyncOperation<IncomingPhoneNumber>)AsyncInfo.Run((System.Threading.CancellationToken ct) => GetIncomingPhoneNumberAsyncInternal(incomingPhoneNumberSid));
+ }
+ private async Task<IncomingPhoneNumber> GetIncomingPhoneNumberAsyncInternal(string incomingPhoneNumberSid)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/IncomingPhoneNumbers/{IncomingPhoneNumberSid}.json";
+
+ request.AddUrlSegment("IncomingPhoneNumberSid", incomingPhoneNumberSid);
+
+ var result = await ExecuteAsync(request, typeof(IncomingPhoneNumber));
+ return (IncomingPhoneNumber)result;
+ }
+
+ /// <summary>
+ /// List all incoming phone numbers on current account
+ /// </summary>
+ public IAsyncOperation<IncomingPhoneNumberResult> ListIncomingPhoneNumbersAsync()
+ {
+ return (IAsyncOperation<IncomingPhoneNumberResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListIncomingPhoneNumbersAsyncInternal(null,null,null,null));
+ }
+
+ /// <summary>
+ /// List incoming phone numbers on current account with filters
+ /// </summary>
+ /// <param name="phoneNumber">Optional phone number to match</param>
+ /// <param name="friendlyName">Optional friendly name to match</param>
+ /// <param name="pageNumber">Page number to start retrieving results from</param>
+ /// <param name="count">How many results to return</param>
+ public IAsyncOperation<IncomingPhoneNumberResult> ListIncomingPhoneNumbersAsync(string phoneNumber, string friendlyName, int? pageNumber, int? count)
+ {
+ return (IAsyncOperation<IncomingPhoneNumberResult>)AsyncInfo.Run((System.Threading.CancellationToken ct) => ListIncomingPhoneNumbersAsyncInternal(phoneNumber, friendlyName, pageNumber, count));
+ }
+ private async Task<IncomingPhoneNumberResult> ListIncomingPhoneNumbersAsyncInternal(string phoneNumber, string friendlyName, int? pageNumber, int? count)
+ {
+ var request = new RestRequest();
+ request.Resource = "Accounts/{AccountSid}/IncomingPhoneNumbers.json";
+
+ if (phoneNumber.HasValue()) request.AddParameter("PhoneNumber", phoneNumber);
+ if (friendlyName.HasValue()) request.AddParameter("FriendlyName", friendlyName);
+
+ if (pageNumber.HasValue) request.AddParameter("Page", pageNumber.Value);
+ if (count.HasValue) request.AddParameter("PageSize", count.Value);
+
+ var result = await ExecuteAsync(request, typeof(IncomingPhoneNumberResult));
+ return (IncomingPhoneNumberResult)result;
+ }
+
+ /// <summary>
+ /// Purchase/provision a local phone number
+ /// </summary>
+ /// <param name="options">Optional parameters to use when purchasing number</param>
+ public IAsyncOperation<IncomingPhoneNumber> AddIncomingPhoneNumberAsync(PhoneNumberOptions options)
+ {
+ return (IAsyncOperation<IncomingPhoneNumber>)AsyncInfo.Run((System.Threading.CancellationToken ct) => AddIncomingPhoneNumberAsyncInternal(options));
+ }
+ private async Task<IncomingPhoneNumber> AddIncomingPhoneNumberAsyncInternal(PhoneNumberOptions options)
+ {
+ var request = new RestRequest();
+ request.Method = Method.POST;
+ request.Resource = "Accounts/{AccountSid}/IncomingPhoneNumbers.json";
+
+ if (options.PhoneNumber.HasValue())
+ {
+ request.AddParameter("PhoneNumber", options.PhoneNumber);
+ }
+ else
+ {
+ if (options.AreaCode.HasValue()) request.AddParameter("AreaCode", options.AreaCode);
+ }
+
+ AddPhoneNumberOptionsToRequest(request, options);
+ AddSmsOptionsToRequest(request, options);
+
+ var result = await ExecuteAsync(request, typeof(IncomingPhoneNumber));
+ return (IncomingPhoneNumber)result;
+ }
+
+ /// <summary>
+ /// Update the settings of an incoming phone number
+ /// </summary>
+ /// <param name="incomingPhoneNumberSid">The Sid of the phone number to update</param>
+ /// <param name="options">Which settings to update. Only properties with values set will be updated.</param>
+ public IAsyncOperation<IncomingPhoneNumber> UpdateIncomingPhoneNumberAsync(string incomingPhoneNumberSid, PhoneNumberOptions options)
+ {
+ return (IAsyncOperation<IncomingPhoneNumber>)AsyncInfo.Run((System.Threading.CancellationToken ct) => UpdateIncomingPhoneNumberAsyncInternal(incomingPhoneNumberSid, options));
+ }
+ private async Task<IncomingPhoneNumber> UpdateIncomingPhoneNumberAsyncInternal(string incomingPhoneNumberSid, PhoneNumberOptions options)
+ {
+ Require.Argument("IncomingPhoneNumberSid", incomingPhoneNumberSid);
+
+ var request = new RestRequest();
+ request.Method = Method.POST;
+ request.Resource = "Accounts/{AccountSid}/IncomingPhoneNumbers/{IncomingPhoneNumberSid}.json";
+
+ request.AddParameter("IncomingPhoneNumberSid", incomingPhoneNumberSid, ParameterType.UrlSegment);
+ AddPhoneNumberOptionsToRequest(request, options);
+ AddSmsOptionsToRequest(request, options);
+
+ var result = await ExecuteAsync(request, typeof(IncomingPhoneNumber));
+ return (IncomingPhoneNumber)result;
+ }
+
+ /// <summary>
+ /// Remove (deprovision) a phone number from the current account
+ /// </summary>
+ /// <param name="incomingPhoneNumberSid">The Sid of the number to remove</param>
+ public IAsyncOperation<DeleteStatus> DeleteIncomingPhoneNumberAsync(string incomingPhoneNumberSid)
+ {
+ return (IAsyncOperation<DeleteStatus>)AsyncInfo.Run((System.Threading.CancellationToken ct) => DeleteIncomingPhoneNumberAsyncInternal(incomingPhoneNumberSid));
+ }
+ private async Task<DeleteStatus> DeleteIncomingPhoneNumberAsyncInternal(string incomingPhoneNumberSid)
+ {
+ Require.Argument("IncomingPhoneNumberSid", incomingPhoneNumberSid);
+ var request = new RestRequest();
+ request.Method = Method.DELETE;
+
+ request.Resource = "Accounts/{AccountSid}/IncomingPhoneNumbers/{IncomingPhoneNumberSid}.json";
+
+ request.AddParameter("IncomingPhoneNumberSid", incomingPhoneNumberSid, ParameterType.UrlSegment);
+
+ var response = (RestResponse)await ExecuteAsync(request);
+ return response.StatusCode == (int)System.Net.HttpStatusCode.NoContent ? DeleteStatus.Success : DeleteStatus.Failed;
+ }
+
+ private void AddPhoneNumberOptionsToRequest(RestRequest request, PhoneNumberOptions options)
+ {
+ if (options.AccountSid.HasValue())
+ {
+ request.AddParameter("AccountSid", options.AccountSid);
+ }
+
+ if (options.FriendlyName.HasValue())
+ {
+ Validate.IsValidLength(options.FriendlyName, 64);
+ request.AddParameter("FriendlyName", options.FriendlyName);
+ }
+ // some check for null. in those cases an empty string is a valid value (to remove a URL assignment)
+ if (options.VoiceApplicationSid != null) request.AddParameter("VoiceApplicationSid", options.VoiceApplicationSid);
+
+ if (options.VoiceUrl != null) request.AddParameter("VoiceUrl", options.VoiceUrl);
+ if (options.VoiceMethod.HasValue()) request.AddParameter("VoiceMethod", options.VoiceMethod.ToString());
+ if (options.VoiceFallbackUrl != null) request.AddParameter("VoiceFallbackUrl", options.VoiceFallbackUrl);
+ if (options.VoiceFallbackMethod.HasValue()) request.AddParameter("VoiceFallbackMethod", options.VoiceFallbackMethod.ToString());
+ if (options.VoiceCallerIdLookup.HasValue) request.AddParameter("VoiceCallerIdLookup", options.VoiceCallerIdLookup.Value);
+ if (options.StatusCallback.HasValue()) request.AddParameter("StatusCallback", options.StatusCallback);
+ if (options.StatusCallbackMethod.HasValue()) request.AddParameter("StatusCallbackMethod", options.StatusCallbackMethod.ToString());
+ }
+
+ private void AddSmsOptionsToRequest(RestRequest request, PhoneNumberOptions options)
+ {
+ // some check for null. in those cases an empty string is a valid value (to remove a URL assignment)
+ if (options.SmsApplicationSid != null) request.AddParameter("SmsApplicationSid", options.SmsApplicationSid);
+ if (options.SmsUrl != null) request.AddParameter("SmsUrl", options.SmsUrl);
+ if (options.SmsMethod.HasValue()) request.AddParameter("SmsMethod", options.SmsMethod.ToString());
+ if (options.SmsFallbackUrl != null) request.AddParameter("SmsFallbackUrl", options.SmsFallbackUrl);
+ if (options.SmsFallbackMethod.HasValue()) request.AddParameter("SmsFallbackMethod", options.SmsFallbackMethod.ToString());
+ }
+ }
+}
View
45 src/Twilio.WinRT/Model/Account.cs
@@ -0,0 +1,45 @@
+using System;
+using System.Collections.Generic;
+
+namespace Twilio
+{
+ /// <summary>
+ /// An Account instance resource represents a single Twilio Account.
+ /// </summary>
+ public sealed class Account //: TwilioBase, IDirectlyAddressable
+ {
+ /// <summary>
+ /// Exception encountered during API request
+ /// </summary>
+ public RestException RestException { get; set; }
+ /// <summary>
+ /// The URI for this resource, relative to https://api.twilio.com
+ /// </summary>
+ public Uri Uri { get; set; }
+
+ /// <summary>
+ /// A 34 character string that uniquely identifies this account.
+ /// </summary>
+ public string Sid { get; set; }
+ /// <summary>
+ /// The date that this account was created, given as GMT
+ /// </summary>
+ public DateTimeOffset DateCreated { get; set; }
+ /// <summary>
+ /// The date that this account was last updated, given in as GMT
+ /// </summary>
+ public DateTimeOffset DateUpdated { get; set; }
+ /// <summary>
+ /// A human readable description of this account, up to 64 characters long. By default the FriendlyName is your email address.
+ /// </summary>
+ public string FriendlyName { get; set; }
+ /// <summary>
+ /// The status of this account. Usually active, but can be suspended if you've been bad.
+ /// </summary>
+ public string Status { get; set; }
+ /// <summary>
+ /// The authorization token for this account. This token should be kept a secret, so no sharing.
+ /// </summary>
+ public string AuthToken { get; set; }
+ }
+}
View
71 src/Twilio.WinRT/Model/AccountResult.cs
@@ -0,0 +1,71 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Twilio
+{
+ /// <summary>
+ /// Twilio API call result with paging information
+ /// </summary>
+ public sealed class AccountResult
+ {
+ /// <summary>
+ /// The current page number. Zero-indexed, so the first page is 0.
+ /// </summary>
+ public int Page { get; set; }
+ /// <summary>
+ /// The total number of pages.
+ /// </summary>
+ public int NumPages { get; set; }
+ /// <summary>
+ /// How many items are in each page
+ /// </summary>
+ public int PageSize { get; set; }
+ /// <summary>
+ /// The total number of items in the list.
+ /// </summary>
+ public int Total { get; set; }
+ /// <summary>
+ /// The position in the overall list of the first item in this page.
+ /// </summary>
+ public int Start { get; set; }
+ /// <summary>
+ /// The position in the overall list of the last item in this page.
+ /// </summary>
+ public int End { get; set; }
+ /// <summary>
+ /// The URI for the first page of this list.
+ /// </summary>
+ public Uri FirstPageUri { get; set; }
+ /// <summary>
+ /// The URI for the next page of this list.
+ /// </summary>
+ public Uri NextPageUri { get; set; }
+ /// <summary>
+ /// The URI for the previous page of this list.
+ /// </summary>
+ public Uri PreviousPageUri { get; set; }
+ /// <summary>
+ /// The URI for the last page of this list.
+ /// </summary>
+ public Uri LastPageUri { get; set; }
+
+
+ /// <summary>
+ /// Exception encountered during API request
+ /// </summary>
+ public RestException RestException { get; set; }
+ /// <summary>
+ /// The URI for this resource, relative to https://api.twilio.com
+ /// </summary>
+ public Uri Uri { get; set; }
+
+
+ /// <summary>
+ /// List of accounts returned by API
+ /// </summary>
+ public IList<Account> Accounts { get; set; }
+ }
+}
View
26 src/Twilio.WinRT/Model/AccountStatus.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace Twilio
+{
+ /// <summary>
+ /// The status of an <see cref="Account">Account</see>
+ /// </summary>
+ public enum AccountStatus
+ {
+ /// <summary>
+ /// Available to be used
+ /// </summary>
+ Active,
+ /// <summary>
+ /// Temporarily suspended
+ /// </summary>
+ Suspended,
+ /// <summary>
+ /// Closed forever
+ /// </summary>
+ Closed
+ }
+}
View
93 src/Twilio.WinRT/Model/Application.cs
@@ -0,0 +1,93 @@
+using System;
+
+namespace Twilio
+{
+ /// <summary>
+ /// An Application instance resource represents a single Twilio Application.
+ /// </summary>
+ public sealed class Application //: TwilioBase, IDirectlyAddressable
+ {
+ /// <summary>
+ /// Exception encountered during API request
+ /// </summary>
+ public RestException RestException { get; set; }
+ /// <summary>
+ /// The URI for this resource, relative to https://api.twilio.com
+ /// </summary>
+ public Uri Uri { get; set; }
+
+
+ /// <summary>
+ /// A 34 character string that uniquely identifies this account.
+ /// </summary>
+ public string Sid { get; set; }
+ /// <summary>
+ /// The date that this account was created, given as GMT
+ /// </summary>
+ public DateTimeOffset DateCreated { get; set; }
+ /// <summary>
+ /// The date that this account was last updated, given in as GMT
+ /// </summary>
+ public DateTimeOffset DateUpdated { get; set; }
+ /// <summary>
+ /// A human readable description of this account, up to 64 characters long. By default the FriendlyName is your email address.
+ /// </summary>
+ public string FriendlyName { get; set; }
+ /// <summary>
+ /// The unique id of the Account responsible for this phone number.
+ /// </summary>
+ public string AccountSid { get; set; }
+ /// <summary>
+ /// Calls to this phone number will start a new TwiML session with this API version.
+ /// </summary>
+ public string ApiVersion { get; set; }
+ /// <summary>
+ /// Look up the caller's caller-ID name from the CNAM database (additional charges apply)
+ /// </summary>
+ public bool VoiceCallerIdLookup { get; set; }
+ /// <summary>
+ /// The URL Twilio will request when this phone number receives a call.
+ /// </summary>
+ public string VoiceUrl { get; set; }
+ /// <summary>
+ /// The HTTP method Twilio will use when requesting the above Url. Either GET or POST.
+ /// </summary>
+ public string VoiceMethod { get; set; }
+ /// <summary>
+ /// The URL that Twilio will request if an error occurs retrieving or executing the TwiML requested by Url.
+ /// </summary>
+ public string VoiceFallbackUrl { get; set; }
+ /// <summary>
+ /// The HTTP method Twilio will use when requesting the VoiceFallbackUrl. Either GET or POST.
+ /// </summary>
+ public string VoiceFallbackMethod { get; set; }
+ /// <summary>
+ /// The URL that Twilio will request to pass status parameters (such as call ended) to your application.
+ /// </summary>
+ public string StatusCallback { get; set; }
+ /// <summary>
+ /// The URL that Twilio will request to pass status parameters (such as call ended) to your application.
+ /// </summary>
+ public string SmsStatusCallback { get; set; }
+ /// <summary>
+ /// Twilio will make a POST request to this URL to pass status parameters (such as sent or failed) to your application if you specify this application's Sid as the ApplicationSid on an outgoing SMS request.
+ /// </summary>
+ public string StatusCallbackMethod { get; set; }
+ /// <summary>
+ /// The URL Twilio will request when receiving an incoming SMS message to this number.
+ /// </summary>
+ public string SmsUrl { get; set; }
+ /// <summary>
+ /// The HTTP method Twilio will use when making requests to the SmsUrl. Either GET or POST.
+ /// </summary>
+ public string SmsMethod { get; set; }
+ /// <summary>
+ /// The URL that Twilio will request if an error occurs retrieving or executing the TwiML from SmsUrl.
+ /// </summary>
+ public string SmsFallbackUrl { get; set; }
+ /// <summary>
+ /// The HTTP method Twilio will use when requesting the above URL. Either GET or POST.
+ /// </summary>
+ public string SmsFallbackMethod { get; set; }
+ }
+}
View
59 src/Twilio.WinRT/Model/ApplicationOptions.cs
@@ -0,0 +1,59 @@
+namespace Twilio
+{
+ /// <summary>
+ /// Available options when creating a Twilio Application via the API.
+ /// </summary>
+ public sealed class ApplicationOptions
+ {
+ /// <summary>
+ /// The URL that Twilio should request when somebody dials the a phone number using this application.
+ /// </summary>
+ public string VoiceUrl { get; set; }
+ /// <summary>
+ /// The HTTP method that should be used to request the VoiceUrl. Must be either GET or POST. Defaults to POST.
+ /// </summary>
+ public string VoiceMethod { get; set; }
+ /// <summary>
+ /// A URL that Twilio will request if an error occurs requesting or executing the TwiML at Url.
+ /// </summary>
+ public string VoiceFallbackUrl { get; set; }
+ /// <summary>
+ /// The HTTP method that should be used to request the VoiceFallbackUrl. Either GET or POST. Defaults to POST.
+ /// </summary>
+ public string VoiceFallbackMethod { get; set; }
+
+ /// <summary>
+ /// The URL that Twilio should request when somebody sends an SMS to the phone number using this application.
+ /// </summary>
+ public string SmsUrl { get; set; }
+ /// <summary>
+ /// The HTTP method that should be used to request the SmsUrl. Must be either GET or POST. Defaults to POST.
+ /// </summary>
+ public string SmsMethod { get; set; }
+ /// <summary>
+ /// A URL that Twilio will request if an error occurs requesting or executing the TwiML defined by SmsUrl.
+ /// </summary>
+ public string SmsFallbackUrl { get; set; }
+ /// <summary>
+ /// The HTTP method that should be used to request the SmsFallbackUrl. Must be either GET or POST. Defaults to POST.
+ /// </summary>
+ public string SmsFallbackMethod { get; set; }
+
+ /// <summary>
+ /// Do a lookup of a caller's name from the CNAM database and post it to your app. Either true or false. Defaults to false.
+ /// </summary>
+ public bool? VoiceCallerIdLookup { get; set; }
+ /// <summary>
+ /// The URL that Twilio will request to pass status parameters (such as call ended) to your application.
+ /// </summary>
+ public string StatusCallback { get; set; }
+ /// <summary>
+ /// Twilio will make a POST request to this URL to pass status parameters (such as sent or failed) to your application if you specify this application's Sid as the ApplicationSid on an outgoing SMS request.
+ /// </summary>
+ public string SmsStatusCallback { get; set; }
+ /// <summary>
+ /// The HTTP method Twilio will use to make requests to the StatusCallback URL. Either GET or POST. Defaults to POST.
+ /// </summary>
+ public string StatusCallbackMethod { get; set; }
+ }
+}
View
68 src/Twilio.WinRT/Model/ApplicationResult.cs
@@ -0,0 +1,68 @@
+using System;
+using System.Collections.Generic;
+
+namespace Twilio
+{
+ /// <summary>
+ /// Twilio API call result with paging information
+ /// </summary>
+ public sealed class ApplicationResult //: TwilioListBase
+ {
+ /// <summary>
+ /// The current page number. Zero-indexed, so the first page is 0.
+ /// </summary>
+ public int Page { get; set; }
+ /// <summary>
+ /// The total number of pages.
+ /// </summary>
+ public int NumPages { get; set; }
+ /// <summary>
+ /// How many items are in each page
+ /// </summary>
+ public int PageSize { get; set; }
+ /// <summary>
+ /// The total number of items in the list.
+ /// </summary>
+ public int Total { get; set; }
+ /// <summary>
+ /// The position in the overall list of the first item in this page.
+ /// </summary>
+ public int Start { get; set; }
+ /// <summary>
+ /// The position in the overall list of the last item in this page.
+ /// </summary>
+ public int End { get; set; }
+ /// <summary>
+ /// The URI for the first page of this list.
+ /// </summary>
+ public Uri FirstPageUri { get; set; }
+ /// <summary>
+ /// The URI for the next page of this list.
+ /// </summary>
+ public Uri NextPageUri { get; set; }
+ /// <summary>
+ /// The URI for the previous page of this list.
+ /// </summary>
+ public Uri PreviousPageUri { get; set; }
+ /// <summary>
+ /// The URI for the last page of this list.
+ /// </summary>
+ public Uri LastPageUri { get; set; }
+
+
+ /// <summary>
+ /// Exception encountered during API request
+ /// </summary>
+ public RestException RestException { get; set; }
+ /// <summary>
+ /// The URI for this resource, relative to https://api.twilio.com
+ /// </summary>
+ public Uri Uri { get; set; }
+
+
+ /// <summary>
+ /// List of Application instances returned by API
+ /// </summary>
+ public IList<Application> Applications { get; set; }
+ }
+}
View
58 src/Twilio.WinRT/Model/AuthorizedConnectApp.cs
@@ -0,0 +1,58 @@
+using System;
+using System.Collections.Generic;
+
+namespace Twilio
+{
+ /// <summary>
+ /// An AuthorizedConnectApp instance
+ /// </summary>
+ public sealed class AuthorizedConnectApp //: TwilioBase
+ {
+ /// <summary>
+ /// Exception encountered during API request
+ /// </summary>
+ public RestException RestException { get; set; }
+ /// <summary>
+ /// The URI for this resource, relative to https://api.twilio.com
+ /// </summary>
+ public Uri Uri { get; set; }
+
+
+ /// <summary>
+ /// A 34 character string that uniquely identifies this authorized app.
+ /// </summary>
+ public string Sid { get; set; }
+ /// <summary>
+ /// The AccountSid of the SubAccount this Connect App has access to.
+ /// </summary>
+ public string AccountSid { get; set; }
+ /// <summary>
+ /// The date that this account was created, given as GMT
+ /// </summary>
+ public DateTimeOffset DateCreated { get; set; }
+ /// <summary>
+ /// The date that this account was last updated, given in as GMT
+ /// </summary>
+ public DateTimeOffset DateUpdated { get; set; }
+ /// <summary>
+ /// The set of permissions that you have authorized for this Connect App. Valid permisisons are get-all or post-all.
+ /// </summary>
+ public IList<Permission> Permissions { get; set; }
+ /// <summary>
+ /// A human readable name for the Connect App.
+ /// </summary>
+ public string FriendlyName { get; set; }
+ /// <summary>
+ /// A more detailed human readable description of the Connect App.
+ /// </summary>
+ public string Description { get; set; }
+ /// <summary>
+ /// The company name set for this Connect App.
+ /// </summary>
+ public string CompanyName { get; set; }
+ /// <summary>
+ /// The public URL for this Connect App.
+ /// </summary>
+ public string HomepageUrl { get; set; }
+ }
+}
View
59 src/Twilio.WinRT/Model/AuthorizedConnectAppResult.cs
@@ -0,0 +1,59 @@
+using System;
+using System.Collections.Generic;
+
+namespace Twilio
+{
+ /// <summary>
+ /// Twilio API call result with paging information
+ /// </summary>
+ public sealed class AuthorizedConnectAppResult //: TwilioListBase
+ {
+ /// <summary>
+ /// The current page number. Zero-indexed, so the first page is 0.
+ /// </summary>
+ public int Page { get; set; }
+ /// <summary>
+ /// The total number of pages.
+ /// </summary>
+ public int NumPages { get; set; }
+ /// <summary>
+ /// How many items are in each page
+ /// </summary>
+ public int PageSize { get; set; }
+ /// <summary>
+ /// The total number of items in the list.
+ /// </summary>
+ public int Total { get; set; }
+ /// <summary>
+ /// The position in the overall list of the first item in this page.
+ /// </summary>
+ public int Start { get; set; }
+ /// <summary>
+ /// The position in the overall list of the last item in this page.
+ /// </summary>
+ public int End { get; set; }
+ /// <summary>
+ /// The URI for the first page of this list.
+ /// </summary>
+ public Uri FirstPageUri { get; set; }
+ /// <summary>
+ /// The URI for the next page of this list.
+ /// </summary>
+ public Uri NextPageUri { get; set; }
+ /// <summary>
+ /// The URI for the previous page of this list.
+ /// </summary>
+ public Uri PreviousPageUri { get; set; }
+ /// <summary>
+ /// The URI for the last page of this list.
+ /// </summary>
+ public Uri LastPageUri { get; set; }
+
+
+
+ /// <summary>
+ /// List of AuthorizedConnectApp instances returned by API
+ /// </summary>
+ public IList<AuthorizedConnectApp> AuthorizedConnectApps { get; set; }
+ }
+}
View
57 src/Twilio.WinRT/Model/AvailablePhoneNumber.cs
@@ -0,0 +1,57 @@
+using System;
+
+namespace Twilio
+{
+ /// <summary>
+ /// An AvailablePhoneNumber instance resource represents a single AvailablePhoneNumber.
+ /// </summary>
+ public sealed class AvailablePhoneNumber //: TwilioBase
+ {
+ /// <summary>
+ /// Exception encountered during API request
+ /// </summary>
+ public RestException RestException { get; set; }
+ /// <summary>
+ /// The URI for this resource, relative to https://api.twilio.com
+ /// </summary>
+ public Uri Uri { get; set; }
+
+
+ /// <summary>
+ /// A nicely-formatted version of the phone number.
+ /// </summary>
+ public string FriendlyName { get; set; }
+ /// <summary>
+ /// The phone number, in E.164 (i.e. "+1") format.
+ /// </summary>
+ public string PhoneNumber { get; set; }
+ /// <summary>
+ /// The LATA of this phone number.
+ /// </summary>
+ public string Lata { get; set; }
+ /// <summary>
+ /// The rate center of this phone number.
+ /// </summary>
+ public string RateCenter { get; set; }
+ /// <summary>
+ /// The latitude coordinate of this phone number.
+ /// </summary>
+ public double? Latitude { get; set; }
+ /// <summary>
+ /// The longitude coordinate of this phone number.
+ /// </summary>
+ public double? Longitude { get; set; }
+ /// <summary>
+ /// The two-letter state or province abbreviation of this phone number.
+ /// </summary>
+ public string Region { get; set; }
+ /// <summary>
+ /// The postal (zip) code of this phone number.
+ /// </summary>
+ public string PostalCode { get; set; }
+ /// <summary>
+ /// The ISO country code of this phone number.
+ /// </summary>
+ public string IsoCountry { get; set; }
+ }
+}
View
47 src/Twilio.WinRT/Model/AvailablePhoneNumberListRequest.cs
@@ -0,0 +1,47 @@
+using System;
+
+namespace Twilio
+{
+ /// <summary>
+ /// Search filter options for AvailablePhoneNumber search
+ /// </summary>
+ public sealed class AvailablePhoneNumberListRequest
+ {
+ /// <summary>
+ /// Find phone numbers in the specified Area Code. Only available for North American numbers.
+ /// </summary>
+ public string AreaCode { get; set; }
+ /// <summary>
+ /// A pattern to match phone numbers on. Valid characters are '*' and [0-9a-zA-Z]. The '*' character will match any single digit.
+ /// </summary>
+ public string Contains { get; set; }
+ /// <summary>
+ /// Limit results to a particular region (i.e. State/Province). Given a phone number, search within the same Region as that number.
+ /// </summary>
+ public string InRegion { get; set; }
+ /// <summary>
+ /// Limit results to a particular postal code. Given a phone number, search within the same postal code as that number.
+ /// </summary>
+ public string InPostalCode { get; set; }
+ /// <summary>
+ /// Given a latitude/longitude pair lat,long find geographically close numbers within Distance miles.
+ /// </summary>
+ public string NearLatLong { get; set; }
+ /// <summary>
+ /// Specifies the search radius for a Near- query in miles. If not specified this defaults to 25 miles.
+ /// </summary>
+ public int? Distance { get; set; }
+ /// <summary>
+ /// Given a phone number, find a geographically close number within Distance miles. Distance defaults to 25 miles.
+ /// </summary>
+ public string NearNumber { get; set; }
+ /// <summary>
+ /// Limit results to a specific Local access and transport area (LATA). Given a phone number, search within the same LATA as that number.
+ /// </summary>
+ public string InLata { get; set; }
+ /// <summary>
+ /// Limit results to a specific rate center, or given a phone number search within the same rate center as that number. Requires InLata to be set as well.
+ /// </summary>
+ public string InRateCenter { get; set; }
+ }
+}
View
60 src/Twilio.WinRT/Model/AvailablePhoneNumberResult.cs
@@ -0,0 +1,60 @@
+using System;
+using System.Collections.Generic;
+
+namespace Twilio
+{
+ /// <summary>
+ /// Twilio API call result with paging information
+ /// </summary>
+ public sealed class AvailablePhoneNumberResult //: TwilioListBase
+ {
+
+ /// <summary>
+ /// The current page number. Zero-indexed, so the first page is 0.
+ /// </summary>
+ public int Page { get; set; }
+ /// <summary>
+ /// The total number of pages.
+ /// </summary>
+ public int NumPages { get; set; }
+ /// <summary>
+ /// How many items are in each page
+ /// </summary>
+ public int PageSize { get; set; }
+ /// <summary>
+ /// The total number of items in the list.
+ /// </summary>
+ public int Total { get; set; }
+ /// <summary>
+ /// The position in the overall list of the first item in this page.
+ /// </summary>
+ public int Start { get; set; }
+ /// <summary>
+ /// The position in the overall list of the last item in this page.
+ /// </summary>
+ public int End { get; set; }
+ /// <summary>
+ /// The URI for the first page of this list.
+ /// </summary>
+ public Uri FirstPageUri { get; set; }
+ /// <summary>
+ /// The URI for the next page of this list.
+ /// </summary>
+ public Uri NextPageUri { get; set; }
+ /// <summary>
+ /// The URI for the previous page of this list.
+ /// </summary>
+ public Uri PreviousPageUri { get; set; }
+ /// <summary>
+ /// The URI for the last page of this list.
+ /// </summary>
+ public Uri LastPageUri { get; set; }
+
+
+
+ /// <summary>
+ /// List of AvailablePhoneNumbers search results
+ /// </summary>
+ public IList<AvailablePhoneNumber> AvailablePhoneNumbers { get; set; }
+ }
+}
View
88 src/Twilio.WinRT/Model/Call.cs
@@ -0,0 +1,88 @@
+using System;
+
+namespace Twilio
+{
+ /// <summary>
+ /// An Call instance resource represents a single Twilio Call.
+ /// </summary>
+ public sealed class Call //: TwilioBase
+ {
+ /// <summary>
+ /// Exception encountered during API request
+ /// </summary>
+ public RestException RestException { get; set; }
+ /// <summary>
+ /// The URI for this resource, relative to https://api.twilio.com
+ /// </summary>
+ public Uri Uri { get; set; }
+
+ /// <summary>
+ /// A 34 character string that uniquely identifies this resource.
+ /// </summary>
+ public string Sid { get; set; }
+ /// <summary>
+ /// A 34 character string that uniquely identifies the call that created this leg.
+ /// </summary>
+ public string ParentCallSid { get; set; }
+ /// <summary>
+ /// The date that this resource was created, given as GMT
+ /// </summary>
+ public DateTimeOffset DateCreated { get; set; }
+ /// <summary>