From 27a7dcbf77928c088dc89522b072a86775d6780e Mon Sep 17 00:00:00 2001 From: Mikhail Grebenkin Date: Thu, 20 Aug 2020 21:17:45 +0300 Subject: [PATCH] new comments and examples --- redmine.php | 12 ++- tester.php | 255 +++++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 222 insertions(+), 45 deletions(-) diff --git a/redmine.php b/redmine.php index e4cc990..db0d46e 100644 --- a/redmine.php +++ b/redmine.php @@ -12,7 +12,7 @@ class class_redmine { protected $redmine_url = ''; /** - * Upload $filecontent and return token. + * Uploads $filecontent and returns token. * * @param mixed $filecontent - content of file * @return array 0 => http response, 1 => $token is object, string can be obtained in $token->upload->token @@ -86,6 +86,14 @@ class class_redmine { * @param string $issue_id numeric issue id * @param string $project_id numeric project id * @param array $inc array of string with options to include. Example: array( 0 => "journals", 1 => "attachments" ); + * possible options: + * *children + * *attachments + * *relations + * *changesets + * *journals + * *watchers + * * @return array 0 => http response, 1 => $issue - json data of issue */ function get_issue(string $issue_id='',string $project_id='', array $inc=array()) { @@ -151,7 +159,7 @@ class class_redmine { } - //Projects nowadays we don't use it. + //Projects, nowadays we don't use it. function get_projects($project_id='') { $proj_url = ($project_id=='')?$this->redmine_url.'projects.json?key='.$this->redmine_key : $this->redmine_url.'projects/'.$project_id.'.json?key='.$this->redmine_key; return $this->curl_redmine($proj_url); diff --git a/tester.php b/tester.php index 2617515..ef98c60 100644 --- a/tester.php +++ b/tester.php @@ -2,62 +2,231 @@ 'https://tracker.a-real.ru/contacts/2906.json?include=issues', -// //CURLOPT_URL => 'https://tracker.a-real.ru/issues/10259.json?include=contact', -// CURLOPT_RETURNTRANSFER => true, -// CURLOPT_POST => true, -// CURLOPT_USERNAME => 'mix', -// CURLOPT_PASSWORD => 'CC35U8TXwgztS', -// CURLOPT_CUSTOMREQUEST => 'GET' -// // CURLOPT_POSTFIELDS => http_build_query(array(/*здесь массив параметров запроса*/)) -//)); -//$response = curl_exec($myCurl); -//curl_close($myCurl); -// -//var_dump($response) $obj_redmine = new class_bitrix_to_redmine(); $test_contact = array("contact" => array("first_name" => "Test testing", "project_id" => "managers", - //"is_company" => false, + "is_company" => false, "phone" => "+79997994838", "email" => "mvg@a-real.ru" ) ); -//$data = array("last_name"=> "Тестер тестович", -// "webtolead_email1" => "mail@a-real.ru", -// "phone_work" => "333333333333", -// "campaign_id" => "50c0d2a6-bbb7-fad1-640d-4c77b63b39e1", -// "lead_source" => "Web Site", -// "lead_source_description" => $ext_referer, -// "lead_source_description_to" => $ext_referer_to, -// "redirect_url" => "http://xserver.a-real.ru", -// "assign_user_id" => "e3eb89ec-9d10-1aba-ccbb-4b580a4cdb34", -// "req_id" => "last_name;webtolead_email1;" -//); - - -// $res = $obj_redmine->send_contact($data); -//$res = $obj_redmine->get_contact_id("3373", true); -//var_dump($res); - -//$inc[]= "contacts"; -//$inc[]= "relations"; -//$res = $obj_redmine->get_issue($issue_id="11380", "",$inc=$inc); -$res = $obj_redmine->get_contact_id("3373", true); -var_dump($res); -// $res = $obj_redmine->create_ticket("besco@yabesco.ru", "One more test", "test test one more"); +// для получения данных тикета: +$include[]= "relations"; +$include[]= "journals"; +$res = $obj_redmine->get_issue($issue_id="11380", $project_id = "", $inc=$include); // var_dump($res); +// вернется массив, первым элементом которого будет http ответ, 200 в случае успеха, ну или другой какой, если что-то пошло не так +// вторым элементом - json со всеми доступными и заполненными полями. +/* array(2) { +* [0]=> int(200) - код ответа +* [1]=> - все возможные поля, с типами +* object(stdClass)#14 (1) { +* ["issue"]=> object(stdClass)#2 (20) { +* ["id"]=> int(11380) +* ["project"]=> object(stdClass)#3 (2) { +* ["id"]=> int(14) +* ["name"]=> string(45) "Пользовательские тикеты" +* } +* ["tracker"]=> object(stdClass)#4 (2) { +* ["id"]=> int(3) +* ["name"]=> string(18) "Поддержка" +* } +* ["status"]=> object(stdClass)#5 (2) { +* ["id"]=> int(5) +* ["name"]=> string(14) "Закрыта" +* } +* ["priority"]=> object(stdClass)#6 (2) { +* ["id"]=> int(2) +* ["name"]=> string(20) "Нормальный" +* } +* ["author"]=> object(stdClass)#7 (2) { +* ["id"]=> int(277) +* ["name"]=> string(31) "Михаил Гребенкин" +* } +* ["assigned_to"]=> object(stdClass)#8 (2) { +* ["id"]=> int(7) +* ["name"]=> string(7) "Support" +* } +* ["subject"]=> string(13) "One more test" +* ["description"]=> string(18) "test test one more" +* ["start_date"]=> NULL +* ["due_date"]=> NULL +* ["done_ratio"]=> int(0) +* ["is_private"]=> bool(true) +* ["estimated_hours"]=> NULL +* ["total_estimated_hours"]=> NULL +* ["custom_fields"]=> array(2) { +* [0]=> object(stdClass)#9 (3) { +* ["id"]=> int(32) +* ["name"]=> string(16) "Версия ICS" +* ["value"]=> string(5) "7.0.1" +* } +* [1]=> object(stdClass)#10 (3) { +* ["id"]=> int(33) +* ["name"]=> string(21) "Тип клиента" +* ["value"]=> string(0) "" +* } +* } +* ["created_on"]=> string(20) "2020-08-18T13:34:33Z" +* ["updated_on"]=> string(20) "2020-08-19T05:09:53Z" +* ["closed_on"]=> string(20) "2020-08-19T05:09:53Z" +* ["journals"]=> array(1) { - тут отображаются все комментарии к задачам +* [0]=> object(stdClass)#11 (6) { +* ["id"]=> int(43939) +* ["user"]=> object(stdClass)#12 (2) { +* ["id"]=> int(56) +* ["name"]=> string(29) "Дарья Канцырева" +* } +* ["notes"]=> NULL +* ["created_on"]=> string(20) "2020-08-19T05:09:53Z" +* ["private_notes"]=> bool(false) +* ["details"]=> array(1) { +* [0]=> object(stdClass)#13 (4) { +* ["property"]=> string(4) "attr" +* ["name"]=> string(9) "status_id" +* ["old_value"]=> string(1) "1" +* ["new_value"]=> string(1) "5" +* } +* } +* } +* } +* } +* } +*} +*/ + +$res = $obj_redmine->get_contact_id("3373", true); +// var_dump($res); +/* + [0]=> int(200) + [1]=> object(stdClass)#32 (1) { + ["contact"]=> object(stdClass)#15 (20) { + ["id"]=> int(3373) + ["is_company"]=> bool(false) + ["first_name"]=> string(15) "Wasiliy Besedin" + ["last_name"]=> NULL + ["middle_name"]=> NULL + ["company"]=> NULL + ["website"]=> NULL + ["skype_name"]=> NULL + ["birthday"]=> NULL + ["job_title"]=> NULL + ["background"]=> NULL + ["address"]=> object(stdClass)#16 (6) { + ["full_address"]=> NULL + ["street"]=> NULL + ["city"]=> NULL + ["region"]=> NULL + ["country"]=> NULL + ["postcode"]=> NULL + } + ["phones"]=> array(1) { + [0]=> object(stdClass)#17 (1) { + ["number"]=> string(12) "+79066352453" + } + } + ["emails"]=> array(1) { + [0]=> object(stdClass)#18 (1) { + ["address"]=> string(16) "besco@yabesco.ru" + } + } + ["tag_list"]=> array(0) { + } + ["custom_fields"]=> array(9) { + [0]=> object(stdClass)#19 (3) { + ["id"]=> int(5) + ["name"]=> string(6) "ИНН" + ["value"]=> string(10) "7655546378" + } + [1]=> object(stdClass)#20 (3) { + ["id"]=> int(10) + ["name"]=> string(27) "Номер договора" + ["value"]=> string(0) "" + } + [2]=> object(stdClass)#21 (3) { + ["id"]=> int(11) + ["name"]=> string(16) "Лицензия" + ["value"]=> string(0) "" + } + [3]=> object(stdClass)#22 (3) { + ["id"]=> int(6) + ["name"]=> string(31) "Статус поддержки" + ["value"]=> string(0) "" + } + [4]=> object(stdClass)#23 (3) { + ["id"]=> int(12) + ["name"]=> string(26) "Логин на сайте" + ["value"]=> string(0) "" + } + [5]=> object(stdClass)#24 (3) { + ["id"]=> int(13) + ["name"]=> string(21) "Внешний код" + ["value"]=> string(0) "" + } + [6]=> object(stdClass)#25 (3) { + ["id"]=> int(14) + ["name"]=> string(30) "Лицензия. Начало" + ["value"]=> string(0) "" + } + [7]=> object(stdClass)#26 (3) { + ["id"]=> int(15) + ["name"]=> string(28) "Лицензия. Финал" + ["value"]=> string(0) "" + } + [8]=> object(stdClass)#27 (3) { + ["id"]=> int(16) + ["name"]=> string(5) "UF_IP" + ["value"]=> string(0) "" + } + } + ["created_on"]=> string(20) "2020-02-24T21:27:02Z" + ["updated_on"]=> string(20) "2020-02-24T21:27:02Z" + ["projects"]=> array(2) { + [0]=> object(stdClass)#28 (2) { + ["id"]=> int(17) + ["name"]=> string(8) "Managers" + } + [1]=> object(stdClass)#29 (2) { + ["id"]=> int(14) + ["name"]=> string(45) "Пользовательские тикеты" + } + } + ["issues"]=> array(1) { + [0]=> object(stdClass)#30 (6) { + ["id"]=> int(10442) + ["subject"]=> string(21) "testing testing again" + ["status"]=> object(stdClass)#31 (2) { + ["id"]=> int(5) + ["name"]=> string(14) "Закрыта" + } + ["due_date"]=> NULL + ["created_on"]=> string(20) "2020-06-26T15:17:02Z" + ["updated_on"]=> string(20) "2020-06-29T12:24:50Z" + } + } + } + } +} +*/ + + +// для создания тикета можно воспользоваться: +// поиск контакта - только по e-mail +$res = $obj_redmine->create_ticket("besco@yabesco.ru", "One more test", "test test one more"); +// var_dump($res); +/* +} + [0]=> int(201) - код возврата. 201 - успех + [1]=> NULL +} +*/ + +// работа с файлами //$filecontent = file_get_contents("screenshot.png"); //$token = $obj_redmine->get_upload_token($filecontent);