本文整理汇总了C#中RestSharp.RestRequest.AddParameterIfHasValue方法的典型用法代码示例。如果您正苦于以下问题:C# RestRequest.AddParameterIfHasValue方法的具体用法?C# RestRequest.AddParameterIfHasValue怎么用?C# RestRequest.AddParameterIfHasValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RestSharp.RestRequest
的用法示例。
在下文中一共展示了RestRequest.AddParameterIfHasValue方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PutParams
internal void PutParams(RestRequest request)
{
Require.Argument("Name", Name);
request.AddParameter("Name", Name);
request.AddParameterIfHasValue("Note", Note);
}
示例2: GetContacts
/// <summary>
/// Get a list of contacts stored in your Ez Texting contact list.
/// </summary>
/// <param name="query">(Optional) Search contacts by first name / last name / phone number</param>
/// <param name="source">(Optional) Source of contacts. Available values: 'Unknown', 'Manually Added', 'Upload', 'Web Widget', 'API', 'Keyword'</param>
/// <param name="optout">(Optional) Opted out / opted in contacts. Available values: true, false.</param>
/// <param name="group">(Optional) Name of the group the contacts belong to</param>
/// <param name="sortBy">(Optional) Property to sort by. Available values: PhoneNumber, FirstName, LastName, CreatedAt</param>
/// <param name="sortDir">(Optional) Direction of sorting. Available values: asc, desc</param>
/// <param name="itemsPerPage">(Optional) Number of results to retrieve. By default, 10 most recently added contacts are retrieved.</param>
/// <param name="page">(Optional) Page of results to retrieve</param>
/// <returns></returns>
public List<Contact> GetContacts(string query, string source, string optout, string group, string sortBy, string sortDir, string itemsPerPage, string page)
{
var request = new RestRequest();
request.Resource = "contacts";
request.AddParameterIfHasValue("query", query);
request.AddParameterIfHasValue("source", source);
request.AddParameterIfHasValue("optout", optout);
request.AddParameterIfHasValue("group", group);
request.AddParameterIfHasValue("sortBy", sortBy);
request.AddParameterIfHasValue("sortDir", sortDir);
request.AddParameterIfHasValue("itemsPerPage", itemsPerPage);
request.AddParameterIfHasValue("page", page);
return Execute<ContactsWrapper>(request).Entries;
}
示例3: PutParams
internal void PutParams(RestRequest request)
{
Require.Argument("PhoneNumber", PhoneNumber);
request.AddParameter("PhoneNumber", PhoneNumber);
request.AddParameterIfHasValue("FirstName", FirstName);
request.AddParameterIfHasValue("LastName", LastName);
request.AddParameterIfHasValue("Email", Email);
request.AddParameterIfHasValue("Note", Note);
if (Groups != null)
{
for (int i = 0; i < Groups.Count; i++)
{
request.AddParameter("Groups[" + i + "]", Groups[i]);
}
}
}