diff --git a/app/Factory/ClientGatewayTokenFactory.php b/app/Factory/ClientGatewayTokenFactory.php new file mode 100644 index 000000000000..2aa382e7ceb1 --- /dev/null +++ b/app/Factory/ClientGatewayTokenFactory.php @@ -0,0 +1,31 @@ +user_id = $user_id; + $client_gateway_token->company_id = $company_id; + $client_gateway_token->is_default = false; + $client_gateway_token->meta = ''; + $client_gateway_token->is_deleted = false; + $client_gateway_token->token = ''; + $client_gateway_token->routing_number = ''; + + return $client_gateway_token; + } +} diff --git a/app/Http/Controllers/ClientGatewayTokenController.php b/app/Http/Controllers/ClientGatewayTokenController.php new file mode 100644 index 000000000000..2e9cb5eb0766 --- /dev/null +++ b/app/Http/Controllers/ClientGatewayTokenController.php @@ -0,0 +1,433 @@ +client_gateway_token_repo = $client_gateway_token_gateway_token_repo; + } + + /** + * @OA\Get( + * path="/api/v1/client_gateway_tokens", + * operationId="getClientGatewayTokens", + * tags={"client_gateway_tokens"}, + * summary="Gets a list of client_gateway_tokens", + * description="Lists client_gateway_tokens, search and filters allow fine grained lists to be generated. + + Query parameters can be added to performed more fine grained filtering of the client_gateway_tokens, these are handled by the ClientGatewayTokenFilters 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\Parameter(ref="#/components/parameters/index"), + * @OA\Response( + * response=200, + * description="A list of client_gateway_tokens", + * @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-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/ClientGatewayToken"), + * ), + * @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"), + * ), + * ) + * @param ClientGatewayTokenFilters $filters + * @return Response|mixed + */ + public function index(Request $request) + { + $client_gateway_token_gateway_tokens = ClientGatewayToken::scope(); + + return $this->listResponse($client_gateway_token_gateway_tokens); + } + + /** + * Display the specified resource. + * + * @param ShowClientGatewayTokenRequest $request + * @param ClientGatewayToken $client_gateway_token + * @return Response + * + * + * @OA\Get( + * path="/api/v1/client_gateway_tokens/{id}", + * operationId="showClientGatewayToken", + * tags={"client_gateway_tokens"}, + * summary="Shows a client", + * description="Displays a client 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 ClientGatewayToken Hashed ID", + * example="D2J234DFA", + * required=true, + * @OA\Schema( + * type="string", + * format="string", + * ), + * ), + * @OA\Response( + * response=200, + * description="Returns the cl.ient object", + * @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-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/ClientGatewayToken"), + * ), + * @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 show(ShowClientGatewayTokenRequest $request, ClientGatewayToken $client_gateway_token) + { + return $this->itemResponse($client_gateway_token); + } + + /** + * Show the form for editing the specified resource. + * + * @param EditClientGatewayTokenRequest $request + * @param ClientGatewayToken $client_gateway_token + * @return Response + * + * + * @OA\Get( + * path="/api/v1/client_gateway_tokens/{id}/edit", + * operationId="editClientGatewayToken", + * tags={"client_gateway_tokens"}, + * summary="Shows a client for editting", + * description="Displays a client 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 ClientGatewayToken Hashed ID", + * example="D2J234DFA", + * required=true, + * @OA\Schema( + * type="string", + * format="string", + * ), + * ), + * @OA\Response( + * response=200, + * description="Returns the client object", + * @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-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/ClientGatewayToken"), + * ), + * @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 edit(EditClientGatewayTokenRequest $request, ClientGatewayToken $client_gateway_token) + { + return $this->itemResponse($client_gateway_token); + } + + /** + * Update the specified resource in storage. + * + * @param UpdateClientGatewayTokenRequest $request + * @param ClientGatewayToken $client_gateway_token + * @return Response + * + * + * + * @OA\Put( + * path="/api/v1/client_gateway_tokens/{id}", + * operationId="updateClientGatewayToken", + * tags={"client_gateway_tokens"}, + * summary="Updates a client", + * description="Handles the updating of a client 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 ClientGatewayToken Hashed ID", + * example="D2J234DFA", + * required=true, + * @OA\Schema( + * type="string", + * format="string", + * ), + * ), + * @OA\Response( + * response=200, + * description="Returns the client object", + * @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-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/ClientGatewayToken"), + * ), + * @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 update(UpdateClientGatewayTokenRequest $request, ClientGatewayToken $client_gateway_token) + { + + $client_gateway_token = $this->client_gateway_token_repo->save($request->all(), $client_gateway_token); + + return $this->itemResponse($client_gateway_token->fresh()); + } + + /** + * Show the form for creating a new resource. + * + * @param CreateClientGatewayTokenRequest $request + * @return Response + * + * + * + * @OA\Get( + * path="/api/v1/client_gateway_tokens/create", + * operationId="getClientGatewayTokensCreate", + * tags={"client_gateway_tokens"}, + * summary="Gets a new blank client 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 client object", + * @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-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/ClientGatewayToken"), + * ), + * @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 create(CreateClientGatewayTokenRequest $request) + { + $client_gateway_token = ClientGatewayTokenFactory::create(auth()->user()->company()->id, auth()->user()->id); + + return $this->itemResponse($client_gateway_token); + } + + /** + * Store a newly created resource in storage. + * + * @param StoreClientGatewayTokenRequest $request + * @return Response + * + * + * + * @OA\Post( + * path="/api/v1/client_gateway_tokens", + * operationId="storeClientGatewayToken", + * tags={"client_gateway_tokens"}, + * summary="Adds a client", + * description="Adds an client to a company", + * @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 client object", + * @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-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/ClientGatewayToken"), + * ), + * @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 store(StoreClientGatewayTokenRequest $request) + { + + + return $this->itemResponse($client_gateway_token); + } + + /** + * Remove the specified resource from storage. + * + * @param DestroyClientGatewayTokenRequest $request + * @param ClientGatewayToken $client_gateway_token + * @return Response + * + * + * @throws \Exception + * @OA\Delete( + * path="/api/v1/client_gateway_tokens/{id}", + * operationId="deleteClientGatewayToken", + * tags={"client_gateway_tokens"}, + * summary="Deletes a client", + * description="Handles the deletion of a client 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 ClientGatewayToken Hashed ID", + * example="D2J234DFA", + * required=true, + * @OA\Schema( + * type="string", + * format="string", + * ), + * ), + * @OA\Response( + * response=200, + * description="Returns a HTTP status", + * @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-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\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 destroy(DestroyClientGatewayTokenRequest $request, ClientGatewayToken $client_gateway_token) + { + + $this->client_gateway_token_repo->delete($client_gateway_token); + + return $this->itemResponse($client_gateway_token->fresh()); + + } + +} diff --git a/app/Http/Requests/ClientGatewayToken/CreateClientGatewayTokenRequest.php b/app/Http/Requests/ClientGatewayToken/CreateClientGatewayTokenRequest.php new file mode 100644 index 000000000000..acf74aa05ee7 --- /dev/null +++ b/app/Http/Requests/ClientGatewayToken/CreateClientGatewayTokenRequest.php @@ -0,0 +1,28 @@ +user()->isAdmin(); + } +} diff --git a/app/Http/Requests/ClientGatewayToken/DestroyClientGatewayTokenRequest.php b/app/Http/Requests/ClientGatewayToken/DestroyClientGatewayTokenRequest.php new file mode 100644 index 000000000000..755d0033643b --- /dev/null +++ b/app/Http/Requests/ClientGatewayToken/DestroyClientGatewayTokenRequest.php @@ -0,0 +1,27 @@ +user()->isAdmin(); + } +} diff --git a/app/Http/Requests/ClientGatewayToken/EditClientGatewayTokenRequest.php b/app/Http/Requests/ClientGatewayToken/EditClientGatewayTokenRequest.php new file mode 100644 index 000000000000..33fb1b30e96b --- /dev/null +++ b/app/Http/Requests/ClientGatewayToken/EditClientGatewayTokenRequest.php @@ -0,0 +1,28 @@ +user()->isAdmin(); + } + +} diff --git a/app/Http/Requests/ClientGatewayToken/ShowClientGatewayTokenRequest.php b/app/Http/Requests/ClientGatewayToken/ShowClientGatewayTokenRequest.php new file mode 100644 index 000000000000..004d068ac6f6 --- /dev/null +++ b/app/Http/Requests/ClientGatewayToken/ShowClientGatewayTokenRequest.php @@ -0,0 +1,27 @@ +user()->isAdmin(); + } +} diff --git a/app/Http/Requests/ClientGatewayToken/StoreClientGatewayTokenRequest.php b/app/Http/Requests/ClientGatewayToken/StoreClientGatewayTokenRequest.php new file mode 100644 index 000000000000..26efee9291f8 --- /dev/null +++ b/app/Http/Requests/ClientGatewayToken/StoreClientGatewayTokenRequest.php @@ -0,0 +1,66 @@ +user()->isAdmin() + } + + public function rules() + { + $rules = [ + 'client_id' => 'required', + 'company_gateway_id' => 'required', + ]; + + + return $this->globalRules($rules); + + } + + protected function prepareForValidation() + { + $input = $this->all(); + + $input = $this->decodePrimaryKeys($input); + + + $this->replace($input); + } + + public function messages() + { + return [ + ]; + } + +} diff --git a/app/Http/Requests/ClientGatewayToken/UpdateClientGatewayTokenRequest.php b/app/Http/Requests/ClientGatewayToken/UpdateClientGatewayTokenRequest.php new file mode 100644 index 000000000000..ff38aa0e62a8 --- /dev/null +++ b/app/Http/Requests/ClientGatewayToken/UpdateClientGatewayTokenRequest.php @@ -0,0 +1,56 @@ +user()->isAdmin(); + } + + public function rules() + { + /* Ensure we have a client name, and that all emails are unique*/ + $rules = []; + return $rules; + } + + public function messages() + { + return [ + ]; + } + + protected function prepareForValidation() + { + $input = $this->all(); + + + $this->replace($input); + } + +} diff --git a/app/Models/ClientGatewayToken.php b/app/Models/ClientGatewayToken.php index a68ad9224837..9f4c9b227ade 100644 --- a/app/Models/ClientGatewayToken.php +++ b/app/Models/ClientGatewayToken.php @@ -66,9 +66,9 @@ class ClientGatewayToken extends BaseModel * @param null $field * @return Model|null */ - public function resolveRouteBinding($value, $field = null) - { - return $this - ->where('id', $this->decodePrimaryKey($value))->firstOrFail(); - } + // public function resolveRouteBinding($value, $field = null) + // { + // return $this + // ->where('id', $this->decodePrimaryKey($value))->firstOrFail(); + // } } diff --git a/app/Repositories/ClientGatewayTokenRepository.php b/app/Repositories/ClientGatewayTokenRepository.php new file mode 100644 index 000000000000..6da85b82947b --- /dev/null +++ b/app/Repositories/ClientGatewayTokenRepository.php @@ -0,0 +1,19 @@ + 'Disable Two Factor', 'invoice_task_datelog' => 'Invoice Task Datelog', 'invoice_task_datelog_help' => 'Add date details to the invoice line items', + 'lang_Russian' => 'Russian', + ); return $LANG;