55 "strings"
66
77 "github.com/trivago/tgo/tcontainer"
8+ "github.com/google/go-querystring/query"
89)
910
1011// CreateMetaInfo contains information about fields and their attributed to create a ticket.
@@ -36,20 +37,31 @@ type MetaIssueType struct {
3637 Description string `json:"description,omitempty"`
3738 IconUrl string `json:"iconurl,omitempty"`
3839 Name string `json:"name,omitempty"`
39- Subtasks bool `json:"subtask,omitempty"`
40+ Subtasks bool `json:"subtask,omitempty"`
4041 Expand string `json:"expand,omitempty"`
4142 Fields tcontainer.MarshalMap `json:"fields,omitempty"`
4243}
4344
4445// GetCreateMeta makes the api call to get the meta information required to create a ticket
4546func (s * IssueService ) GetCreateMeta (projectkey string ) (* CreateMetaInfo , * Response , error ) {
47+ return s .GetCreateMetaWithOptions (& GetQueryOptions {ProjectKey : projectkey , Expand : "projects.issuetypes.fields" })
48+ }
4649
47- apiEndpoint := fmt .Sprintf ("rest/api/2/issue/createmeta?projectKeys=%s&expand=projects.issuetypes.fields" , projectkey )
50+ // GetCreateMetaWithOptions makes the api call to get the meta information without requiring to have a projectKey
51+ func (s * IssueService ) GetCreateMetaWithOptions (options * GetQueryOptions ) (* CreateMetaInfo , * Response , error ) {
52+ apiEndpoint := "rest/api/2/issue/createmeta"
4853
4954 req , err := s .client .NewRequest ("GET" , apiEndpoint , nil )
5055 if err != nil {
5156 return nil , nil , err
5257 }
58+ if options != nil {
59+ q , err := query .Values (options )
60+ if err != nil {
61+ return nil , nil , err
62+ }
63+ req .URL .RawQuery = q .Encode ()
64+ }
5365
5466 meta := new (CreateMetaInfo )
5567 resp , err := s .client .Do (req , meta )
@@ -60,7 +72,6 @@ func (s *IssueService) GetCreateMeta(projectkey string) (*CreateMetaInfo, *Respo
6072
6173 return meta , resp , nil
6274}
63-
6475// GetProjectWithName returns a project with "name" from the meta information received. If not found, this returns nil.
6576// The comparison of the name is case insensitive.
6677func (m * CreateMetaInfo ) GetProjectWithName (name string ) * MetaProject {
0 commit comments