/// <summary>
 /// Perform a transition on an issue. When performing the transition you can update or set other issue fields.
 /// </summary>
 /// <param name="issue">The issue on which to obtain the available transitions for.</param>
 /// <param name="transitionInput">Information about the transition to perform.</param>
 /// <exception cref="WebServiceException">There is no transition specified, or the requested issue is not found, or the user does not have permission to view it.</exception>
 public void Transition(Issue issue, TransitionInput transitionInput)
 {
     Transition(issue.TransitionsUri ?? issue.Self.Append("transitions"), transitionInput);
 }
        /// <summary>
        /// Removes a label from an issue.
        /// </summary>
        /// <param name="issue">The issue to remove the label from.</param>
        /// <param name="label">The label to remove.</param>
        public void RemoveLabel(Issue issue, string label)
        {
            if (issue == null)
            {
                throw new ArgumentNullException("issue");
            }

            if (string.IsNullOrWhiteSpace(label))
            {
                throw new ArgumentException("Label cannot be empty", "label");
            }

            var update = new UpdateFieldInput(IssueFieldId.Labels);
            update.AddOperation(StandardOperation.Remove, label);

            var json = IssueEditMetaJsonGenerator.Generate(new List<UpdateFieldInput> { update });
            client.Put<JsonObject>(issue.Self.ToString(), json);
        }
        /// <summary>
        /// Get a list of the transitions possible for this issue by the current user, along with fields that are required and their types.
        /// </summary>
        /// <param name="issue">The issue on which to obtain the available transitions for.</param>
        /// <returns>Transition information about the transitions available for the selected issue in its current state.</returns>
        /// <exception cref="WebServiceException">The requested issue is not found, or the user does not have permission to view it.</exception>
        public IEnumerable<Transition> GetTransitions(Issue issue)
        {
            if (issue.TransitionsUri != null)
            {
                return GetTransitions(issue.TransitionsUri);
            }

            var uri = issue.Self.Append("transitions");
            return GetTransitions(uri);
        }
 /// <summary>
 /// Assigns an issue to the automatic assignee or removes the assignee entirely.
 /// </summary>
 /// <param name="issue">The issue to make the assignment for.</param>
 /// <param name="assignee">The special assignee type.</param>
 public void AssignTo(Issue issue, SpecialAssignee assignee)
 {
     var user = assignee == SpecialAssignee.Automatic ? "-1" : null;
     AssignTo(issue, user);
 }
        /// <summary>
        /// Assigns an issue to a user.
        /// </summary>
        /// <param name="issue">The issue to make the assignment for.</param>
        /// <param name="user">The username of the person to assign the issue to.</param>
        public void AssignTo(Issue issue, string user)
        {
            if (issue == null)
            {
                throw new ArgumentNullException("issue");
            }

            var request = new JsonObject { { "name", user } };
            client.Put<JsonObject>(issue.Self.Append(AssigneeUriPostfix).ToString(), request);
        }
        internal static Issue IssueJsonParser(JsonObject json)
        {
            var issue = new Issue(json.Get<int>("id"), json.Get<string>("key"), json.Get<Uri>("self"));
            var fields = json.Get<JsonObject>("fields");
            if (fields != null)
            {
                issue.Summary = fields.Get<string>("summary");
                issue.Reporter = fields.Get<User>("reporter");
                issue.Assignee = fields.Get<User>("assignee");
                issue.Description = fields.Get<string>("description");
                issue.Project = fields.Get<BasicProject>("project");

                if (fields.ContainsKey("transitions"))
                {
                    issue.TransitionsUri = fields.Get<Uri>("transitions");
                }
                else if (issue.Self != null)
                {
                    issue.TransitionsUri = issue.Self.Append("transitions");
                }

                issue.FixVersions = fields.Get<IEnumerable<JiraVersion>>("fixVersions");
                issue.AffectedVersions = fields.Get<IEnumerable<JiraVersion>>("versions");
                issue.Watchers = fields.Get<BasicWatchers>("watches");
                issue.Votes = fields.Get<BasicVotes>("votes");
                issue.Attachments = fields.Get<IEnumerable<Attachment>>("attachment");
                issue.Labels = fields.Get<IEnumerable<string>>("labels");
            }

            return issue;
        }