本文整理汇总了C#中Simple.RestRequest类的典型用法代码示例。如果您正苦于以下问题:C# RestRequest类的具体用法?C# RestRequest怎么用?C# RestRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RestRequest类属于Simple命名空间,在下文中一共展示了RestRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddApplication
/// <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>
/// <param name="callback">Method to call upon successful completion</param>
public virtual void AddApplication(string friendlyName, ApplicationOptions options, Action<Application> callback)
{
var request = new RestRequest(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());
}
ExecuteAsync<Application>(request, (response) => { callback(response); });
}
示例2: ListVoiceCountriesAsync
public virtual async Task<VoiceCountryResult> ListVoiceCountriesAsync()
{
var request = new RestRequest(Method.GET);
request.Resource = "Voice/Countries";
return await Execute<VoiceCountryResult>(request);
}
示例3: GetSandbox
/// <summary>
/// Returns the Sandbox resource associated with the account identified by {YourAccountSid}.
/// Twilio accounts upgraded prior to February 2010 may not have a Sandbox resource, and in this case you will receive a 404 (Not Found) response.
/// Makes a GET request to the Sandbox Instance resource.
/// </summary>
public virtual Sandbox GetSandbox()
{
var request = new RestRequest();
request.Resource = "Accounts/{AccountSid}/Sandbox.json";
return Execute<Sandbox>(request);
}
示例4: ListMessagesAsync
/// <summary>
/// Returns a filtered list of Messages. The list includes paging information.
/// Makes a GET request to the Messages List resource.
/// </summary>
/// <param name="options">The list filters for the request</param>
public virtual async Task<MessageResult> ListMessagesAsync(MessageListRequest options)
{
var request = new RestRequest();
request.Resource = "Accounts/{AccountSid}/Messages.json";
AddMessageListOptions(options, request);
return await Execute<MessageResult>(request);
}
示例5: ListVoiceCountries
public virtual void ListVoiceCountries(Action<VoiceCountryResult> callback)
{
var request = new RestRequest(Method.GET);
request.Resource = "Voice/Countries";
ExecuteAsync<VoiceCountryResult>(request, (response) => callback(response));
}
示例6: ListSubAccounts
/// <summary>
/// List all subaccounts created for the authenticated account. Makes a GET request to the Account List resource.
/// </summary>
public virtual AccountResult ListSubAccounts()
{
var request = new RestRequest();
request.Resource = "Accounts.json";
return Execute<AccountResult>(request);
}
示例7: ListPhoneNumberCountries
public virtual PhoneNumberCountryResult ListPhoneNumberCountries()
{
var request = new RestRequest(Method.GET);
request.Resource = "PhoneNumbers/Countries";
return Execute<PhoneNumberCountryResult>(request);
}
示例8: GetAccountAsync
/// <summary>
/// Retrieve the account details for the currently authenticated account. Makes a GET request to an Account Instance resource.
/// </summary>
public virtual async Task<Account> GetAccountAsync()
{
var request = new RestRequest();
request.Resource = "Accounts/{AccountSid}.json";
return await Execute<Account>(request);
}
示例9: ListPhoneNumberCountriesAsync
public virtual async Task<PhoneNumberCountryResult> ListPhoneNumberCountriesAsync()
{
var request = new RestRequest(Method.GET);
request.Resource = "PhoneNumbers/Countries";
return await Execute<PhoneNumberCountryResult>(request);
}
示例10: AddCallOptions
private static 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");
if (options.SipAuthUsername.HasValue()) request.AddParameter("SipAuthUsername", options.SipAuthUsername);
if (options.SipAuthPassword.HasValue()) request.AddParameter("SipAuthPassword", options.SipAuthPassword);
}
示例11: GetSandbox
/// <summary>
/// Returns the Sandbox resource associated with the account identified by {YourAccountSid}. Twilio accounts upgraded prior to February 2010 may not have a Sandbox resource, and in this case you will receive a 404 (Not Found) response.
/// </summary>
/// <param name="callback">Method to call upon successful completion</param>
public virtual void GetSandbox(Action<Sandbox> callback)
{
var request = new RestRequest();
request.Resource = "Accounts/{AccountSid}/Sandbox.json";
ExecuteAsync<Sandbox>(request, callback);
}
示例12: ListQueues
/// <summary>
/// Return a list of all Queue resources
/// </summary>
/// <param name="callback">Method to call upon successful completion</param>
/// <returns></returns>
public virtual void ListQueues(Action<QueueResult> callback)
{
var request = new RestRequest();
request.Resource = "Accounts/{AccountSid}/Queues.json";
ExecuteAsync<QueueResult>(request, (response) => callback(response) );
}
示例13: ListQueues
/// <summary>
/// Return a list of all Queue resources
/// </summary>
/// <returns></returns>
public virtual QueueResult ListQueues()
{
var request = new RestRequest();
request.Resource = "Accounts/{AccountSid}/Queues.json";
return Execute<QueueResult>(request);
}
示例14: GetSandboxAsync
/// <summary>
/// Returns the Sandbox resource associated with the account identified by {YourAccountSid}.
/// Twilio accounts upgraded prior to February 2010 may not have a Sandbox resource, and in this case you will receive a 404 (Not Found) response.
/// Makes a GET request to the Sandbox Instance resource.
/// </summary>
public virtual async Task<Sandbox> GetSandboxAsync()
{
var request = new RestRequest();
request.Resource = "Accounts/{AccountSid}/Sandbox.json";
return await Execute<Sandbox>(request);
}
示例15: GetAccount
/// <summary>
/// Retrieve the account details for the currently authenticated account
/// </summary>
/// <param name="callback">Method to call upon successful completion</param>
public virtual void GetAccount(Action<Account> callback)
{
var request = new RestRequest();
request.Resource = "Accounts/{AccountSid}.json";
ExecuteAsync<Account>(request, (response) => { callback(response); });
}