Version 4.3.0

This commit is contained in:
Neo committed 2025-12-19 05:47:12 -08:00
1 parent 96997ddd8e
commit fe1acf984a
1349 files changed
+116159 -67711

No files matched your search

+21 -5
View File
@@ -27,11 +27,13 @@ class _shipments extends \IPS\Api\Controller
* GET /nexus/shipments
* Get list of shipments
*
* @note For requests using an OAuth Access Token for a particular member, only the members own shipments will be included
* @apiparam string statuses Comma-delimited list of statuses - if provided, only transactions with those statuses are returned - see order object for status keys
* @apiparam string methods Comma-delimited list of shipping method IDs - if provided, only shipments from those methods are returned
* @apiparam string sortBy What to sort by. Can be 'date', 'shipped_date' or do not specify for ID
* @apiparam string sortDir Sort direction. Can be 'asc' or 'desc' - defaults to 'asc'
* @apiparam int page Page number
* @apiparam int perPage Number of results per page - defaults to 25
* @return \IPS\Api\PaginatedResponse<IPS\nexus\Shipping\Order>
*/
public function GETindex()
@@ -50,7 +52,13 @@ class _shipments extends \IPS\Api\Controller
{
$where[] = array( \IPS\Db::i()->in( 'o_method', array_filter( explode( ',', \IPS\Request::i()->methods ) ) ) );
}
/* Permission */
if ( $this->member )
{
$where[] = array( \IPS\Db::i()->in( 'o_invoice', iterator_to_array( \IPS\Db::i()->select( 'i_id', 'nexus_invoices', array( 'i_member=?', $this->member->member_id ) ) ) ) );
}
/* Sort */
if ( isset( \IPS\Request::i()->sortBy ) and in_array( \IPS\Request::i()->sortBy, array( 'date', 'shipped_date' ) ) )
{
@@ -68,7 +76,9 @@ class _shipments extends \IPS\Api\Controller
\IPS\Db::i()->select( '*', 'nexus_ship_orders', $where, "{$sortBy} {$sortDir}" ),
isset( \IPS\Request::i()->page ) ? \IPS\Request::i()->page : 1,
'IPS\nexus\Shipping\Order',
\IPS\Db::i()->select( 'COUNT(*)', 'nexus_ship_orders', $where )->first()
\IPS\Db::i()->select( 'COUNT(*)', 'nexus_ship_orders', $where )->first(),
$this->member,
isset( \IPS\Request::i()->perPage ) ? \IPS\Request::i()->perPage : NULL
);
}
@@ -77,14 +87,20 @@ class _shipments extends \IPS\Api\Controller
* Get information about a specific shipment
*
* @param int $id ID Number
* @throws 2X307/1 INVALID_ID The shipment ID does not exist
* @throws 2X307/1 INVALID_ID The shipment ID does not exist or the authorized user does not have permission to view it
* @return \IPS\nexus\Shipping\Order
*/
public function GETitem( $id )
{
try
{
return new \IPS\Api\Response( 200, \IPS\nexus\Shipping\Order::load( $id )->apiOutput() );
{
$shipment = \IPS\nexus\Shipping\Order::load( $id );
if ( $this->member and !$shipment->invoice->canView( $this->member ) )
{
throw new \OutOfRangeException;
}
return new \IPS\Api\Response( 200, $shipment->apiOutput( $this->member ) );
}
catch ( \OutOfRangeException $e )
{