Estrutura inicial
commit
c527b74930
@ -0,0 +1,34 @@
|
|||||||
|
### Laravel template
|
||||||
|
/vendor/
|
||||||
|
node_modules/
|
||||||
|
npm-debug.log
|
||||||
|
yarn-error.log
|
||||||
|
composer.lock
|
||||||
|
|
||||||
|
# Laravel 4 specific
|
||||||
|
bootstrap/compiled.php
|
||||||
|
app/storage/
|
||||||
|
|
||||||
|
# Laravel 5 & Lumen specific
|
||||||
|
public/storage
|
||||||
|
public/hot
|
||||||
|
|
||||||
|
# Laravel 5 & Lumen specific with changed public path
|
||||||
|
public_html/storage
|
||||||
|
public_html/hot
|
||||||
|
|
||||||
|
storage/*.key
|
||||||
|
.env
|
||||||
|
Homestead.yaml
|
||||||
|
Homestead.json
|
||||||
|
/.vagrant
|
||||||
|
.phpunit.result.cache
|
||||||
|
|
||||||
|
# php-cs-fixer
|
||||||
|
.php-cs-fixer.cache
|
||||||
|
tools/php-cs-fixer/vendor
|
||||||
|
tools/php-cs-fixer/composer.lock
|
||||||
|
|
||||||
|
# IDE
|
||||||
|
.idea
|
||||||
|
.vscode
|
@ -0,0 +1 @@
|
|||||||
|
preset: symfony
|
@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"name": "ae3/jasperserver-laravel-integrator",
|
||||||
|
"description": "Esta lib permite requisições às rotas rest2 do jasperserver a partir de um projeto em Laravel. ",
|
||||||
|
"minimum-stability": "dev",
|
||||||
|
"license": "MIT",
|
||||||
|
"authors": [
|
||||||
|
{
|
||||||
|
"name": "José Tobias de Freitas Neto",
|
||||||
|
"email": "tobias@ae3tecnologia.com.br"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"require": {
|
||||||
|
"php": "^7.1.3",
|
||||||
|
"laravel/framework": "5.8.*",
|
||||||
|
"jaspersoft/rest-client": "^2.0"
|
||||||
|
},
|
||||||
|
"require-dev": {
|
||||||
|
"orchestra/testbench": "^3.8"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"Ae3\\JasperServer\\Laravel\\Integrator\\": "src/"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"extra": {
|
||||||
|
"laravel": {
|
||||||
|
"providers": [
|
||||||
|
"Ae3\\JasperServer\\Laravel\\Integrator\\app\\Providers\\IntegratorServiceProvider"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Ae3\JasperServer\Laravel\Integrator\app\Providers;
|
||||||
|
|
||||||
|
use Ae3\JasperServer\Laravel\Integrator\app\Services\Contracts\JasperServerRequestServiceContract;
|
||||||
|
use Ae3\JasperServer\Laravel\Integrator\app\Services\JasperServerRequestService;
|
||||||
|
use Illuminate\Support\ServiceProvider;
|
||||||
|
use Jaspersoft\Client\Client;
|
||||||
|
|
||||||
|
class IntegratorServiceProvider extends ServiceProvider
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Register any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function register()
|
||||||
|
{
|
||||||
|
$this->mergeConfigFrom(__DIR__ . '/../../config/config.php', 'jasperserver-laravel-integrator');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bootstrap any application services.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function boot()
|
||||||
|
{
|
||||||
|
if ($this->app->runningInConsole()) {
|
||||||
|
$this->publishes([
|
||||||
|
__DIR__ . '/../../config/config.php' => config_path('jasperserver-laravel-integrator.php'),
|
||||||
|
], 'config');
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->app->bind(JasperServerRequestServiceContract::class, function ($app) {
|
||||||
|
$config = $app['config']['jasperserver-laravel-integrator']['server'];
|
||||||
|
|
||||||
|
$client = $this->app->make(Client::class, [
|
||||||
|
'serverUrl' => $config['uri'],
|
||||||
|
'username' => $config['username'],
|
||||||
|
'password' => $config['password']
|
||||||
|
]);
|
||||||
|
|
||||||
|
return new JasperServerRequestService($client);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,75 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Ae3\JasperServer\Laravel\Integrator\app\Services\Contracts;
|
||||||
|
|
||||||
|
use Ae3\JasperServer\Laravel\Integrator\app\Services\JasperServerRequestService;
|
||||||
|
|
||||||
|
interface JasperServerRequestServiceContract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @param string $key
|
||||||
|
* @param $value
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function addInputControl(string $key, $value): JasperServerRequestService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $timeout
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setRequestTimeout(int $timeout): JasperServerRequestService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $format
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setFormat(string $format): JasperServerRequestService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $attachmentsPrefix
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setAttachmentsPrefix($attachmentsPrefix): JasperServerRequestService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $freshData
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setFreshData(bool $freshData): JasperServerRequestService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $interactive
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setInteractive(bool $interactive): JasperServerRequestService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $onePagePerSheet
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setOnePagePerSheet(bool $onePagePerSheet): JasperServerRequestService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $pages
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setPages(string $pages): JasperServerRequestService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $saveDataSnapshot
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setSaveDataSnapshot(bool $saveDataSnapshot): JasperServerRequestService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $transformerKey
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setTransformerKey(string $transformerKey): JasperServerRequestService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $uri
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function call(string $uri): string;
|
||||||
|
}
|
@ -0,0 +1,197 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Ae3\JasperServer\Laravel\Integrator\app\Services;
|
||||||
|
|
||||||
|
use Ae3\JasperServer\Laravel\Integrator\app\Services\Contracts\JasperServerRequestServiceContract;
|
||||||
|
use Jaspersoft\Client\Client;
|
||||||
|
|
||||||
|
class JasperServerRequestService implements JasperServerRequestServiceContract
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @var Client|null
|
||||||
|
*/
|
||||||
|
protected $client = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var string
|
||||||
|
*/
|
||||||
|
protected $format = 'html';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var null
|
||||||
|
*/
|
||||||
|
protected $pages = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var null
|
||||||
|
*/
|
||||||
|
protected $attachmentsPrefix = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var null
|
||||||
|
*/
|
||||||
|
protected $inputControls = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $interactive = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $onePagePerSheet = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $freshData = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var bool
|
||||||
|
*/
|
||||||
|
protected $saveDataSnapshot = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var null
|
||||||
|
*/
|
||||||
|
protected $transformerKey = null;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
protected $requestTimeout = 60;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Client $client
|
||||||
|
*/
|
||||||
|
public function __construct(
|
||||||
|
Client $client
|
||||||
|
) {
|
||||||
|
$this->client = $client;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $key
|
||||||
|
* @param $value
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function addInputControl(string $key, $value): self
|
||||||
|
{
|
||||||
|
if (!$this->inputControls) {
|
||||||
|
$this->inputControls = [];
|
||||||
|
}
|
||||||
|
$this->inputControls[$key] = $value;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $timeout
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setRequestTimeout(int $timeout): self
|
||||||
|
{
|
||||||
|
$this->requestTimeout = $timeout;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $format
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setFormat(string $format): self
|
||||||
|
{
|
||||||
|
$this->format = $format;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $attachmentsPrefix
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setAttachmentsPrefix($attachmentsPrefix): self
|
||||||
|
{
|
||||||
|
$this->attachmentsPrefix = $attachmentsPrefix;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $freshData
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setFreshData(bool $freshData): self
|
||||||
|
{
|
||||||
|
$this->freshData = $freshData;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $interactive
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setInteractive(bool $interactive): self
|
||||||
|
{
|
||||||
|
$this->interactive = $interactive;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $onePagePerSheet
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setOnePagePerSheet(bool $onePagePerSheet): self
|
||||||
|
{
|
||||||
|
$this->onePagePerSheet = $onePagePerSheet;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $pages
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setPages(string $pages): self
|
||||||
|
{
|
||||||
|
$this->pages = $pages;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param bool $saveDataSnapshot
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setSaveDataSnapshot(bool $saveDataSnapshot): self
|
||||||
|
{
|
||||||
|
$this->saveDataSnapshot = $saveDataSnapshot;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $transformerKey
|
||||||
|
* @return $this
|
||||||
|
*/
|
||||||
|
public function setTransformerKey(string $transformerKey): self
|
||||||
|
{
|
||||||
|
$this->transformerKey = $transformerKey;
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $uri
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function call(string $uri): string
|
||||||
|
{
|
||||||
|
return $this->client->reportService()->runReport(
|
||||||
|
$uri,
|
||||||
|
$this->format,
|
||||||
|
$this->pages,
|
||||||
|
$this->attachmentsPrefix,
|
||||||
|
$this->inputControls,
|
||||||
|
$this->interactive,
|
||||||
|
$this->onePagePerSheet,
|
||||||
|
$this->freshData,
|
||||||
|
$this->saveDataSnapshot,
|
||||||
|
$this->transformerKey
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
return [
|
||||||
|
'server' => [
|
||||||
|
'uri' => env('JASPER_SERVER_URL'),
|
||||||
|
'username' => env('JASPER_SERVER_USERNAME'),
|
||||||
|
'password' => env('JASPER_SERVER_PASSWORD')
|
||||||
|
]
|
||||||
|
];
|
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"require": {
|
||||||
|
"friendsofphp/php-cs-fixer": "^3.14"
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue