Skip to content

Commit 0fac2e6

Browse files
committed
Merge branch 'main' of github.com:lesstif/php-JiraCloud-RESTAPI
* 'main' of github.com:lesstif/php-JiraCloud-RESTAPI: fix phpcs add possibility to pass request params to getCustomFieldOptions fix phpcs added ability to get, create and update custom select fields Update README.md Fixed issue where versions will not get unset because of some typo
2 parents 31686f6 + ebd4550 commit 0fac2e6

3 files changed

Lines changed: 88 additions & 4 deletions

File tree

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2692,6 +2692,4 @@ try {
26922692
Apache V2 License
26932693

26942694
# JIRA Rest API Documents
2695-
* 6.4 - https://docs.atlassian.com/jira/REST/6.4/
2696-
* Jira Server latest - https://docs.atlassian.com/jira/REST/server/
2697-
* Jira Cloud latest - https://docs.atlassian.com/jira/REST/latest/
2695+
* https://developer.atlassian.com/cloud/jira/platform/rest/v3/

src/Field/FieldService.php

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,90 @@ public function create(Field $field)
9393

9494
return $cf;
9595
}
96+
97+
/**
98+
* @param int $fieldId The custom field Id
99+
*
100+
* @throws \JiraCloud\JiraException
101+
*
102+
* @return string|bool
103+
*/
104+
public function getCustomFieldContexts(int $fieldId)
105+
{
106+
$url = sprintf('%s/customfield_%s/contexts', $this->uri, $fieldId);
107+
$ret = $this->exec($url);
108+
109+
$this->log->debug("get custom Field Contexts=\n".$ret);
110+
111+
return $ret;
112+
}
113+
114+
/**
115+
* Get a custom fields options.
116+
*
117+
* @param int $fieldId The custom field Id
118+
* @param int $contextId Context ID related to the custom field
119+
* @param array $paramArray Query parameters like 'startAt' and 'maxResults'
120+
*
121+
* @see https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-custom-field-options/#api-rest-api-3-field-fieldid-context-contextid-option-get
122+
*
123+
* @throws \JiraCloud\JiraException
124+
*
125+
* @return string
126+
*/
127+
public function getCustomFieldOptions(int $fieldId, int $contextId, array $paramArray = [])
128+
{
129+
$url = sprintf('%s/customfield_%s/context/%s/option%s', $this->uri, $fieldId, $contextId, $this->toHttpQueryParameter($paramArray));
130+
$ret = $this->exec($url);
131+
132+
$this->log->debug("get custom Field Options=\n".$ret);
133+
134+
return $ret;
135+
}
136+
137+
/**
138+
* Create custom field options.
139+
*
140+
* @param int $fieldId The custom field Id to add options to
141+
* @param int $contextId Context ID related to the custom field
142+
* @param array $options The options array
143+
*
144+
* @see https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-custom-field-options/#api-rest-api-3-field-fieldid-context-contextid-option-post
145+
*
146+
* @throws \JiraCloud\JiraException
147+
*
148+
* @return string
149+
*/
150+
public function createCustomFieldOptions(int $fieldId, int $contextId, array $options = [])
151+
{
152+
$url = sprintf('%s/customfield_%s/context/%s/option', $this->uri, $fieldId, $contextId);
153+
$ret = $this->exec($url, json_encode($options), 'POST');
154+
155+
$this->log->debug("create custom Field Options=\n".$ret);
156+
157+
return $ret;
158+
}
159+
160+
/**
161+
* Update a custom field options.
162+
*
163+
* @param int $fieldId The custom field Id
164+
* @param int $contextId Context ID related to the custom field
165+
* @param array $options The new options array
166+
*
167+
* @see https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issue-custom-field-options/#api-rest-api-3-field-fieldid-context-contextid-option-put
168+
*
169+
* @throws \JiraCloud\JiraException
170+
*
171+
* @return string
172+
*/
173+
public function updateCustomFieldOptions(int $fieldId, int $contextId, array $options = [])
174+
{
175+
$url = sprintf('%s/customfield_%s/context/%s/option', $this->uri, $fieldId, $contextId);
176+
$ret = $this->exec($url, json_encode($options), 'PUT');
177+
178+
$this->log->debug("update custom Field Options=\n".$ret);
179+
180+
return $ret;
181+
}
96182
}

src/Project/Project.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public function jsonSerialize()
106106
unset($params['leadName']);
107107
}
108108
if ($this->versions === null or count($this->versions) === 0) {
109-
unset($params['version']);
109+
unset($params['versions']);
110110
}
111111

112112
return $params;

0 commit comments

Comments
 (0)