internal static JsonObject Generate(TransitionInput transitionInput, ServerInfo serverInfo) { var jsonObject = new JsonObject(); if (serverInfo.BuildNumber >= ServerVersionConstants.BuildNumberJira5) { var id = new JsonObject { { "id", transitionInput.Id.ToString() } }; jsonObject.Add("transition", id.ToJson()); } else { jsonObject.Add("transition", transitionInput.Id.ToString()); } if (transitionInput.Comment != null) { var comment = CommentJsonGenerator.Generate(transitionInput.Comment, serverInfo).ToJson(); if (serverInfo.BuildNumber >= ServerVersionConstants.BuildNumberJira5) { var jsonComment = new JsonArrayObjects { new JsonObject { { "add", comment } } }; var jsonUpdate = new JsonObject { { "comment", jsonComment.ToJson() } }; jsonObject.Add("update", jsonUpdate.ToJson()); } else { jsonObject.Add("comment", comment); } } if (transitionInput.Fields != null && transitionInput.Fields.Any()) { var list = transitionInput.Fields.Where(f => f.Value != null).ToDictionary(f => f.Id, f => ComplexIssueInputFieldValueJsonGenerator.GenerateFieldValueForJson(f.Value)); jsonObject.Add("fields", list.ToJson()); } return jsonObject; }
/// <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> /// Perform a transition on an issue. When performing the transition you can update or set other issue fields. /// </summary> /// <param name="transitionsUri">URI of transitions resource of selected issue. Usually obtained by getting the <see cref="Issue.TransitionsUri"/> property.</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(Uri transitionsUri, TransitionInput transitionInput) { var json = TransitionInputJsonGenerator.Generate(transitionInput, GetServerInfo()); client.Post<JsonObject>(transitionsUri.ToString(), json); }