Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 issue_impl_adf.go edited #302

Merged
merged 1 commit into from
Aug 11, 2024
Merged

🐛 issue_impl_adf.go edited #302

merged 1 commit into from
Aug 11, 2024

Conversation

ctreminiom
Copy link
Owner

@ctreminiom ctreminiom commented Aug 11, 2024

  1. Fixed the Issue.Created() method when the customfield struct is provided without any fields.
  2. Relates to Custom Fields not optional during issue create? #300
  3. Refactored the method implementation

1. Fixed the Issue.Created() method when the customfield struct is provided without any fields.
@ctreminiom ctreminiom added bug Something isn't working Jira Software Cloud V2 Jira Cloud V2 V3 Jira Cloud V3 labels Aug 11, 2024
@ctreminiom ctreminiom linked an issue Aug 11, 2024 that may be closed by this pull request
5 tasks
@ctreminiom ctreminiom merged commit 1a08651 into main Aug 11, 2024
20 checks passed
@ctreminiom ctreminiom deleted the bug/300 branch August 11, 2024 06:33
@ctreminiom
Copy link
Owner Author

This change enables the Created() method to create an issue when the models.CustomFields{} struct is created but without any customfields attached, see below:

package main

import (
	"context"
	"github.com/ctreminiom/go-atlassian/jira/v3"
	"github.com/ctreminiom/go-atlassian/pkg/infra/models"
	"log"
	"os"
)

func main() {

	var (
		host  = os.Getenv("SITE")
		mail  = os.Getenv("MAIL")
		token = os.Getenv("TOKEN")
	)

	atlassian, err := v3.New(nil, host)
	if err != nil {
		log.Fatal(err)
	}

	atlassian.Auth.SetBasicAuth(mail, token)

	var payload = models.IssueScheme{
		Fields: &models.IssueFieldsScheme{
			Summary:   "New summary test",
			Project:   &models.ProjectScheme{ID: "10000"},
			IssueType: &models.IssueTypeScheme{Name: "Story"},
		},
	}

	//CustomFields
	var customFields = models.CustomFields{}
	newIssue, response, err := atlassian.Issue.Create(context.Background(), &payload, &customFields)
	if err != nil {
		log.Fatal(err)
	}

	log.Println("HTTP Endpoint Used", response.Endpoint)
	log.Printf("The new issue %v has been created with the ID %v", newIssue.Key, newIssue.ID)
}

Creates the issue without any customfield,

ctreminio@air-m3 playground % go run issue/create/main.go                    
2024/08/11 00:28:59 HTTP Endpoint Used https://ctreminiom.atlassian.net/rest/api/3/issue
2024/08/11 00:28:59 The new issue KP-29 has been created with the ID 10053
ctreminio@air-m3 playground % 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Jira Software Cloud V2 Jira Cloud V2 V3 Jira Cloud V3
Projects
Status: Released
Development

Successfully merging this pull request may close these issues.

Custom Fields not optional during issue create?
1 participant