| 
						 | 
						- 
 - <?php
 - 
 - require_once("redmine.php");
 - 
 - $obj_redmine    =   new class_bitrix_to_redmine();
 - 
 - $test_contact = array("contact" => array("first_name" => "Test testing",
 -             "project_id" => "managers",
 -             "is_company" => false,
 -             "phone" => "+79997994838",
 -             "email" => "mvg@a-real.ru"
 -         )
 -     );
 - 
 - // для получения данных тикета:
 - 
 - $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"
 -         }
 -       }
 -     }
 -   }
 - }
 - */
 - 
 - 
 - // для создания тикета create_ticket()
 - // поиск контакта - только по 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);
 - 
 - //$token = $token->upload->token;
 - 
 - //var_dump($token);
 - 
 - // закачать вложение, сразу прикрепить к issue (тикет)
 - //$filecontent = file_get_contents("screenshot.png");
 - // $res = $obj_redmine->upload_attachment('10314', 'screenshot.png', 'image/png', $filecontent);
 - // var_dump($res);
 - 
 - // получить issue с журналом и вложениями
 - // $inc = array( 0 => "journals",
 - //               1 => "attachments"
 - //             );
 - 
 - //$res = $obj_redmine->get_issue('10314', '', $inc);
 - //var_dump($res);
 - 
 - // получить прикрепленное вложение
 - //  $thumbnail - если true, то выкачается эскиз.
 - // $res = $obj_redmine->download_attachment('5152', true);
 - //file_put_contents('screenshot_eskiz.png', $res);
 - 
 - ?>
 
 
  |