mi-lopez/jira-php

Jira PHP 是一个增强型 PHP API 客户端,允许您与 Jira API 和 Service Desk API 进行交互

v0.1.1 2024-03-09 21:41 UTC

This package is auto-updated.

Last update: 2024-09-09 23:02:16 UTC


README

Jira PHP

GitHub Workflow Status (master) Total Downloads Latest Version License

Jira PHP 是一个增强型 PHP API 客户端,允许您与 Jira APIService Desk API 进行交互。

开始使用

需要 PHP 8.1+

首先,使用 Composer 包管理器安装 devmoath/jira-php

composer require devmoath/jira-php

然后,与 Jira 的 API 进行交互

$client = Jira::client('USERNAME', 'PASSWORD', 'jira.domain.com');

$result = $client->issues()->search();

echo $result['issues'][0]['key']; // KEY-1000

用法

Attachments 资源

get 函数

检索附件的元数据。

$client->attachments()->get(id: '1000');
响应示例
[
    'self' => 'https://www.example.com/jira/rest/api/2.0/attachments/10000',
    'filename' => 'picture.jpg',
    'author' => [
        'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
        'name' => 'fred',
        'avatarUrls' => [
            '48x48' => 'https://www.example.com/jira/secure/useravatar?size=large&ownerId=fred',
            '24x24' => 'https://www.example.com/jira/secure/useravatar?size=small&ownerId=fred',
            '16x16' => 'https://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred',
            '32x32' => 'https://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred',
        ],
        'displayName' => 'Fred F. User',
        'active' => false,
    ],
    'created' => '2019-02-09T10:08:20.478+0000',
    'size' => 23123,
    'mimeType' => 'image/jpeg',
    'content' => 'https://www.example.com/jira/attachments/10000',
    'thumbnail' => 'https://www.example.com/jira/secure/thumbnail/10000',
];

remove 函数

删除附件。

$client->attachments()->remove(id: '1000');
响应示例
null

download 函数

下载附件内容。

$attachment = $client->attachments()->get(id: '1000');

$client->attachments()->download(url: $attachment['content']);
响应示例
{"a":"b"}\n

Customers 资源

create 函数

创建一个未与服务项目关联的客户。

$client->customers()->create(
    body: [
        'fullName' => 'name',
        'email' => 'name@example.com',
    ],
);
响应示例
[
    'name' => 'fred',
    'key' => 'fred',
    'emailAddress' => 'fred@example.com',
    'displayName' => 'Fred F. User',
    'active' => true,
    'timeZone' => 'Australia/Sydney',
    '_links' => [
        'jiraRest' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
        'avatarUrls' => [
            '48x48' => 'https://www.example.com/jira/secure/useravatar?size=large&ownerId=fred',
            '24x24' => 'https://www.example.com/jira/secure/useravatar?size=small&ownerId=fred',
            '16x16' => 'https://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred',
            '32x32' => 'https://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred',
        ],
        'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
    ],
];

Groups 资源

create 函数

通过给定的组参数创建一个组。

$client->groups()->create(
    body: [
        'name' => 'group name',
    ],
);
响应示例
[
    'name' => 'jira-administrators',
    'self' => 'https://www.example.com/jira/rest/api/2/group?groupname=jira-administrators',
    'users' => [
        'size' => 1,
        'items' => [
            [
                'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
                'name' => 'fred',
                'displayName' => 'Fred F. User',
                'active' => false,
            ],
        ],
        'max-results' => 50,
        'start-index' => 0,
        'end-index' => 0,
    ],
    'expand' => 'users',
];

remove 函数

通过给定的组参数删除一个组。

$client->groups()->remove(
    query: [
        'name' => 'group name',
    ],
);
响应示例
null

getUsers 函数

返回指定组及其子组的成员的按页列表。

$client->groups()->getUsers(
    query: [
        'groupname' => 'group name',
    ],
);
响应示例
[
    'self' => 'https://example.com/rest/api/2/group/member?groupname=admin&startAt=2&maxResults=2',
    'nextPage' => 'https://example.com/rest/api/2/group/member?groupname=admin&startAt=4&maxResults=2',
    'maxResults' => 2,
    'startAt' => 3,
    'total' => 5,
    'isLast' => false,
    'values' => [
        [
            'self' => 'https://example/jira/rest/api/2/user?username=fred',
            'name' => 'Fred',
            'key' => 'fred',
            'emailAddress' => 'fred@atlassian.com',
            'avatarUrls' => [],
            'displayName' => 'Fred',
            'active' => true,
            'timeZone' => 'Australia/Sydney',
        ],
        [
            'self' => 'https://example/jira/rest/api/2/user?username=barney',
            'name' => 'Barney',
            'key' => 'barney',
            'emailAddress' => 'barney@atlassian.com',
            'avatarUrls' => [],
            'displayName' => 'Barney',
            'active' => false,
            'timeZone' => 'Australia/Sydney',
        ],
    ],
];

addUser 函数

将指定用户添加到组中。

$client->groups()->addUser(
    query: [
        'groupname' => 'group name',
    ],
    body: [
        'name' => 'user name',
    ],
);
响应示例
[
    'name' => 'example',
    'self' => 'url',
    'users' => [],
    'expand' => '',
];

removeUser 函数

从组中删除指定用户。

$client->groups()->removeUser(
    query: [
        'groupname' => 'group name',
        'username' => 'user name',
    ],
);
响应示例
null

Issues 资源

create 函数

从 JSON 表示形式创建一个或多个问题或子任务。

$client
    ->issues()
    ->create(body: [...]);
响应示例
[
    'id' => '10000',
    'key' => 'TST-24',
    'self' => 'https://www.example.com/jira/rest/api/2/issue/10000',
];

bulk 函数

从 JSON 表示形式创建问题或子任务。

$client
    ->issues()
    ->bulk(body: [
        [...],
        [...],
        [...]
    ]);
响应示例
[
    'issues' => [
        [
            'id' => '10000',
            'key' => 'TST-24',
            'self' => 'https://www.example.com/jira/rest/api/2/issue/10000',
        ],
        [
            'id' => '10001',
            'key' => 'TST-25',
            'self' => 'https://www.example.com/jira/rest/api/2/issue/10001',
        ],
    ],
    'errors' => [],
];

get 函数

返回给定问题键的问题的完整表示。

$client->issues()->get(id: 'KEY-1000', query: [...]);
响应示例
[
    'expand' => 'renderedFields,names,schema,operations,editmeta,changelog,versionedRepresentations',
    'id' => '10002',
    'self' => 'https://www.example.com/jira/rest/api/2/issue/10002',
    'key' => 'EX-1',
    'fields' => [
        'watcher' => [
            'self' => 'https://www.example.com/jira/rest/api/2/issue/EX-1/watchers',
            'isWatching' => false,
            'watchCount' => 1,
            'watchers' => [
                [
                    'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
                    'name' => 'fred',
                    'displayName' => 'Fred F. User',
                    'active' => false,
                ],
            ],
        ],
        'attachment' => [
            [
                'self' => 'https://www.example.com/jira/rest/api/2.0/attachments/10000',
                'filename' => 'picture.jpg',
                'author' => [
                    'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
                    'name' => 'fred',
                    'avatarUrls' => [
                        '48x48' => 'https://www.example.com/jira/secure/useravatar?size=large&ownerId=fred',
                        '24x24' => 'https://www.example.com/jira/secure/useravatar?size=small&ownerId=fred',
                        '16x16' => 'https://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred',
                        '32x32' => 'https://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred',
                    ],
                    'displayName' => 'Fred F. User',
                    'active' => false,
                ],
                'created' => '2019-02-09T10:08:20.478+0000',
                'size' => 23123,
                'mimeType' => 'image/jpeg',
                'content' => 'https://www.example.com/jira/attachments/10000',
                'thumbnail' => 'https://www.example.com/jira/secure/thumbnail/10000',
            ],
        ],
        'sub-tasks' => [
            [
                'id' => '10000',
                'type' => [
                    'id' => '10000',
                    'name' => '',
                    'inward' => 'Parent',
                    'outward' => 'Sub-task',
                ],
                'outwardIssue' => [
                    'id' => '10003',
                    'key' => 'EX-2',
                    'self' => 'https://www.example.com/jira/rest/api/2/issue/EX-2',
                    'fields' => [
                        'status' => [
                            'iconUrl' => 'https://www.example.com/jira/images/icons/statuses/open.png',
                            'name' => 'Open',
                        ],
                    ],
                ],
            ],
        ],
        'description' => 'example bug report',
        'project' => [
            'self' => 'https://www.example.com/jira/rest/api/2/project/EX',
            'id' => '10000',
            'key' => 'EX',
            'name' => 'Example',
            'avatarUrls' => [
                '48x48' => 'https://www.example.com/jira/secure/projectavatar?size=large&pid=10000',
                '24x24' => 'https://www.example.com/jira/secure/projectavatar?size=small&pid=10000',
                '16x16' => 'https://www.example.com/jira/secure/projectavatar?size=xsmall&pid=10000',
                '32x32' => 'https://www.example.com/jira/secure/projectavatar?size=medium&pid=10000',
            ],
            'projectCategory' => [
                'self' => 'https://www.example.com/jira/rest/api/2/projectCategory/10000',
                'id' => '10000',
                'name' => 'FIRST',
                'description' => 'First Project Category',
            ],
        ],
        'comment' => [
            [
                'self' => 'https://www.example.com/jira/rest/api/2/issue/10010/comment/10000',
                'id' => '10000',
                'author' => [
                    'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
                    'name' => 'fred',
                    'displayName' => 'Fred F. User',
                    'active' => false,
                ],
                'body' => 'Lorem ipsum dolor sit amet.',
                'updateAuthor' => [
                    'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
                    'name' => 'fred',
                    'displayName' => 'Fred F. User',
                    'active' => false,
                ],
                'created' => '2019-02-09T10:08:20.180+0000',
                'updated' => '2019-02-09T10:08:20.181+0000',
                'visibility' => [
                    'type' => 'role',
                    'value' => 'Administrators',
                ],
            ],
        ],
        'issuelinks' => [
            [
                'id' => '10001',
                'type' => [
                    'id' => '10000',
                    'name' => 'Dependent',
                    'inward' => 'depends on',
                    'outward' => 'is depended by',
                ],
                'outwardIssue' => [
                    'id' => '10004L',
                    'key' => 'PRJ-2',
                    'self' => 'https://www.example.com/jira/rest/api/2/issue/PRJ-2',
                    'fields' => [
                        'status' => [
                            'iconUrl' => 'https://www.example.com/jira//images/icons/statuses/open.png',
                            'name' => 'Open',
                        ],
                    ],
                ],
            ],
            [
                'id' => '10002',
                'type' => [
                    'id' => '10000',
                    'name' => 'Dependent',
                    'inward' => 'depends on',
                    'outward' => 'is depended by',
                ],
                'inwardIssue' => [
                    'id' => '10004',
                    'key' => 'PRJ-3',
                    'self' => 'https://www.example.com/jira/rest/api/2/issue/PRJ-3',
                    'fields' => [
                        'status' => [
                            'iconUrl' => 'https://www.example.com/jira//images/icons/statuses/open.png',
                            'name' => 'Open',
                        ],
                    ],
                ],
            ],
        ],
        'worklog' => [
            [
                'self' => 'https://www.example.com/jira/rest/api/2/issue/10010/worklog/10000',
                'author' => [
                    'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
                    'name' => 'fred',
                    'displayName' => 'Fred F. User',
                    'active' => false,
                ],
                'updateAuthor' => [
                    'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
                    'name' => 'fred',
                    'displayName' => 'Fred F. User',
                    'active' => false,
                ],
                'comment' => 'I did some work here.',
                'updated' => '2019-02-09T10:08:20.486+0000',
                'visibility' => [
                    'type' => 'group',
                    'value' => 'jira-developers',
                ],
                'started' => '2019-02-09T10:08:20.486+0000',
                'timeSpent' => '3h 20m',
                'timeSpentSeconds' => 12000,
                'id' => '100028',
                'issueId' => '10002',
            ],
        ],
        'updated' => 1,
        'timetracking' => [
            'originalEstimate' => '10m',
            'remainingEstimate' => '3m',
            'timeSpent' => '6m',
            'originalEstimateSeconds' => 600,
            'remainingEstimateSeconds' => 200,
            'timeSpentSeconds' => 400,
        ],
    ],
    'names' => [
        'watcher' => 'watcher',
        'attachment' => 'attachment',
        'sub-tasks' => 'sub-tasks',
        'description' => 'description',
        'project' => 'project',
        'comment' => 'comment',
        'issuelinks' => 'issuelinks',
        'worklog' => 'worklog',
        'updated' => 'updated',
        'timetracking' => 'timetracking',
    ],
    'schema' => [],
];

delete 函数

删除一个问题。

$client->issues()->delete(id: 'KEY-1000', query: [...]);
响应示例
null

edit 函数

从 JSON 表示形式编辑问题。

$client->issues()->edit(id: 'KEY-1000', body: [...], query: [...]);
响应示例
null

archive 函数

归档一个问题。

$client->issues()->archive(id: 'KEY-1000');
响应示例
null

assign 函数

将一个问题分配给一个用户。

$client->issues()->assign(id: 'KEY-1000', body: [...]);
响应示例
null

getComments 函数

返回一个问题的所有评论。

$client->issues()->getComments(id: 'KEY-1000', query: [...]);
响应示例
[
    'startAt' => 0,
    'maxResults' => 1,
    'total' => 1,
    'comments' => [
        [
            'self' => 'https://www.example.com/jira/rest/api/2/issue/10010/comment/10000',
            'id' => '10000',
            'author' => [
                'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
                'name' => 'fred',
                'displayName' => 'Fred F. User',
                'active' => false,
            ],
            'body' => 'Lorem ipsum dolor sit amet.',
            'updateAuthor' => [
                'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
                'name' => 'fred',
                'displayName' => 'Fred F. User',
                'active' => false,
            ],
            'created' => '2019-02-09T10:08:20.180+0000',
            'updated' => '2019-02-09T10:08:20.181+0000',
            'visibility' => [
                'type' => 'role',
                'value' => 'Administrators',
            ],
        ],
    ],
];

addComment 函数

向一个问题添加新评论。

$client->issues()->addComment(id: 'KEY-1000', body: [...], query: [...]);
响应示例
[
    'self' => 'https://www.example.com/jira/rest/api/2/issue/10010/comment/10000',
    'id' => '10000',
    'author' => [
        'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
        'name' => 'fred',
        'displayName' => 'Fred F. User',
        'active' => false,
    ],
    'body' => 'Lorem ipsum dolor sit amet.',
    'updateAuthor' => [
        'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
        'name' => 'fred',
        'displayName' => 'Fred F. User',
        'active' => false,
    ],
    'created' => '2019-02-09T10:08:20.180+0000',
    'updated' => '2019-02-09T10:08:20.181+0000',
    'visibility' => [
        'type' => 'role',
        'value' => 'Administrators',
    ],
];

updateComment 函数

使用其 JSON 表示形式更新现有评论。

$client->issues()->updateComment(id: 'KEY-1000', commentId: '10000', body: [...], query: [...]);
响应示例
[
    'self' => 'https://www.example.com/jira/rest/api/2/issue/10010/comment/10000',
    'id' => '10000',
    'author' => [
        'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
        'name' => 'fred',
        'displayName' => 'Fred F. User',
        'active' => false,
    ],
    'body' => 'Lorem ipsum dolor sit amet.',
    'updateAuthor' => [
        'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
        'name' => 'fred',
        'displayName' => 'Fred F. User',
        'active' => false,
    ],
    'created' => '2019-02-09T10:08:20.180+0000',
    'updated' => '2019-02-09T10:08:20.181+0000',
    'visibility' => [
        'type' => 'role',
        'value' => 'Administrators',
    ],
];

deleteComment 函数

删除一个现有评论。

$client->issues()->deleteComment(id: 'KEY-1000', commentId: '10000', query: [...]);
响应示例
null

getComment 函数

返回单个评论。

$client->issues()->getComment(id: 'KEY-1000', commentId: '10000', query: [...]);
响应示例
[
    'self' => 'https://www.example.com/jira/rest/api/2/issue/10010/comment/10000',
    'id' => '10000',
    'author' => [
        'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
        'name' => 'fred',
        'displayName' => 'Fred F. User',
        'active' => false,
    ],
    'body' => 'Lorem ipsum dolor sit amet.',
    'updateAuthor' => [
        'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
        'name' => 'fred',
        'displayName' => 'Fred F. User',
        'active' => false,
    ],
    'created' => '2019-02-09T10:08:20.180+0000',
    'updated' => '2019-02-09T10:08:20.181+0000',
    'visibility' => [
        'type' => 'role',
        'value' => 'Administrators',
    ],
];

getTransitions 函数

获取当前用户可以进行的问题转换列表,包括所需的字段及其类型。

$client->issues()->getTransitions(id: 'KEY-1000', query: [...]);
响应示例
[
    'expand' => 'transitions',
    'transitions' => [
        [
            'id' => '2',
            'name' => 'Close Issue',
            'to' => [
                'self' => 'https://:8090/jira/rest/api/2.0/status/10000',
                'description' => 'The issue is currently being worked on.',
                'iconUrl' => 'https://:8090/jira/images/icons/progress.gif',
                'name' => 'In Progress',
                'id' => '10000',
                'statusCategory' => [
                    'self' => 'https://:8090/jira/rest/api/2.0/statuscategory/1',
                    'id' => 1,
                    'key' => 'in-flight',
                    'colorName' => 'yellow',
                    'name' => 'In Progress',
                ],
            ],
            'fields' => [
                'summary' => [
                    'required' => false,
                    'schema' => [
                        'type' => 'array',
                        'items' => 'option',
                        'custom' => 'com.atlassian.jira.plugin.system.customfieldtypes:multiselect',
                        'customId' => 10001,
                    ],
                    'name' => 'My Multi Select',
                    'hasDefaultValue' => false,
                    'operations' => ['set', 'add'],
                    'allowedValues' => ['red', 'blue'],
                ],
            ],
        ],
        [
            'id' => '711',
            'name' => 'QA Review',
            'to' => [
                'self' => 'https://:8090/jira/rest/api/2.0/status/5',
                'description' => 'The issue is closed.',
                'iconUrl' => 'https://:8090/jira/images/icons/closed.gif',
                'name' => 'Closed',
                'id' => '5',
                'statusCategory' => [
                    'self' => 'https://:8090/jira/rest/api/2.0/statuscategory/9',
                    'id' => 9,
                    'key' => 'completed',
                    'colorName' => 'green',
                ],
            ],
            'fields' => [
                'summary' => [
                    'required' => false,
                    'schema' => [
                        'type' => 'array',
                        'items' => 'option',
                        'custom' => 'com.atlassian.jira.plugin.system.customfieldtypes:multiselect',
                        'customId' => 10001,
                    ],
                    'name' => 'My Multi Select',
                    'hasDefaultValue' => false,
                    'operations' => ['set', 'add'],
                    'allowedValues' => ['red', 'blue'],
                ],
                'colour' => [
                    'required' => false,
                    'schema' => [
                        'type' => 'array',
                        'items' => 'option',
                        'custom' => 'com.atlassian.jira.plugin.system.customfieldtypes:multiselect',
                        'customId' => 10001,
                    ],
                    'name' => 'My Multi Select',
                    'hasDefaultValue' => false,
                    'operations' => ['set', 'add'],
                    'allowedValues' => ['red', 'blue'],
                ],
            ],
        ],
    ],
];

doTransition 函数

对一个问题执行转换。

$client->issues()->doTransition(id: 'KEY-1000', body: [...], query: [...]);
响应示例
null

attach 函数

向一个问题添加一个或多个附件。

$client->issues()->attach(id: 'KEY-1000', body: [...]);
响应示例
[
    [
        'self' => 'https://www.example.com/jira/rest/api/2.0/attachments/10000',
        'filename' => 'picture.jpg',
        'author' => [
            'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
            'name' => 'fred',
            'avatarUrls' => [
                '48x48' => 'https://www.example.com/jira/secure/useravatar?size=large&ownerId=fred',
                '24x24' => 'https://www.example.com/jira/secure/useravatar?size=small&ownerId=fred',
                '16x16' => 'https://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred',
                '32x32' => 'https://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred',
            ],
            'displayName' => 'Fred F. User',
            'active' => false,
        ],
        'created' => '2019-02-09T10:08:20.478+0000',
        'size' => 23123,
        'mimeType' => 'image/jpeg',
        'content' => 'https://www.example.com/jira/attachments/10000',
        'thumbnail' => 'https://www.example.com/jira/secure/thumbnail/10000',
    ],
    [
        'self' => 'https://www.example.com/jira/rest/api/2.0/attachments/10001',
        'filename' => 'dbeuglog.txt',
        'author' => [
            'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
            'name' => 'fred',
            'avatarUrls' => [
                '48x48' => 'https://www.example.com/jira/secure/useravatar?size=large&ownerId=fred',
                '24x24' => 'https://www.example.com/jira/secure/useravatar?size=small&ownerId=fred',
                '16x16' => 'https://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred',
                '32x32' => 'https://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred',
            ],
            'displayName' => 'Fred F. User',
            'active' => false,
        ],
        'created' => '2019-02-09T10:08:20.478+0000',
        'size' => 2460,
        'mimeType' => 'text/plain',
        'content' => 'https://www.example.com/jira/attachments/10001',
        'thumbnail' => 'https://www.example.com/jira/secure/thumbnail/10002',
    ],
];

search 函数

使用 JQL 搜索问题。

$client->issues()->search(query: [...]);
响应示例
[
    'expand' => 'names,schema',
    'startAt' => 0,
    'maxResults' => 50,
    'total' => 1,
    'issues' => [
        [
            'expand' => '',
            'id' => '10001',
            'self' => 'https://www.example.com/jira/rest/api/2/issue/10001',
            'key' => 'HSP-1',
        ],
    ],
];

Requests 资源

create 函数

在服务项目中创建客户请求。

$client->requests()->create(body: [...]);
响应示例
[
    '_expands' => ['participant', 'status', 'sla', 'requestType', 'serviceDesk'],
    'issueId' => '107001',
    'issueKey' => 'HELPDESK-1',
    'requestTypeId' => '25',
    'serviceDeskId' => '10',
    'createdDate' => [
        'iso8601' => '2015-10-08T14:42:00+0700',
        'jira' => '2015-10-08T14:42:00.000+0700',
        'friendly' => 'Monday 14:42 PM',
        'epochMillis' => 1444290120000,
    ],
    'reporter' => [
        'name' => 'fred',
        'key' => 'fred',
        'emailAddress' => 'fred@example.com',
        'displayName' => 'Fred F. User',
        'active' => true,
        'timeZone' => 'Australia/Sydney',
        '_links' => [
            'jiraRest' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
            'avatarUrls' => [
                '48x48' => 'https://www.example.com/jira/secure/useravatar?size=large&ownerId=fred',
                '24x24' => 'https://www.example.com/jira/secure/useravatar?size=small&ownerId=fred',
                '16x16' => 'https://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred',
                '32x32' => 'https://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred',
            ],
            'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
        ],
    ],
    'requestFieldValues' => [
        [
            'fieldId' => 'summary',
            'label' => 'What do you need?',
            'value' => 'Request JSD help via REST',
        ],
        [
            'fieldId' => 'description',
            'label' => 'Why do you need this?',
            'value' => 'I need a new mouse for my Mac',
        ],
    ],
    'currentStatus' => [
        'status' => 'Waiting for Support',
        'statusDate' => [
            'iso8601' => '2015-10-08T14:01:00+0700',
            'jira' => '2015-10-08T14:01:00.000+0700',
            'friendly' => 'Today 14:01 PM',
            'epochMillis' => 1444287660000,
        ],
    ],
    '_links' => [
        'jiraRest' => 'https://host:port/context/rest/api/2/issue/107001',
        'web' => 'https://host:port/context/servicedesk/customer/portal/10/HELPDESK-1',
        'self' => 'https://host:port/context/rest/servicedeskapi/request/107001',
    ],
];

Users 资源

update 函数

修改用户。

$client->users()->update(body: [...]);
响应示例
[
    'self' => 'https://www.example.com/jira/rest/api/2/user/charlie',
    'key' => 'charlie',
    'name' => 'charlie',
    'emailAddress' => 'charlie@atlassian.com',
    'displayName' => 'Charlie of Atlassian',
];

create 函数

创建用户。

$client->users()->create(body: [...]);
响应示例
[
    'self' => 'https://www.example.com/jira/rest/api/2/user/charlie',
    'key' => 'charlie',
    'name' => 'charlie',
    'emailAddress' => 'charlie@atlassian.com',
    'displayName' => 'Charlie of Atlassian',
];

remove 函数

删除用户及其引用(如项目角色关联、监视、历史记录)。

$client->users()->remove(query: [...]);
响应示例
null

get 函数

返回一个用户。

$client->users()->get(query: [...]);
响应示例
[
    'self' => 'https://www.example.com/jira/rest/api/2/user?username=fred',
    'name' => 'fred',
    'emailAddress' => 'fred@example.com',
    'avatarUrls' => [
        '48x48' => 'https://www.example.com/jira/secure/useravatar?size=large&ownerId=fred',
        '24x24' => 'https://www.example.com/jira/secure/useravatar?size=small&ownerId=fred',
        '16x16' => 'https://www.example.com/jira/secure/useravatar?size=xsmall&ownerId=fred',
        '32x32' => 'https://www.example.com/jira/secure/useravatar?size=medium&ownerId=fred',
    ],
    'displayName' => 'Fred F. User',
    'active' => true,
    'timeZone' => 'Australia/Sydney',
    'groups' => [
        'size' => 3,
        'items' => [
            [
                'name' => 'jira-user',
                'self' => 'https://www.example.com/jira/rest/api/2/group?groupname=jira-user',
            ],
            [
                'name' => 'jira-admin',
                'self' => 'https://www.example.com/jira/rest/api/2/group?groupname=jira-admin',
            ],
            [
                'name' => 'important',
                'self' => 'https://www.example.com/jira/rest/api/2/group?groupname=important',
            ],
        ],
    ],
    'applicationRoles' => [
        'size' => 1,
        'items' => [],
    ],
    'expand' => 'groups,applicationRoles',
];

贡献

感谢您考虑为 Jira PHP 贡献!贡献指南可在 CONTRIBUTING 中找到。

安全漏洞

如果您发现任何与安全相关的问题,请通过电子邮件 moath.alhajrii@gmail.com 联系,而不是使用问题跟踪器。

许可证

Jira PHP 是一个开源软件,遵循 MIT 许可协议