本文整理汇总了C#中BoxRequest.Param方法的典型用法代码示例。如果您正苦于以下问题:C# BoxRequest.Param方法的具体用法?C# BoxRequest.Param怎么用?C# BoxRequest.Param使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoxRequest
的用法示例。
在下文中一共展示了BoxRequest.Param方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAllGroupsAsync
/// <summary>
/// Retrieves all of the groups for given enterprise. Must have permissions to see an enterprise's groups.
/// </summary>
/// <param name="limit">The number of results to return with this request. Refer to the Box API for defaults.</param>
/// <param name="offset">The offset of the results. Refer to the Box API for more details.</param>
/// <param name="fields">Attribute(s) to include in the response.</param>
/// <param name="autoPaginate">Whether or not to auto-paginate to fetch all groups; defaults to false.</param>
/// <returns>A collection of groups.</returns>
public async Task<BoxCollection<BoxGroup>> GetAllGroupsAsync(int? limit = null, int? offset = null, List<string> fields = null, bool autoPaginate = false)
{
BoxRequest request = new BoxRequest(_config.GroupsEndpointUri)
.Param(ParamFields, fields)
.Param("limit", limit.ToString())
.Param("offset", offset.ToString());
if (autoPaginate)
{
if (!limit.HasValue)
{
limit = 100;
request.Param("limit", limit.ToString());
}
if (!offset.HasValue)
request.Param("offset", "0");
return await AutoPaginateLimitOffset<BoxGroup>(request, limit.Value);
}
else
{
IBoxResponse<BoxCollection<BoxGroup>> response = await ToResponseAsync<BoxCollection<BoxGroup>>(request).ConfigureAwait(false);
return response.ResponseObject;
}
}
示例2: SearchAsync
/// <summary>
/// Returns a collection of search results that match the keyword, if there are are no matching search results
/// an empty collection will be returned
/// </summary>
/// <param name="keyword"></param>
/// <param name="limit"></param>
/// <param name="offset"></param>
/// <param name="extraParameters">additional search parameters, see https://developers.box.com/docs/#search-searching-for-content </param>
/// <returns></returns>
public async Task<BoxCollection<BoxItem>> SearchAsync(string keyword, int limit, int offset = 0, Dictionary<string,string> extraParameters = null)
{
keyword.ThrowIfNullOrWhiteSpace("keyword");
BoxRequest request = new BoxRequest(_config.SearchEndpointUri)
.Param("query", keyword)
.Param("limit", limit.ToString())
.Param("offset", offset.ToString());
if (extraParameters != null)
{
if (extraParameters.ContainsKey("query"))
{
throw new ArgumentException("ExtraParamters can not contain query paramter","extraParamters");
}
foreach (string key in extraParameters.Keys)
{
request.Param(key, extraParameters[key]);
}
}
IBoxResponse<BoxCollection<BoxItem>> response = await ToResponseAsync<BoxCollection<BoxItem>>(request).ConfigureAwait(false);
return response.ResponseObject;
}
示例3: AddCollaborationAsync
/// <summary>
/// Used to add a collaboration for a single user or a single group to a folder.
/// Either an email address, a user ID, or a group id can be used to create the collaboration.
/// If the collaboration is being created with a group, access to this endpoint is granted based on the group's invitability_level.
/// </summary>
/// <param name="collaborationRequest">BoxCollaborationRequest object.</param>
/// <param name="fields">Attribute(s) to include in the response.</param>
/// <param name="notify">Determines if the user, (or all the users in the group) should receive email notification of the collaboration.</param>
/// <returns>The new collaboration object is returned. Errors may occur if the IDs are invalid or if the user does not have permissions to create a collaboration.</returns>
public async Task<BoxCollaboration> AddCollaborationAsync(BoxCollaborationRequest collaborationRequest, List<string> fields = null, bool? notify = null)
{
collaborationRequest.ThrowIfNull("collaborationRequest")
.Item.ThrowIfNull("collaborationRequest.Item")
.Id.ThrowIfNullOrWhiteSpace("collaborationRequest.Item.Id");
collaborationRequest.AccessibleBy.ThrowIfNull("collaborationRequest.AccessibleBy");
collaborationRequest.Role.ThrowIfNullOrWhiteSpace("Role");
BoxRequest request = new BoxRequest(_config.CollaborationsEndpointUri)
.Method(RequestMethod.Post)
.Param(ParamFields, fields)
.Payload(_converter.Serialize(collaborationRequest));
if (notify.HasValue)
{
var value = notify.Value ? "true" : "false";
request.Param("notify", value);
}
IBoxResponse<BoxCollaboration> response = await ToResponseAsync<BoxCollaboration>(request).ConfigureAwait(false);
return response.ResponseObject;
}
示例4: GetAllGroupMembershipsForUserAsync
/// <summary>
/// Get the list of group memberships for a given user.
/// </summary>
/// <param name="userId">The id of the user to get the list of memberships for.</param>
/// <param name="limit">The number of results to return with this request. Refer to the Box API for defaults.</param>
/// <param name="offset">The offset of the results. Refer to the Box API for more details.</param>
/// <param name="fields">Attribute(s) to include in the response.</param>
/// <param name="autoPaginate">Whether or not to auto-paginate to fetch all group memberships; defaults to false.</param>
/// <returns>A collection of group memberships for the specified user id.</returns>
public async Task<BoxCollection<BoxGroupMembership>> GetAllGroupMembershipsForUserAsync(string userId, int? limit = null, int? offset = null,
List<string> fields = null, bool autoPaginate = false)
{
userId.ThrowIfNullOrWhiteSpace("userId");
BoxRequest request = new BoxRequest(_config.UserEndpointUri, string.Format(Constants.GroupMembershipPathString, userId))
.Param(ParamFields, fields)
.Param("limit", limit.ToString())
.Param("offset", offset.ToString());
if (autoPaginate)
{
if (!limit.HasValue)
{
limit = 100;
request.Param("limit", limit.ToString());
}
if (!offset.HasValue)
request.Param("offset", "0");
return await AutoPaginateLimitOffset<BoxGroupMembership>(request, limit.Value);
}
else
{
IBoxResponse<BoxCollection<BoxGroupMembership>> response = await ToResponseAsync<BoxCollection<BoxGroupMembership>>(request).ConfigureAwait(false);
return response.ResponseObject;
}
}
示例5: GetCollaborationsForGroupAsync
/// <summary>
/// Retrieves all of the group collaborations for a given group. Note this is only available to group admins.
/// </summary>
/// <param name="groupId">The id of the group to get the list of collaborations for.</param>
/// <param name="limit">The number of results to return with this request. Refer to the Box API for defaults.</param>
/// <param name="offset">The offset of the results. Refer to the Box API for more details.</param>
/// <param name="fields">Attribute(s) to include in the response.</param>
/// <param name="autoPaginate">Whether or not to auto-paginate to fetch all group collaborations; defaults to false.</param>
/// <returns>A collection of collaborations for the specified group id.</returns>
public async Task<BoxCollection<BoxCollaboration>> GetCollaborationsForGroupAsync(string groupId, int? limit = null, int? offset = null,
List<string> fields = null, bool autoPaginate = false)
{
var request = new BoxRequest(_config.GroupsEndpointUri, string.Format(Constants.CollaborationsPathString, groupId))
.Param(ParamFields, fields)
.Param("limit", limit.ToString())
.Param("offset", offset.ToString()); ;
if (autoPaginate)
{
if (!limit.HasValue)
{
limit = 100;
request.Param("limit", limit.ToString());
}
if(!offset.HasValue)
request.Param("offset", "0");
return await AutoPaginateLimitOffset<BoxCollaboration>(request, limit.Value);
}
else
{
var response = await ToResponseAsync<BoxCollection<BoxCollaboration>>(request).ConfigureAwait(false);
return response.ResponseObject;
}
}