internal static JsonObject Generate(LinkIssuesInput linkIssuesInput, ServerInfo serverInfo) { var json = new JsonObject(); if (serverInfo.BuildNumber >= ServerVersionConstants.BuildNumberJira5) { var jsonType = new JsonObject { { "name", linkIssuesInput.LinkType } }; var jsonInward = new JsonObject { { "key", linkIssuesInput.FromIssueKey } }; var jsonOutward = new JsonObject { { "key", linkIssuesInput.ToIssueKey } }; json.Add("type", jsonType.ToJson()); json.Add("inwardIssue", jsonInward.ToJson()); json.Add("outwardIssue", jsonOutward.ToJson()); } else { json.Add("linkType", linkIssuesInput.LinkType); json.Add("fromIssueKey", linkIssuesInput.FromIssueKey); json.Add("toIssueKey", linkIssuesInput.ToIssueKey); } if (linkIssuesInput.Comment != null) { json.Add("comment", CommentJsonGenerator.Generate(linkIssuesInput.Comment, serverInfo).ToJson()); } 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); }