2019-09-27 06:31:13 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2020-01-07 01:13:47 +01:00
|
|
|
* @copyright Copyright (c) 2020. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-09-27 06:31:13 +02:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Models\Activity;
|
|
|
|
use App\Transformers\ActivityTransformer;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
|
|
|
|
class ActivityController extends BaseController
|
|
|
|
{
|
|
|
|
protected $entity_type = Activity::class;
|
|
|
|
|
|
|
|
protected $entity_transformer = ActivityTransformer::class;
|
|
|
|
|
|
|
|
public function __construct()
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2019-11-18 11:46:01 +01:00
|
|
|
* @OA\Get(
|
|
|
|
* path="/api/v1/actvities",
|
|
|
|
* operationId="getActivities",
|
|
|
|
* tags={"actvities"},
|
|
|
|
* summary="Gets a list of actvities",
|
|
|
|
* description="Lists all activities",
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Api-Secret"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Api-Token"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/X-Requested-With"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/include"),
|
|
|
|
* @OA\Parameter(ref="#/components/parameters/index"),
|
2019-11-28 11:35:13 +01:00
|
|
|
* @OA\Parameter(
|
|
|
|
* name="rows",
|
2019-12-04 02:06:14 +01:00
|
|
|
* in="query",
|
2019-11-28 11:35:13 +01:00
|
|
|
* description="The number of activities to return",
|
|
|
|
* example="50",
|
2019-12-04 02:06:14 +01:00
|
|
|
* required=false,
|
2019-11-28 11:35:13 +01:00
|
|
|
* @OA\Schema(
|
|
|
|
* type="number",
|
|
|
|
* format="integer",
|
|
|
|
* ),
|
|
|
|
* ),
|
2019-11-18 11:46:01 +01:00
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="A list of actvities",
|
|
|
|
* @OA\Header(header="X-API-Version", ref="#/components/headers/X-API-Version"),
|
|
|
|
* @OA\Header(header="X-RateLimit-Remaining", ref="#/components/headers/X-RateLimit-Remaining"),
|
|
|
|
* @OA\Header(header="X-RateLimit-Limit", ref="#/components/headers/X-RateLimit-Limit"),
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Activity"),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=422,
|
|
|
|
* description="Validation error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
|
|
|
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
2019-12-30 22:59:12 +01:00
|
|
|
* response="default",
|
2019-11-18 11:46:01 +01:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2019-09-27 06:31:13 +02:00
|
|
|
*
|
|
|
|
*/
|
2019-11-28 11:35:13 +01:00
|
|
|
public function index(Request $request)
|
2019-09-27 06:31:13 +02:00
|
|
|
{
|
2019-12-16 12:52:00 +01:00
|
|
|
$default_activities = $request->has('rows') ? $request->input('rows') : 50;
|
2019-09-27 06:31:13 +02:00
|
|
|
|
2019-11-27 10:47:59 +01:00
|
|
|
$activities = Activity::orderBy('created_at', 'DESC')->company()
|
2019-11-28 11:35:13 +01:00
|
|
|
->take($default_activities);
|
2019-11-27 10:47:59 +01:00
|
|
|
|
|
|
|
|
2019-09-27 06:31:13 +02:00
|
|
|
return $this->listResponse($activities);
|
|
|
|
}
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|