2019-10-03 05:23:00 +02:00
|
|
|
<?php
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
2019-10-03 05:23:00 +02:00
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
2021-01-03 22:54:54 +01:00
|
|
|
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
|
2019-10-03 05:23:00 +02:00
|
|
|
*
|
|
|
|
* @license https://opensource.org/licenses/AAL
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
|
|
|
|
use App\Factory\CompanyGatewayFactory;
|
|
|
|
use App\Http\Requests\CompanyGateway\CreateCompanyGatewayRequest;
|
|
|
|
use App\Http\Requests\CompanyGateway\DestroyCompanyGatewayRequest;
|
|
|
|
use App\Http\Requests\CompanyGateway\EditCompanyGatewayRequest;
|
|
|
|
use App\Http\Requests\CompanyGateway\ShowCompanyGatewayRequest;
|
|
|
|
use App\Http\Requests\CompanyGateway\StoreCompanyGatewayRequest;
|
|
|
|
use App\Http\Requests\CompanyGateway\UpdateCompanyGatewayRequest;
|
|
|
|
use App\Models\CompanyGateway;
|
|
|
|
use App\Repositories\CompanyRepository;
|
|
|
|
use App\Transformers\CompanyGatewayTransformer;
|
|
|
|
use App\Utils\Traits\MakesHash;
|
|
|
|
use Illuminate\Foundation\Bus\DispatchesJobs;
|
|
|
|
use Illuminate\Http\Request;
|
2020-10-28 11:10:49 +01:00
|
|
|
use Illuminate\Http\Response;
|
2019-10-03 05:23:00 +02:00
|
|
|
|
|
|
|
/**
|
2020-09-06 11:38:10 +02:00
|
|
|
* Class CompanyGatewayController.
|
2019-10-03 05:23:00 +02:00
|
|
|
*/
|
|
|
|
class CompanyGatewayController extends BaseController
|
|
|
|
{
|
|
|
|
use DispatchesJobs;
|
|
|
|
use MakesHash;
|
|
|
|
|
|
|
|
protected $entity_type = CompanyGateway::class;
|
|
|
|
|
|
|
|
protected $entity_transformer = CompanyGatewayTransformer::class;
|
|
|
|
|
|
|
|
protected $company_repo;
|
|
|
|
|
|
|
|
public $forced_includes = [];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* CompanyGatewayController constructor.
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param CompanyRepository $company_repo
|
2019-10-03 05:23:00 +02:00
|
|
|
*/
|
|
|
|
public function __construct(CompanyRepository $company_repo)
|
|
|
|
{
|
|
|
|
parent::__construct();
|
|
|
|
|
|
|
|
$this->company_repo = $company_repo;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display a listing of the resource.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @return Response
|
2019-10-07 06:09:04 +02:00
|
|
|
*
|
2019-12-30 22:59:12 +01:00
|
|
|
*
|
|
|
|
*
|
2019-10-07 06:09:04 +02:00
|
|
|
* @OA\Get(
|
|
|
|
* path="/api/v1/company_gateways",
|
|
|
|
* operationId="getCompanyGateways",
|
|
|
|
* tags={"company_gateways"},
|
|
|
|
* summary="Gets a list of company_gateways",
|
|
|
|
* description="Lists company_gateways, search and filters allow fine grained lists to be generated.
|
|
|
|
|
|
|
|
Query parameters can be added to performed more fine grained filtering of the company_gateways, these are handled by the CompanyGatewayFilters class which defines the methods available",
|
|
|
|
* @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\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="A list of company_gateways",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2019-10-07 06:09:04 +02:00
|
|
|
* @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/CompanyGateway"),
|
|
|
|
* ),
|
|
|
|
* @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-10-07 06:09:04 +02:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2019-10-03 05:23:00 +02:00
|
|
|
*/
|
|
|
|
public function index()
|
|
|
|
{
|
|
|
|
$company_gateways = CompanyGateway::whereCompanyId(auth()->user()->company()->id);
|
|
|
|
|
|
|
|
return $this->listResponse($company_gateways);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for creating a new resource.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param CreateCompanyGatewayRequest $request
|
|
|
|
* @return Response
|
2019-10-07 06:09:04 +02:00
|
|
|
*
|
2019-12-30 22:59:12 +01:00
|
|
|
*
|
|
|
|
*
|
2019-10-07 06:09:04 +02:00
|
|
|
* @OA\Get(
|
|
|
|
* path="/api/v1/company_gateways/create",
|
|
|
|
* operationId="getCompanyGatewaysCreate",
|
|
|
|
* tags={"company_gateways"},
|
|
|
|
* summary="Gets a new blank CompanyGateway object",
|
|
|
|
* description="Returns a blank object with default values",
|
|
|
|
* @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\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="A blank CompanyGateway object",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2019-10-07 06:09:04 +02:00
|
|
|
* @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/CompanyGateway"),
|
|
|
|
* ),
|
|
|
|
* @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-10-07 06:09:04 +02:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2019-10-03 05:23:00 +02:00
|
|
|
*/
|
|
|
|
public function create(CreateCompanyGatewayRequest $request)
|
|
|
|
{
|
|
|
|
$company_gateway = CompanyGatewayFactory::create(auth()->user()->company()->id, auth()->user()->id);
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2019-10-03 05:23:00 +02:00
|
|
|
return $this->itemResponse($company_gateway);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Store a newly created resource in storage.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param StoreCompanyGatewayRequest $request
|
|
|
|
* @return Response
|
2019-10-07 06:09:04 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @OA\Post(
|
|
|
|
* path="/api/v1/company_gateways",
|
|
|
|
* operationId="storeCompanyGateway",
|
|
|
|
* tags={"company_gateways"},
|
|
|
|
* summary="Adds a CompanyGateway",
|
|
|
|
* description="Adds an CompanyGateway to the system",
|
|
|
|
* @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\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Returns the saved CompanyGateway object",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2019-10-07 06:09:04 +02:00
|
|
|
* @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/CompanyGateway"),
|
|
|
|
* ),
|
|
|
|
* @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-10-07 06:09:04 +02:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2019-10-03 05:23:00 +02:00
|
|
|
*/
|
|
|
|
public function store(StoreCompanyGatewayRequest $request)
|
|
|
|
{
|
|
|
|
$company_gateway = CompanyGatewayFactory::create(auth()->user()->company()->id, auth()->user()->id);
|
|
|
|
$company_gateway->fill($request->all());
|
|
|
|
$company_gateway->save();
|
|
|
|
|
|
|
|
return $this->itemResponse($company_gateway);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Display the specified resource.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param ShowCompanyGatewayRequest $request
|
|
|
|
* @param CompanyGateway $company_gateway
|
|
|
|
* @return Response
|
2019-10-07 06:09:04 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* @OA\Get(
|
|
|
|
* path="/api/v1/company_gateways/{id}",
|
|
|
|
* operationId="showCompanyGateway",
|
|
|
|
* tags={"company_gateways"},
|
|
|
|
* summary="Shows an CompanyGateway",
|
|
|
|
* description="Displays an CompanyGateway by id",
|
|
|
|
* @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(
|
|
|
|
* name="id",
|
|
|
|
* in="path",
|
|
|
|
* description="The CompanyGateway Hashed ID",
|
|
|
|
* example="D2J234DFA",
|
|
|
|
* required=true,
|
|
|
|
* @OA\Schema(
|
|
|
|
* type="string",
|
|
|
|
* format="string",
|
|
|
|
* ),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Returns the CompanyGateway object",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2019-10-07 06:09:04 +02:00
|
|
|
* @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/CompanyGateway"),
|
|
|
|
* ),
|
|
|
|
* @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-10-07 06:09:04 +02:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2019-12-30 22:59:12 +01:00
|
|
|
*/
|
2019-10-03 05:23:00 +02:00
|
|
|
public function show(ShowCompanyGatewayRequest $request, CompanyGateway $company_gateway)
|
|
|
|
{
|
|
|
|
return $this->itemResponse($company_gateway);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show the form for editing the specified resource.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param EditCompanyGatewayRequest $request
|
|
|
|
* @param CompanyGateway $company_gateway
|
|
|
|
* @return Response
|
2019-10-07 06:09:04 +02:00
|
|
|
*
|
2019-12-30 22:59:12 +01:00
|
|
|
*
|
2019-10-07 06:09:04 +02:00
|
|
|
* @OA\Get(
|
|
|
|
* path="/api/v1/company_gateways/{id}/edit",
|
|
|
|
* operationId="editCompanyGateway",
|
|
|
|
* tags={"company_gateways"},
|
|
|
|
* summary="Shows an CompanyGateway for editting",
|
|
|
|
* description="Displays an CompanyGateway by id",
|
|
|
|
* @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(
|
|
|
|
* name="id",
|
|
|
|
* in="path",
|
|
|
|
* description="The CompanyGateway Hashed ID",
|
|
|
|
* example="D2J234DFA",
|
|
|
|
* required=true,
|
|
|
|
* @OA\Schema(
|
|
|
|
* type="string",
|
|
|
|
* format="string",
|
|
|
|
* ),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Returns the CompanyGateway object",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2019-10-07 06:09:04 +02:00
|
|
|
* @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/CompanyGateway"),
|
|
|
|
* ),
|
|
|
|
* @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-10-07 06:09:04 +02:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2019-10-03 05:23:00 +02:00
|
|
|
*/
|
|
|
|
public function edit(EditCompanyGatewayRequest $request, CompanyGateway $company_gateway)
|
|
|
|
{
|
2019-12-30 22:59:12 +01:00
|
|
|
return $this->itemResponse($company_gateway);
|
2019-10-03 05:23:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Update the specified resource in storage.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param UpdateCompanyGatewayRequest $request
|
|
|
|
* @param CompanyGateway $company_gateway
|
|
|
|
* @return Response
|
2019-10-07 06:09:04 +02:00
|
|
|
*
|
2019-12-30 22:59:12 +01:00
|
|
|
*
|
2019-10-07 06:09:04 +02:00
|
|
|
* @OA\Put(
|
|
|
|
* path="/api/v1/company_gateways/{id}",
|
|
|
|
* operationId="updateCompanyGateway",
|
|
|
|
* tags={"company_gateways"},
|
|
|
|
* summary="Updates an CompanyGateway",
|
|
|
|
* description="Handles the updating of an CompanyGateway by id",
|
|
|
|
* @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(
|
|
|
|
* name="id",
|
|
|
|
* in="path",
|
|
|
|
* description="The CompanyGateway Hashed ID",
|
|
|
|
* example="D2J234DFA",
|
|
|
|
* required=true,
|
|
|
|
* @OA\Schema(
|
|
|
|
* type="string",
|
|
|
|
* format="string",
|
|
|
|
* ),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Returns the CompanyGateway object",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2019-10-07 06:09:04 +02:00
|
|
|
* @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/CompanyGateway"),
|
|
|
|
* ),
|
|
|
|
* @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-10-07 06:09:04 +02:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2019-12-30 22:59:12 +01:00
|
|
|
*/
|
2019-10-03 05:23:00 +02:00
|
|
|
public function update(UpdateCompanyGatewayRequest $request, CompanyGateway $company_gateway)
|
|
|
|
{
|
|
|
|
$company_gateway->fill($request->all());
|
2019-11-11 13:21:19 +01:00
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
if (! $request->has('fees_and_limits')) {
|
2019-11-11 13:21:19 +01:00
|
|
|
$company_gateway->fees_and_limits = '';
|
2019-12-30 22:59:12 +01:00
|
|
|
}
|
2019-11-11 13:21:19 +01:00
|
|
|
|
2019-10-03 05:23:00 +02:00
|
|
|
$company_gateway->save();
|
|
|
|
|
|
|
|
return $this->itemResponse($company_gateway);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Remove the specified resource from storage.
|
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param DestroyCompanyGatewayRequest $request
|
|
|
|
* @param CompanyGateway $company_gateway
|
|
|
|
* @return Response
|
2019-10-07 06:09:04 +02:00
|
|
|
*
|
2019-12-30 22:59:12 +01:00
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @throws \Exception
|
2019-10-07 06:09:04 +02:00
|
|
|
* @OA\Delete(
|
|
|
|
* path="/api/v1/company_gateways/{id}",
|
|
|
|
* operationId="deleteCompanyGateway",
|
|
|
|
* tags={"company_gateways"},
|
|
|
|
* summary="Deletes a CompanyGateway",
|
|
|
|
* description="Handles the deletion of an CompanyGateway by id",
|
|
|
|
* @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(
|
|
|
|
* name="id",
|
|
|
|
* in="path",
|
|
|
|
* description="The CompanyGateway Hashed ID",
|
|
|
|
* example="D2J234DFA",
|
|
|
|
* required=true,
|
|
|
|
* @OA\Schema(
|
|
|
|
* type="string",
|
|
|
|
* format="string",
|
|
|
|
* ),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Returns a HTTP status",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2019-10-07 06:09:04 +02:00
|
|
|
* @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\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-10-07 06:09:04 +02:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2019-10-03 05:23:00 +02:00
|
|
|
*/
|
|
|
|
public function destroy(DestroyCompanyGatewayRequest $request, CompanyGateway $company_gateway)
|
|
|
|
{
|
|
|
|
$company_gateway->delete();
|
|
|
|
|
2021-01-17 05:28:03 +01:00
|
|
|
return $this->itemResponse($company_gateway->fresh());
|
2019-10-03 05:23:00 +02:00
|
|
|
}
|
2020-06-04 00:18:27 +02:00
|
|
|
|
2020-09-06 11:38:10 +02:00
|
|
|
/**
|
|
|
|
* Perform bulk actions on the list view.
|
2020-06-04 00:18:27 +02:00
|
|
|
*
|
2020-10-28 11:10:49 +01:00
|
|
|
* @return Response
|
2020-06-04 00:18:27 +02:00
|
|
|
*
|
|
|
|
*
|
|
|
|
* @OA\Post(
|
|
|
|
* path="/api/v1/company_gateways/bulk",
|
|
|
|
* operationId="bulkCompanyGateways",
|
|
|
|
* tags={"company_gateways"},
|
|
|
|
* summary="Performs bulk actions on an array of company_gateways",
|
|
|
|
* description="",
|
|
|
|
* @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/index"),
|
|
|
|
* @OA\RequestBody(
|
|
|
|
* description="Array of company gateway IDs",
|
|
|
|
* required=true,
|
|
|
|
* @OA\MediaType(
|
|
|
|
* mediaType="application/json",
|
|
|
|
* @OA\Schema(
|
|
|
|
* type="array",
|
|
|
|
* @OA\Items(
|
|
|
|
* type="integer",
|
|
|
|
* description="Array of hashed IDs to be bulk 'actioned",
|
|
|
|
* example="[0,1,2,3]",
|
|
|
|
* ),
|
|
|
|
* )
|
|
|
|
* )
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="The Company Gateways response",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2020-06-04 00:18:27 +02:00
|
|
|
* @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/CompanyGateway"),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=422,
|
|
|
|
* description="Validation error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/ValidationError"),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response="default",
|
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
|
|
|
*/
|
|
|
|
public function bulk()
|
|
|
|
{
|
|
|
|
$action = request()->input('action');
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-06-04 00:18:27 +02:00
|
|
|
$ids = request()->input('ids');
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-06-04 00:18:27 +02:00
|
|
|
$company_gateways = CompanyGateway::withTrashed()->find($this->transformKeys($ids));
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-06-04 00:18:27 +02:00
|
|
|
$company_gateways->each(function ($company_gateway, $key) use ($action) {
|
|
|
|
if (auth()->user()->can('edit', $company_gateway)) {
|
2020-06-04 23:23:42 +02:00
|
|
|
$this->company_repo->{$action}($company_gateway);
|
2020-06-04 00:18:27 +02:00
|
|
|
}
|
|
|
|
});
|
2020-09-06 11:38:10 +02:00
|
|
|
|
2020-06-04 00:18:27 +02:00
|
|
|
return $this->listResponse(CompanyGateway::withTrashed()->whereIn('id', $this->transformKeys($ids)));
|
|
|
|
}
|
2019-10-03 05:23:00 +02:00
|
|
|
}
|