ctreminiom / go-atlassian

✨ Golang Client Library for Atlassian Cloud.
https://docs.go-atlassian.io
MIT License
114 stars 29 forks source link

Added Raw custom field function to add custom structs to fields #277

Open Fank opened 4 days ago

Fank commented 4 days ago

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post

I wanted to add timetracking to fields, and did not found a function for it so i added Raw to add a custom defined type to jira fields. From the example:

    "timetracking": {
      "originalEstimate": "10",
      "remainingEstimate": "5"
    },

How I use it:

fields.Raw("timetracking", map[string]any{
    "originalEstimate": fmt.Sprintf("%.0fm", position.OrderOriginalEstimate),
}),

Personally I would prefer a typed variation, but I did not find any kind of information about it. But to provide the ability to define it, I decided to go for a Raw function which can handle any type.