PHP Class chobie\Jira\Api

Show file Open project: chobie/jira-api-restclient Class Usage Examples

Protected Properties

Property Type Description
$authentication chobie\Jira\Api\Authentication\AuthenticationInterface Authentication.
$client chobie\Jira\Api\Client\ClientInterface Client.
$endpoint string Endpoint URL.
$fields array | null Client-side cache of fields. List of fields when loaded, null when nothing is fetched yet.
$options integer Options.
$priorities array | null Client-side cache of priorities. List of priorities when loaded, null when nothing is fetched yet.
$resolutions array | null Client-side cache of resolutions. List of resolutions when loaded, null when nothing is fetched yet.
$statuses array | null Client-side cache of statuses. List of statuses when loaded, null when nothing is fetched yet.

Public Methods

Method Description
__construct ( string $endpoint, chobie\Jira\Api\Authentication\AuthenticationInterface $authentication, chobie\Jira\Api\Client\ClientInterface $client = null ) Create a JIRA API client.
addComment ( string $issue_key, array | string $params ) : Result | false Add a comment to a ticket.
api ( string $method = self::REQUEST_GET, string $url, array | string $data = [], boolean $return_as_array = false, boolean $is_file = false, boolean $debug = false ) : array | Result | false Send request to specified host.
closeIssue ( string $issue_key ) : Result | array Closes issue.
createAttachment ( string $issue_key, string $filename, string $name = null ) : Result | false Create attachment.
createIssue ( string $project_key, string $summary, string $issue_type, array $options = [] ) : Result | false Creates an issue.
createRemotelink ( string $issue_key, array $object = [], string $relationship = null, string $global_id = null, array $application = null ) : array | false Creates a remote link.
createVersion ( string $project_key, string $version, array $options = [] ) : Result | false Creates new version.
downloadAttachment ( string $url ) : array | string Downloads attachment.
editIssue ( string $issue_key, array $params ) : Result | false Edits the issue.
findVersionByName ( string $project_key, string $name ) : array | null Helper method to find a specific version based on the name of the version.
getAttachment ( string $attachment_id ) : array | false Gets attachment.
getAttachmentsMetaInformation ( ) : array Gets attachments meta information.
getCreateMeta ( array $project_ids = null, array $project_keys = null, array $issue_type_ids = null, array $issue_type_names = null, array $expand = null ) : array | false Returns the meta data for creating issues.
getEndpoint ( ) : string Get Endpoint URL.
getFields ( ) : array Get fields definitions.
getIssue ( string $issue_key, string $expand = '' ) : Result | false Get specified issue.
getIssueTypes ( ) : IssueType[] Get available issue types.
getPriorities ( ) : array Get available priorities.
getProject ( string $project_key ) : array | false Returns one project.
getProjectComponents ( string $project_key ) : array Returns project components.
getProjectIssueTypes ( string $project_key ) : array Get all issue types with valid status values for a project.
getProjects ( ) : Result | false Returns all projects.
getResolutions ( ) : array Returns a list of all resolutions.
getRoleDetails ( string $project_key, string $role_id ) : array | false Returns role details.
getRoles ( string $project_key ) : array | false Returns all roles of a project.
getStatuses ( ) : array Get available statuses.
getTransitions ( string $issue_key, array $params ) : Result | false Get available transitions for a ticket.
getVersions ( string $project_key ) : array | false Get versions of a project.
getWorklogs ( string $issue_key, array $params ) : Result | false Get all worklogs for an issue.
releaseVersion ( integer $version_id, string | null $release_date = null, array $params = [] ) : false Shorthand to mark a version as Released.
search ( string $jql, integer $start_at, integer $max_results = 20, string $fields = '*navigable' ) : Result | false Query issues.
setEndpoint ( string $url ) : void Set Endpoint URL.
setOptions ( integer $options ) : void Sets options.
setWatchers ( string $issue_key, array $watchers ) : Result | false Set issue watchers.
transition ( string $issue_key, array $params ) : Result | false Transition a ticket.
updateVersion ( integer $version_id, array $params = [] ) : false Updates version.

Protected Methods

Method Description
automapFields ( array $issue ) : array Automaps issue fields.
clearLocalCaches ( ) : void Helper method to clear the local caches. Is called when switching endpoints

Method Details

__construct() public method

Create a JIRA API client.
public __construct ( string $endpoint, chobie\Jira\Api\Authentication\AuthenticationInterface $authentication, chobie\Jira\Api\Client\ClientInterface $client = null )
$endpoint string Endpoint URL.
$authentication chobie\Jira\Api\Authentication\AuthenticationInterface Authentication.
$client chobie\Jira\Api\Client\ClientInterface Client.

addComment() public method

Add a comment to a ticket.
public addComment ( string $issue_key, array | string $params ) : Result | false
$issue_key string Issue key should be "YOURPROJ-221".
$params array | string Params.
return chobie\Jira\Api\Result | false

api() public method

Send request to specified host.
public api ( string $method = self::REQUEST_GET, string $url, array | string $data = [], boolean $return_as_array = false, boolean $is_file = false, boolean $debug = false ) : array | Result | false
$method string Request method.
$url string URL.
$data array | string Data.
$return_as_array boolean Return results as associative array.
$is_file boolean Is file-related request.
$debug boolean Debug this request.
return array | chobie\Jira\Api\Result | false

automapFields() protected method

Automaps issue fields.
protected automapFields ( array $issue ) : array
$issue array Issue.
return array

clearLocalCaches() protected method

Helper method to clear the local caches. Is called when switching endpoints
protected clearLocalCaches ( ) : void
return void

closeIssue() public method

Closes issue.
public closeIssue ( string $issue_key ) : Result | array
$issue_key string Issue key.
return chobie\Jira\Api\Result | array

createAttachment() public method

Create attachment.
public createAttachment ( string $issue_key, string $filename, string $name = null ) : Result | false
$issue_key string Issue key.
$filename string Filename.
$name string Name.
return chobie\Jira\Api\Result | false

createIssue() public method

Creates an issue.
public createIssue ( string $project_key, string $summary, string $issue_type, array $options = [] ) : Result | false
$project_key string Project key.
$summary string Summary.
$issue_type string Issue type.
$options array Options.
return chobie\Jira\Api\Result | false

createVersion() public method

Creates new version.
public createVersion ( string $project_key, string $version, array $options = [] ) : Result | false
$project_key string Project key.
$version string Version.
$options array Options.
return chobie\Jira\Api\Result | false

downloadAttachment() public method

Downloads attachment.
public downloadAttachment ( string $url ) : array | string
$url string URL.
return array | string

editIssue() public method

Edits the issue.
public editIssue ( string $issue_key, array $params ) : Result | false
$issue_key string Issue key.
$params array Params.
return chobie\Jira\Api\Result | false

findVersionByName() public method

Helper method to find a specific version based on the name of the version.
Since: 2.0.0
public findVersionByName ( string $project_key, string $name ) : array | null
$project_key string Project Key.
$name string The version name to match on.
return array | null Version data on match or null when there is no match.

getAttachment() public method

Gets attachment.
public getAttachment ( string $attachment_id ) : array | false
$attachment_id string Attachment ID.
return array | false

getAttachmentsMetaInformation() public method

Gets attachments meta information.
Since: 2.0.0

getCreateMeta() public method

This includes the available projects, issue types and fields, including field types and whether or not those fields are required. Projects will not be returned if the user does not have permission to create issues in that project. Fields will only be returned if "projects.issuetypes.fields" is added as expand parameter.
public getCreateMeta ( array $project_ids = null, array $project_keys = null, array $issue_type_ids = null, array $issue_type_names = null, array $expand = null ) : array | false
$project_ids array Combined with the projectKeys param, lists the projects with which to filter the results. If absent, all projects are returned. Specifying a project that does not exist (or that you cannot create issues in) is not an error, but it will not be in the results.
$project_keys array Combined with the projectIds param, lists the projects with which to filter the results. If null, all projects are returned. Specifying a project that does not exist (or that you cannot create issues in) is not an error, but it will not be in the results.
$issue_type_ids array Combined with issuetypeNames, lists the issue types with which to filter the results. If null, all issue types are returned. Specifying an issue type that does not exist is not an error.
$issue_type_names array Combined with issuetypeIds, lists the issue types with which to filter the results. If null, all issue types are returned. This parameter can be specified multiple times, but is NOT interpreted as a comma-separated list. Specifying an issue type that does not exist is not an error.
$expand array Optional list of entities to expand in the response.
return array | false

getEndpoint() public method

Get Endpoint URL.
public getEndpoint ( ) : string
return string

getFields() public method

Get fields definitions.
public getFields ( ) : array
return array

getIssue() public method

Get specified issue.
public getIssue ( string $issue_key, string $expand = '' ) : Result | false
$issue_key string Issue key should be "YOURPROJ-221".
$expand string Expand.
return chobie\Jira\Api\Result | false

getIssueTypes() public method

Get available issue types.
public getIssueTypes ( ) : IssueType[]
return IssueType[]

getPriorities() public method

Get available priorities.
Since: 2.0.0
public getPriorities ( ) : array
return array

getProject() public method

Returns one project.
public getProject ( string $project_key ) : array | false
$project_key string Project key.
return array | false

getProjectComponents() public method

Returns project components.
Since: 2.0.0
public getProjectComponents ( string $project_key ) : array
$project_key string Project key.
return array

getProjectIssueTypes() public method

Get all issue types with valid status values for a project.
Since: 2.0.0
public getProjectIssueTypes ( string $project_key ) : array
$project_key string Project key.
return array

getProjects() public method

Returns all projects.
public getProjects ( ) : Result | false
return chobie\Jira\Api\Result | false

getResolutions() public method

Returns a list of all resolutions.
Since: 2.0.0
public getResolutions ( ) : array
return array

getRoleDetails() public method

Returns role details.
public getRoleDetails ( string $project_key, string $role_id ) : array | false
$project_key string Project key.
$role_id string Role ID.
return array | false

getRoles() public method

Returns all roles of a project.
public getRoles ( string $project_key ) : array | false
$project_key string Project key.
return array | false

getStatuses() public method

Get available statuses.
public getStatuses ( ) : array
return array

getTransitions() public method

Get available transitions for a ticket.
public getTransitions ( string $issue_key, array $params ) : Result | false
$issue_key string Issue key should be "YOURPROJ-22".
$params array Params.
return chobie\Jira\Api\Result | false

getVersions() public method

Get versions of a project.
public getVersions ( string $project_key ) : array | false
$project_key string Project key.
return array | false

getWorklogs() public method

Get all worklogs for an issue.
Since: 2.0.0
public getWorklogs ( string $issue_key, array $params ) : Result | false
$issue_key string Issue key should be "YOURPROJ-22".
$params array Params.
return chobie\Jira\Api\Result | false

releaseVersion() public method

Shorthand to mark a version as Released.
Since: 2.0.0
public releaseVersion ( integer $version_id, string | null $release_date = null, array $params = [] ) : false
$version_id integer Version ID.
$release_date string | null Date in Y-m-d format (defaults to today).
$params array Optionally extra parameters.
return false

setEndpoint() public method

Set Endpoint URL.
public setEndpoint ( string $url ) : void
$url string Endpoint URL.
return void

setOptions() public method

Sets options.
public setOptions ( integer $options ) : void
$options integer Options.
return void

setWatchers() public method

Set issue watchers.
public setWatchers ( string $issue_key, array $watchers ) : Result | false
$issue_key string Issue key.
$watchers array Watchers.
return chobie\Jira\Api\Result | false

transition() public method

Transition a ticket.
public transition ( string $issue_key, array $params ) : Result | false
$issue_key string Issue key should be "YOURPROJ-22".
$params array Params.
return chobie\Jira\Api\Result | false

updateVersion() public method

Updates version.
public updateVersion ( integer $version_id, array $params = [] ) : false
$version_id integer Version ID.
$params array Key->Value list to update the version with.
return false

Property Details

$authentication protected property

Authentication.
protected AuthenticationInterface,chobie\Jira\Api\Authentication $authentication
return chobie\Jira\Api\Authentication\AuthenticationInterface

$client protected property

Client.
protected ClientInterface,chobie\Jira\Api\Client $client
return chobie\Jira\Api\Client\ClientInterface

$endpoint protected property

Endpoint URL.
protected string $endpoint
return string

$fields protected property

Client-side cache of fields. List of fields when loaded, null when nothing is fetched yet.
protected array|null $fields
return array | null

$options protected property

Options.
protected int $options
return integer

$priorities protected property

Client-side cache of priorities. List of priorities when loaded, null when nothing is fetched yet.
protected array|null $priorities
return array | null

$resolutions protected property

Client-side cache of resolutions. List of resolutions when loaded, null when nothing is fetched yet.
protected array|null $resolutions
return array | null

$statuses protected property

Client-side cache of statuses. List of statuses when loaded, null when nothing is fetched yet.
protected array|null $statuses
return array | null