Skip to content

Commit

Permalink
Merge pull request #2 from php/RE-912_add_user_account_Id
Browse files Browse the repository at this point in the history
[RE-912]: add user account id
  • Loading branch information
konorlevich authored and GitHub Enterprise committed Sep 18, 2023
2 parents 3996a98 + 2353d0e commit 6d317e8
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions src/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,36 @@ public function __toString()
return "{$this->getDisplayName()} ({$this->getName()})";
}

public function getKey() : string
/**
* Retrieves the account ID associated with the user, if it's a jira Cloud user.
*
* 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 The account ID for Jira Cloud users, or an empty string for Jira Server users.
*
* @throws REST\Exception If an error occurs during the API request.
*/
public function getAccountId(): string
{
return $this->getOriginalObject()->accountId ?? "";
}

/**
* Retrieves the user key associated with the user, if it's a Jira Server user.
*
* 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 The user key for Jira Server users, or an empty string for Jira Cloud users.
*
* @throws REST\Exception If an error occurs during the API request.
*/
public function getKey(): string
{
return $this->getOriginalObject()->key;
return $this->getOriginalObject()->key ?? "";
}

public function getName() : string
Expand Down

0 comments on commit 6d317e8

Please # to comment.