Introduced `economicPaymentTermsRoute` and `economic_payment_terms_endpoint` to handle fetching payment terms from the economic API. Updated the `economic` class to include the new payment terms endpoint. Logging and session validation were also implemented for enhanced traceability and security.
42 lines
1.2 KiB
PHP
42 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace routes;
|
|
|
|
use classes\authentication;
|
|
use classes\economic;
|
|
use classes\response;
|
|
use classes\router;
|
|
use objects\logs_o;
|
|
use traits\route_t;
|
|
|
|
class economicPaymentTermsRoute
|
|
{
|
|
use route_t;
|
|
|
|
public function run(): void
|
|
{
|
|
global /** @var response $response */
|
|
/** @var router $router */
|
|
$router, $response;
|
|
|
|
|
|
$this->get('/economic/payment-terms', function () {
|
|
global $response;
|
|
$this->requirePermission('economic_payment_terms');
|
|
$user = (new authentication())->get_user();
|
|
if ($user) {
|
|
(new logs_o())->add('economic_payment_terms', 'global', 1, $user->id, 'ECONOMIC_PAYMENT_TERMS', 'Successfully fetched economic payment terms');
|
|
$response->success(
|
|
(new economic())->payment_terms->get()->collection
|
|
);
|
|
} else {
|
|
(new logs_o())->add('economic_payment_terms', 'global', 1, 0, 'ECONOMIC_PAYMENT_TERMS', 'No user found, or invalid session');
|
|
$response->error('Invalid session', 400);
|
|
}
|
|
},
|
|
[
|
|
'economic_payment_terms' => 'Get economic payment terms'
|
|
]
|
|
);
|
|
}
|
|
} |