From cedde7b2cda4f862a97797721724c3638ae15cef Mon Sep 17 00:00:00 2001 From: "oncall@orange" Date: Thu, 3 Sep 2020 17:46:02 -0400 Subject: [PATCH] tbh I don't even know --- update_redmine.php | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/update_redmine.php b/update_redmine.php index cf8f54d..79c60df 100644 --- a/update_redmine.php +++ b/update_redmine.php @@ -87,6 +87,13 @@ class update_redmine { } $this->fullUrl = $this->baseUrl . "/issues/$issue.json"; } + if ($this->action === 'get_issue') { + $this->prepareRetrieveIssue(); + } + } + + private function prepareRetrieveIssue() { + $this->fullUrl = $this->baseUrl . "/issues/$issue.json"; } public function sendAction() { @@ -95,16 +102,19 @@ class update_redmine { } } - public function sendToRedmine($method = 'GET', $json) { - // use key 'http' even if you send the request to https://... - $options = [ - 'http' => [ - 'header' => "Content-type: application/json\r\nX-Redmine-API-Key: $this->apiKey\r\n", - 'method' => $method, - 'content' => $json, - ], - ]; - $context = stream_context_create($options); + public function sendToRedmine(string $method = 'GET', string $json) { + $context = NULL; + if ($method !== 'GET') { + // use key 'http' even if you send the request to https://... + $options = [ + 'http' => [ + 'header' => "Content-type: application/json\r\nX-Redmine-API-Key: $this->apiKey\r\n", + 'method' => $method, + 'content' => $json, + ], + ]; + $context = stream_context_create($options); + } $result = file_get_contents($this->fullUrl, FALSE, $context); if ($result === FALSE) { print_r($result);