added new button to create tickets
This commit is contained in:
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Represents the OpenProject API.
|
||||
*/
|
||||
class XinonProject {
|
||||
private string $apiUrl = 'https://project.xinon.at/api/v3/';
|
||||
|
||||
/**
|
||||
* XinonProject constructor.
|
||||
*/
|
||||
public function __construct() {}
|
||||
|
||||
|
||||
public function createNewFaultTicket(string $subject, string $description, string $customer_name, string $customer_number, string $customer_address, string $customer_phone_number, string $customer_email, string $customer_service_pin, string $apiKey) {
|
||||
|
||||
$data = [
|
||||
'subject' => $subject,
|
||||
'customField2' => $customer_name,
|
||||
'customField3' => $customer_address,
|
||||
'customField4' => $customer_phone_number,
|
||||
'customField5' => $customer_email,
|
||||
'customField6' => $customer_number,
|
||||
'customField7' => $customer_service_pin,
|
||||
'description' => [
|
||||
'raw' => $description
|
||||
]
|
||||
];
|
||||
|
||||
$curl = curl_init();
|
||||
|
||||
curl_setopt_array($curl, array(
|
||||
CURLOPT_URL => 'https://project.xinon.at/api/v3/projects/10/work_packages',
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_ENCODING => '',
|
||||
CURLOPT_MAXREDIRS => 10,
|
||||
CURLOPT_TIMEOUT => 0,
|
||||
CURLOPT_FOLLOWLOCATION => true,
|
||||
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
|
||||
CURLOPT_CUSTOMREQUEST => 'POST',
|
||||
CURLOPT_POSTFIELDS => json_encode($data),
|
||||
CURLOPT_HTTPHEADER => array('Content-Type: application/json'),
|
||||
CURLOPT_USERPWD => 'apikey:'.$apiKey
|
||||
));
|
||||
curl_setopt($curl, CURLOPT_USERPWD, 'apikey:'.$apiKey);
|
||||
|
||||
$response = curl_exec($curl);
|
||||
|
||||
curl_close($curl);
|
||||
return $response;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
Reference in New Issue
Block a user