mirror of
https://github.com/itflow-org/itflow
synced 2026-03-23 14:05:38 +00:00
Merge pull request #354 from wrongecho/api
Add contact & ticket read to api
This commit is contained in:
30
api/v1/contacts/read.php
Normal file
30
api/v1/contacts/read.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
require('../validate_api_key.php');
|
||||||
|
|
||||||
|
if($_SERVER['REQUEST_METHOD'] !== "GET"){
|
||||||
|
header("HTTP/1.1 405 Method Not Allowed");
|
||||||
|
$return_arr['success'] = "False";
|
||||||
|
$return_arr['message'] = "Can only send GET requests to this endpoint.";
|
||||||
|
echo json_encode($return_arr);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Specific contact via ID (single)
|
||||||
|
if(isset($_GET['contact_id'])){
|
||||||
|
$id = intval($_GET['contact_id']);
|
||||||
|
$sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_id = '$id' AND company_id = '$company_id'");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Specific contact via email (single)
|
||||||
|
elseif(isset($_GET['contact_email'])){
|
||||||
|
$email = trim($_GET['contact_email']);
|
||||||
|
$sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE contact_email = '$email' AND company_id = '$company_id'");
|
||||||
|
}
|
||||||
|
|
||||||
|
// All contacts
|
||||||
|
else{
|
||||||
|
$sql = mysqli_query($mysqli, "SELECT * FROM contacts WHERE company_id = '$company_id' ORDER BY contact_id LIMIT $limit OFFSET $offset");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output
|
||||||
|
include("../read_output.php");
|
||||||
24
api/v1/tickets/read.php
Normal file
24
api/v1/tickets/read.php
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
<?php
|
||||||
|
require('../validate_api_key.php');
|
||||||
|
|
||||||
|
if($_SERVER['REQUEST_METHOD'] !== "GET"){
|
||||||
|
header("HTTP/1.1 405 Method Not Allowed");
|
||||||
|
$return_arr['success'] = "False";
|
||||||
|
$return_arr['message'] = "Can only send GET requests to this endpoint.";
|
||||||
|
echo json_encode($return_arr);
|
||||||
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Specific ticket via ID (single)
|
||||||
|
if(isset($_GET['ticket_id'])){
|
||||||
|
$id = intval($_GET['ticket_id']);
|
||||||
|
$sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_id = '$id' AND company_id = '$company_id'");
|
||||||
|
}
|
||||||
|
|
||||||
|
// All tickets
|
||||||
|
else{
|
||||||
|
$sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE company_id = '$company_id' ORDER BY ticket_id LIMIT $limit OFFSET $offset");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Output
|
||||||
|
include("../read_output.php");
|
||||||
Reference in New Issue
Block a user