internal static JsonObject Generate(Comment comment, ServerInfo serverInfo)
        {
            var json = new JsonObject();

            if (comment.Body != null)
            {
                json.Add("body", comment.Body);
            }

            if (comment.Visibility != null)
            {
                if (serverInfo.BuildNumber >= ServerVersionConstants.BuildNumberJira43)
                {
                    var visibilityJson = new JsonObject();
                    var commentVisibilityType = comment.Visibility.Type == Visibility.VisibilityType.Group ? "group" : "role";

                    if (serverInfo.BuildNumber < ServerVersionConstants.BuildNumberJira5)
                    {
                        commentVisibilityType = commentVisibilityType.ToUpper();
                    }

                    visibilityJson.Add("type", commentVisibilityType);
                    visibilityJson.Add("value", comment.Visibility.Value);
                    json.Add("visibility", visibilityJson.ToJson());
                }
                else
                {
                    json.Add(comment.Visibility.Type == Visibility.VisibilityType.Role ? "role" : "group", comment.Visibility.Value);
                }
            }

            return json;
        }
        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;
        }
 private ServerInfo GetServerInfo()
 {
     return serverInfo ?? (serverInfo = metadataClient.GetServerInfo());
 }