| 1 |
<?php |
| 2 |
|
| 3 |
namespace BitCode\BitForm\Core\Util; |
| 4 |
|
| 5 |
use BitCode\BitForm\Core\Database\FormEntryLogModel; |
| 6 |
|
| 7 |
final class ApiResponse |
| 8 |
{ |
| 9 |
public function apiResponse($logID, $integrationId, $apiType, $responseType, $responseObj) |
| 10 |
{ |
| 11 |
if (!$apiType || !$responseObj) { |
| 12 |
return false; |
| 13 |
} |
| 14 |
$apiType = wp_json_encode($apiType); |
| 15 |
$responseObj = wp_json_encode($responseObj); |
| 16 |
|
| 17 |
$ipTool = new IpTool(); |
| 18 |
$user_details = $ipTool->getUserDetail(); |
| 19 |
$formEntryModel = new FormEntryLogModel(); |
| 20 |
$result = $formEntryModel->log_history_insert( |
| 21 |
[ |
| 22 |
'log_id' => $logID, |
| 23 |
'integration_id' => $integrationId, |
| 24 |
'api_type' => $apiType, |
| 25 |
'response_type' => $responseType, |
| 26 |
'response_obj' => $responseObj, |
| 27 |
'created_at' => $user_details['time'], |
| 28 |
] |
| 29 |
); |
| 30 |
return $result; |
| 31 |
} |
| 32 |
} |
| 33 |
|