本文整理汇总了C#中Simple.RestRequest.AddParameter方法的典型用法代码示例。如果您正苦于以下问题:C# RestRequest.AddParameter方法的具体用法?C# RestRequest.AddParameter怎么用?C# RestRequest.AddParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Simple.RestRequest
的用法示例。
在下文中一共展示了RestRequest.AddParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: When_Request_Method_Is_POST_Then_Request_Body_Contains_Encoded_Parameters
public void When_Request_Method_Is_POST_Then_Request_Body_Contains_Encoded_Parameters()
{
string body = "Foo=12345&Bar=abcde";
var sourcebytes = Encoding.UTF8.GetBytes(body);
client = new RestClient();
client.BaseUrl = BASE_URL;
var request = new RestRequest();
request.Method = "POST";
request.AddParameter("Foo", "12345");
request.AddParameter("Bar", "abcde");
var wrapper = new HttpWebRequestWrapper();
wrapper.Request = new FakeHttpWebRequest();
var webrequest = (FakeHttpWebRequest)wrapper.ConfigureRequest(client, request);
var stream = webrequest.GetRequestStream();
stream.Position = 0;
byte[] actualbytes = stream.ReadAsBytes();
Assert.AreEqual(sourcebytes.Length, webrequest.ContentLength);
Assert.AreEqual(sourcebytes.Length, actualbytes.Length);
CollectionAssert.AreEquivalent(sourcebytes, actualbytes);
}
示例2: ListTranscriptions
/// <summary>
/// Returns a paged set of Transcriptions that includes paging information.
/// Makes a GET request to the Transcriptions List resource.
/// </summary>
/// <param name="pageNumber">The page to start retrieving results from</param>
/// <param name="count">The number of results to retrieve</param>
public virtual TranscriptionResult ListTranscriptions(int? pageNumber, int? count)
{
var request = new RestRequest();
request.Resource = "Accounts/{AccountSid}/Transcriptions.json";
if (pageNumber.HasValue) request.AddParameter("Page", pageNumber.Value);
if (count.HasValue) request.AddParameter("PageSize", count.Value);
return Execute<TranscriptionResult>(request);
}
示例3: ListTranscriptions
/// <summary>
/// Returns a paged set of Transcriptions that includes paging information, sorted by 'DateUpdated', with most recent transcripts first.
/// </summary>
/// <param name="pageNumber">The page to start retrieving results from</param>
/// <param name="count">The number of results to retrieve</param>
/// <param name="callback">The method to call upon the completion of the request</param>
public virtual void ListTranscriptions(int? pageNumber, int? count, Action<TranscriptionResult> callback)
{
var request = new RestRequest();
request.Resource = "Accounts/{AccountSid}/Transcriptions.json";
if (pageNumber.HasValue) request.AddParameter("Page", pageNumber.Value);
if (count.HasValue) request.AddParameter("PageSize", count.Value);
ExecuteAsync<TranscriptionResult>(request, (response) => callback(response));
}
示例4: CreateQueue
/// <summary>
/// Creates a new Queue resource
/// </summary>
/// <param name="friendlyName">The name of the Queue</param>
/// <param name="maxSize">The maximum number of calls allowed in the queue</param>
/// <param name="callback">Method to call upon successful completion</param>
/// <returns></returns>
public virtual void CreateQueue(string friendlyName, int maxSize, Action<Queue> callback)
{
var request = new RestRequest(Method.POST);
request.Resource = "Accounts/{AccountSid}/Queues.json";
request.AddParameter("FriendlyName", friendlyName);
request.AddParameter("MaxSize", maxSize);
ExecuteAsync<Queue>(request, (response) => callback(response));
}
示例5: DeleteMessageMedia
/// <summary>
/// Delete the specified media instance. Makes a DELETE request to a
/// Media Instance resource.
/// </summary>
/// <param name="messageSid"></param>
/// <param name="mediaSid">The Sid of the media to delete</param>
/// <param name="callback"></param>
public virtual void DeleteMessageMedia(string messageSid, string mediaSid, Action<DeleteStatus> callback)
{
var request = new RestRequest(Method.DELETE);
request.Resource = "Accounts/{AccountSid}/Messages/{MessageSid}/Media/{MediaSid}.json";
request.AddParameter("MediaSid", mediaSid, ParameterType.UrlSegment);
request.AddParameter("MessageSid", messageSid, ParameterType.UrlSegment);
ExecuteAsync(request, (response) => { callback(response.StatusCode == System.Net.HttpStatusCode.NoContent ? DeleteStatus.Success : DeleteStatus.Failed); });
}
示例6: ListConnectApps
/// <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 virtual ConnectAppResult ListConnectApps(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);
return Execute<ConnectAppResult>(request);
}
示例7: ListDomainsAsync
/// <summary>
/// Return a list of all SIP Domain resources
/// </summary>
/// <param name="pageNumber"></param>
/// <param name="count"></param>
/// <returns></returns>
public virtual async Task<DomainResult> ListDomainsAsync(int? pageNumber, int? count)
{
var request = new RestRequest();
request.Resource = "Accounts/{AccountSid}/SIP/Domains.json";
if (pageNumber.HasValue) request.AddParameter("Page", pageNumber.Value);
if (count.HasValue) request.AddParameter("PageSize", count.Value);
return await Execute<DomainResult>(request);
}
示例8: ListAuthorizedConnectApps
/// <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>
/// <param name="callback">Method to call upon successful completion</param>
public virtual void ListAuthorizedConnectApps(int? pageNumber, int? count, Action<AuthorizedConnectAppResult> callback)
{
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);
ExecuteAsync<AuthorizedConnectAppResult>(request, (response) => { callback(response); });
}
示例9: ListAuthorizedConnectAppsAsync
/// <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 virtual async Task<AuthorizedConnectAppResult> ListAuthorizedConnectAppsAsync(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);
return await Execute<AuthorizedConnectAppResult>(request);
}
示例10: CreateQueueAsync
/// <summary>
/// Creates a new Queue resource
/// </summary>
/// <param name="friendlyName">The name of the Queue</param>
/// <param name="maxSize">The maximum number of calls allowed in the queue</param>
/// <returns></returns>
public virtual async Task<Queue> CreateQueueAsync(string friendlyName, int maxSize)
{
var request = new RestRequest(Method.POST);
request.Resource = "Accounts/{AccountSid}/Queues.json";
request.AddParameter("FriendlyName", friendlyName);
request.AddParameter("MaxSize", maxSize);
return await Execute<Queue>(request);
}
示例11: ListApplications
/// <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>
/// <param name="callback">Method to call upon successful completion</param>
public virtual void ListApplications(string friendlyName, int? pageNumber, int? count, Action<ApplicationResult> callback)
{
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);
ExecuteAsync<ApplicationResult>(request, callback);
}
示例12: When_Request_Method_Is_GET_Then_Request_Body_Does_Not_Contain_Encoded_Parameters
public void When_Request_Method_Is_GET_Then_Request_Body_Does_Not_Contain_Encoded_Parameters()
{
var request = new RestRequest();
request.Method = "GET";
request.AddParameter("Foo", "12345");
request.AddParameter("Bar", "abcde");
var requestmessage = client.ConfigureRequestMessage(request);
Assert.IsNull(requestmessage.Content);
}
示例13: When_Request_Method_Is_POST_Then_ContentType_Is_FormEncoded
public void When_Request_Method_Is_POST_Then_ContentType_Is_FormEncoded()
{
var request = new RestRequest();
request.Method = "POST";
request.AddParameter("Foo", "12345");
request.AddParameter("Bar", "abcde");
var requestmessage = client.ConfigureRequestMessage(request);
Assert.AreEqual("application/x-www-form-urlencoded", requestmessage.Content.Headers.ContentType.MediaType);
}
示例14: ListApplicationsAsync
/// <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 virtual async Task<ApplicationResult> ListApplicationsAsync(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 await Execute<ApplicationResult>(request);
}
示例15: DeleteMessageMediaAsync
/// <summary>
/// Delete the specified media instance. Makes a DELETE request to a
/// Media Instance resource.
/// </summary>
/// <param name="mediaSid">The Sid of the media to delete</param>
public virtual async Task<DeleteStatus> DeleteMessageMediaAsync(string messageSid, string mediaSid)
{
var request = new RestRequest(Method.DELETE);
request.Resource = "Accounts/{AccountSid}/Messages/{MessageSid}/Media/{MediaSid}.json";
request.AddParameter("MediaSid", mediaSid, ParameterType.UrlSegment);
request.AddParameter("MessageSid", messageSid, ParameterType.UrlSegment);
var response = await Execute(request);
return response.StatusCode == System.Net.HttpStatusCode.NoContent ? DeleteStatus.Success : DeleteStatus.Failed;
}