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

Description Markdown #40

Open
cfreak opened this issue Feb 9, 2023 · 2 comments
Open

Description Markdown #40

cfreak opened this issue Feb 9, 2023 · 2 comments

Comments

@cfreak
Copy link
Contributor

cfreak commented Feb 9, 2023

Hey guys,

i have tried to post a markdown as description for a issue.

the example in the docs is not working, because the class DescriptionV3() and the method setDescriptionV3 do not exist.

Can you please correct the docs and help me to get it working?

<?php
require 'vendor/autoload.php';

use JiraCloud\Issue\IssueService;
use JiraCloud\Issue\IssueFieldV3;
use JiraCloud\Issue\DescriptionV3;
use JiraCloud\JiraException;

try {
    $issueField = new IssueFieldV3();

    $paraDesc =<<< DESC
Full description for issue
- order list 1
- order list 2
-- sub order list 1
-- sub order list 1
- order list 3 
DESC;
            $descV3 = new DescriptionV3();
            $descV3->addDescriptionContent('paragraph', $paraDesc);

            $issueField->setProjectKey('TEST')
                ->setSummary("something's wrong")
                ->setAssigneeAccountId('user-account-id-here')
                ->setPriorityNameAsString('Critical')
                ->setIssueTypeAsString('Bug')
                ->setDescriptionV3($descV3)
            ;
	
    $issueService = new IssueService();

    $ret = $issueService->create($issueField);
	
    //If success, Returns a link to the created issue.
    var_dump($ret);
} catch (JiraCloud\JiraException $e) {
	print('Error Occurred! ' . $e->getMessage());
}
@cfreak
Copy link
Contributor Author

cfreak commented Mar 1, 2023

any news here?

@lesstif
Copy link
Owner

lesstif commented Mar 12, 2023

Hi @cfreak, sorry for the late reply.

This library only supports REST API v3, and your code is V2 based code.

You can use this sample to create an issue with the Atlassian Document format.
(see doc link)

<?php
require 'vendor/autoload.php';

use JiraCloud\Issue\IssueService;
use JiraCloud\Issue\IssueField;
use JiraCloud\JiraException;
use DH\Adf\Node\Block\Document;
use JiraCloud\ADF\AtlassianDocumentFormat;

try {
    $issueField = new IssueField();
    
    $code =<<<CODE
<?php
\$i = 123;
\$a = ['hello', 'world', ];
var_dump([\$i => \$a]);
CODE;

    $doc = (new Document())
        ->heading(1)            // header level 1, can have child blocks (needs to be closed with `->end()`)
          ->text('h1')        // simple unstyled text, cannot have child blocks (no `->end()` needed)
        ->end()                 // closes `heading` node
        ->paragraph()           // paragraph, can have child blocks (needs to be closed with `->end()`)
            ->text('we’re ')    // simple unstyled text
            ->strong('support') // text node embedding a `strong` mark
            ->text(' ')         // simple unstyled text
            ->em('markdown')    // text node embedding a `em` mark
            ->text('. ')        // simple unstyled text
            ->underline('like') // text node embedding a `underline` mark
            ->text(' this.')    // simple unstyled text
        ->end()                 // closes `paragraph` node
        ->heading(2)            // header level 2
            ->text('h2')        // simple unstyled text
        ->end()                 // closes `heading` node
        ->heading(3)
            ->text('heading 3')
        ->end()
        ->paragraph()           // paragraph
            ->text('also support heading.') // simple unstyled text
        ->end()                 // closes `paragraph` node
        ->codeblock('php')
           ->text($code)
        ->end()
    ;

    $descV3 = new AtlassianDocumentFormat($doc);         

    $issueField->setProjectKey('TEST')
                ->setSummary('something\'s wrong')
                ->setAssigneeNameAsString('lesstif')
                ->setPriorityNameAsString('Highest')
                ->setIssueTypeAsString('Story')
                ->setDescription($descV3)
                ->addVersionAsString('1.0.1')
                ->addVersionAsArray(['1.0.2', '1.0.3'])
                ->addComponentsAsArray(['Component-1', 'Component-2'])
                // set issue security if you need.
                ->setSecurityId(10001 /* security scheme id */)
                ->setDueDateAsString('2023-06-19')
                // or you can use DateTimeInterface
                //->setDueDateAsDateTime(
                //            (new DateTime('NOW'))->add(DateInterval::createFromDateString('1 month 5 day'))
                // )
            ;
	
    $issueService = new IssueService();

    $ret = $issueService->create($issueField);
	
    //If success, Returns a link to the created issue.
    var_dump($ret);
} catch (JiraCloud\JiraException $e) {
	print('Error Occurred! ' . $e->getMessage());
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants