Credit PDF download

This commit is contained in:
David Bomba 2023-02-01 19:54:30 +11:00
parent be03714aa4
commit 4c502919dc
3 changed files with 22 additions and 0 deletions

View File

@ -646,6 +646,10 @@ class CreditController extends BaseController
{
$invitation = $this->credit_repository->getInvitationByKey($invitation_key);
if (! $invitation) {
return response()->json(['message' => 'no record found'], 400);
}
$credit = $invitation->credit;
$file = $credit->service()->getCreditPdf($invitation);

View File

@ -172,6 +172,7 @@ Route::group(['middleware' => ['throttle:300,1', 'api_db', 'token_auth', 'locale
Route::put('credits/{credit}/upload', [CreditController::class, 'upload'])->name('credits.upload');
Route::get('credits/{credit}/{action}', [CreditController::class, 'action'])->name('credits.action');
Route::post('credits/bulk', [CreditController::class, 'bulk'])->name('credits.bulk');
Route::get('credit/{invitation_key}/download', [CreditController::class, 'downloadPdf'])->name('credits.downloadPdf');
Route::resource('designs', DesignController::class); // name = (payments. index / create / show / update / destroy / edit
Route::post('designs/bulk', [DesignController::class, 'bulk'])->name('designs.bulk');

View File

@ -40,6 +40,23 @@ class CreditTest extends TestCase
$this->makeTestData();
}
public function testQuoteDownloadPDF()
{
$i = $this->credit->invitations->first();
$response = $this->withHeaders([
'X-API-SECRET' => config('ninja.api_secret'),
'X-API-TOKEN' => $this->token,
])->get("/api/v1/credit/{$i->key}/download");
$response->assertStatus(200);
$this->assertTrue($response->headers->get('content-type') == 'application/pdf');
}
public function testBulkActions()
{