Skip to content

Commit

Permalink
report bro config default (#29)
Browse files Browse the repository at this point in the history
* report bro config default

* report bro config default

* report bro config default

* Update src/EscolaLmsTemplatesPdfServiceProvider.php

Co-authored-by: Maciej Rymarz <59456825+mako321@users.noreply.github.com>

---------

Co-authored-by: Mateusz Wojczal <mateusz@wojczal.com>
Co-authored-by: Maciej Rymarz <59456825+mako321@users.noreply.github.com>
  • Loading branch information
3 people committed May 18, 2023
1 parent 14b09de commit 96fbfc7
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
8 changes: 4 additions & 4 deletions src/EscolaLmsTemplatesPdfServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ public function register()

$this->app->register(AuthServiceProvider::class);
$this->app->register(UserTemplateServiceProvider::class);

if (class_exists(\EscolaLms\Settings\Facades\AdministrableConfig::class)) {
AdministrableConfig::registerConfig(self::CONFIG_KEY . '.reportbro_url', ['required', 'string'], true);
}
}

public function boot()
Expand All @@ -42,10 +46,6 @@ public function boot()
if ($this->app->runningInConsole()) {
$this->bootForConsole();
}

if (class_exists(\EscolaLms\Settings\Facades\AdministrableConfig::class)) {
AdministrableConfig::registerConfig(self::CONFIG_KEY . '.reportbro_url', ['required', 'string'], true);
}
}

public function bootForConsole()
Expand Down
6 changes: 2 additions & 4 deletions src/Services/ReportBroService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@

class ReportBroService implements ReportBroServiceContract
{


public function getKeyFromPayload(string $payload): string
{

$reportBroUrl = config(EscolaLmsTemplatesPdfServiceProvider::CONFIG_KEY . '.reportbro_url', "https://pdfs.escolalms-api-stage.s.escolait.pl/reportbro/report/run");
$reportBroUrl = config(EscolaLmsTemplatesPdfServiceProvider::CONFIG_KEY . '.reportbro_url');

$response = Http::withBody($payload, 'application/json')
->send('PUT', $reportBroUrl);
Expand All @@ -27,7 +25,7 @@ public function getKeyFromPayload(string $payload): string

public function getFilepathFromKey(string $key): string
{
$reportBroUrl = config(EscolaLmsTemplatesPdfServiceProvider::CONFIG_KEY . '.reportbro_url', "https://pdfs.escolalms-api-stage.s.escolait.pl/reportbro/report/run");
$reportBroUrl = config(EscolaLmsTemplatesPdfServiceProvider::CONFIG_KEY . '.reportbro_url');
$tempName = tempnam(sys_get_temp_dir(), 'response') . '.pdf';

Http::sink($tempName)->get($reportBroUrl, ['key' => $key, 'outputFormat' => 'pdf']);
Expand Down
4 changes: 3 additions & 1 deletion src/config.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<?php

return [];
return [
'reportbro_url' => env('REPORTBRO_URL', "https://www.reportbro.com/report/run"),
];
1 change: 1 addition & 0 deletions src/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

Route::group(['prefix' => 'api/pdfs'], function () {
Route::put('/reportbro/report/run', [FabricPdfController::class, 'reportBro']);
Route::get('/reportbro/report/run', [FabricPdfController::class, 'reportBro']);
Route::get('/', [FabricPdfController::class, 'index']);
Route::get('/generate/{id}', [FabricPdfController::class, 'generate']);
Route::get('/{id}', [FabricPdfController::class, 'show']);
Expand Down

0 comments on commit 96fbfc7

Please sign in to comment.