Exemplo n.º 1
0
        /// <summary>
        /// Create a new Assignment, which will apply the Legal Hold Policy to the target of the Assignment.
        /// </summary>
        /// <param name="createRequest">BoxLegalHoldPolicyAssignmentRequest object.</param>
        /// <returns>For a successful request, returns object with information about the Assignment created.
        /// If the policy or assign-to target cannot be found, null will be returned.
        /// </returns>
        public async Task <BoxLegalHoldPolicyAssignment> CreateAssignmentAsync(BoxLegalHoldPolicyAssignmentRequest createRequest)
        {
            createRequest.ThrowIfNull("createRequest")
            .PolicyId.ThrowIfNullOrWhiteSpace("createRequest.PolicyId");
            createRequest.AssignTo.ThrowIfNull("createRequest.AssignTo")
            .Id.ThrowIfNullOrWhiteSpace("createRequest.AssignTo.Id");
            createRequest.AssignTo.Type.ThrowIfNull("createRequest.AssignTo.Type");

            BoxRequest request = new BoxRequest(_config.LegalHoldPolicyAssignmentsEndpointUri)
                                 .Method(RequestMethod.Post)
                                 .Payload(_converter.Serialize(createRequest));

            IBoxResponse <BoxLegalHoldPolicyAssignment> response = await ToResponseAsync <BoxLegalHoldPolicyAssignment>(request).ConfigureAwait(false);

            return(response.ResponseObject);
        }