Version 5.0.0 beta 1

This commit is contained in:
Neo committed 2025-12-19 16:27:35 -08:00
1 parent 25ddeb65d6
commit 15c7beabc5
6736 files changed
+627902 -497943

No files matched your search

+30 -19
View File
@@ -12,16 +12,25 @@
namespace IPS\nexus\api;
/* To prevent PHP errors (extending class does not exist) revealing path */
if ( !\defined( '\IPS\SUITE_UNIQUE_KEY' ) )
use IPS\Api\Controller;
use IPS\Api\Exception;
use IPS\Api\Response;
use IPS\nexus\Purchase\LicenseKey;
use IPS\Request;
use OutOfRangeException;
use function defined;
if ( !defined( '\IPS\SUITE_UNIQUE_KEY' ) )
{
header( ( isset( $_SERVER['SERVER_PROTOCOL'] ) ? $_SERVER['SERVER_PROTOCOL'] : 'HTTP/1.0' ) . ' 403 Forbidden' );
header( ( $_SERVER['SERVER_PROTOCOL'] ?? 'HTTP/1.0' ) . ' 403 Forbidden' );
exit;
}
/**
* @brief License Key API
*/
class _lkey extends \IPS\Api\Controller
class lkey extends Controller
{
/**
* GET /nexus/lkey/{key}
@@ -29,24 +38,25 @@ class _lkey extends \IPS\Api\Controller
*
* @param string $lkey License key
* @throws 2X310/1 INVALID_KEY The license key does not exist or the authorized user does not have permission to view it
* @return \IPS\nexus\Purchase
* @apireturn \IPS\nexus\Purchase
* @return Response
*/
public function GETitem( $lkey )
public function GETitem( string $lkey ): Response
{
try
{
$licenseKey = \IPS\nexus\Purchase\LicenseKey::load( $lkey );
$licenseKey = LicenseKey::load( $lkey );
$purchase = $licenseKey->purchase;
if ( $this->member and !$purchase->canView( $this->member ) )
{
throw new \OutOfRangeException;
throw new OutOfRangeException;
}
return new \IPS\Api\Response( 200, $purchase->apiOutput( $this->member ) );
return new Response( 200, $purchase->apiOutput( $this->member ) );
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException )
{
throw new \IPS\Api\Exception( 'INVALID_KEY', '2X332/1', 404 );
throw new Exception( 'INVALID_KEY', '2X332/1', 404 );
}
}
@@ -58,24 +68,25 @@ class _lkey extends \IPS\Api\Controller
* @apiparam object customFields Values for custom fields
* @param string $lkey License key
* @throws 2X310/2 INVALID_KEY The license key does not exist
* @return \IPS\nexus\Purchase
* @apireturn \IPS\nexus\Purchase
* @return Response
*/
public function POSTitem( $lkey )
public function POSTitem( string $lkey ): Response
{
try
{
$licenseKey = \IPS\nexus\Purchase\LicenseKey::load( $lkey );
$purchase = $licenseKey->purchase;
$licenseKey = LicenseKey::load( $lkey );
$purchase = $licenseKey->purchase;
}
catch ( \OutOfRangeException $e )
catch ( OutOfRangeException )
{
throw new \IPS\Api\Exception( 'INVALID_KEY', '2X332/2', 404 );
throw new Exception( 'INVALID_KEY', '2X332/2', 404 );
}
if ( isset( \IPS\Request::i()->customFields ) )
if ( isset( Request::i()->customFields ) )
{
$customFields = $purchase->custom_fields;
foreach ( \IPS\Request::i()->customFields as $k => $v )
foreach ( Request::i()->customFields as $k => $v )
{
$customFields[ $k ] = $v;
}
@@ -84,6 +95,6 @@ class _lkey extends \IPS\Api\Controller
$purchase->save();
return new \IPS\Api\Response( 200, $purchase->apiOutput( $this->member ) );
return new Response( 200, $purchase->apiOutput( $this->member ) );
}
}