From 11bc4342fa5ca9f4dbfad01fd8393aeaf13b458a Mon Sep 17 00:00:00 2001 From: "petr.travkin" Date: Fri, 15 Sep 2023 17:03:28 +0400 Subject: [PATCH 1/2] [RE-912]: add user account id --- src/User.php | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/User.php b/src/User.php index 8037ddc..921dcc9 100644 --- a/src/User.php +++ b/src/User.php @@ -218,9 +218,36 @@ public function __toString() return "{$this->getDisplayName()} ({$this->getName()})"; } - public function getKey() : string + /** + * User account ID available for Jira Cloud API + * + * Empty string for Jira Cloud API + * + * @link https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-get + * + * @return string + * + * @throws REST\Exception + */ + public function getAccountId(): string + { + return $this->getOriginalObject()->accountId ?? ""; + } + + /** + * User key available only for Jira Server API. + * + * Empty string for Jira Cloud API + * + * @link https://docs.atlassian.com/software/jira/docs/api/REST/9.7.2/#api/2/user-getUser + * + * @return string + * + * @throws REST\Exception + */ + public function getKey(): string { - return $this->getOriginalObject()->key; + return $this->getOriginalObject()->key ?? ""; } public function getName() : string From 2353d0e729392dd8934a1ec1b989d187c94c17c6 Mon Sep 17 00:00:00 2001 From: Petr Travkin Date: Mon, 18 Sep 2023 11:15:35 +0400 Subject: [PATCH 2/2] [RE-912]: update method comments Co-authored-by: Ruslan Osmanov --- src/User.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/User.php b/src/User.php index 921dcc9..76efa06 100644 --- a/src/User.php +++ b/src/User.php @@ -219,15 +219,15 @@ public function __toString() } /** - * User account ID available for Jira Cloud API + * Retrieves the account ID associated with the user, if it's a jira Cloud user. * - * Empty string for Jira Cloud API + * Returns an empty string if it's a Jira Server user. * * @link https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-users/#api-rest-api-3-user-get * - * @return string + * @return string The account ID for Jira Cloud users, or an empty string for Jira Server users. * - * @throws REST\Exception + * @throws REST\Exception If an error occurs during the API request. */ public function getAccountId(): string { @@ -235,15 +235,15 @@ public function getAccountId(): string } /** - * User key available only for Jira Server API. + * Retrieves the user key associated with the user, if it's a Jira Server user. * - * Empty string for Jira Cloud API + * Returns an empty string if it's a Jira Cloud user. * * @link https://docs.atlassian.com/software/jira/docs/api/REST/9.7.2/#api/2/user-getUser * - * @return string + * @return string The user key for Jira Server users, or an empty string for Jira Cloud users. * - * @throws REST\Exception + * @throws REST\Exception If an error occurs during the API request. */ public function getKey(): string {