2019-10-16 22:12:38 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Controllers\Support\Messages;
|
|
|
|
|
|
|
|
use App\Http\Controllers\Controller;
|
|
|
|
use App\Mail\SupportMessageSent;
|
|
|
|
use Illuminate\Http\Request;
|
|
|
|
use Illuminate\Support\Facades\Mail;
|
|
|
|
|
|
|
|
class SendingController extends Controller
|
|
|
|
{
|
2019-10-17 11:31:47 +02:00
|
|
|
/**
|
|
|
|
* Send a support message.
|
|
|
|
*
|
|
|
|
* @OA\Post(
|
|
|
|
* path="/api/v1/support/messages/send",
|
|
|
|
* operationId="supportMessage",
|
|
|
|
* tags={"support"},
|
|
|
|
* summary="Sends a support message to Invoice Ninja team",
|
|
|
|
* description="Allows a user to send a support message to the Invoice Ninja Team",
|
|
|
|
* @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\RequestBody(
|
|
|
|
* description="The message",
|
|
|
|
* required=true,
|
|
|
|
* @OA\MediaType(
|
|
|
|
* mediaType="application/json",
|
|
|
|
* @OA\Schema(
|
|
|
|
* type="string",
|
|
|
|
* @OA\Property(
|
|
|
|
* property="message",
|
|
|
|
* description="The support message",
|
|
|
|
* type="string",
|
|
|
|
* ),
|
|
|
|
* )
|
|
|
|
* ),
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
|
|
|
* response=200,
|
|
|
|
* description="Success",
|
2020-06-21 23:30:25 +02:00
|
|
|
* @OA\Header(header="X-MINIMUM-CLIENT-VERSION", ref="#/components/headers/X-MINIMUM-CLIENT-VERSION"),
|
2019-10-17 11:31:47 +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\MediaType(
|
|
|
|
* mediaType="application/json",
|
|
|
|
* @OA\Schema(
|
|
|
|
* type="array",
|
|
|
|
* @OA\Items(
|
|
|
|
* type="string",
|
|
|
|
* description="Server response",
|
|
|
|
* example=true,
|
|
|
|
* ),
|
|
|
|
* )
|
|
|
|
* )
|
|
|
|
* ),
|
|
|
|
* @OA\Response(
|
2019-12-30 22:59:12 +01:00
|
|
|
* response="default",
|
2019-10-17 11:31:47 +02:00
|
|
|
* description="Unexpected Error",
|
|
|
|
* @OA\JsonContent(ref="#/components/schemas/Error"),
|
|
|
|
* ),
|
|
|
|
* )
|
2020-10-28 11:10:49 +01:00
|
|
|
* @param Request $request
|
|
|
|
* @return \Illuminate\Http\JsonResponse
|
2019-10-17 11:31:47 +02:00
|
|
|
*/
|
2019-10-16 22:12:38 +02:00
|
|
|
public function __invoke(Request $request)
|
|
|
|
{
|
|
|
|
$request->validate([
|
|
|
|
'message' => ['required'],
|
|
|
|
]);
|
|
|
|
|
2020-01-19 04:02:02 +01:00
|
|
|
$send_logs = false;
|
|
|
|
|
2020-03-21 06:37:30 +01:00
|
|
|
if ($request->has('send_logs')) {
|
2020-01-19 04:02:02 +01:00
|
|
|
$send_logs = $request->input('send_logs');
|
2020-03-21 06:37:30 +01:00
|
|
|
}
|
2020-01-19 04:02:02 +01:00
|
|
|
|
2019-10-16 22:12:38 +02:00
|
|
|
Mail::to(config('ninja.contact.ninja_official_contact'))
|
2020-01-19 04:02:02 +01:00
|
|
|
->send(new SupportMessageSent($request->message, $send_logs));
|
2019-10-16 22:12:38 +02:00
|
|
|
|
|
|
|
return response()->json([
|
2020-09-06 11:38:10 +02:00
|
|
|
'success' => true,
|
2020-05-04 13:13:46 +02:00
|
|
|
], 200);
|
2019-10-16 22:12:38 +02:00
|
|
|
}
|
|
|
|
}
|